// This function declaration takes an advantage
// of the already  missing function call on static PTP pages
// that are not calling setupPtp function
// Otherwise should use the initPtpDates
function initialize() {
  initPtpDates();
}

function initPtpDates() {  
  var form = document.form1;
  var now = new Date();
  var ahead = (arguments.length > 0)? arguments[0]: { year:0, month:1, day:0};
  var date = new Date(now.getFullYear()+ahead.year, now.getMonth()+ahead.month,
    now.getDate()+ahead.day);
  setValue(form.d0, date.getDate());
  setValue(form.m0, date.getMonth()+1);
  date.setDate(date.getDate()+14)
  setValue(form.d1, date.getDate());
  setValue(form.m1, date.getMonth()+1);
}

function populate(f)
{
  var e = f.split('=');

  if (e[0] && e[1]) {
    if (e[0] == 'F0') 
      document.form1.F0.value = e[1];
    if (e[0] == 'T0') 
      document.form1.T0.value = e[1];
  }
}

function populateFromTo()
{
  var querystr = window.location.search;
  var e = querystr.split('&');
  if (e[1]) {
    populate(e[1]);
  }
  if (e[0]) {
    populate(e[0].replace(/\?/, ""));
  }
}
