var registerformchecks = new Array ("Name","Please enter a name to continue",
									"Address","Please enter an address to continue",
									"Telephone","Please enter an telephone number to continue",
									"Fax","Please enter a fax number to continue",
									"Email","Please enter an email address to continue",
									"Contact","Please enter a contact to continue",
									"Terms","You must tick to accept the terms and conditions in order to continue");

window.onload = function()
{
	standard_onload();

	if (document.getElementById) 
	{
		currentForm = document.getElementById('registrationform');
		if (currentForm != null)
		{
			arrayToCheck = registerformchecks;
			currentForm.onsubmit = RegisterSpecificChecks;
		}
	}
}

function RegisterSpecificChecks()
{
	Result = true;
	var bFailedAlready = false;
	if (Result != false)
	{
		authorisationRadio = document.getElementById('AuthorisationYes');
		if (authorisationRadio.checked)
		{
			authorisationDetailsInput = document.getElementById('AuthorisationNotes');
			if (authorisationDetailsInput.value == '')
			{
				alert('Please enter FSA number to continue');
				return false;
				bFailedAlready = true;
			}
		}
	}
	if (Result != false)
	{
		appointedrepRadio = document.getElementById('AppointedRepYes');
		if (appointedrepRadio.checked)
		{
			appointedrepDetailsInput = document.getElementById('AppointedRepNotes');
			if (appointedrepDetailsInput.value == '')
			{
				alert('Please enter name of firm and their FSA number continue');
				return false;
				bFailedAlready = true;
			}
		}
	}
		
	typeOfBusinessSelect = document.getElementById('TypeOfBusiness');
	if (typeOfBusinessSelect.value == 'Other')
	{
		otherDetailsInput = document.getElementById('OtherDetails');
		if (otherDetailsInput.value == '')
		{
			alert('Please enter more information about your type of business');
			return false;
			bFailedAlready = true;
		}
	}
	if (!bFailedAlready)
	{
		var bProdSelected = false;
		// Ensure at least one product is selected
		for (aIndex = 0; aIndex < registerformprods.length; aIndex++)
		{
			currentProd = document.getElementById(registerformprods[aIndex]);
			if (currentProd != null)
			{
			     if (currentProd.checked == true) bProdSelected = true;
			}
		}
		if (!bProdSelected) 
		{
			alert('Please select at least one product that you will be marketing');
			return false;	
		}
		else return CheckForm();
	}
}