var homeOn = new Image();
var homeOff = new Image();
var welcomeOn = new Image();
var welcomeOff = new Image();
var storeOn = new Image();
var storeOff = new Image();
var whatsOn = new Image();
var whatsOff = new Image();
var howOn = new Image();
var howOff = new Image();
var registerOn = new Image();
var registerOff = new Image();
var contactOn = new Image();
var contactOff = new Image();
var linksOn = new Image();
var linksOff = new Image();
var cashOn = new Image();
var cashOff = 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 validateRegisterForm(pForm)
{
	var bValid;
	bValid = true;

	if ((bValid) && (pForm.Title.value==''))
	{
		alert('You must enter your Title.');
		bValid = false;
	}

	if ((bValid) && (pForm.First_Name.value==''))
	{
		alert('You must enter your First Name.');
		bValid = false;
	}

	if ((bValid) && (pForm.Surname.value==''))
	{
		alert('You must enter your Surname.');
		bValid = false;
	}

	if ((bValid) && (pForm.Gender.value==''))
	{
		alert('You must select your Gender.');
		bValid = false;
	}

	if ((bValid) && (pForm.Age.value==''))
	{
		alert('You must enter your Age.');
		bValid = false;
	}
	
	if ((bValid) && (validEmail(pForm.Email_Address.value)))
	{
		bValid = true;
	}
	else
	{
		bValid = false;
	}
	
	if ((bValid) && (pForm.Read_Privacy.checked==false))
	{
		alert('You must read the privacy policy.');
		bValid = false;	
	}
	
	return bValid;
}
