var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var bIE=false;
var bNetscape=false;
var strErrorMessage = "";

if (bName == "Netscape" && bVer >= 3){
	bNetscape = true;
}
else if (bName == "Microsoft Internet Explorer" && bVer >= 4) {
	bIE = true;
}

function trimleadingandtrailing(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function fnTrapKD(btn, event){
 if (document.all){
  if (event.keyCode == 13){
   event.returnValue=false;
   event.cancel = true;
   btn.click();
  }
 }
 else if (document.getElementById){
  if (event.which == 13){
   event.returnValue=false;
   event.cancel = true;
   btn.click();
  }
 }
 else if(document.layers){
  if(event.which == 13){
   event.returnValue=false;
   event.cancel = true;
   btn.click();
  }
 }
}

function disableEnterKey() 
{ 
   if (window.event.keyCode == 13 && window.event.srcElement.type == undefined)
   {
		if( window.event.srcElement == '[object]' )
			window.event.keyCode = 0; 
    }
} 

function GetPrefix(varname)
	{
	var f = document.all("aspnetForm");
	for (var n = 0; n < f.length; n++)
		 {
		 if (f(n).id.indexOf(varname) >= 0) {return f(n).id.substring(0, f(n).id.lastIndexOf("_") + 1); }
		 }
	// next n
	}
// end GetPrefix()

function ZIPLookup(result, context)
	{
	if (result == ";")
		 {
		 alert("Please enter a valid ZIP code");
		 return;
		 }
	// end if

	var CityState = result.split(";");
   var strPrefix = GetPrefix("txtName");
	document.all(strPrefix + "txtCity").value = CityState[0];
	var cmb = document.all(strPrefix + "cmbState");
	for (n = 0; n < cmb.options.length - 1; n++)
		 {
		 if (cmb.options(n).value == CityState[1]) {cmb.selectedIndex = n;}
		 }
	// next n
	}
// end ZIPLookup

