// JavaScript Document

function validator(form){
	
	if (document.getElementById("topic").selectedIndex==0) {
	hideAllErrors();
	document.getElementById("topicError").style.display = "inline";
	document.getElementById("topic").focus();
	return false;
	}
	if(notEmpty(form.txtFName.value)==false){
		hideAllErrors();
		document.getElementById("fnameError").style.display = "inline";
		form.txtFName.focus();
	return false;
	}
	if(notEmpty(form.txtLName.value)==false){
		hideAllErrors();
		document.getElementById("lnameError").style.display = "inline";
		form.txtLName.focus();
	return false;
	}
	if(notEmpty(form.txtAddress.value)==false){
		hideAllErrors();
		document.getElementById("addressError").style.display = "inline";
		form.txtAddress.focus();
	return false;
	}
	if(notEmpty(form.txtCity.value)==false){
		hideAllErrors();
		document.getElementById("cityError").style.display = "inline";
		form.txtCity.focus();
	return false;
	}
	if (document.getElementById("state").selectedIndex==0) {
	hideAllErrors();
	document.getElementById("stateError").style.display = "inline";
	document.getElementById("state").focus();
	return false;
	}
	if(validateZip(form.txtZip.value)==false){
		hideAllErrors();
		document.getElementById("zipError").style.display = "inline";
		form.txtZip.focus();
		return false;
	}
	form.txtZip.value = formatZip(form.txtZip.value);
	if(validateUSPhone(form.txtPhone.value)==false){
		hideAllErrors()
		document.getElementById("phoneError").style.display = "inline";
		form.txtPhone.focus();
		return false;
	}
	form.txtPhone.value = formatPhone(form.txtPhone.value);
	
	if(notEmpty(form.txtCity.value)==false){
		hideAllErrors();
		document.getElementById("cityError").style.display = "inline";
		form.txtCity.focus();
	return false;
	}
	if(validateEMail(form.txtBlah.value)==false){
		hideAllErrors();
		document.getElementById("emailError").style.display = "inline";
		form.txtBlah.focus();
		return false;
	}
	form.txtBlah.value = strip(" \n\r\t",form.txtBlah.value);
	if (document.getElementById("preferred").selectedIndex==0) {
		hideAllErrors();
		document.getElementById("preferredError").style.display = "inline";
		document.getElementById("preferred").focus();
		return false;
	}
	if(notEmpty(form.txtComment.value)==false){
		hideAllErrors();
		document.getElementById("commentError").style.display = "inline";
		form.txtComment.focus();
	return false;
	}
	
}

function hideAllErrors() {
document.getElementById("topicError").style.display = "none"
document.getElementById("fnameError").style.display = "none"
document.getElementById("lnameError").style.display = "none"
document.getElementById("addressError").style.display = "none"
document.getElementById("cityError").style.display = "none"
document.getElementById("stateError").style.display = "none"
document.getElementById("zipError").style.display = "none"
document.getElementById("phoneError").style.display = "none"
document.getElementById("emailError").style.display = "none"
document.getElementById("preferredError").style.display = "none"
document.getElementById("commentError").style.display = "none"

  }
