function  formvalidation(thisform)
{ 
	with (thisform)
	{ 
			if(fname.value=="name")fname.value="";		
			if (emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false) 
			{
				fname.select();
				fname.focus();
				return false;
			}
			
			if(email.value=="email")email.value="";		
			if (emptyvalidation(email,"Woops! You forgot to fill in your  Email Address")==false) 
			{
				email.select();
				email.focus();
				return false;
			}
			
			if(emailvalidation(email)==false)
			{
				alert("Woops! You have entered an invalid Email Address");
				email.select();
				email.focus();
				return false;
			}
			
		
			if(phone.value=="phone")phone.value="";
			if (emptyvalidation(phone,"Woops! You forgot to fill in your  Phone Number")==false) 
			{
				phone.select();
				phone.focus();
				return false;
			}
			
				if(comments.value=="comments")comments.value="";
			if (emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false) 
			{
				comments.select();
				comments.focus();
				return false;
			}
			
	if (userdigit.value==userdigit.defaultValue)
			{
			userdigit.value="";	
			}
			if(emptyvalidation(userdigit,"Please fill in your Verification code.")==false)
			{
			userdigit.focus();
			return false;
			}
			runAjax('check_captcha','process_mail.php',thisform.userdigit.value);
			return false;

			
		//	document.getElementById("loadimagenew").innerHTML='<img  src="images/loader2.gif" alt=""  />';
	
		
	} 
	runAjax('check_captcha','process_mail.php',document.form1.userdigit.value);
return false;
/*document.getElementById("load_button").innerHTML='<img  src="images/ajax-loader.gif" alt="" />';*/

		//thisform.submit();
	}
//}

//------------------------------------------------------
function captcha_refresh()
{ 
document.getElementById("button_div").src='button.php?'+Math.random();
return false;
}

<!--Ajax for checking the captcha code ends here -->

var xmlHttp
function runAjax(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+"?userdigit="+argVal
url=url+"&sid="+Math.random()
if(field=='check_captcha')
xmlHttp.onreadystatechange=check_captcha;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function check_captcha() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	//alert(xmlHttp.responseText);
			if(xmlHttp.responseText=="yes")
			{
		
		//	document.getElementById("loadimagenew").innerHTML='<img src="images/loader2.gif" alt="" />';
			document.getElementById("load_button").innerHTML='<img  src="images/ajax-loader.gif" alt="" />';
			document.form1.submit();
	return true;
			
			}
			else
			{			

				 //document.getElementById("loadimagenew").innerHTML='<a href="#" onclick="return validate_contactus(document.contactform);"><img src="grafx/submit.jpg" border="0"  /></a>';
				captcha_refresh();
				
			 	document.form1.userdigit.value="Invalid Verification Code";
		        document.form1.userdigit.focus();
				document.form1.userdigit.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
}

 

