

function createajax()

{

var xmlhttp;

if (window.XMLHttpRequest)

  {

  // code for IE7+, Firefox, Chrome, Opera, Safari

  xmlhttp=new XMLHttpRequest();

  }

else if (window.ActiveXObject)

  {

  // code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

else

  {

  alert("Your browser does not support XMLHTTP!");

  xmlhttp=null

  }

  return xmlhttp;

}



var ajax;

function validation()

{

	var name=document.getElementById("name").value;

	if(!name)

	{

	alert("Enter your name");

	document.getElementById("name").focus();

	return false;

	}

	var email=document.getElementById("email").value;

	if(!email)

	{

		alert("Enter the Email-Id");

		document.getElementById("email").focus();

		return false;

		

	}

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

 	if (filter.test(email))

  	{}

 	 else{

  		 alert("Invalid email address! Enter again")

		 document.getElementById("email").focus();

  		return false

 	 }

	

	

	var phone=document.getElementById("phone").value;

	if(!phone)

	{

		alert("Enter the phone no");

		document.getElementById("phone").focus();

		return false;

	}

	var pho=/^[0-9+]*$/;

	if (!pho.test(phone))

	{

		alert("Invalid phone number! Enter again")

		document.getElementById("phone").focus();

		return false

	}

	

	var spamcode=document.getElementById("spamcode").value;

	if(!spamcode)

	{

		alert("Enter image verification code");

		document.getElementById("spamcode").focus();

		return false;

	}

	

	ajax = createajax();if(ajax==null)return;

	

	var fom = document.getElementsByTagName("form")[0];

	

	

	var param = "command=contactus&name="+fom.name.value+"&email="+fom.email.value+"&phone="+fom.phone.value+"&comments="+fom.comments.value+"&spamcode="+fom.spamcode.value;	

	ajax.open("POST","contactus.php")

	ajax.onreadystatechange = xajax;

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded")

	ajax.send(param)

}



function xajax()

{

	if(ajax.readyState==4)

	{

		document.getElementById('errmsg').style.display='block'

		document.getElementById('errmsg').innerHTML = ajax.responseText

	}

}




