//Routines to submit the form on any press of the Enter key.
function netscapeKeyPress(e) {
	if (e.which==13) {
		submitPage();
	}
}

function microsoftKeyPress() {
	if (window.event.keyCode == 13) {
			submitPage();
	}
}

if (navigator.appName == 'Netscape') {
    window.captureEvents(Event.KEYPRESS);
    window.onKeyPress = netscapeKeyPress;
}

//Function to validate character input. Used ONLY in default.asp.
//If 2nd param="Yes" check for characters; if 2nd param="No" check numbers.
function ValidateInput(strTest,Alpha) {
	var Valid;
	var Validated;
	var Blank;
	var Msg;
	var FocusBox;
	if (strTest=="" || strTest==null) {
		return;
	}
	//set alpha or number variables
	if (Alpha=="Yes") {
		Valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -,'/";
		Blank="window.document.form1.city.value=''";
		Msg="Please enter a valid city name."
		FocusBox="window.document.form1.city.focus();";
	} else {
		Valid="1234567890 -";
		Blank="window.document.form1.zip.value=''";
		Msg="Please enter a valid zip code."
		FocusBox="window.document.form1.zip.focus();";
	}
	//test each entered character against valid list
	for (var i=0;i<strTest.length;i++) {
		if (Valid.search(strTest.charAt(i)) != -1) {
			Validated = "Yes";
		} else {
			Validated = "No";
		}
	}
	//display error or exit
	if (Validated=="No") {
		eval(Blank);
		eval(FocusBox);
		alert(Msg);
	}
	return Validated;
}

//Function to submit international maps. Used ONLY in default.asp.
function International(countryCD) {
	window.document.form1.action="V_locationsINT.asp?AD4=" + countryCD + "&BID=<%=strBagID%>&h=<%=strHeader%>";
	window.document.form1.submit();
}

var strCityFocus = "";
//Function to submit the form. Used ONLY in default.asp.
function submitPage() {
	var flgValid = "Yes";
	if (window.document.form1.city.value>"") {
		flgValid = ValidateInput(window.document.form1.city.value,"Yes");
	}
	if (window.document.form1.zip.value>"") {
		flgValid = ValidateInput(window.document.form1.zip.value,"No");
	}
	if (flgValid=="Yes") {
		if (window.document.form1.city.value=="" && window.document.form1.zip.value=="") {
			strCityFocus = CityFocus(window.document.form1.state.value);
			window.document.form1.action="V_locations.asp?BID=<%=strBagID%>&h=<%=strHeader%>"+strCityFocus+"&StateOnly=Y";
			window.document.form1.submit();
		} else if (window.document.form1.state.value=="" && window.document.form1.zip.value=="") {
			alert("Please select a state or enter zip code.");
			window.document.form1.city.focus();
		} else {
			window.document.form1.method = "POST";
			window.document.form1.action = "V_locations.asp?BID=<%=strBagID%>&h=<%=strHeader%>";
			window.document.form1.submit();
		}
	}
}
//Function to clear all forms and place cursor in City input field. Used ONLY in default.asp.
function ClearAllForms() {
	for (var i=0;i<window.document.forms.length;i++) {
		document.forms[i].reset();
	}
	window.document.form1.city.focus();
}

