<!--

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());
var caller = -1;

function NewWindow(mypage, myname, w, h, scroll) {
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
  win = window.open(mypage, myname, winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function y2k(number) {
  return (number < 1000) ? number + 1900 : number;
}


function padout(number) {
  return (number < 10) ? '0' + number : number;
}

function restart() {
  var arr_Month_Name = new Array;
  arr_Month_Name[0] = "Jan";
  arr_Month_Name[1] = "Feb";
  arr_Month_Name[2] = "Mar";
  arr_Month_Name[3] = "Apr";
  arr_Month_Name[4] = "May";
  arr_Month_Name[5] = "Jun";
  arr_Month_Name[6] = "Jul";
  arr_Month_Name[7] = "Aug";
  arr_Month_Name[8] = "Sep";
  arr_Month_Name[9] = "Oct";
  arr_Month_Name[10] = "Nov";
  arr_Month_Name[11] = "Dec";

  //caller.value = '' + padout(day) + ' ' + arr_Month_Name[month] + ' ' + year;
  caller.value = '' + year + '-' + padout((parseInt(month) + 1)) + '-' + padout(day);
  mywindow.close();
}

function newCalWindow(in_caller, path_to_cal_htm) {
  caller = in_caller;
  var w = 350;
  var h = 270;
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  var winprops = 'height=' + h + ',width=' + w +',top='+wint+',left='+winl+',resizable=no';

  mywindow=open(path_to_cal_htm + 'cal.htm','myname',winprops);
  mywindow.location.href = path_to_cal_htm + 'cal.htm';
  if (mywindow.opener == null) mywindow.opener = self;
}

function printToday() {
  var dt = new Date();
  var int_day = dt.getDate();
  var int_month = dt.getMonth();
  var int_year = dt.getYear();

  var arr_Month_Name = new Array;
  arr_Month_Name[0] = "January"
  arr_Month_Name[1] = "Febuary"
  arr_Month_Name[2] = "March"
  arr_Month_Name[3] = "April"
  arr_Month_Name[4] = "May"
  arr_Month_Name[5] = "June"
  arr_Month_Name[6] = "July"
  arr_Month_Name[7] = "August"
  arr_Month_Name[8] = "September"
  arr_Month_Name[9] = "October"
  arr_Month_Name[10] = "November"
  arr_Month_Name[11] = "December"

  document.write(int_day + " " + arr_Month_Name[int_month] + " " + getCorrectedYear(int_year));
}


function getCorrectedYear(year) {
  if (year < 70) return (2000 + year);
  if (year < 1900) return (1900 + year);
  return year;
}


function submitForm()
{
  document.form1.submit();
}

// Function to validate the dropdown form input

function dropdown_validator() {
  // Variables for the current date, year and month
  var right_now=new Date();
  var the_year=right_now.getYear();
  var the_month=right_now.getMonth();
  var the_day=right_now.getDay();

  var in_day = dropdown_form.fm_day.value;
  var in_month = dropdown_form.fm_month.value;
  var in_year = dropdown_form.fm_year.value;

  // Check for input in the day, month and year fields
  if (in_day == "" || in_month == "" || in_year == "") {
    alert("Please select a date, month and year");
    return false;
  }

  // Check the 31th day of month
  if (in_day == "31") {
    if(in_month == "2" || in_month == "4" || in_month == "6" || in_month == "9" || in_month == "11") {
      var tmp_date = in_year+ "/" + in_month + "/" + in_day;
      alert("Invalid Date: " + tmp_date + " Please check the date of your request.");
      return (false);  
    }  
  }

  // Check the day of Feb
  if (in_month == "2" && in_day >=30) {
    var tmp_date = in_year+ "/" + in_month + "/" + in_day;
    alert("Invalid Date: " + tmp_date + " Please check the date of your request.");
    return (false);  
  }

  dropdown_form.receive_date.value = in_year + "/" + in_month + "/" + in_day;
}

//-->

