var homeOn = new Image();
var homeOff = new Image();
var servicesOn = new Image();
var servicesOff = new Image();
var quotationsOn = new Image();
var quotationsOff = new Image();

function setPicky(imageName, image, imagePath)
{
	if (image.src == '')
	{
		image.src = imagePath;
	}
	document.images[imageName].src = image.src;
}

function NumberOfChar(str,char)
{
	var ii, charCount;
	charCount = 0;
	for (ii=0; ii < str.length;ii++)
	{
		var cc = str.charAt(ii);
		if (cc == char)
		{
			charCount = charCount + 1;
		}
	}
	return charCount;
}

function validEmail(str)
{
	var bool;
	bool = true;
	if (str.length < 6)
	{
		bool = false;
		alert("Email address has too few characters.");
	}
	if ((bool) && ((NumberOfChar(str,'@')==0)||(NumberOfChar(str,'@')>1)))
	{
		bool = false;
		alert("Email address contains the wrong number of @'s.");
	}
	if ((bool) && (NumberOfChar(str,'.')==0))
	{
		bool = false;
		alert("Email address must contain at least one '.'.");
	}
	if ((bool) && (NumberOfChar(str,' ')!=0))
	{
		bool = false;
		alert("Email address must not contain any spaces.");
	}
	return bool;
}

function validateQuoteForm(pForm)
{
	var bValid;
	bValid = true;

	if ((bValid) && (pForm.Name.value==''))
	{
		alert('You must enter your name.');
		bValid = false;
	}

	if ((bValid) && (pForm.Telephone_No.value=='') && (pForm.Work_No.value=='') && (pForm.Mobile_No.value==''))
	{
		alert('You must enter at least one contact number.');
		bValid = false;
	}
	
	if ((bValid) && (validEmail(pForm.Email.value)))
	{
		bValid = true;
	}
	else
	{
		bValid = false;
	}

	if ((bValid) && (pForm.Removal_Date.value==''))
	{
		alert('You must enter your removal date.');
		bValid = false;
	}

	if ((bValid) && (pForm.Present_Address.value==''))
	{
		alert('You must enter your present address.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.Present_Postcode.value==''))
	{
		alert('You must enter your present postcode.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.Present_Property.value==''))
	{
		alert('You must enter your present property type.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.Lift_Available_at_Present.value==''))
	{
		alert('You must tell us if there is a lift at your present property.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.No_of_Beds_at_Present.value==''))
	{
		alert('You must enter the number of bedrooms at your present property.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.No_of_Floors_at_Present.value==''))
	{
		alert('You must enter the number of floors at your present property.');
		bValid = false;
	}
		
	if ((bValid) && (pForm.Distance_at_Present.value==''))
	{
		alert('You must enter the distance between your house and the loading area.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.New_Address.value==''))
	{
		alert('You must enter your new address.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.New_Postcode.value==''))
	{
		alert('You must enter your new postcode.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.New_Property.value==''))
	{
		alert('You must enter your new property type.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.Lift_Available_at_New.value==''))
	{
		alert('You must tell us if there is a lift at your new property.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.No_of_Beds_at_New.value==''))
	{
		alert('You must enter the number of bedrooms at your new property.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.No_of_Floors_at_New.value==''))
	{
		alert('You must enter the number of floors at your new property.');
		bValid = false;
	}
	
	if ((bValid) && (pForm.Distance_at_New.value==''))
	{
		alert('You must enter the distance between your new house and the loading area.');
		bValid = false;
	}
	
	return bValid;
}
