function chkEMail(str, id)
{
	var isEMail = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
	str = Trim(str);
	if(typeof id != 'undefined')
		id.value = str;
	return isEMail.test(str);
}	
function Trim(str)
{

	str = str.replace(/^([ ]+)?/i, '');
	str = str.replace(/([ ]+)?$/i, '');
	return str;
}	

function checkForm()
{
	/*
	var varify_from_txtbox=document.getElementById('recaptcha_response_field').value;
	alert(varify_from_txtbox);
	
	varify_from_txtbox=varify_from_txtbox.toUpperCase(varify_from_txtbox);alert(varify_from_txtbox);
	var varify_from_hidden_field=document.getElementById('recaptcha_response_field').value;
	alert(varify_from_hidden_field);
	//varify_from_hidden_field=varify_from_hidden_field.toUpperCase(varify_from_hidden_field);
	
	*/
	

	if(document.getElementById('Name').value==null || document.getElementById('Name').value=="")
	{				
		alert('Please fill up your Name.');
		document.getElementById('Name').focus();
		return false;	
	}	
	
	if(document.getElementById('Email').value==null || document.getElementById('Email').value=="")
	{		
		alert('Please fill up your email address.');
		document.getElementById('Email').focus();
		return false;	
	}
	if(document.getElementById('Email').value!=null)
	{
		var t=chkEMail(document.getElementById('Email').value,'Email');
		if(t==false)
		{
			alert('Please enter your valid email address.');
			document.getElementById('Email').focus();
			return false;
		}
		
	}	

	if(document.getElementById('Company').value==null || document.getElementById('Company').value=="")
	{		
		alert('Please fill up the Company Name.');
		document.getElementById('Company').focus();
		return false;	
	}

	if(document.getElementById('Phone').value==null || document.getElementById('Phone').value=="")
	{		
		alert('Please fill up the Phone no.');
		document.getElementById('Phone').focus();
		return false;	
	}
	if(document.getElementById('Comments').value==null || document.getElementById('Comments').value=="")
	{		
		alert('Please fill up the Comments.');
		document.getElementById('Comments').focus();
		return false;	
	}
	
/*
	if(document.getElementById('recaptcha_response_field').value==null || document.getElementById('recaptcha_response_field').value=="")
	{		
		alert("The verification code did not matched !!!\nPlease try again.");
		document.getElementById('recaptcha_response_field').focus();
		return false;	
	}

	if(document.getElementById('category_id').options[document.getElementById('category_id').selectedIndex].value=='0')
	{		
		alert('Please select your project category.');
		document.getElementById('category_id').focus();
		return false;	
	}*/
	
	/*
	if(varify_from_hidden_field!=varify_from_txtbox)
	{
		alert("The verification code did not matched !!!\nPlease try again.");
		document.getElementById('recaptcha_challenge_field').focus();
		//AjaxFunction();
		return false;
	}
	if(!document.getElementById('check_agree').checked)
	{
		alert('Please check the terms and condition.');
		return false;
	}
*/
	return true;
	
}
















function AjaxFunction()
{
		
		var xmlHttp=null;
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		 {
			 alert ("Browser does not support HTTP Request");
			 return;
		 }
		var url="getCapcha.php?";
		url=url+"sid="+Math.random();
		xmlHttp.onreadystatechange=show;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		function show()
		{ 
			//alert(xmlHttp.responseText);
			document.getElementById("verify_code_text_hidden").innerHTML=xmlHttp.responseText;
			
		}
		
		function GetXmlHttpObject()
		{
			var xmlHttp=null;
			try
			 {
				 // Firefox, Opera 8.0+, Safari
				 xmlHttp=new XMLHttpRequest();
			 }
			catch (e)
			 {
				 //Internet Explorer
				 
				 try
				  {
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					
				  }
				 catch (e)
				  {
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				  }
			 }
			return xmlHttp;
		}		
}
