<!--

  /* the following  functions are referenced from can_1day.asp only */
  function newWindow4x()  {
    mapWindow = window.open('pop_small.html','testWin','scrollbar=no,width=300,height=310')
  }
  function newWindow6x()  {
    mapWindow = window.open('pop_large.html','testWin','scrollbar=no,width=420,height=430')
  }
  function SubmitIfValid(){
    if(document.frmMain2.ID.value == ""){
	  alert("Please pick a city from the list");
	  return false;
	}
	document.frmMain2.submit();
  }
  /* end can_1day.asp functions */



  /* redirects top frame content to value of document var */
  function changeTopFrame(document) {
    parent.header.location.href = document;
  }


  /////////////////////////////////////////////////////////////////////////////
  // SHOW HIDE DIV LAYER FUNCTIONS (used on 4-day forecast)
  function HideContent(d) {
    if(d.length < 1) {
      return;
    }
    document.getElementById(d).style.display = "none";
  }

  function ShowContent(d) {
    if(d.length < 1) {
      return;
    }
  document.getElementById(d).style.display = "";
  }

  function ReverseContentDisplay(d) {
    if(d.length < 1) {
      return;
    }
    if(document.getElementById(d).style.display == "none") {
      document.getElementById(d).style.display = "";
    } else {
      document.getElementById(d).style.display = "none";
    }
  }
  // END - SHOW HIDE DIV LAYER FUNCTIONS
  /////////////////////////////////////////////////////////////////////////////



  function ValidateForm(){
    var strMsg = "";
    if(document.form1.EmailFrom.value == ""){
      strMsg = "Please fill in your email address.\n";
    }
    if(strMsg == ""){
      return true;
    } else{
      alert(strMsg);
      return false;
    }
  }

  function open_window(url) {
    mywin = window.open(url,"win",'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=345,height=350');
  }
  function CloseWindow() {
    mywin = window.close()
  }

  function isValidEmail(str) {
    var at        = "@";
    var dot       = ".";
    var lat       = str.indexOf(at);
    var lstr      = str.length;
    var ldot      = str.indexOf(dot);
    var blnResult = true;

    if (str.indexOf(at)==-1) {
      var blnResult = false;
    }
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
      var blnResult = false;
    }
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      var blnResult = false;
    }
    if (str.indexOf(at,(lat+1))!=-1){
      var blnResult = false;
    }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      var blnResult = false;
    }
    if (str.indexOf(dot,(lat+2))==-1){
      var blnResult = false;
    }
    if (str.indexOf(" ")!=-1){
      var blnResult = false;
    }
    return blnResult;
  }

  function isValidZip(str) {
    var strValidChars = "0123456789";
    var strChar;
    var blnResult     = true;

    if (str.length < 5) {
      blnResult = false;
    }
    // string comprised of only the valid characters listed above?
    for (i=0; i<str.length && blnResult==true; i++) {
      strChar = str.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) {
        blnResult = false;
      }
    }
    return blnResult;
  }

  function formMainSubmit(formToSubmit) {
    if (formToSubmit == "AA_Signup_Form") {
      var form = document.AA_Signup_Form;
    } else {
      var form = document.AA_Signup_Form_LeftNav;
    }

    // invalid email
    if (!isValidEmail(form.Email.value)) {
      alert("Please enter a valid e-mail address where you'd like to receive your alerts.");
      return false;
    }
    // invalid zip
    if (!isValidZip(form.PostalCode.value)) {
      alert("Please enter the valid 5-digit zip code of the city you'd like reported in your email alerts.");
      return false;
    }
    form.Email2.value = form.Email.value;
    form.submit();
  }
// -->