function checkForm(theForm, fieldArray)
{
	for (var i = 0; i < fieldArray.length; i++)
	{
		var currentElement = theForm.elements[fieldArray[i]];
		var currentElementValue = currentElement.value;
		if ((currentElementValue == "") || ((currentElement.type == "checkbox") && !(currentElement.checked)))
		{
			window.alert("Please complete all mandatory fields of the form.");
			currentElement.focus();
			return false;
		}
		else if (fieldArray[i] == "email")
		{
			if ((currentElementValue.indexOf("@") < 1) || (currentElementValue.indexOf("@") >= (currentElementValue.length - 4)))
			{
				window.alert("Invalid e-mail address.");
				currentElement.focus();
				return false;
			}
			else if (currentElementValue.lastIndexOf(".") >= (currentElementValue.length - 2))
			{
				window.alert("Invalid e-mail address.");
				currentElement.focus();
				return false;
			}
			
			// Check for confirm field
			if (theForm.elements["email_confirm"] != null)
			{
				if (theForm.elements["email_confirm"].value != currentElementValue)
				{
					window.alert("Your e-mail address and your confirm e-mail address do not match, please check both are your correct e-mail address.");
					currentElement.focus();
					return false;
				}
			}
		}
	}
	return true;
}

function openNewWin(theElement)
{
	var theURL = theElement.getAttribute("href");
	void(window.open(theURL));
	return false;
}
