/*			contact.js		*/

var debugFlag = false;
window.onload = jsInitializeForm;

function jsInitializeForm()
{
debugAlert("jsInitializeForm()");
		if (!document.getElementById) return;

	var oObj = document.getElementById("Subject");
	oObj.onchange = jsChangeSubject;
	
	oObj = document.getElementById("contactForm");
	oObj.onsubmit = jsValidateInput;

}

function jsValidateInput()
{
	//debugFlag = true;
	debugAlert("jsValidateInput()");

	var oObj = document.getElementById("contactName");
		if (oObj.value == "")
		{
			oObj.focus()
			alert("Please enter your name");
			return false;
		}
	
	oObj = document.getElementById("contactEmail");
		if (oObj.value == "")
		{
			oObj.focus()
			alert("Please enter your email address");
			return false;
		}
	
	var oObj = document.getElementById("Subject")
	var sVal = oObj.options[oObj.selectedIndex].value;
		if (oObj.value == "")
		{
			oObj.focus()
			alert("Please enter a subject");
			return false;
		}

		if (sVal == "other")
		{
			oObj = document.getElementById("SubjectOther");
				if (oObj.value == "")
				{
					oObj.focus()
					alert("Please enter a subject");
					return false;
				}
		}

	oObj = document.getElementById("contactMessage");
		if (oObj.value == "")
		{
			oObj.focus()
			alert("Please enter a message");
			return false;
		}
	
}


function jsChangeSubject()
{
	//debugFlag = true;
	debugAlert("jsChangeSubject()");

	var oList = this;

	var sVal = this.options[this.selectedIndex].value;
	debugAlert("sVal = " + sVal);

	var oOther = document.getElementById("SubjectOtherBox");
	
		if (sVal == "other")
		{
			oOther.style.display = "block";
		} else {
			oOther.style.display = "none";
		}
}


function debugAlert(argText)
{
	if (debugFlag) alert(argText);
}