
function handleHttpResponse() 
{ 
 if (http.readyState == 4) { 
  captchaOK = http.responseText; 
  if(captchaOK != 1) { 
       alert('Please Enter Correct Code'); 
	   document.index_form.code.value=''; 
	   document.index_form.code.focus(); return false; 
	   } 
	   document.index_form.submit(); 
	   } 
	   } 
	   
	   
function zwitch_handleHttpResponse() 
	{ 
	  if (http.readyState == 4) { 
	  captchaOK = http.responseText; 
	  if(captchaOK != 1) { 
       alert('Please Enter Correct Code'); 
	   document.zwitch.txtCaptcha.value=''; 
	   document.zwitch.txtCaptcha.focus(); 
	   return false; 
	   } 
	   document.zwitch.submit(); 
	   } 
	   } 
	   
	   function checkcode(thecode) { 
	   //alert(thecode);
	   http.open("GET", url + escape(thecode), true); 
	   http.onreadystatechange = handleHttpResponse; 
	   http.send(null); 
	   } 
	   
	   function zwitch_checkcode(thecode) { 
	   http.open("GET", url + escape(thecode), true); 
	   http.onreadystatechange = zwitch_handleHttpResponse; 
	   http.send(null); 
	   } 
	   
function zwitch_validate()
{

	if(document.getElementById('FirstName').value=="")
			{
				alert("Please Enter Name");
				document.getElementById('FirstName').focus();
				return false;
			}
	
	if(!isNaN(document.getElementById('FirstName').value))
			{
				alert("Please Enter Correct Name");
				document.getElementById('FirstName').focus();
				return false;
			}	
			
	if(document.zwitch.Email.value=="")
			{
				alert("Please Enter Email");
				document.zwitch.Email.focus();
				return false;
			}
	if(!mailchk(document.zwitch.Email.value))
			{
				alert("Please Enter Correct Email");
				document.zwitch.Email.focus();
				return false;
			}
			
	if(document.zwitch.Phone.value=="")
			{
				alert("Please Enter Phone (E.g., 1248341378)");
				document.zwitch.Phone.focus();
				return false;
			}
	if(isNaN(document.zwitch.Phone.value))
			{
				alert("Please enter Numeric Phone no (E.g., 1248341378)");
				document.zwitch.Phone.focus();
				return false;
			}
	if (checkInternationalPhone(document.zwitch.Phone.value)==false){
			alert("Please Enter a Valid Phone Number (E.g., 1248341378)")
			document.zwitch.Phone.focus();
			return false
		}
	
	var str=document.zwitch.Description.value;
	if(str.match("viagra") || str.match("VIAGRA") ||  str.match("Viagra") || str.match("cialis") ||  str.match("CIALIS") || str.match("Cialis") )
	{
		alert("This Word Is Not Allowed");
		document.zwitch.Description.focus();
		return false;
	}
	
	if(document.zwitch.txtCaptcha.value=='') 
	{ 
			alert('Please Enter Correct Code'); 
			document.zwitch.txtCaptcha.value=''; 
			document.zwitch.txtCaptcha.focus(); 
			return false; 
			
	} // Now the Ajax CAPTCHA validation 
		
	zwitch_checkcode(document.zwitch.txtCaptcha.value); 
	return false; 
}
	   
function validate()
{
	
if(document.getElementById('FirstName').value=="")
		{
		   	alert("Please Enter Name");
			document.getElementById('FirstName').focus();
			return false;
		}
	if(!isNaN(document.getElementById('FirstName').value))
		{
			alert("Please Enter Correct Name");
			document.getElementById('FirstName').focus();
			return false;
		}	
if(document.index_form.Email.value=="")
		{
			alert("Please Enter Email");
			document.index_form.Email.focus();
			return false;
		}
if(!mailchk(document.index_form.Email.value))
		{
			alert("Please Enter Correct Email");
			document.index_form.Email.focus();
			return false;
		}
if(document.index_form.Phone.value=="")
		{
			alert("Please Enter Phone (E.g., 1248341378)");
			document.index_form.Phone.focus();
			return false;
		}
		
		
/*if(isNaN(document.index_form.Phone.value))
		{
			alert("Please enter Numeric Phone no (E.g., 1248341378)");
			document.index_form.Phone.focus();
			return false;
		}
if (checkInternationalPhone(document.index_form.Phone.value)==false){
		alert("Please Enter a Valid Phone Number (E.g., 1248341378)")
		document.index_form.Phone.focus();
		return false
	}
*/

if (checkInternationalPhone(document.index_form.Phone.value)==false){
		alert("Please Enter Valid Phone Number")
		document.index_form.Phone.value=""
		document.index_form.Phone.focus()
		return false
	}
	
if (document.index_form.Services.value == '-None-')
		{
			alert("Please Select The Services." );
			document.index_form.Services.focus();
			return false;
		}
var str=document.index_form.Description.value;
if(str.match("viagra") || str.match("VIAGRA") ||  str.match("Viagra") || str.match("cialis") ||  str.match("CIALIS") || str.match("Cialis") )
{
	alert("This Word Is Not Allowed");
	document.index_form.Description.focus();
	return false;
}
			
			if(document.index_form.txtCaptcha.value=='') { 
			alert('Please Enter Verification Code'); 
			document.index_form.txtCaptcha.value=''; 
			document.index_form.txtCaptcha.focus(); 
			return false; 
			} // Now the Ajax CAPTCHA validation 
			checkcode(document.index_form.txtCaptcha.value); 
			return false; 
			}
var digits = "0123456789";



var phoneNumberDelimiters = "()- ";



var validWorldPhoneChars = phoneNumberDelimiters + "+";



var minDigitsInIPhoneNumber = 10;



function isInteger(s)
{   
	var i;
    for (i = 0; i < s.length; i++)
	{
	    var c = s.charAt(i);

    if (((c < "0") || (c > "9"))) return false;



    }



    return true;



}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;

}

function checkInternationalPhone(strPhone)
{
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
function mailchk(ww)
	{ 
	  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(ww)){
		return (true)
		}
		return (false)
	}	
/* var m=0;
  var n=990;
  var speed4=100;
function scrollPics() {
     document.getElementById('div1').style.left=m+'px';
     document.getElementById('div2').style.left=n+'px';
   m--;
   n--;
if(m==-990) {
   m=990;
 }
if(n==-990) {
   n=990;
 }
setTimeout('scrollPics()',speed4);
 } */
 <!-- start :captcha validations -->
 //Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {

 if (window.XMLHttpRequest) {

    return new XMLHttpRequest(); //Mozilla, Safari ...

 } else if (window.ActiveXObject) {

    return new ActiveXObject("Microsoft.XMLHTTP"); //IE

 } else {

    //Display our error message

    alert("Your browser doesn't support the XmlHttpRequest object.");

 }

}

//Our XmlHttpRequest object

var receiveReq = getXmlHttpRequestObject();

//Initiate the AJAX request

function makeRequest(url, param) {

//If our readystate is either not started or finished, initiate a new request

 if (receiveReq.readyState == 0) {
//alert(receiveReq.readyState);
   //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 

   receiveReq.open("POST", url, true);

   //Set the function that will be called when the XmlHttpRequest objects state changes

   receiveReq.onreadystatechange = updatePage; 



   //Add HTTP headers to the request

   receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

   receiveReq.setRequestHeader("Content-length", param.length);

   receiveReq.setRequestHeader("Connection", "close");



   //Make the request

   receiveReq.send(param);

 }   

 if(receiveReq.readyState == 4 ){
//alert("rsdfda");

	 receiveReq.open("POST", url, true);
	//alert(receiveReq.readyState);
   //Set the function that will be called when the XmlHttpRequest objects state changes

   receiveReq.onreadystatechange = updatePage; 

	//return true;
    //document.index_form.submit();

   //Add HTTP headers to the request

   receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

   receiveReq.setRequestHeader("Content-length", param.length);

   receiveReq.setRequestHeader("Connection", "close");



   //Make the request

  // receiveReq.send(param);

	 }

}

//Called every time our XmlHttpRequest objects state changes

function updatePage() {

 //Check if our response is ready

 if (receiveReq.readyState == 4) {

   //Set the content of the DIV element with the response text

   document.getElementById('result').innerHTML = receiveReq.responseText;

   //Get a reference to CAPTCHA image

   img = document.getElementById('imgCaptcha'); 

   //Change the image

   img.src = 'create_image.php?' + Math.random();

 }

}

//Called every time when form is perfomed

function getParam(theForm) {

 //Set the URL

 var url = 'captcha.php';

 //Set up the parameters of our AJAX call

 var postStr = theForm.txtCaptcha.name + "=" + encodeURIComponent( theForm.txtCaptcha.value );

 //Call the function that initiate the AJAX request

 makeRequest(url, postStr);

}



 <!-- End : Captcha Validation -->











