// JavaScript Document
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 contactcheckcode(thecode) { 
	   http.open("GET", url + escape(thecode), true); 
	   http.onreadystatechange = contactHandleHttpResponse; 
	   http.send(null); 
	   } 
 	   
function contactHandleHttpResponse() 
{ 
	 if (http.readyState == 4) { 
	  captchaOK = http.responseText; 
	  if(captchaOK != 1) { 
       alert('Please Enter Correct Code'); 
	   document.form_contactus.txtCaptcha.value=''; 
	   document.form_contactus.txtCaptcha.focus(); return false; 
	   } 
	   document.form_contactus.submit(); 
	   }     
} 

function ValidForm()
{

  var firstname = document.getElementById('FirstName');
  var lastname = document.getElementById('LastName');
  var title = document.form_contactus.Title;
  var email = document.form_contactus.Email;
  var phone = document.form_contactus.Phone;
  var Mobile = document.form_contactus.Mobile;
  var website = document.form_contactus.Website;
  var LeadSource = document.form_contactus.LeadSource;
  var Industry = document.form_contactus.Industry;
  var NoofEmployees = document.form_contactus.NoofEmployees;
  var AnnualRevenue = document.form_contactus.AnnualRevenue;
  var services = document.form_contactus.Services;
   var Street = document.form_contactus.Street;
  var City = document.form_contactus.City;
  var country = document.form_contactus.Country;
  var Description = document.form_contactus.Description;
   var str=document.form_contactus.Description.value;

	var validate = document.form_contactus.txtCaptcha;

  if (firstname.value == "")
    {
        window.alert("Please Enter First Name");
       firstname.focus();
         return false;
    }
	if(!isNaN(firstname.value))
		{
			alert("Please Enter Correct First Name");
			firstname.focus();
			return false;
		}
	
	 /*if (lastname.value == "")
    {
        window.alert("Please enter your Last Name.");
       lastname.focus();
         return false;
    }*/
	/* if (title.value == "")
    {
        window.alert("Please enter your Title.");
        title.focus();
         return false;
    }
*/
	 if (!mailchk(email.value))
    {
        window.alert("Please Enter Valid Email");
        email.focus();
        return false;
    }
   /* if (email.value.indexOf("@", 0) < 0)
    {
        window.alert("Please enter a valid Email.");
        email.focus();
        return false;
    }
    if (email.value.indexOf(".", 0) < 0)
    {
        window.alert("Please enter a valid Email.");
       email.focus();
         return false;
    }*/



if ((phone.value==null)||(phone.value=="")){
		alert("Please Enter Phone Number")
		phone.focus()
		return false
	}
if (checkInternationalPhone(phone.value)==false){
		alert("Please Enter Valid Phone Number")
		phone.value=""
		phone.focus()
		return false
	}

	/*if ((Mobile.value==null)||(Mobile.value=="")){
		alert("Please Enter your Mobile Number")
		Mobile.focus()
		return false
	}
*/

	if (website.value == "")
    {
        window.alert("Please Enter Website");
       website.focus();
        return false;
    }
	if(!isURL(website.value))
	{
		 window.alert("Please Enter Correct Website");
       website.focus();
        return false;
	}
	/* if (LeadSource.selectedIndex < 1)
    {
        alert("Please select LeadSource.");
        LeadSource.focus();
        return false;
    }
	 if (Industry.selectedIndex < 1)
    {
        alert("Please select Industry.");
        Industry.focus();
        return false;
    }



	if (NoofEmployees.value == "")
    {
        window.alert("Please enter NoofEmployees.");
       NoofEmployees.focus();
        return false;
    }
	if (AnnualRevenue.value == "")
    {
        window.alert("Please enter AnnualRevenue.");
       AnnualRevenue.focus();
        return false;
    }*/
	if (services.selectedIndex < 1)
    {
        alert("Please Select Services");
        services.focus();
        return false;
    }

	/*if (Street.value == "")
    {
        window.alert("Please enter Street.");
       Street.focus();
        return false;
    }*/
	if (City.value == "")
    {
        window.alert("Please Enter City");
      City.focus();
        return false;
    }
	if ( !isNaN(City.value) )
		{
			alert("Please Enter Correct City" );
			City.focus();
			return false;
		}	
	if (country.value == "")
    {
        window.alert("Please Enter Country");
        country.focus();
         return false;

	}
	if ( !isNaN(country.value) )
		{
			alert("Please Enter Correct Country" );
			country.focus();
			return false;
		}
	if (Description.value == "")
    {
        window.alert("Please Enter Description");
        Description.focus();
         return false;

	}
	
	if(str.match("viagra") || str.match("VIAGRA") ||  str.match("Viagra") || str.match("cialis") ||  str.match("CIALIS") || str.match("Cialis") )
	//if(in_array("",$array))
	{
		alert("This Word Is Not Allowed");
		Description.focus();
		return false;
	}

    if(validate.value=='') { 
			alert('Please Enter Verification Code'); 
			//alert('hi');
			validate.value=''; 
			validate.focus(); 
			return false; 
			} // Now the Ajax CAPTCHA validation 
			//alert(validate.value);
			contactcheckcode(validate.value); 
		return false;

//if(test==true)
//	document.form_contactus.submit();
}

function isURL(s)
{
	var regexp = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
	//var regexp =  new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
	return regexp.test(s);
}

function mailchk(ww)
	{ 
	/*var m = ww;
	var n = ww;
	var cnt=0,spc=0,dot=0;
	for(var i=1;i<=m.length;i++)
	  {
		 if(m.charAt(i)=="@")  cnt++;
		 if(m.charAt(i)==" ")  spc++;
		 if(m.charAt(i)==".")  dot++;
	  }
	  lnm=m.length
	  if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )
	  { 
		return false;
	  } 
	  else
	  {
		return true;
	  }*/
	  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(ww)){
		return (true)
		}
		//alert("Invalid E-mail Address! Please re-enter.")
		return (false)
	  
	}

 <!-- 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 -->




/*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);
 } */
 
 