function validateForm(form)
{
    if(!validate_AGE_01(form)) {
        return false;
    } else if(!validate_ZIP_01(form)) {
        return false;
    } else {
      if(formSubmitted==true) {
        alert( "You have already submitted this form." );
        return false;
      } else {
        noPopup=true;
        formSubmitted=true;
        return true;
      }
    }
}

function submitForm2PopUnderValidateForm(form) {
    var status = validateForm(form);
    if (status == true && form && form.popunder && form.popunder.value == 'true') {
        setForm2Fields(form);
        window.document.form2.MATCH_SUREHITS_UNDER.value = "YES";  
        
        var newWindow = window.open('', 'formWindow', 'height=1000,width=1000,scrollbars=yes');
        newWindow.blur();
        
        window.document.form2.target='formWindow';
        document.form2.submit();
        window.focus();
    }
    return status;
}

function queryString(key){
  var page = new PageQuery(window.location.search);
  return unescape(page.getValue(key));
}

function initF()
{
  if (window.document.form1.STATE_ONLY_FORM && window.document.form1.STATE_ONLY_FORM.value == 'YES') {
    formSubmitted = true;
    document.form1.submit();
  } else {
    formSubmitted=false;
    if (typeof(showErrors)!="undefined" && showErrors == true) {
        showErrors();
    }
    var zip = queryString("ZIP_01");
    if(zip && window.document.form1.ZIP_01) {
        window.document.form1.ZIP_01.value = zip;
    }
    preselect_AGE_01();
  }
}
