function formvalidation(thisform)
{
	with (thisform)
	{
		if (fname.value==fname.defaultValue)fname.value=""; 
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false) 
			{
			fname.focus();
			return false;
			}
		
		/*if(phone.value==phone.defaultValue)phone.value=""; 
		if(emptyvalidation(phone,"Woops! You forgot to fill in your Phone Number")==false) 
		{
			phone.focus();
			return false;
		}*/
		if (email.value==email.defaultValue)email.value=""; 
		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false) 
			{
			email.focus();
			return false;
			}
					
		if (email.value!="email to reply to")
		if(emailvalidation(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}

		if (comments.value==comments.defaultValue)comments.value=""; 
		if(emptyvalidation(comments,"Woops! You forgot to fill in your Questions")==false) 
		{
		comments.focus();
		return false;
		}
		if(userdigit.value==userdigit.defaultValue)userdigit.value=""; 
		if(emptyvalidation(userdigit,"Woops! You forgot to fill in your Verification Code")==false) 
		{
			userdigit.focus();
			return false;
		}
		
			if(thisform.formsubmit.value=="Y")
	{
		
		document.getElementById("button2").style.display='none';
		alert("Please wait while the form is getting submitted");
		return false;
	}
	else
	{
		
		thisform.formsubmit.value="Y";
	    document.getElementById("button2").style.display='none';
		document.getElementById("button_show_hide").innerHTML='<img  src="images/loader.gif" alt="" width="109" height="15"/>';
		runAjax('check_captcha','process_mail.php','sendmail');
		//thisform.submit();
		return false;
	}
		
		
		
	}
		
		thisform.submit();

}

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

var xmlHttp

function runAjax(field,argurl,argVal)

{

//document.getElementById("check_captcha").innerHTML=" Loading...";

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

{

alert ("Browser does not support HTTP Request")

return

} 

var url=argurl

url=url+"?verify_digit="+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")

	{ 

			

			if(xmlHttp.responseText=="yes")

			{
				
					document.quick_contact.submit();
					return false;

				

			}
			else
			{
				
				
					document.quick_contact.submit();
					return false;
				
			
			}

			

			

	} 

} 



function GetXmlHttpObject()

{ 

	var objXMLHttp=null

if (window.XMLHttpRequest)

{

	objXMLHttp=new XMLHttpRequest()

}

else if (window.ActiveXObject)

{

	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")

}

	return objXMLHttp

}

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




//Code for validating empty text box
function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
			
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}




//Code for validating invalid email address
function emailvalidation(entered,alertbox)
{
	with (entered)
	{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = value;
   if(reg.test(address) == false)
		{
			if (alertbox)
			{
				alert(alertbox);
			}
			return false;
		}
		else {return true;}
	}
}

