<!--
// This file contains data validation JavaScript functions for HTML pages with forms

function valtext() {
  if (document.aform.aref.value.length==0 &&
      document.aform.aname.value.length==0 &&
      document.aform.alocn.value.length==0) {
      window.alert('Enter an Application Ref.\n OR an Applicant name\n OR a Location');
      return false;
      }
  else {
        return true;
       }
}

// Validate FROM Date components (day, month, year)

function valfdate(mth) {
  var i = mth.selectedIndex;
  if(mth.options[i].value == "2") {
    document.aform.fday.options[30] = null;
    document.aform.fday.options[29] = null;
    var j = document.aform.fyr.selectedIndex;
    var year = eval(document.aform.fyr.options[j].value);
    if ( ((year%400)==0) || (((year%100)!=0) && ((year%4)==0)) ) {
      if (document.aform.fday.options[28] == null) {
        document.aform.fday.options[28] = new Option("29");
        document.aform.fday.options[28].value = "29";
      }
    } else {
      document.aform.fday.options[28] = null;
    }
  }

  if(mth.options[i].value == "1" ||
     mth.options[i].value == "3" ||
     mth.options[i].value == "5" ||
     mth.options[i].value == "7" ||
     mth.options[i].value == "8" ||
     mth.options[i].value == "10" ||
     mth.options[i].value == "12")
  {
    if (document.aform.fday.options[28] == null) {
      document.aform.fday.options[28] = new Option("29");
      document.aform.fday.options[28].value = "29";
    }
    if (document.aform.fday.options[29] == null) {
      document.aform.fday.options[29] = new Option("30");
      document.aform.fday.options[29].value = "30";
    }
    if (document.aform.fday.options[30] == null) {
      document.aform.fday.options[30] = new Option("31");
      document.aform.fday.options[30].value = "31";
    }
  }

  if(mth.options[i].value == "4" ||
     mth.options[i].value == "6" ||
     mth.options[i].value == "9" ||
     mth.options[i].value == "11")
  {
    if (document.aform.fday.options[28] == null) {
      document.aform.fday.options[28] = new Option("29");
      document.aform.fday.options[28].value = "29";
    }
    if (document.aform.fday.options[29] == null) {
      document.aform.fday.options[29] = new Option("30");
      document.aform.fday.options[29].value = "30";
    }
    document.aform.fday.options[30] = null;
  }

  if (document.aform.fday.selectedIndex == -1) {
    document.aform.fday.selectedIndex = 0;
  }
}

// Validate TO Date

function valtdate(mth) {
  var i = mth.selectedIndex;
  if(mth.options[i].value == "2") {
    document.aform.tday.options[30] = null;
    document.aform.tday.options[29] = null;
    var j = document.aform.tyr.selectedIndex;
    var year = eval(document.aform.tyr.options[j].value);
    if ( ((year%400)==0) || (((year%100)!=0) && ((year%4)==0)) ) {
      if (document.aform.tday.options[28] == null) {
        document.aform.tday.options[28] = new Option("29");
        document.aform.tday.options[28].value = "29";
      }
    } else {
      document.aform.tday.options[28] = null;
    }
  }

  if(mth.options[i].value == "1" ||
     mth.options[i].value == "3" ||
     mth.options[i].value == "5" ||
     mth.options[i].value == "7" ||
     mth.options[i].value == "8" ||
     mth.options[i].value == "10" ||
     mth.options[i].value == "12")
  {
    if (document.aform.tday.options[28] == null) {
      document.aform.tday.options[28] = new Option("29");
      document.aform.tday.options[28].value = "29";
    }
    if (document.aform.tday.options[29] == null) {
      document.aform.tday.options[29] = new Option("30");
      document.aform.tday.options[29].value = "30";
    }
    if (document.aform.tday.options[30] == null) {
      document.aform.tday.options[30] = new Option("31");
      document.aform.tday.options[30].value = "31";
    }
  }

  if(mth.options[i].value == "4" ||
     mth.options[i].value == "6" ||
     mth.options[i].value == "9" ||
     mth.options[i].value == "11")
  {
    if (document.aform.tday.options[28] == null) {
      document.aform.tday.options[28] = new Option("29");
      document.aform.tday.options[28].value = "29";
    }
    if (document.aform.tday.options[29] == null) {
      document.aform.tday.options[29] = new Option("30");
      document.aform.tday.options[29].value = "30";
    }
    document.aform.tday.options[30] = null;
  }

  if (document.aform.tday.selectedIndex == -1) {
    document.aform.tday.selectedIndex = 0;
  }
}

// -->

