// **********************************************
// * pop-up the calendar window
// **********************************************

function calWindow(objField)
{
  var strYear, strMonth, strDay, intResult;

  var elems = objField.value.split("/");
  if (elems.length == 3)      // display current date as the default
  {
    strMonth = (parseInt(elems[0], 10) - 1);
    strDay = parseInt(elems[1], 10);
    strYear = parseInt(elems[2], 10);
  }
  else
  {
    var today = new Date();
    strDay = today.getDate();
    strMonth = today.getMonth();
    strYear = y2k(today.getYear());
  }

  fldCurrent = objField;
  mywindow = open('/includes/popup/cal.asp?strYear=' + strYear + '&strMonth=' + strMonth 
      + '&strDay=' + strDay, 'myname','resizable=no,width=350,height=300');
  mywindow.location.href = '/includes/popup/cal.asp?strYear=' + strYear 
      + '&strMonth=' + strMonth + '&strDay=' + strDay;
  if (mywindow.opener == null) { mywindow.opener = self; }
}

// **********************************************
// * return a y2k year
// **********************************************

function y2k(number)
{
  return (number < 1000) ? number + 1900 : number;
}

// **********************************************
// * redisplay the window
// **********************************************

function restart()
{
  fldCurrent.value = '' + padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
  if (fldCurrent.onchange != null)
  {
    eval("fldCurrent.onchange();"); // call onChange event for the actual date field
  }
  mywindow.close();
}

// **********************************************
// * make a 2 digit number
// **********************************************

function padout(number)
{
  return (number < 10) ? '0' + number : number;
}
