function Map(page) {
OpenWin=this.open(page,"ctrlwindow","left=20,top=-440,width=440,height=400,toolbar=no,location=no,scrollbars=yes,resize=yes");
	}

// A utility function that returns true if a string contains only 
// whitespace characters.
function isblank(s) {
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}  // End function

// DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	if (str.lastIndexOf(dot) == (lstr-1)){
	    return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
	    return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
	    return false
	}
		
	if (str.indexOf(" ")!=-1){
	    return false
	}

 	return true					
}
// A utility function that returns true if a string contains a non-positive integer number,
// commas aren't allowed.
function fieldNotInteger(e) {

    var istrValidChars = "0123456789";
    var istrChar;
    var istrNxtChar;
    var iisNumeric;
    var ibadStrEnd;
    var idblChar;
    var idecmCount;

    iisNumeric = true;
    ibadStrEnd = false;
    idblChar = false;
    idecmCount = 0;
    for(var m = 0; m < e.value.length && iisNumeric; m++) {
        if (e.value.charAt(0) === "," ||  e.value.charAt(e.value.length-1) === ",") ibadStrEnd = true;
        if (!ibadStrEnd) {
            istrChar = e.value.charAt(m);
            if (istrChar === ".") idecmCount++;
            if (idecmCount < 2 && m != e.value.length-1) {
       	        istrNxtChar = e.value.charAt(m+1);
                if ((istrChar === "," && istrNxtChar === ",") ||
                    (istrChar === "," && istrNxtChar === ".") ||
                    (istrChar === "." && istrNxtChar === ",") ||
                    (istrChar === "." && istrNxtChar === ".")) idblChar = true;
            }
        }
        if (istrValidChars.indexOf(istrChar) == -1 || ibadStrEnd || idecmCount > 1 || idblChar) {
            iisNumeric = false;
            return true;
        }
    }   //  End for loop

    return false;

}  // End function


// A utility function that returns true if a string contains an invalid decimal number
function fieldNotDecimal(e) {

    var strValidChars = "0123456789,.-";
    var strChar;
    var strNxtChar;
    var isNumeric;
    var badStrEnd;
    var dblChar;
    var decmCount;

    isNumeric = true;
    badStrEnd = false;
    dblChar = false;
    decmCount = 0;
    for(var j = 0; j < e.value.length && isNumeric; j++) {
        if (e.value.charAt(0) === "," ||  e.value.charAt(e.value.length-1) === ",") badStrEnd = true;
        if (!badStrEnd) {
            strChar = e.value.charAt(j);
            if (strChar === ".") decmCount++;
            if (decmCount < 2 && j != e.value.length-1) {
       	        strNxtChar = e.value.charAt(j+1);
                if ((strChar === "," && strNxtChar === ",") ||
                    (strChar === "," && strNxtChar === ".") ||
                    (strChar === "." && strNxtChar === ",") ||
                    (strChar === "." && strNxtChar === ".")) dblChar = true;
            }
        }
        if (strValidChars.indexOf(strChar) == -1 || badStrEnd || decmCount > 1 || dblChar) {
            isNumeric = false;
            return true;
        }
    }   //  End for loop

    return false;

}  // End function

function Form1_Validator(theForm)
{

  var msg_all;
  var msg_txt = "";
  var msg = new Array();
  var errors = "";

  if ((theForm.state.selectedIndex <= 1) && ((theForm.zipcode.value == null) || (theForm.zipcode.value == "") || isblank(theForm.zipcode.value)))
  {
    theForm.zipcode.focus();
    errors = "yes";
	msg[0] = "yes";	  
  }
  else
  {
	  if (theForm.state.selectedIndex > 1 && !isblank(theForm.zipcode.value))
	  {
		theForm.zipcode.focus();
		errors = "yes";
		msg[1] = "yes";	  
	  }
	  else
	  {
		  if (theForm.zipcode.value.length < 5 && !isblank(theForm.zipcode.value))
		  {
			theForm.zipcode.focus();
			errors = "yes";
			msg[2] = "yes";	  
		  }
		  if ((!isblank(theForm.zipcode.value)) && fieldNotDecimal(theForm.zipcode))
		  {
			theForm.zipcode.focus();
			errors = "yes";
			msg[3] = "yes";
		  }
	  }
  }
        
  if (errors == "yes")
  {
    if (msg[0] == "yes")
	  msg_txt += "\n-- Zip Code or State must be entered.\n";
    if (msg[1] == "yes")
	  msg_txt += "\n-- Enter either Zip Code or State, not BOTH. Remove a selected state by selecting \"No State\" at top of the state selection column.\n";
    if (msg[2] == "yes")
	  msg_txt += "\n-- You've entered an invalid Zip Code.\n";
    if (msg[3] == "yes")
	  msg_txt += "\n-- Zip Code must be numeric.\n";

    msg_all  = "______________________________________________________\n\n"
    msg_all += "The form was not submitted because of the following error(s).\n";
    msg_all += "Please correct these error(s) and click Continue.\n";
    msg_all += "______________________________________________________\n\n"
    
	msg_all += msg_txt;
	alert(msg_all);
	return (false);	  
  }
  else
    return (true);
}