
var CheckList = new Array() 

function Check(errorMessage, FormValue, Type) 
{
	this.errorMessage = errorMessage;
	this.FormValue = FormValue;
	this.Type = Type;
} 


function checkForm(form)
{
	formError = false;
	var invalidChar=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var invalidNumber=/^\d+$/ ;
	for (var i=1; i<=CheckList.length-1; i++) 
	{


		var fieldvalue = CheckList[ i ].FormValue;


		var type = CheckList[ i ].Type;
		stringValue = eval("document."+form+"."+fieldvalue+".value");

		if (type=="mail")
		{
			if(!invalidChar.test(stringValue))
			{
				errorMail="Incorrect email!";
				formError=true;
			
			}				
			else
			{
				errorMail="";
			}
		}
		if (type=="Name")
		{

			if(stringValue.length<2)
			{
				errorName="Invalid name!";
				//stringValue="";
				formError=true;
			}				
			else
			{
				errorName="";
			}
		}
		if(type=="phone")
		{
		
			if(!invalidNumber.test(stringValue))
			{
				errorPhone="Please enter a valid number!";
				formError=true;
			}				
			else
			{
				errorPhone="";
			}		
		}	
	}

	if (formError)
	{
			nameBlock.innerHTML = errorName;
			emailBlock.innerHTML = errorMail;
		return false;
	}
	else
	{
		return true;
	}
}

