// quicklaw inc   Last modified: April 30, 2002 - mtm
// April 28, 2006 - "ConstructQLBrowser -- to handle MSIE 7.0" - mtm
// August 18, 2009 - Allow MSIE 8 - Pat & Dave

var londebug=false;

function msg(t) {
  if (QLBrowser.safari && londebug)
    alert(t);
} // msg

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function wcookie(acookie,deltatime) {
  var ed = new Date();
  var s  = ed.getTime() + deltatime
  ed.setTime(s);
  acookie += ' path=/;';
  acookie += ' expires=' + ed.toGMTString();
  msg("setting cookie to " + acookie);
  document.cookie = acookie;
}

function SetSignon()
{
  if (document.Login.RememberPW) document.Login.RememberPW.checked=false;
  if (document.Login.userid)  document.Login.userid.value="";
  if (!usecookie) return;
  var tc=document.cookie;
  msg("in setsignon cookie is " + tc);
  if (tc=="") return;
  var st=tc.indexOf('QLSIGNON=');
  if (st == -1) return;
  if (st != 0) {
    tc=tc.substring(st,tc.length);
    st=tc.indexOf('QLSIGNON=');
    msg("QLSIGNON not at start, tc is " + tc);
  }
  st+=9;
  msg("st is " + st);
  var end = tc.indexOf(';');
  msg("end is " + end);
  if (end == -1) end=tc.length;
  msg("end is " + end);
  var si=tc.substring(st,end);
  msg("si is '" + si +"'");
  if (si == "delete") {
    wcookie(tc,-365*24*60*60000);
    return;
  }
  document.Login.userid.value=si;
  document.Login.RememberPW.checked=true;
} // SetSignon


function CheckNS()
{
 if (document.Login.userid.value.toLowerCase()=="nosave") {
  var tc='QLSIGNON=nosave;';
  wcookie(tc,365*24*60*60000);
  location.reload();
  return false;
 };
 if (document.Login.userid.value.toLowerCase()=="reset") {
  var tc='QLSIGNON=nosave;';
  wcookie(tc,-365*24*60*60000);
  location.reload();
  return false;
 };
 if (!usecookie) {
  if (document.Login.RememberPW) document.Login.RememberPW.checked=false;
  return true;
 }
 return true;
}

function DontOffer()
{
  var tc='QLSIGNON=nosave;';
  wcookie(tc,365*24*60*60000);
  location.reload();
  return false;
}

function ConstructQLBrowser() {

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var ver=navigator.appVersion.toLowerCase();

    this.mac   = (agt.indexOf('macintosh') != -1) ||
                 (ver.indexOf('macintosh') != -1);

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    this.ns  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)
                && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    this.ns4 = (this.ns && (this.major == 4));
    this.ns5 = (this.ns && (this.major == 5));
    this.ns5up = (this.ns && (this.major >= 5));

    this.ie   = (agt.indexOf("msie") != -1);
    this.ie4  = (this.ie && (this.major == 4)
                && (agt.indexOf("msie 5.")==-1) );
    this.ie4up  = (this.ie  && (this.major >= 4));
    this.ie5  = (this.ie && (this.major == 4) &&
                (agt.indexOf("msie 5.")!=-1) );
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
    this.ie6  = (this.ie && (agt.indexOf("msie 6.")!=-1) );
    this.ie7  = (this.ie && (agt.indexOf("msie 7.")!=-1) );
    this.ie8  = (this.ie && (agt.indexOf("msie 8.")!=-1) );
    this.ie5up = (this.ie5up || this.ie6 || this.ie7 || this.ie8);
    this.ie5mac = (this.ie5up && this.mac);

    this.dom = (this.ie5up || this.ns5up);
    this.safari = false;

    // check for "buggy" versions of ns6 and mozilla 1.0
    if (this.ns5up) {
      g = agt.indexOf("safari");
      if (g != -1) {
        this.safari = true;
        return;
      }
      g = agt.indexOf("gecko/");
      if (g != -1) {
        g += 6; // point to start of date
        date = agt.slice(g,g+8);
        if (date < "20020823")
          this.dom = false;  // deny access
      }
      else
        this.dom = false;  // deny access
    } // for mozilla "version 5"
}

QLBrowser = new ConstructQLBrowser()

function setfocus() {
  if (QLBrowser.dom || QLBrowser.ns4){
    if (QLBrowser.dom)
      document.Login.ctype.value="M";
    else if (QLBrowser.ns4)
      document.Login.ctype.value="N";
    SetSignon();
    document.Login.userid.focus();
    var td=new Date();
    document.Login.IGNUNQ.value=td.getTime().toString();
  }
  else
    document.location.href=((!FR_INT) ? "badlogin.html" : "fr_badlogin.html");
}

var usecookie=true;
var tc=document.cookie;

if (tc!="") {
 var st=tc.indexOf('QLSIGNON=');
 if (st != -1) {
  if (st != 0) {
    tc=tc.substring(st,tc.length);
    st=tc.indexOf('QLSIGNON=');
    msg("QLSIGNON not at start, tc is " + tc);
  }
  st+=9;
  var end = tc.indexOf(';');
  if (end == -1) end=tc.length;
  var si=tc.substring(st,end);
  if (si == "nosave") {
   usecookie=false;
   document.write('<STYLE>\n#sccb {display: none}\n</STYLE>');
  }
 }
}
else {
 tc='QLSIGNON=delete;';
 wcookie(tc,60*60000);
 tc ="";
 tc=document.cookie;
 if (tc=="") {
  usecookie=false;
  document.write('<STYLE>\n#sccb {display: none}\n</STYLE>');
 }
}
