// --------------------------------------------------------------------SCRIPT--

function todays_date()
{
   today = new Date;
   var month_name = new String;
   year = today.getYear()+1900;
   month = today.getMonth();
   if (month == 0)
      month_name = "January";
   else if (month == 1)
      month_name = "February";
   else if (month == 2)
      month_name = "March";
   else if (month == 3)
      month_name = "April";
   else if (month == 4)
      month_name = "May";
   else if (month == 5)
      month_name = "June";
   else if (month == 6)
      month_name = "July";
   else if (month == 7)
      month_name = "August";
   else if (month == 8)
      month_name = "September";
   else if (month == 9)
      month_name = "October";
   else if (month == 10)
      month_name = "November";
   else if (month == 11)
      month_name = "December";
   document.write(month_name+" "+today.getDate()+", "+year);
}

// ----------------------------------------------------------------------------

function kilroy()
{
   document.write("<img width=\"36\" height=\"14\" border=\"0\" "  +
                  "src=\"/programs/kilroy"+
                  "?referrer="+ escape(document.referrer)          +
                  "&url="     + escape(window.location.href)       +
                  "&appname=" + escape(navigator.appName)          +
                  "&appver="  + escape(navigator.appVersion)       +
                  "\" alt=\"kilroy\">");
}

// ----------------------------------------------------------------------------

function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

// ----------------------------------------------------------------------------

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf(";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

// ----------------------------------------------------------------------------

function getCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal(j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

// ----------------------------------------------------------------------------

function setCustomerCookie(_pn, _m, _d, _y, _mz) {
  setCookie("pn", _pn, null, "/imACustomer", "infinity-insurance.com", false);
  setCookie("m", _m, null, "/imACustomer", "infinity-insurance.com", false);
  setCookie("d", _d, null, "/imACustomer", "infinity-insurance.com", false);
  setCookie("y", _y, null, "/imACustomer", "infinity-insurance.com", false);
  setCookie("mz", _mz, null, "/imACustomer", "infinity-insurance.com", false);
}

// ----------------------------------------------------------------------------

function customerCookieLogin(form) {
  var pn = getCookie("pn");
  var m = getCookie("m");
  var d = getCookie("d");
  var y = getCookie("y");
  var mz = getCookie("mz");
  if (pn != null) {
    form.userid.value = pn;
    form.birthdate_m.value = m;
    form.birthdate_d.value = d;
    form.birthdate_y.value = y;
    form.password.value = mz;
    form.submit();
  }
  else {
    window.location.href = 
      "http://www.infinity-insurance.com/imACustomer/login.html";
  }
  return true;
}

// ----------------------------------------------------------------------------

function setAgentCookie(_an, _pw) {
  setCookie("an", _an, null, "/", "infinity-insurance.com", false);
  setCookie("pw", _pw, null, "/imAnAgent", "infinity-insurance.com", false);
}

// ----------------------------------------------------------------------------

function agentCookieLogin(form) {
  var an = getCookie("an");
  var pw = getCookie("pw");
  if (an != null) {
    form.userid.value = an;
    form.password.value = pw;
    form.submit();
  }
  else {
    window.location.href = 
      "http://www.infinity-insurance.com/imAnAgent/login.html";
  }
  return true;
}

// ----------------------------------------------------------------------------
