// Jan. 22/2001 - mods for MSIE5 on Mac/DOM
// Mar. 05/2001 - French Language interface
// Jul. 31/2001 - remove highlighting, open in new window added
// Oct. 12/2001 - added KILL variable.
// May. 01/2002 - mods for DOM to accomodate NS6
// Oct. 02/2002 - more mods for NS7 Mozilla 1.1
// Nov. 01/2002 - NS7/Mozilla 1.1 support put into production
// Dec. 05/2002 - "Jurisprudence citee" changed to "Releve QUICKCITE"
// Feb. 05/2003 - mods for safari browser
// Mar. 10/2003 - change links for "lnext" and "lprev" on MSIE MAC
// Apr. 24/2003 - Change DRS Summary to CCS Summary
// June 02/2003 - Hide QuickCite signals for print
// June 26/2003 - Minor fix for no search terms in myb4print - mtm
// Nov. 03/2003 - Change single Summary link to dynamic menu of links - csk
// Nov. 21/2003 - New dynamic menu of Commentary links - csk
// Feb. 29/2004 - Summaries/Commentaries - production - mtm
// Mar. 09/2004 - Down arrow for multiple commentaries - csk
// Apr. 27/2004 - Hide "dsel" class when getting rid of color - mtm
// Oct. 14/2005 - Position persistence - mtm


FR_INT = false;
QBI = false;

function setqbi() {
  if ("undefined" == typeof isqbi)
    QBI = false;
  else
    QBI = isqbi;
}

function setfr () {
if (window.opener) tw=window.opener.parent.top; else tw=parent.top;
if ("undefined" == typeof tw.iscf)
  FR_INT = false;
else
  FR_INT = parent.top.iscf;
}

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.ie5up = (this.ie5up || this.ie6);
    this.ie5mac = (this.ie5up && this.mac);

    this.dom = (this.ie5up || this.ns5up);
    this.safari = (agt.indexOf('safari')!=-1) && this.dom;
}

if (!top.QLBrowser) QLBrowser = new ConstructQLBrowser()

var ddispdebug = false;

function ddmsg(m) {
  if (top.QLBrowser.safari && ddispdebug)
    alert(m);
}

function initg()
{
  QLG.name="globalobj";
  if (!QLG.rsz || QLBrowser.ie) QLG.rsz=resizewin;
  if (!QLG.hdc || QLBrowser.ie) QLG.hdc=hidecommands;
  if (!QLG.lnext || QLBrowser.ie) QLG.lnext=lnext;
  if (!QLG.lprev || QLBrowser.ie) QLG.lprev=lprev;
  QLG.standalone = true;
  QLG.activatelinks = false;
  QLG.first = 1;
}
if (!top.QLG) QLG = new Object();

// this nonsense required because MSIE on the mac doesn't use the
// iso-8859-1 charset for the alert box - it uses x-mac-roman encoding
// also for some reason string.replace did't work so ended up needing
// to code a bunch of "if .. else" constructions

function TR(s) {
////////////////////////////////////////
//if (parent.top.QLBrowser.ie5mac) {
////////////////////////////////////////
//later versions of Mac MSIE 5 and above DO use iso-8859-1, so take this out
 if (false){
   var n ='';
   for (i=0; i< s.length; i++) {
     c = s.charAt(i);
     if (c == '\xE8') c = '\x8F';
     else if (c == '\xE9') c = '\x8E';
     else if (c == '\xEA') c = '\x90';
     else if (c == '\xEB') c = '\x91';
     else if (c == '\xE0') c = '\x88';
     else if (c == '\xE1') c = '\x87';
     else if (c == '\xE2') c = '\x89';
     else if (c == '\xE4') c = '\x8A';
     else if (c == '\xEC') c = '\x93';
     else if (c == '\xED') c = '\x92';
     else if (c == '\xEE') c = '\x94';
     else if (c == '\xEF') c = '\x95';
     else if (c == '\xF2') c = '\x98';
     else if (c == '\xF3') c = '\x97';
     else if (c == '\xF4') c = '\x99';
     else if (c == '\xF6') c = '\x9A';
     else if (c == '\xF9') c = '\x9D';
     else if (c == '\xFA') c = '\x9C';
     else if (c == '\xFB') c = '\x9E';
     else if (c == '\xFC') c = '\x9F';
     else if (c == '\xC0') c = '\xCB';
     else if (c == '\xC1') c = '\xE7';
     else if (c == '\xC2') c = '\xE5';
     else if (c == '\xC4') c = '\x80';
     else if (c == '\xC8') c = '\xE9';
     else if (c == '\xC9') c = '\x83';
     else if (c == '\xCA') c = '\xE6';
     else if (c == '\xCB') c = '\xE8';
     else if (c == '\xCC') c = '\xED';
     else if (c == '\xCD') c = '\xEA';
     else if (c == '\xCE') c = '\xEB';
     else if (c == '\xCF') c = '\xEC';
     else if (c == '\xD2') c = '\xF1';
     else if (c == '\xD3') c = '\xEE';
     else if (c == '\xD4') c = '\xEF';
     else if (c == '\xD6') c = '\x85';
     else if (c == '\xD9') c = '\xF4';
     else if (c == '\xDA') c = '\xF2';
     else if (c == '\xDB') c = '\xF3';
     else if (c == '\xDC') c = '\x86';
     else if (c == '\xC7') c = '\x82';
     else if (c == '\xE7') c = '\x8D';
     n += c;
   }
   return n;
 }
 return s;
}

// given HTMLElement find its absolute y-pos in the document
function absy(a) { var e = a; var y = a.offsetTop;
  while (e.offsetParent) { e = e.offsetParent;  y += e.offsetTop; }
  return y;}

// given HTMLElement find its absolute x-pos in the document
function absx(a) { var e = a; var y = a.offsetLeft;
  while (e.offsetParent) { e = e.offsetParent;  y += e.offsetLeft; }
  return y;}

// locate next search term not currently on screen - scroll to it
function lnextMSIE() {
  var rfocus=top.RIGHT;
  var bottomy = document.body.scrollTop + document.body.clientHeight;
  if (top.QLBrowser.ie5mac) var sts = document.all.item('LOCT');
  else var sts = document.getElementsByName("LOCT");
  if (sts) var alen = sts.length; else var alen = 0;
  if (!sts) {
    top.alert((!FR_INT) ? 'There are no search terms to locate.' :
    TR("Il n'y a pas d'occurrence de mots de recherche \xE0 rep\xE9rer."));
    rfocus.focus(); return;
  }
  if (!alen) {  posy = absy(sts);   // single element
    if (absx(sts)+sts.offsetWidth > document.body.clientWidth)
      posy += sts.offsetHeight;
    if ( posy > bottomy) { window.scrollTo(0,posy); rfocus.focus(); return;}
  }
  else {
    for (i = 0; i < alen; i++) { posy = absy(sts[i]);
      if (absx(sts[i])+sts[i].offsetWidth > document.body.clientWidth)
        posy += sts[i].offsetHeight;
      if ( posy > bottomy) { window.scrollTo(0,posy);
        rfocus.focus();return;
   }
 }
  }
  top.alert((!FR_INT) ? 'There are no further search terms to locate.' :
  TR("Il n'y a plus d'occurrence de mots de recherche \xE0 rep\xE9rer."));
  rfocus.focus();
}

// locate previous search term not currently on screen - scroll to it
function lprevMSIE() {
  var rfocus=top.RIGHT;
  var topy = document.body.scrollTop; var goup = document.body.clientHeight;
  if (top.QLBrowser.ie5mac) var sts = document.all.item('LOCT');
  else var sts = document.getElementsByName("LOCT");
  if (sts) var alen = sts.length; else var alen = 0;
  if (!sts) {
    top.alert((!FR_INT) ? 'There are no search terms to locate.' :
    TR("Il n'y a pas d'occurrence de mots de recherche \xE0 rep\xE9rer."));
    rfocus.focus(); return;
  }
  if (!alen) {  posy = absy(sts);   // single element
    if ( posy < topy) { posy -= goup; posy += sts.offsetHeight;
      if ( posy < 0) posy = 0;
      if (absx(sts)+sts.offsetWidth > document.body.clientWidth)
        posy += sts.offsetHeight;
      window.scrollTo(0,posy); rfocus.focus(); return;
 }
  }
  else {
    for (i = alen-1; i > -1; i--) { posy = absy(sts[i]);
      if ( posy < topy) { posy -= goup; posy += sts[i].offsetHeight;
        if ( posy < 0) posy = 0;
        if (absx(sts[i])+sts[i].offsetWidth > document.body.clientWidth)
          posy += sts[i].offsetHeight;
        window.scrollTo(0,posy); rfocus.focus(); return;
   }
 }
  }
  top.alert((!FR_INT) ? 'There are no previous search terms to locate.' :
  TR("Il n'y a pas d'occurrence pr\xE9c\xE9dente de mots de" +
  " recherche \xE0 rep\xE9rer."));
rfocus.focus();
}

// locate next search term not currently on screen - scroll to it
// netscape 6 and 7 version and safari
function lnextNS6() {
  var rfocus=top.RIGHT;
  var bottomy = document.body.scrollTop + document.body.clientHeight;
  if (top.QLBrowser.safari)
    bottomy = document.body.scrollTop + document.body.offsetTop +
              parent.top.RIGHT.innerHeight;
  var sts = document.getElementsByTagName("SPAN");
  if (!sts) {
    top.alert((!FR_INT) ? 'There are no search terms to locate.' :
    TR("Il n'y a pas d'occurrence de mots de recherche \xE0 rep\xE9rer."));
    rfocus.focus(); return;
  }
  for (i = 0; i < sts.length; i++) {
    if (sts[i].id == "LOCT") {
      posy = absy(sts[i]);
      if ( posy > bottomy-sts[i].offsetHeight) {
        window.scrollTo(0,posy);
        rfocus.focus();return;
      }
    }
  }
  top.alert((!FR_INT) ? 'There are no further search terms to locate.' :
  TR("Il n'y a plus d'occurrence de mots de recherche \xE0 rep\xE9rer."));
  rfocus.focus();
}

// locate previous search term not currently on screen - scroll to it
// netscape 6 and 7 version and safari
function lprevNS6() {
  var rfocus=top.RIGHT;
  var topy = document.body.scrollTop;
  var goup = document.body.clientHeight;
  if (top.QLBrowser.safari) {
    topy = document.body.scrollTop + document.body.offsetTop;
    goup = parent.top.RIGHT.innerHeight;
  }
  var sts = document.getElementsByTagName("SPAN");
  if (!sts) {
    top.alert((!FR_INT) ? 'There are no search terms to locate.' :
    TR("Il n'y a pas d'occurrence de mots de recherche \xE0 rep\xE9rer."));
    rfocus.focus(); return;
  }
  for (i = sts.length-1; i > -1; i--) {
    if (sts[i].id == "LOCT") {
      posy = absy(sts[i]);
      if ( posy < topy) {
        posy -= (goup-sts[i].offsetHeight);
        if ( posy < 0) posy = 0;
        window.scrollTo(0,posy); rfocus.focus(); return;
      }
    }
  }
  top.alert((!FR_INT) ? 'There are no previous search terms to locate.' :
  TR("Il n'y a pas d'occurrence pr\xE9c\xE9dente de mots de" +
  " recherche \xE0 rep\xE9rer."));
rfocus.focus();
}

function lnextNS() {
  var rfocus=parent.top.RIGHT;
  windowbottom = parent.RIGHT.pageYOffset + parent.RIGHT.innerHeight;
  var sts=parent.RIGHT.document.anchors;
  if (sts) var alen = sts.length; else var alen = 0;
  if (!sts) {
    top.alert((!FR_INT) ? 'There are no search terms to locate.' :
    TR("Il n'y a pas d'occurrence de mots de recherche \xE0 rep\xE9rer."));
    rfocus.focus(); return;
  }
  for (i = 0; i < alen; i++) { a=sts[i];
    if (a.name.indexOf('QLST') == 0) {
      if ( a.y > windowbottom) { parent.RIGHT.scrollTo(0,a.y);
        rfocus.focus();return;
   }
 }
  }
  top.alert((!FR_INT) ? 'There are no further search terms to locate.' :
  TR("Il n'y a plus d'occurrence de mots de recherche \xE0 rep\xE9rer."));
  rfocus.focus();
} //lnextNS

function lprevNS()
{ var rfocus=parent.top.RIGHT;
  windowtop = parent.RIGHT.pageYOffset;
  var  goup = parent.RIGHT.window.innerHeight;
  var sts=parent.RIGHT.document.anchors;
  if (sts) var alen = sts.length; else var alen = 0;
  if (!sts) {
    top.alert((!FR_INT) ? 'There are no search terms to locate.' :
    TR("Il n'y a pas d'occurrence de mots de recherche \xE0 rep\xE9rer."));
    rfocus.focus(); return;
  }
  for (i = alen-1; i > -1; i--) { a=sts[i];
    if (a.name.indexOf('QLST') == 0) {
      if ( a.y < windowtop) { posy = a.y - goup; posy += 20;
        if ( posy < 0) posy = 0;
        parent.RIGHT.scrollTo(0,posy);
        rfocus.focus();return;
   }
 }
  }
  top.alert((!FR_INT) ? 'There are no previous search terms to locate.' :
  TR("Il n'y a pas d'occurrence pr\xE9c\xE9dente de mots de" +
  " recherche \xE0 rep\xE9rer."));
  rfocus.focus();
} //lprevNS


function lnext() {   // common stub
//  alert('window.mytop is ' + window.mytop); return;
  if (top.QLBrowser.ie) lnextMSIE();
  else if (top.QLBrowser.dom && top.QLBrowser.ns) lnextNS6();
  else if (top.QLBrowser.ns4) lnextNS(); }

function lprev() {  // common stub
 if (window.parent.top.QLBrowser.ie) lprevMSIE();
  else if (top.QLBrowser.dom && top.QLBrowser.ns) lprevNS6();
  else if (top.QLBrowser.ns4) lprevNS(); }


// on document unload hide the "Command" frame
function hidecommands() {
if (!top.QLBrowser.dom) return;
var frset = top.document.getElementById("FRSC");
if (frset) {
  if (top.QLBrowser.ns || top.QLBrowser.ie5mac)
    frset.rows = "0,*";
  else
    frset.rows = "0%,100%";
  }
}

// if non null string add separating nbsps
function addsep(t) { if (t != "") t += '&nbsp;&nbsp;&nbsp;&nbsp;\n';
  return t;}

// adjust size of command frame if necessary
function sizecmd()
{
  if (!top.QLBrowser.dom) return;

  // bail out if NS6, 7 or Mozilla
  if (top.QLBrowser.ns) return;

  var frset = top.document.getElementById("FRSC");
  if (frset) {
    if ((frset.rows != "0%,100%") && (frset.rows != "0,*")) {
      var d=top.COMMANDS.document;
      if (d.getElementById("CMDS")) {
        var tlnks=d.getElementById("LNKS");
        if (top.QLBrowser.ie)
          tlnks.style.width = d.body.offsetWidth;
        var bht = tlnks.offsetHeight + 0;
        var cht = d.body.clientHeight;
        if (bht == cht) return;
        var s=bht + ",*";
//      top.alert('bht is ' + bht + ', cht is ' + cht);
        frset.rows = s;
      } // if d.all.CMDS
    } // if frset.rows != "0%,100%"
  } // if frset
  parent.top.RIGHT.focus();
}

var lc=0;

function sizecommands() {
  if (!top.QLBrowser.dom) return;
  if (top.window.opener) return;
  if (top.QLBrowser.ns) return;

  lc += 1; if (lc > 20) return;
  if ((top.COMMANDS.document.readyState != "loading") &&
      (top.COMMANDS.document.readyState != "uninitialized")) { lc=0;
    sizecmd(); }
  else
    setTimeout("sizecommands()",50);
}

// function showcommands() runs on document load to build and display
// the green bar frame of commands at the top of the page.

function showcommands()
{
setqbi();
setfr();
setprint();
if (top.QLG) {
 if (!top.QLG.rsz) top.initg();}  // init global object if necessary
top.QLG.activatelinks = true;
var s = window.location.href;
if (window.opener) s = window.opener.location.href;
if (s.indexOf('%2ehtm') != -1) rhflag=true; else rhflag=false;
if (rhflag) {
  l = document.links;
  for(i=0; i<l.length; i++) {
    s = l[i].protocol.toLowerCase();
    if (s.indexOf('http:') != -1) {
      l[i].onclick=denylink;
      l[i].onmouseover=moverlink;
      l[i].onfocus=linkfocus;
    } // if
  } // for
} // if

// new for positon persistence
// make sure we record window positons BEFORE navigating to something new
//
if (!QBI && !rhflag) {
	// new for position persistence
	if ("undefined" != typeof top.record_pos) {
		// Loop through links
		l = document.links;
		for(i = 0; i < l.length; i++) {
		  s = l[i].href.toLowerCase();
		  var theid = l[i].id.toLowerCase();
		  if (s.indexOf('http:') != -1  && theid != 'qcsel') {  // not on javascript please
		    if (s.indexOf('&c=s+') == -1)  // make sure its not a new search!
		      l[i].onclick=top.record_pos;
		  } // if not javascript
		} // for each link
		
	  setTimeout("pos_persist();",200);
	} // if top.record_pos exists
} // if WBI


var s=""; // null commands string
var y=""; // null pages string

top.makecomm=false; // default no commenu
top.makesumm=false; // default no summenu

if ("undefined" == typeof KILL) KILL="N";
if ("undefined" == typeof DOLOCATE) DOLOCATE="N";
if ("undefined" == typeof DISPOPTS) DISPOPTS="N";
if ("undefined" == typeof QCGET) QCGET="";
if ("undefined" == typeof LHGET) LHGET="";
if ("undefined" == typeof NPAGES) NPAGES="";
if ("undefined" == typeof COMMENTS) COMMENTS="";

if ("undefined" != typeof comments_general)
  comments_general(); // general comments creation function
if ("undefined" != typeof digests_general)
  digests_general(); // general digests creation function

var x = '<table width=100% cellspacing=0 cellpadding=0 ';
if (!parent.top.QLBrowser.ns4){
  if ((top.makesumm == true) || (top.makecomm == true)){
    x += 'onmouseover="parent.RIGHT.gb_check_hide(event)" ';
    x += 'onmousemove="parent.RIGHT.gb_check_hide(event)" ';
  } // if DOM table event handlers required
} // if DOM
x += 'border=0 class="gb"><TR>'; // open green bar outer table
x += '<TD width="1">'; // force height of table
x += '<img border=0 ';
x += 'src="../img/fudge.gif" height=32 width=1></TD>';

if (NPAGES) { // number of pages
  y = '<TD width=42 valign="middle">';
  y1= '~' + NPAGES.toString() + '&nbsp;';
  if (NPAGES > 1)
    y1+= 'pp.';
  else
    y1+= 'pg.';
  y = y+y1+'</TD>';
} // number of pages

if (top.makecomm == true) { // nested commentaries table properties
  s += '<TD align="center">'; // green bar table cell holds nested table
  s += '<Table class="comtab" id="comtab" '; // nested table properties
  s += 'cellspacing=0 cellpadding=0 border=0';
  if (parent.top.QLBrowser.ns4){ // ns4.x no table event handlers
    s += '>'; // ns4.x just closes table tag
  } // if ns4.x table
  else { // assign DOM table event handlers
    s += ' onmouseover="parent.RIGHT.com_show_menu()" ';
    s += 'onmousemove="parent.RIGHT.commentaries_mm(event)" ';
    s += 'onmouseout="parent.RIGHT.commentaries_hide_menu(event)">';
  } // else DOM table
  s += '<TR><TD class="comtab">'; // nested table cell

  if (parent.top.QLBrowser.ns4){ // ns4.x anchor event handlers
    s += '<a class="comtab" name="commentaries" ';
    s += 'HREF="javascript: com_net_show_test(event);" TARGET="RIGHT" ';
    s += 'onmouseover="parent.RIGHT.com_net_show_test(event)" '
    s += 'onmouseout="parent.RIGHT.com_net_hide_test(event)">';
    s += '<img class="comtab" name="comimage" border=0 ';
    if (!FR_INT){
      s += 'src="../img/comeimage.gif" width=88 ';
    }
    else{
      s += 'src="../img/comfimage.gif" width=57 ';
    }
    s += 'height=32></a>';
  } // if ns4.x anchor image
  else {
    s += '<img class="comtab" border=0 ';
    s += 'src="../img/fudge.gif" height=32 width=1>';
    s += '</TD><TD class="comtab">';
    s += '<a class="comtab" ';
    s += 'name="commentaries" href="" onClick="return false;" '
    s += '>';
    s += '<span class="comtab">';
    s += (!FR_INT) ? 'Commentaries' : 'Doctrine';
    if (top.numcom > 1) s +=  '&darr;';
    s += '</span></A>';
  } // else DOM anchor in table

  s += '</TD></TR></TABLE>'; // end of nested table
  s += '</TD>'; // end of green bar table entry
}

if (top.makesumm == true) { // nested summaries table properties
  s += '<TD align="center">'; // green bar table cell holds nested table
  s += '<Table class="sumtab" id="sumtab" '; // nested table properties
  s += 'cellspacing=0 cellpadding=0 border=0';
  if (parent.top.QLBrowser.ns4){ // ns4.x no table event handlers
    s += '>'; // ns4.x just closes table tag
  } // if ns4.x table
  else { // assign DOM table event handlers
    s += ' onmouseover="parent.RIGHT.show_menu()" ';
    s += 'onmousemove="parent.RIGHT.summaries_mm(event)" ';
    s += 'onmouseout="parent.RIGHT.summaries_hide_menu(event)">';
  } // else DOM table
  s += '<TR><TD class="sumtab">'; // nested table cell

  if (parent.top.QLBrowser.ns4){ // ns4.x anchor event handlers
    s += '<a class="sumtab" name="summaries" ';
    s += 'HREF="javascript: net_show_test(event);" TARGET="RIGHT" ';
    s += 'onmouseover="parent.RIGHT.net_show_test(event)" '
    s += 'onmouseout="parent.RIGHT.net_hide_test(event)">';
    s += '<img class="sumtab" name="sumimage" border=0 ';
    if (!FR_INT){
      s += 'src="../img/sumeimage.gif" width=68 ';
    }
    else{
      s += 'src="../img/sumfimage.gif" width=59 ';
    }
    s += 'height=32></a>';
  } // if ns4.x anchor image
  else {
    s += '<img class="sumtab" border=0 ';
    s += 'src="../img/fudge.gif" height=32 width=1>';
    s += '</TD><TD class="sumtab">';
    s += '<a class="sumtab" ';
    s += 'name="summaries" href="" onClick="return false;" '
    s += '>';
    s += '<span class="sumtab">';
    s += (!FR_INT) ? 'Summaries' : 'R\xE9sum\xE9s';
    if (top.numsum > 1) s +=  '&darr;';
    s += '</span></A>';
  } // else DOM anchor in table

  s += '</TD></TR></TABLE>'; // end of nested table
  s += '</TD>'; // end of green bar table entry
}

if (QCGET) { // QUICKCITE link
  s += '<TD>';
  s += '<A HREF="' + CMDPFX + 'QCGET=';
  s+= QCGET; s += '" TARGET="_top"';
  if ("undefined" != typeof top.record_pos)
    s += ' onclick="top.record_pos();"';
  s +='>';
  var theqcn=0;
  var qcnum=QCGET.match(/(\D*)(\d*)/i);
  if (qcnum.length > 2) {
    qcn=qcnum[2].match(/0*(\d*)/i);
    if (qcn.length > 1) theqcn=parseInt(qcn[1]);
  }
  if (theqcn > 599999) s += 'QUICKCITE</A>';
  else
    s += (!FR_INT) ? 'Note&nbsp;up&nbsp;with&nbsp;QUICKCITE</A>' :
         'Relev\xE9 QUICKCITE</A>';
  s += '</TD>';
}

if (DISPOPTS=="Y") { // display options
  s += '<TD>';
  s += '<A HREF="' + CMDPFX + 'HTDISPOPTIONS" TARGET="_top">';
  s += (!FR_INT) ? 'Display&nbsp;options</A>' :
       "Options&nbsp;d'affichage</A>";
  s += '</TD>';
}

if (DOLOCATE=="Y") { // locate previous
  s +='<TD>';
//  s += '<A HREF="javascript: parent.top.QLG.lprev();">';
  if (top.QLBrowser.safari || top.QLBrowser.ie5mac) {
    s += '<A HREF="" onClick="' + "parent.top.RIGHT.lprev();";
    s += ' return false;">';
  }
  else
    s += '<A HREF="javascript: lprev();" TARGET="RIGHT">';
  s += (!FR_INT) ? 'Locate&nbsp;previous</A>' :
       "Occurrence&nbsp;pr\xE9c\xE9dente</A>";
  s += '</TD>';
}

if (DOLOCATE=="Y"){ // locate next
  s += '<TD>';
//  s += '<A HREF="javascript: parent.top.QLG.lnext();">';
  if (top.QLBrowser.safari || top.QLBrowser.ie5mac) {
    s += '<A HREF="" onClick="' + "parent.top.RIGHT.lnext();";
    s += ' return false;">';
  }
  else
    s += '<A HREF="javascript: lnext();" TARGET="RIGHT">';
  s += (!FR_INT) ? 'Locate&nbsp;next</A>' :
       "Occurrence&nbsp;suivante</A>";
  s += '</TD>';
}

if (KILL=="Y") { // delete
  s += '<TD>';
  s += '<A HREF="' + CMDPFX + 'KILL=YES';s += '" TARGET="_top">';
  s += (!FR_INT) ? 'Delete</A>' :
       "Supprimer</A>";
  s += '</TD>';
}

if (s) { // have green bar inner table
  s1 = '<table class="gb" cellpadding=0 cellspacing=0 border=0><TR>';
  s1 += s + '</TD></TR></table>';
  s = '<TD align="center" valign="middle">'
    + s1 + '</TD>\n'; // close inner table
}
if (y) {  // have pages
  x += y; // add pages section to outer table
}
if (s) {  // have inner table
  x += s; // add inner table section to outer table
}
x += '</TR></table>'; // close green bar outer table

//  alert("Green bar HTML string is " + x);
if (s || y) {
  if (top.QLBrowser.dom) {
    var frset = top.document.getElementById("FRSC");
    if (frset) {
      if (top.QLBrowser.ie) frset.rows="60,*";

//    alert("frset.rows now is " + frset.rows);

      if (QBI)
        d=parent.top.COMMANDS.document;
      else
        d=parent.top.CMDDOC;
//      alert("d is " + d);
      var c=d.getElementById("LNKS");
      if (c) {
        var dothis = false;
        if (!c.innerHTML) dothis = true;
        if (c.innerHTML == "") dothis = true;
        if (c.innerHTML == null) dothis = true;
        // have to do the following if IE5 on MAC
        if (top.QLBrowser.ie5mac && dothis) {
          var oTable=d.createElement("TABLE");
          oTable.width = "100%";
          oTable.cellSpacing = 0;
          oTable.cellPadding = 0;
          var oTBody=d.createElement("TBODY");
          var oRow=d.createElement("TR");
          var oCell=d.createElement("TD");
//          oCell.width = 42;
//          var oCell2=d.createElement("TD");
//          oCell2.align="center";
          oRow.appendChild(oCell);
//          oRow.appendChild(oCell2);
          oTable.appendChild(oTBody);
          oTBody.appendChild(oRow);
          c.appendChild(oTable);
          oCell.innerHTML=x;
//          oCell2.innerHTML=s1;
        }  // ie5 mac
        else               // if ie5 on win platform - just use "innerHTML"
        if (!top.QLBrowser.ie5mac)
          c.innerHTML = x;

        c.style.visibility = "visible";
        // only set width if MSIE not NS6 or NS7
        if (top.QLBrowser.ie)
          c.style.width = d.body.offsetWidth;
        sizecommands();
      } // if c
    } // if frset
  } // if dom
  else if ((parent.top.QLBrowser.ns4) && (parent.COMMANDS))
  {
    var d = parent.COMMANDS.document;
    if (d.layers && d.layers.length==1) {
      cd=d.layers[0].document;
      d.layers[0].clip.right = d.layers[0].window.outerWidth;
      h = parent.COMMANDS.document.LNKS.document.height;
      if ( h==0)
        cd.write(x);
      d.layers[0].visibility = "show";
      parent.top.RIGHT.focus();
    }
  } // if netscape
 } // if s id not null
} // end function showcommands

function resizewin()
{
//////////////////////////////
//if (top.QLBrowser.ie5up)
//////////////////////////////
  if (top.QLBrowser.dom)
    if (!top.QLBrowser.ns) sizecommands();
  else if (top.QLBrowser.ns4)
  {
    showcommands();
  }
} // resizewin

function BuildReloadUrl() {
 reloadurl = "";
 var s = window.location.href;
 if ((s.charAt(s.length-1) == "?") || (window.location.search == ""))
  reloadurl = window.location.href;
 else {
  var x = window.location.protocol + "//" + window.location.host;
  var os = window.location.search;
  s = os.toLowerCase();
  var i = s.indexOf("sid=");
  if (i != -1) {
   x += "/qltemp/"; x+= os.substr(i+4,16); x+= "/";
   i = s.indexOf("qlcid=");
   if (i != -1) {
    x += os.substr(i+6,5);
    i = s.indexOf("filename=");
    if (i != -1) {
     for (j=i+9; j < s.length; j++) {
      if (os.charAt(j) != '&')
       x += os.charAt(j);
      else break;
     } // for loop
     reloadurl = x;
    } // if filename found
   } // if qlcid found
  } // if sid found
 } // search string found
} // function buildreloadurl


function dorh() {
  setfr();
  rhflag=false;
  var s = window.location;
  if (window.opener) s = window.opener.location;
  ddmsg('s.href is ' + s.href);
  if (s.href.indexOf('%2ehtm') != -1) rhflag=true;
  ddmsg('s.hash is ' + s.hash);
  if (s.hash == "#rh") rhflag=true;
  if (rhflag) {
    x = '<style>\n.ST {background: white}\nfont {color: black}\n';
    x+= 'a, a:visited,a:active,a:hover ';
    x+= '{text-decoration: none; color: #000000}\n';
    x+= 'a.ml,a.ml:visited,a.ml:active,a.ml:hover ';
    x+= '{text-decoration: underline; color: blue}\n';
    x+= 'IMG {display: none}\n';
    x+= '.dsel {display: none}\n';
    x+= "</style>";
    ddmsg("x is " + x);
    document.write(x);
  }
  else {
   x = '<style>\na.ml:visited {color: blue};\n</style>';
   document.write(x);
  }

  if (window.opener) x ="";
  else {
   x= "<DIV>\n<font size=-1>";
   if (!rhflag) {
    if (top.QLBrowser.safari) {
      x+= '<A href="" onClick="if (parent.top.RIGHT.ca())';
      x+= ' parent.top.RIGHT.rh(); return false;" class=ml>';
    }
    else {
      x+= '<A href="javascript:rh()" target="_self" '
      x+= 'onClick="return ca();" class=ml>';
    }
    x+= (!FR_INT) ?
          'Remove highlighting, colour, links, QuickCite signal</A>' :
          'Supprimer la surbrillance, les couleurs, les hyperliens' +
          ' et les codes signal&eacute;tiques</A>';
    x+= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n';
   }
   x+= '<A href="javascript:lw()" target="_self" '
   x+= 'onClick="return ca();" class=ml>';
   x+= (!FR_INT) ? 'Open in new window</A>\n' :
                   'Ouvrir dans une nouvelle fen&ecirc;tre</A>\n';
   x+= '</font><br><br></DIV>\n';
  }
  
  ddmsg("x is " + x);
  if (x !="") {
   document.write(x);
  } // if x not null

} // function dorh

function rh()
{
  ddmsg("here i am in rh");
  BuildReloadUrl();
  if (reloadurl != "") {
   i = reloadurl.indexOf('%2ehtm');
   if (i == -1) {
     i = reloadurl.indexOf('.htm');
     if (i != -1) {
       x = reloadurl.slice(0,i) + "%2e" + reloadurl.slice(i+1);
       reloadurl = x;
     }
   }

   if (top.parent.QLBrowser.safari) {
     i = reloadurl.indexOf('#');
     if ( i != -1)
       x = reloadurl.slice(0,i);
     reloadurl += "#rh";
   }

   ddmsg("reloadurl is " + reloadurl);
   window.location.replace(reloadurl); // force a reload
  }
} // function rh

function lw()
{
  ddmsg("here i am in lw");
  BuildReloadUrl();
  if (reloadurl != "") { s = window.screen;
   if (s.availHeight) h=s.availHeight; else h=s.height;
   if (s.availWidth)  w=s.availWidth;  else w=s.width;

   lf = window.Math.round(w*.04);
   tp = window.Math.round(h*.04);
   w=window.Math.round(w*.80);
   h=window.Math.round(h*.70);

   features="height=" + h.toString();
   features += ",width="+w.toString()+",menubar,resizable,scrollbars,toolbar";
///////////////////////////////
// if (top.QLBrowser.ie5up)
///////////////////////////////
   if (top.QLBrowser.dom)
     features += ",top="+tp.toString()+",left="+lf.toString();
   else if (top.QLBrowser.ns4)
     features += ",screenY="+tp.toString()+",screenX="+lf.toString();

// alert("features are " + features);  
     
   window.open(reloadurl,"_blank",features); // force a reload
  }
} // function lw

function ca() {if (top.QLG.activatelinks) return true; else return false;}
function denylink() {return false;}
function moverlink() {top.window.status="";return true;}
function linkfocus() {top.window.status="";return true;}

function setprint() {
  if (QBI) {
    if (window.print) {
        window.onbeforeprint=myb4print;
        window.onafterprint=myafterprint;
    }
  }
} // function setprint

function myb4print() { // QBI only
  l = top.document.whoPrint;
  if (l) {
    if (l == "hlist") return;
  }
  msg  = "Remove highlighting, colour, links and QuickCite ";
  msg += "signal on printed copy?\r\n\r\n";
  msg += '"OK" = Remove, "Cancel" = print as is';

  frmsg  = "Supprimer la surbrillance, les couleurs, les hyperliens ";
  frmsg += "et le code signal\xE9tique QuickCITE sur la copie ";
  frmsg += "imprim\xE9e?\r\n\r\n";
  frmsg += '"OK" = supprimer, "Annuler" = imprimer tel quel';

  remove = confirm((!FR_INT) ? msg : TR(frmsg));

  if (remove) {
    // get rid of highlighting
    sts = document.getElementsByName("LOCT");
    if (sts) {
      alen = sts.length;
      if (alen) {
        for (i=0; i<alen; i++)
          sts[i].style.backgroundColor = "white";
      }
      else if (alen == 1) // single term
        sts.style.backgroundColor = "white";
    }

    fs = document.all.tags('font');
    if (fs) n = fs.length;
    if (n)
      for (i=0;i<n;i++) fs[i].style.color="black";
    else
      if (fs) fs.style.color="black";

    // Disable links
    l = document.links;
    for(i = 0; i < l.length; i++) {
      s = l[i].protocol.toLowerCase();
      if (s.indexOf('http:') != -1) {
        l[i].onclick=denylink;
        l[i].onmouseover=moverlink;
        l[i].onfocus=linkfocus;
        l[i].style.textDecoration = "none";
        l[i].style.color = "#000000";
      } // if not javasript
    } // for each link

    // get rid of QC signals if user desires
    l = document.images;
    for(i = 0; i < l.length; i++) {
      l[i].style.display="none";
    } // for each image

  } // if removing stuff
} // myb4print

function myafterprint() { window.location.reload();}

// new for positon persistence
// if there is a saved "position" for the document
// scroll the viewport to that position
//
function pos_persist() {
	
  if ("undefined" != typeof top.has_pos) {
		var pos = top.has_pos(window);
		if (pos) {
	    if (top.QLBrowser.dom || top.QLBrowser.ns4 ) {
			  window.scrollTo(0,pos);
	    } // DOM or netscape 4
		} // if pos
	} // if has_pos exists
} // pos_persist
