$(function() {  
		$('.error').hide();
		$('#loading').hide();
		
		$("#submit_btn").click(function() {
			$('.error').hide();
			var name = $("input#name").val();
			if (name == "" || name == 'Name*') 
			{
				$("span#name_error").show();
				//$("input#name").focus();
				return false;
			}
			
			var email = $("input#email").val();
			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			
			if (email == "" || !emailReg.test(email)) 
			{
		        $("span#email_error").show();
		      //  $("input#email").focus();
		        return false;
		    }
		    
	  		var phone = $("input#phone").val();
	  		if (phone == "" || phone == 'Phone*') 
	  		{
	        	$("span#phone_error").show();
	        	//$("input#phone").focus();
	        	return false;
	      	}
	      	
	      	var url = $("input#url").val();
	      	var v = new RegExp();
		    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
	  		if (url == "" || url == 'Website Url*' || !v.test(url)) 
	  		{
	        	$("span#url_error").show();
	        //	$("input#url").focus();
	        	return false;
	      	}
	      	
	      	var dataString =  $("#contact_form form").serialize(); //'name='+ name + '&email=' + email + '&phone=' + phone;
			//alert (dataString);return false;
			$("#loading").ajaxStart(function(){
   				$(this).show();
 			});
 			
 			$("#loading").ajaxStop(function(){
			   $(this).hide();
			 });
 			
			$.ajax({
				type: "POST",
			    url: "sendmail.php",
			    data: dataString,
			    success: function() {
			    $('#contact_form').html("<div id='message'></div>");
			      $('#message').html("<br><br><div class='greenBold'>Contact Form Submitted!</div><br>")
			      .append("<p>We will be in touch soon.</p>")
			      .hide()
			      .fadeIn(2500, function() {
			     //   $('#message').append("<img id='checkmark' src='images/check.png' />");
			      });
			    }
			  });
			return false;
			  
		});
	});