// JavaScript Document

//form fields validation
function isValid(formobj)
{	
	var teststring;
	var error_msg='';
	var iserror=0;
	var teststring=/\S/;
    
	if(formobj.first_name && !teststring.test(formobj.first_name.value))
	{
		alert("Please enter First Name");
		formobj.first_name.focus();
		return false;
	}
	
	if(formobj.address1 && !teststring.test(formobj.address1.value))
    {
    	alert("Please enter your address");
    	formobj.address1.focus();
    	return false;
    }
	
	if(formobj.city && !teststring.test(formobj.city.value))
    {
    	alert("Please enter your Town/city");
    	formobj.city.focus();
    	return false;
    }
	
	if(formobj.email && !teststring.test(formobj.email.value))
    {
    	alert("Please enter your Email");
    	formobj.email.focus();
    	return false;
    }
	
	if(!isEmail(formobj.email.value))
	{
		alert("Please enter valid Email address");
		formobj.email.focus();
		return false;
	}
	
	if(formobj.surname && !teststring.test(formobj.surname.value))
    {
    	alert("Please enter your Surname");
    	formobj.surname.focus();
    	return false;
    }
	
	if(formobj.postcode && !teststring.test(formobj.postcode.value))
    {
    	alert("Please enter your Postcode");
    	formobj.postcode.focus();
    	return false;
    }
	

   return true;
}

//Email Validation
function isEmail(newstr)
{
	var emailexp = /^[a-z][a-z_0-9\-\.]+@[a-z_0-9\-\.]+\.[a-z]{2,5}$/i
	//Check that the email entry is valid
	if (!emailexp.test(newstr) || newstr.indexOf("..") >= 0)
	{
		return false;
	}
	return true;
}