var xmlHttpctus;
function contactUs()
{ 

var uname=document.getElementById("con_name").value;
var uemail=document.getElementById("con_email").value;
var usub=document.getElementById("con_sub").value;
var umat=document.getElementById("con_mat").value;
var to=document.getElementById("con_to").value;
var home_link=document.getElementById("home_link").value;
umat=umat.replace(/(\r\n|\r|\n)/g, '<br>');


var a=0;
xmlHttpctus=GetXmlHttpObject()

if (xmlHttpctus==null)
 {
 alert ("Browser does not support HTTP Request")
 return 
 }

 if((uemail=="")||(uname=="")||(usub=="0")||(umat==""))
{
	alert("All fields must fill");
	return false;
}
else{
	if (uemail.length>=6) {
			if (uemail.indexOf("@")>0) {
				if ((uemail.indexOf("@")+2)<uemail.lastIndexOf(".")) {
					if (uemail.lastIndexOf(".")<(uemail.length-2)) {
						a = 1;
					}
				}
			}
	}
	if(a==0)
	{
		alert("Invalid Email");
		return 
	}
	else
	{
var url=home_link+"plugins/site/themes/default/contactsend.php"
url=url+"?t="+to+"&n="+uname+"&e="+uemail+"&s="+usub+"&m="+umat;
xmlHttpctus.open("GET",url,true)
xmlHttpctus.onreadystatechange=stateChangedctus ;
xmlHttpctus.send(null);

	}
}
}
function stateChangedctus() 
{ 
if (xmlHttpctus.readyState==4 )

 { 

document.getElementById("con_name").value='';
document.getElementById("con_email").value='';
document.getElementById("con_sub").value='0';
document.getElementById("con_mat").value='';
document.getElementById("ctustxtmsg").innerHTML=xmlHttpctus.responseText 
document.getElementById("con_name").focus();
 } 
}


function GetXmlHttpObject()
{
	var xmlHttpctus=null;
	
try
 {
	 // Firefox, Opera 8.0+, Safari
 xmlHttpctus=new XMLHttpRequest();
 }
catch (e)
 {
	
 //Internet Explorer
 try
  {
  xmlHttpctus=new ActiveXObject("Msxml2.XMLHTTP");
 
  }
 catch (e)
  {
	  
  xmlHttpctus=new ActiveXObject("Microsoft.XMLHTTP");
  
  }
 }
 
 
return xmlHttpctus;

}

function clearcontactUs()
{ 
var uname=document.getElementById("con_name").value='';
var uemail=document.getElementById("con_email").value='';
var usub=document.getElementById("con_sub").value='0';
var umat=document.getElementById("con_mat").value='';
}

