var xmlHttp;
function validate()
{

var name=document.getElementById("name").value;
var emai=document.getElementById("email").value;
var msg=document.getElementById("msg").value;

var cno=document.getElementById("cno").value;
//alert(sj);	
d=/\W/;        //allow letters, numbers, underscores//
if(name=="")
{
document.getElementById("name").focus();
document.getElementById("na").style.display = "";

return false;
}
document.getElementById("na").style.display = "none";

function echeck(str) {
 
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}
 
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}
 
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}
 
		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
 
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }
 
		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
 
 		 return true					
	}
if (emai==""){
		//alert("Please Enter your Email ID")
		document.getElementById("email").focus();
		document.getElementById("ema").style.display = "";
		return false
	}
	document.getElementById("ema").style.display = "none";

	if (echeck(emai)==false){
		document.getElementById("email").focus();
		document.getElementById("ema1").style.display = "";
		return false
	}
	document.getElementById("ema1").style.display = "none";



if(msg=="")
{
document.getElementById("msg").focus();
document.getElementById("msg1").style.display = "";
return false;
}
document.getElementById("msg1").style.display = "none";
if((msg.length < 4))
{
	document.getElementById("msg").focus();
document.getElementById("msg2").style.display = "";
return false;
}
document.getElementById("msg2").style.display = "none";

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="cnt.php";
url=url+"?name="+name+"&email="+emai+"&msg="+msg+"&cno="+cno;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
document.getElementById("tble").style.display = "none";
document.getElementById("loo1").style.display = "Block";
//alert(xmlHttp.responseText);
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 

document.getElementById("loo1").style.display = "none";
document.getElementById("lo1").style.display = "Block";
}

}
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;

}
// JavaScript Document// JavaScript Document
