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 aContactForm = document.getElementById('contactform');
		if (aContactForm != null) aContactForm.onsubmit = JSFnValidateContactForm;
				
		var aQA = document.getElementById('questions');
		if (aQA != null)
		{
			aPs = aQA.getElementsByTagName("p");
			for (aIndex = 0; aIndex < aPs.length; aIndex++)
			{
				if (aPs[aIndex].className == 'question')
				{
					aPs[aIndex].onclick = JSFnDisplayMore; 
					aPs[aIndex].style.cursor = 'pointer'; 
				}
			}				
		}
	}
}


var aContactRequiredFields = new Array ("name","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;
}

function JSFnDisplayMore()
{
	var aQA = document.getElementById('questions');
	if (aQA != null)
	{
		aPs = aQA.getElementsByTagName("p");
		for (aIndex = 0; aIndex < aPs.length; aIndex++)
		{
			if (aPs[aIndex] == this)
			{
				if(aPs[aIndex+1].style.display == 'block')
				{
					aPs[aIndex+1].style.display = 'none';
				}
				else
				{
					aPs[aIndex+1].style.display = 'block';
				}				
			}			
		}				
	}
}

