function validatecontact(){	
	
	errmsg = "";
	// NAME
	if(document.contact.name.value=="")
	{
		errmsg = "Name is required.\n";
	}


	// PHONE 
	phone = document.contact.phone.value;
	if ( phone == "" )
	{
		errmsg = errmsg + "Phone number is required.\n";
	}
	else
	{
		if ( isValidPhoneNo(phone) == false )
			errmsg = errmsg + "Phone number contains illegal characters.\n";
	}
		
	// MOBILE 
	mobile = document.contact.mobile.value;
	if ( mobile == "" )
	{
		errmsg = errmsg + "Mobile number is required.\n";
		 
	}
	else
	{
		if ( isValidPhoneNo(mobile) == false )
			errmsg = errmsg + "Mobile number contains illegal characters.\n"; 
	}

	// EMAIL
	if(document.contact.email.value=="")
	{
		errmsg = errmsg + "Email is required.\n";
	}
	else if(!isEmail(document.contact.email.value))
	{
	    errmsg = errmsg + "Invalid Email.\n";
	}	

	// DETAILS
	if(document.contact.enquiry.value=="")
	{
		errmsg = errmsg + "Enquiry Details required.\n";
	}
	

	// 
	if (errmsg=="")
	{
		 return true;
	}
	else
	{
		errmsg = "The following error(s) occurred:\n" + errmsg;
		alert(errmsg);
		return false; 
	}
	/*if(document.contact.name.value=="" || document.contact.email.value=="" || document.contact.enquiry.value==""){
		alert("Please fill in the required fields");
		return false;
	}*/
}

function isEmail(Email)
{
	if((Email!= "") && ((Email.indexOf("@")==-1) ||(Email.indexOf(".")==-1)))
	{
		return false;
	}
	return true;
} 


function isValidMobileNo(strng)
{
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	//alert('-'+stripped+'-');
	if (isNaN(stripped)) {
	   //alert("The mobile number contains illegal characters.");
	   return false;
	}
	
	/*if (stripped.length < 10) 
	{
		alert("The mobile number is the wrong length.\n");
		return false;
	}*/
	
	return true;
}

function isValidPhoneNo(strng)
{
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	//alert('-'+stripped+'-');
	if (isNaN(stripped)) {
	   //alert("The phone number contains illegal characters.");
	   return false;
	}
	
	/*if (stripped.length < 6) 
	{
		alert("The phone number is the wrong length.\n");
		return false;
	}*/
	
	return true;
}
