﻿var initialize = function() {
    $(".tab").click(function() {
        if (!$(this).hasClass("active")) {

            var TabBody = $(this).attr("id").split("Tab")[0] + "Body";
            var TabDetails = $(this).attr("id").split("Tab")[0] + "Details";
            $(".tab").removeClass("active");
            $("#ServicesDetails .details").css("height", "0px").hide();
            
            $(".TabContent .detailsButton").show();
            $(this).addClass("active");


            $("#ServicesModuleBody").attr("class", "TabContent");
            $("#ServicesModuleBody").addClass(TabBody);
            $(".TabInnerWrapper").hide();
            $("#" + TabBody).fadeIn("normal");
        }
    });

    var $div = $("#ServicesDetails .details");
    var height = $div.height();
    $div.hide().css({ height: 0 });

    $(".TabContent .detailsButton").click(function() {
        
            if ($div.is(':visible')) {
                $div.animate({ height: 0 }, { duration: 700, complete: function() {
                    $div.hide();
                }
                });
            } else {
                $(".TabContent .detailsButton").hide();
                $div.show().animate({ height: height }, { duration: "slow" });

            }

            return false;
        
    });
    
    


};
$(function() {
    initialize(); 
});

$(function() {


if($("#EmailForm").length > 0){
    $("#EmailForm").ajaxForm(function(){    
        $("#Confirmation").html("Thank you! Your message has been received. <br/> Someone will contact you shortly.");
        var wait = setInterval(function() {
	        $("#Confirmation").hide();
            $("#OneLineMessage").attr("value","Message us!").show();
                clearInterval(wait);
                    }, 5000);
    });
    $("#SendEmail").click(function(){
        $("#ContactForm").animate({ height: 0 }, { duration: 700, complete: function() {
                $("#ContactForm").hide();}});
                $("#Confirmation").show();
    });
    var $div = $('#ContactForm');
    var height = $div.height();
    $div.hide().css({ height: 0 });

    $("#OneLineMessage").keypress(function(e) {
    if (e.which == 13) {
        if ($div.is(':visible')) {
            $div.animate({ height: 0 }, { duration: 700, complete: function() {
                $div.hide();
            }
            });
        } else {
            $("#OneLineMessage").hide();
            $("#Message").attr("value", $("#OneLineMessage").attr("value"));
            $div.show().animate({ height: height }, { duration: 700 });

        }

        return false;
        }
    });




    $("#OneLineMessage").Watermark("Message us!", "#a99").focus(function(i) {
        $(this).css("color", "#333");
    });
}
});






