function initContactLink() {
	$("div.contactButton").click(function(){
		$(".quickContact").animate({ height: "440px" }).animate({ height: "340px" }, "fast");
		$("div.contactButton").toggle();
	});
	$('div.hideButton').click(function(){
		$(".quickContact").animate({ height: "0px" }, "fast");
	});	
	  $('div.doneButton').click(function(){
		$('.quickContact').animate({ height: "0px" }, "fast");
		$('div.contactButton').toggle();
	});	
}
function initContactFormSubmit() { 
	var options = { 
		target:        '#hiddenDIV',   // target element(s) to be updated with server response 
	    beforeSubmit:  beforePost,  // pre-submit callback 
	    success:       afterPost  // post-submit callback 
	}
	$('#quickContactForm').validate({
	    submitHandler: function(form) {
			$('#quickContactForm').ajaxSubmit(options);
		}
	});
	// pre-submit callback 
	function beforePost() { 
		$("#contactSubmit").hide();
		$("#submitMessage").show();
	    // here we could return false to prevent the form from being submitted; 
	    // returning anything other than false will allow the form submit to continue 
	    return true; 
	} 
	// post-submit callback 
	function afterPost(rtn)  { 
		var successcontact = rtn.substring(0,7);
	    if(rtn=="success") {
	      	$("#quickContactForm").hide();
			$("#contactNotification").fadeIn("slow");
		}else{
	        //there was an error, so grab the UL in the content ID, 
	        //inside the hidden DIV, and put it into the Message Notification
	      $("#errorMessage").html( $("#hiddenDIV #content ul").html() );
		  $("#hiddenDIV").empty(); 
	     }
	}
}
function initZindex() {
	$(function() {
		var zIndexNumber = 1000;
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	});
	$('#masthead').css('zIndex', 500);
}
function dynamicsPriceQuoteValidation() {
	jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
	    phone_number = phone_number.replace(/\s+/g, "");
		return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(1-?)?(\([2-9]\d\)|[2-9]\d)-?[2-9]\d-?\d$/);
	}, "Please specify a valid phone number");	

	jQuery.validator.addMethod("phone", function(value, element) {
        return this.optional(element) || value.match(/^\d{3}-\d{3}-\d{4}$/);
    }, "Must be 302-555-1212");

	$("#dynamicsPriceQuote").validate({
		rules: {
			company: {
				required: true,
			},
			functionality: {
				required: true,
			},
			implementationSupport: {
				required: true,
			},
			email: {
				required: true,
				email: true
			},
			phone: {
				required: true,
				phone: true
			},
		},
		messages: {
			company: {
				required: "Please enter your company name."
			},
			functionality: {
				required: "Please select one of the above."
			},
			implementationSupport: {
				required: "Please select one of the above."
			},
			email: {
				required: "Please enter your email address.",
				email: "Please enter your email address."
			},
			phone: {
				required: "Please enter your phone number.",
				phone: "Must be 302-555-1212."
			},
		}
	});
}
$(document).ready(function() {
	initContactLink();
	initContactFormSubmit();
	initZindex();
	dynamicsPriceQuoteValidation();
});
	
