function switchMenu(id) {
	if (document.getElementById) {
		var subNavDiv = document.getElementById(id);
		subNavDiv.style.display = (subNavDiv.style.display == 'block') ? 'none' : 'block';
	}
}
function hideMenu(id) {
	if (document.getElementById) document.getElementById(id).style.display = 'none';
}

function otherStateCheck() {
   vState = document.request.StateProvinceName;
   if ( vState.selectedIndex != -1 && vState.options[vState.selectedIndex].value == 'OTHER' ) {
		toggleLayer('otherStateDiv');
      return false;
   }
	return true;
}

function otherLeadCheck() {
   vLead = document.request.LeadSource;
   if ( vLead.selectedIndex != -1 && vLead.options[vLead.selectedIndex].value == 'OTHER' ) {
		toggleLayer('otherLeadDiv');
      return false;
   }
	return true;
}

function toggleLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function DataValidation() {
	if (document.request.FirstName.value == "") {
      alert("Please supply a full name.");
      return false;
   }
	if (document.request.LastName.value == "") {
      alert("Please supply a full name.");
      return false;
   }
   if (document.request.Title.value == "") {
      alert("Please supply a job title.");
      return false;
   }
   if (document.request.CompanyName.value == "") {
      alert("Please supply an institution name.");
      return false;
   }
   var myCompanyType = document.request.CompanyType.selectedIndex;
	if (myCompanyType == 0) {
		alert("Please select an institution type.");
		document.request.CompanyType.focus();
		return false;
	}
   if (document.request.Street1.value == "") {
      alert("Please supply a street address.");
      return false;
   }
   if (document.request.City.value == "") {
      alert("Please supply a city.");
      return false;
   }
   if (document.request.PostalCode.value == "") {
      alert("Please supply a zip or postal code.");
      return false;
   }
   var myCountry = document.request.CountryName.selectedIndex;
   var myState = document.request.StateProvinceName.selectedIndex;
	if (myCountry == 0) {
		alert("Please supply a country or region.");
		document.request.CountryName.focus();
		return false;
	} else {
		if ( document.request.CountryName.options[myCountry].value == 'United States' || document.request.CountryName.options[myCountry].value == 'Canada' ) {
			if (myState == 0 ) {
				alert("Please supply a valid state or province.");
				document.request.StateProvinceName.focus();
				return false;
			}
		}
   }
	if ( document.request.StateProvinceName.options[myState].value == 'OTHER' ) {
		if (document.request.otherState.value == "" || document.request.otherState.value == "provide other") {
			alert("Please supply a valid state or province. (other)");
			return false;
		}	
	}
   if (document.request.EmailAddress.value == "") {
      alert("Please supply a valid e-mail address.");
      return false;
   }
   var myLeadSource = document.request.LeadSource.selectedIndex;
	if (myLeadSource == 0) {
		alert("Please let us know how you heard about us.");
		document.request.LeadSource.focus();
		return false;
	}
	if ( document.request.LeadSource.options[myLeadSource].value == 'OTHER' ) {
		if (document.request.otherLead.value == "" || document.request.otherLead.value == "provide other") {
			alert("Please let us know how you heard about us. (other)");
			return false;
		}	
	}
	if (!document.request.BIPcust[0].checked && !document.request.BIPcust[1].checked && !document.request.BIPcust[2].checked) {
      alert("Please let us know if you're a BIP customer.");
      return false;
   }
	if (!document.request.intPrinted[0].checked && !document.request.intPrinted[1].checked) {
      alert("Please let us know if you're interested in printed materials.");
      return false;
   }
	if (!document.request.intTraining[0].checked && !document.request.intTraining[1].checked) {
      alert("Please let us know if you're interested in on-site training.");
      return false;
   }
	return true;
}
