var xmlHttp;
function formValidator(){
	// Make quick references to our fields
	var name= document.getElementById('name');		
	var email= document.getElementById('email');		
	var subject= document.getElementById('subject');
	var message= document.getElementById('message');	
	var code= document.getElementById('Code');	
	
	if(isEmpty(name, "Please enter your name")){
		return false;
	}
	if(isEmpty(email, "Please enter your email")){
		return false;
	}	
	if(!emailValidator(email, "Please check your email ")){
		return false;
	}	
	if(isEmpty(subject, "Please enter subject for message")){
		return false;
	}		
	if(isEmpty(message, "Please enter message below")){
		return false;
	}		
	if(contentValidator(message)){
		return false;
	}	
	if(isEmpty(code, "Please enter code")){
		return false;
	}	

	//if(isEmpty(Price, "Please enter price of product")){
	//	return false;
	//}	

	return true;
}

function Setfocus()
{
	var name= document.getElementById('name');	
	name.focus();
}


function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return true;
	}
	return false;
}

function isNumeric2(sText,helperMsg)
{
   var ValidChars = "0123456789.";   
   var Char; 
   var flag;
   flag=1;
   for (i = 0; i < sText.length; i++) 
	{ 
		  Char = sText.charAt(i); 
		  if (ValidChars.indexOf(Char) == -1) 
			 {
				 flag=0;		 
			 }
	}
   if(flag==1)
	   return true;   
   else
   {
 	   alert(helperMsg);				  
	   return false;   
	}
}
function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
function contentValidator(elem){

	var str=new Array("http","www","[","]","=","url","/","//","#","::");
		
	for(i=0;i<str.length;i++)
	{
		var content=elem.value;
		//alert(content.indexOf(str[i]));		
		if (content.indexOf(str[i])>-1)
		{
			alert("Your conent can not contain these letters: http,www,[,],url,/,//,#,::");
			elem.focus();
			return true;
		}		
	}	
	return false;	
}