var url = 'captcheck.php?code='; 

var captchaOK = 2; 
// 2 - not yet checked, 1 - correct, 0 - failed 
function getHTTPObject()
 {
  try
   { 
   req = new XMLHttpRequest();
    }
catch (err1)
 {
  try
   {
req = new ActiveXObject("Msxml12.XMLHTTP");
 } 
 catch (err2) 
 { 
 try
  { 
  req = new ActiveXObject("Microsoft.XMLHTTP"); 
  }
   catch (err3) 
{ 
req = false;
} 
} 
}
 return req;
  } 
  var http = getHTTPObject(); 
// We create the HTTP Object 
function handleHttpResponse() 
{
 if (http.readyState == 4) 
 { 
 captchaOK = http.responseText; 
 
 if(captchaOK != 1) 
 {
  alert('The entered code was not correct. Please try again');
   document.frm.code.value=''; document.frm.code.focus(); 
   return false; 
   }
    document.frm.submit(); 
}
}
 function checkcode(thecode)
  { 
  http.open("GET", url + escape(thecode), true); 
  //alert(url + escape(thecode));
  http.onreadystatechange = handleHttpResponse;
   http.send(null); 
}

function checkform(frm)
{
v1=frm.name
if(v1.value==v1.defaultValue) 
{
alert("Your name cannot be blank.");
v1.focus(); 
return false
}

v1=frm.email
if(isblank(v1)==false) 
{
alert("E-mail cannot be blank.");
v1.focus(); 
return false
}
if(isEmail(v1)==false) 
{
alert("The email \""+ v1.value+" \"is not valid email");
v1.focus(); 
return false;
}
v1=frm.phone
if(v1.value==v1.defaultValue) 
{
alert("Phone no cannot be blank.");
v1.focus(); 
return false
}
v1=frm.code
if(isblank(v1)==false) 
{
alert("you must enter varification code");
v1.value=''; 
v1.focus(); 
return false
}
checkcode(document.frm.code.value); 
return false;
}




function isblank(s3) 
{
if (s3.value == "") 
{
return false;
}
else 
{
return true;
   }
}



function isEmail(s2) 
{
if ((s2.value == "" || s2.value.indexOf('@', 0) == -1) || s2.value.indexOf('.')<5) 
{
return false;
}
else {
return true;
   }
}



