/*			contact.js		*/

/*==============================
initialization routines
==============================*/
function jsInit()
{
//debugFlag = true;
	var x;
	x = jsInitMenu();
	x = jsInitializeContact();

debugFlag = false;
}

/*==============================
initialize contact form
==============================*/
function jsInitializeContact()
{
debugAlert("jsInitializeContact()");
		if (!document.getElementById) return;

	var oObj;
	
	oObj = document.getElementById("Subject");
	oObj.onchange = jsChangeSubject;
	
	//jsChangeSubject();
	oObj = document.getElementById("SubjectOtherBox");
	oObj.className = "hidden";
	
	oObj = document.getElementById("contactForm");
	oObj.onsubmit = jsValidateInput;

}

/*==============================
validate input before submitting form
==============================*/
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;
		}
	
}


/*==============================
When Subject changes to Other, display Other input field
==============================*/
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.className = "visible";
			oOther.firstChild.focus();
		} else {
			oOther.className = "hidden";
		}
}

