var xmlHttp

function submitcontactusPage(form,str1)
{ 
	if(document.getElementById("agreement").checked!=true)
	{
		alert("Please check the checkbox!");
		return;
	}

	var url=str1;
	
	
	var name = document.getElementById("name").value;
	var emailid = document.getElementById("emailid").value;
	var subject = document.getElementById("subject").value;
	var mobile= document.getElementById("mobileno").value;
	var city= document.getElementById("city").value;
	var comments= document.getElementById("comments").value;
	
	if(name==""){
		showError("The Name cannot be left blank");
		document.getElementById("name").focus();
		changeError('name')
		return false;
	}else if(isNum(name)){
			//alert("name " + name);
			showError("Numbers are not allowed in the name");
			document.getElementById("name").focus();
			changeError('name')
			return false;
	}
	else if(isSpchar(name)){
			showError("Special characters not allowed in the name");
			document.getElementById("name").focus();
			changeError('name')
			return false;
	}
	else{
		changeProper('name')
	}
	
	if(emailid==""){
		showError("The Email Id cannot be left blank");
		document.getElementById("emailid").focus();
		changeError('emailid');
		return false;
	}else{
		changeProper('emailid')
	} 
	
	if(!isValidEmail(emailid))
	{
		showError("Invalid email address.");
		document.getElementById("emailid").focus();
		changeError('emailid')
		return false;
	}else{
		changeProper('emailid')
	}
	
	if(subject==""){
		showError("The Subject cannot be blank");
		document.getElementById("subject").focus();
		changeError('subject')
		return false;
	}else{
		changeProper('subject')
	}
	
	if(mobile==""){
		showError("Phone Number should not be blank");
		document.getElementById("mobileno").focus();
		changeError('mobileno')
		return false;
	}else{
		changeProper('mobileno')
	}
	
	if(!isNumber(mobile))
	{
		showError("Please enter numbers only");
		document.getElementById("mobileno").focus();
		changeError('mobileno')
		return false;
	}else{
		changeProper('mobileno')
	}
	if(city==""){
		showError("The City cannot be left blank");
		document.getElementById("city").focus();
		changeError('city')
		return false;
	}else if(isNum(city)){
			//alert("city " + city);
			showError("Numbers are not allowed in the city");
			document.getElementById("city").focus();
			changeError('city')
			return false;
	}
	else if(isSpchar(city)){
			showError("Special characters not allowed in the city");
			document.getElementById("city").focus();
			changeError('city')
			return false;
	}
	else{
		changeProper('city')
	}
	
	if(comments==""){
		showError("The Comments cannot be blank");
		document.getElementById("comments").focus();
		changeError('comments')
		return false;
	}else{
		changeProper('comments')
	}
		//toogleElement('msg','none')
		//showThanks(theform)
	
	
	
	
	url=url+"?name="+name;
	url=url+"&emailid="+emailid;
	url=url+"&subject="+subject;
	url=url+"&mobile="+mobile;
	url=url+"&city="+city;
	url=url+"&comments="+comments;
	url=url+"&requestname="+form;
//	alert(url);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
 	 {
		  alert ("Your browser does not support AJAX!");
 		 return;
	  } 
  


xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
toogleElement(form,'none');
toogleElement('thanks','block');
}

function stateChanged() 
{ 

	if (xmlHttp.readyState==1){
	document.getElementById("thanks").innerHTML="Loading...";
	}else if (xmlHttp.readyState==2){
	document.getElementById("thanks").innerHTML="Loading...";
	}else if (xmlHttp.readyState==3){
	document.getElementById("thanks").innerHTML="Loading...";
	}else if (xmlHttp.readyState==4){
	document.getElementById("thanks").innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
} 

