// JavaScript Document

function contactValidation(thisform)
{ 
	//alert("siteurl");
		
	with (thisform)
	{
		 	if (emptyvalidation(fname,"Please fill in your Name.")==false) 
			{
				fname.select();
				fname.focus();
				return false;
			}
			
			
	
		
			
			if (emptyvalidation(email,"Please fill in your Email Address.")==false) 
			{
				email.select();
				email.focus();
				return false;
			}
			 if(emailvalidation(email)==false)
			{
					alert("Sorry, you have entered an invalid Email Address.");
				email.select();
				email.focus();
				return false;			
			}
			
				if (emptyvalidation(phoneno,"Please fill in your Phone Number.")==false) 
			{
				phoneno.select();
				phoneno.focus();
				return false;
			}
			
			/*		if (emptyvalidation(address,"Please fill in your Address.")==false) 
			{
				address.select();
				address.focus();
				return false;
			}*/
			
		
	/*	if(phonevalidation()==false)
		{
		       phoneno.select();
				phoneno.focus();
				return false;
		}*/
		/*if (emptyvalidation(comments,"Please fill in your Comments.")==false) 
			{
				
				comments.focus();
				return false;
			}*/
		 
		

		 
	if (userdigita.value==userdigita.defaultValue || userdigita.value=="Invalid Verification Code")
			{
			userdigita.value="";	
			}
			if(emptyvalidation(userdigita,"Please fill Verification Code.")==false)
			{
			
			userdigita.focus();
			return false;
			}
			document.getElementById("search1").innerHTML='<br><div style="float:right; padding-right:10px; padding-top:1px; color:#999;"><span style="padding:0px 3px 2px 0px;">Please Wait...</span>&nbsp;<img  src="images/ajax-loader.gif" alt="" align="right"  /></div>';
	
			//document.contact.submit();
			runAjax1('check_captcha2','process_mail-contact.php',thisform.userdigita.value);
			return false;
	}
		document.getElementById("search1").innerHTML='<img  src="images/ajax-loader.gif" alt="" align="right"  />';
		
	runAjax1('check_captcha2','process_mail-contact.php',document.quickcontact.userdigita.value);
return false;		
		//	document.getElementById("loadimagenew").innerHTML='<img  src="images/loader2.gif" alt=""  />';
	
		
}
// JavaScript Document

function emailvalidation(thisform) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.value;
   var email = address.split(',');
   
   for (var i = 0; i < email.length; i++) {
   if(reg.test(email[i]) == false) {
     // alert('Invalid Email Address');
      return false;
   }
   else
   {
    }
   }
}
//------------------------------------------------------
function captcha_refresha()
{ 
document.getElementById("button_diva").src='button-contact.php?'+Math.random();
return false;
}

<!--Ajax for checking the captcha code ends here -->

var xmlHttp
function runAjax1(field,argurl,argVal)
{
//document.getElementById("check_captcha1").innerHTML=" Loading...";
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url=argurl
url=url+"?userdigita="+argVal
url=url+"&sid="+Math.random()
if(field=='check_captcha2')
xmlHttp.onreadystatechange=check_captcha2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null)
}

function check_captcha2() 
{ 
//alert("Hi........");
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	//alert(xmlHttp.responseText);
			if(xmlHttp.responseText=="yes")
			{
		
		
			document.contact.submit();
		//	return true;
			
			}
			else
			{			

				document.getElementById("search1").innerHTML='<a href="#" title="Submit" onclick="return contactValidation(document.contact);return false;"><img src="images/submit-bt.jpg" alt="Submit" width="76" height="30" border="0" align="right" /></a>';
				captcha_refresha();
				
			 	document.contact.userdigita.value="Invalid Verification Code";
		        document.contact.userdigita.blur();
				//document.contact.phoneno.focus();
				//document.contact.userdigita.select();
				return false;
			}
	} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
	objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
	return objXMLHttp
}

