function trim(sText)
{
	return sText.replace(/^\s+|\s+$/g,'');
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}
function validation()
{

	if(trim(document.getElementById('_txtName').value)=="")
	{
		alert("Please Enter Your Name");
		document.getElementById('_txtName').focus();
		return false;
	}
	if ((document.getElementById('email').value==null)||(document.getElementById('email').value==""))
	{
		alert("Please Enter Your Email Address")
		document.getElementById('email').focus()
		return false
	}
	if (echeck(document.getElementById('email').value)==false)
	{
		document.getElementById('email').value=""
		document.getElementById('email').focus()
		return false
	}
	if(trim(document.getElementById('phone').value)=="")
	{
		alert("Please Enter Your Phone");
		document.getElementById('phone').focus();
		return false;
	}
	if(trim(document.getElementById('enquiry').value)=="")
	{
		alert("Please Enter Your Enquiry ");
		document.getElementById('enquiry').focus();
		return false;
	}
/*	if(trim(document.getElementById('_txtCompany').value)=="")
	{
		alert("Please Enter Your Company Name");
		document.getElementById('_txtCompany').focus();
		return false;
	}
*/		if(trim(document.getElementById('security_code').value)=="")
	{
		alert("Please Enter Security Code");
		document.getElementById('security_code').focus();
		return false;
	}
	if(Get_Cookie('_cookieCaptcha') != document.getElementById('security_code').value) {
		alert("Security Code Mismatch");
		document.getElementById('security_code').value ="";
		document.getElementById('security_code').focus();
		return false;
	}	
	
}
	
	

function Get_Cookie( name ) 
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;	
	}
	if ( start == -1 ) 
		return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) 
		end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
