
var containErrors = false;
var errorMsg = "";

function IsValidateEmail(Email) 
{
	var regEmail  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return regEmail.test(Email.replace(/\s/g, ""));
}

function ClearErrors()
{
	document.getElementById("spn2title").style.color = '#000000';
	document.getElementById("spn2firstname").style.color = '#000000';
	document.getElementById("spn2surname").style.color = '#000000';
	document.getElementById("spn2Address").style.color = '#000000';
	document.getElementById("spn2postcode").style.color = '#000000';
	document.getElementById("spn2number").style.color = '#000000';
	document.getElementById("spn2occupation").style.color = '#000000';


	containErrors = false;
	
}

function SetError(divError, msg)
{
	
	errorMsg += msg + "\n";
	document.getElementById(divError).style.color = '#ff0000';
	
	containErrors = true;
}

function CheckRentalForm() 
{
	
	var form = document.getElementById("form1");
	var now = new Date();
	
	errorMsg = "";
	
	ClearErrors();
	
	if(form.title2.selectedIndex <= 0)
		SetError("spn2title", "You must enter your Title");
		
	if(form.firstname2.value.replace(/\s/g, "") == "")
		SetError("spn2firstname", "You must enter your first name");
	
	if(form.surname2.value.replace(/\s/g, "") == "")
		SetError("spn2surname", "You must enter your surname");
	
	if(form.propertyaddress2.value.replace(/\s/g, "") == "")
		SetError("spn2Address", "You must enter an address");
	
	if(form.postcode2.value.replace(/\s/g, "") == "")
		SetError("spn2postcode", "You must enter a postcode");
	
	if(form.contactnumber2.value.replace(/\s/g, "") == "")
		SetError("spn2number", "You must enter a contact number");
	
	if(form.occupation2.value.replace(/\s/g, "") == "")
		SetError("spn2occupation", "You must enter your occupation");
	
	
	if(containErrors)
	{
		alert("The following fields are required:\n" + errorMsg);
		window.scrollTo(0,0);
		//return false;
	}
	//return true;
	
}