window.onload = function() 
{
	if (document.getElementById)
	{
		/* Associate logo's onclick event with home page */
		var logo = document.getElementById("logo");
		if (logo != null)
		{
			logo.onclick = function() 
			{
				window.location = 'index.php';
				return false;
			}
		}

		var submenu = document.getElementById("subli");
		if (submenu != null)
		{
				submenu.onmouseover = function() 
				{
					var submenulist = document.getElementById("submenu");
					if (submenulist != null) submenulist.className = 'showmenu';
				}

				submenu.onmouseout = function() 
				{
					var submenulist = document.getElementById("submenu");
					if (submenulist != null) submenulist.className = '';
				}
		}

		var aContactForm = document.getElementById('contactform');
		if (aContactForm != null) aContactForm.onsubmit = JSFnValidateContactForm;
	}	
}

var aContactRequiredFields = new Array ("FullName","Please enter your name to continue");
function JSFnValidateContactForm()
{
	var aEmail = document.getElementById('Email');
	var aAddress = document.getElementById('Address');
	var aTelephone = document.getElementById('Telephone');
	var aFax = document.getElementById('Fax');
	if ((aEmail != null) && (aAddress != null) && (aTelephone != null) && (aFax != null))
	{
		if ((aEmail.value == '') && (aAddress.value == '') && (aTelephone.value == '') && (aFax.value == ''))
		{
			alert('You must provide either your address, telephone/fax number or email address to continue.');
			return false;
		}
	}

	return JSFnValidateForm(aContactRequiredFields);
}

function JSFnValidateForm(aRequiredFields)
{
	for (aIndex = 0; aIndex < aRequiredFields.length; aIndex = aIndex + 2)
	{
		currElement = document.getElementById(aRequiredFields[aIndex]);
		if (currElement != null)
		{
			if  (   (   (currElement.type == 'text')
				     && (currElement.value == ''))
				 || (   (currElement.type == 'password')
				     && (currElement.value == ''))
				 || (   (currElement.type == 'checkbox')
				     && (currElement.checked == false))
				 || (   (currElement.type == 'file')
				     && (currElement.value == ''))
				 || (   (currElement.type == 'textarea')
				     && (currElement.value == ''))
				 || (   (currElement.type == 'select-one')
				     && (currElement.value == '')))
			{
				alert(aRequiredFields[aIndex + 1]);
				return false;
			}
			else if (currElement.type == 'radio')
			{
				aIndex = aIndex + 2;
				if (!currElement.checked)
				{
					currElement = document.getElementById(aRequiredFields[aIndex]);
					if ((currElement.type == 'radio') && (!currElement.checked))
					{
						alert(aRequiredFields[aIndex + 1]);
						return false;
					}
				}
			}
		}
	}
	return true;
}
