$(function()
{
	$('.error').hide();

	$(".contact_button").click(function()
	{
		// validate and process form here
		
		$('.error').hide();
		
		var name = $("input#name").val();
		if (name == "")
		{
			$("label#name_error").show();
			$("input#name").focus();
			return false;
		}
		
		var email = $("input#email").val();
		if (email == "")
		{
			$("label#email_error").show();
			$("input#email").focus();
			return false;
		}
		
		var phone = $("input#phone").val();
		
		var comment = $("textarea#comments").val();
		if (comment == "")
		{
			$("label#comments").show();
			$("textarea#comments").focus();
			return false;
		}
		
		var dataString = 'action=contactForm&name='+ name + '&email=' + email + '&phone=' + 
							phone + '&comments=' + comment;
		//alert (dataString);return false;
		$.ajax({
			   type: "POST",
			   url: "js/process.php",
			   data: dataString,
			   success: function() {
				   $('#contact_form').html("<div id='message'></div>");
				   $('#message').html("<hr><img id='checkmark' src='images/check.png' /><b>Contact Form Submitted!</b><p> We will be in touch soon.</p><hr>");
				}
		  	});
		return false;
	});
	
	$(".onsite_button").click(function()
	{
		// validate and process form here
		$('.error').hide();
		
		var name = $("input#name").val();
		if (name == "")
		{
			$("label#name_error").show();
			$("input#name").focus();
			return false;
		}
		
		var email = $("input#email").val();
		if(email == "")
		{
			$("label#email_error").show();
			$("input#email").focus();
			return false;
		}
		
		var desc = $("textarea#description").val();
		if(desc == "")
		{
			$("label#description_error").show();
			$("textarea#description").focus();
			return false;
		}
		
		var phone = $("input#phone").val();
		if(phone == "")
		{
			$("label#phone_error").show();
			$("input#phone").focus();
			return false;
		}
		
		var address = $("input#address").val();
		var city = $("input#city").val();
		var state = $("input#state").val();
		var zip = $("input#zip").val();
		var besttime = $("input#contacttime").val();
		
		var dataString = 'action=onsiteForm&name='+ name + '&email=' + email + '&phone=' + phone 
		+ '&address=' + address + '&city=' + city + '&state=' + state + '&zip=' + zip + 
		'&contacttime=' + besttime + '&description=' + desc;
		//alert (dataString);return false;
		$.ajax({
			   type: "POST",
			   url: "js/process.php",
			   data: dataString,
			   success: function() {
				   $('#onsite_form').html("<div id='message'></div>");
				   $('#message').html("<hr><img id='checkmark' src='images/check.png' /><b>On-Site Form Submitted!</b><p> We will be in touch soon.</p><hr>");
				}
		  	});
		return false;
	});
});