

$(document).ready(function(){
		$("#ContactForm").validate({
			debug: false,
			rules: {
				name: "required",
				email: {
					required: true,
					email: true
				}
			},
			messages: {
				name: "Please enter name!",
				email: "Please enter valid email!"				
			},
			submitHandler: function(form) {
				// do other stuff for a valid form
				$.post('mail.php', $("#ContactForm").serialize(), function(data) {
					$('#results').html(data);
				location.reload();
				});
				var refreshId = setInterval(function()
					{
					$('#ContactForm').fadeOut("slow").load('mail.php').fadeOut(300);
					}, 1000);
					//alert ('Thank You for contacting us, we will get back to you shortly');
					}
					
					
					
			
		});
	});













// JavaScript Document
function checkForm()
{
	//NAME VALIDATION
	if(document.formName.name.value=="")
	{
		alert ('Please Enter Your Full Name!');
		document.formName.name.focus();
		return false;
	}
	
	
	

	//EMAIL VALIDATION
	if(document.formName.email.value=="")
	{
		alert ('Please Enter Your Email!');
		document.formName.email.focus();
		return false;
	}
	//EMAIL FORMAT VALIDATON
	if (!document.formName.email.value.match(/^[\w\.-]+@(?:[A-Za-z0-9-]+\.)*[A-Za-z0-9-]{1,}\.[a-z]{2,9}$/))
	{
		alert ('Please Enter a Valid Email!');
		document.formName.email.select();
		return false;
	}
	
		
	
		    
	return true;
	
}

function contacts()
{
if(document.frmcontact.name.value=="")
		{
			alert("First Name is Required!");
			document.frmcontact.name.focus();
			return false;
		}
		
		
	
		if(document.frmcontact.email.value=="")		
		{
			alert("Email is Required!");
			document.frmcontact.email.focus();
			return false;
		}
		
		if(document.frmcontact.email.value!="" && !checkMail(document.frmcontact.email.value))
		{
			alert("Email must contain an email address.\n");		
			document.frmcontact.email.focus();		
			return false;
		}
		
		function checkMail(email)
		{
		var x = email;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) 		
		{
		return true;
		}
		else 
		{
		return false;
		}
		}
		
		
		
		
}



