/**********************************************************
 * Select from list definition                            *
 **********************************************************/

var currentVar = '';

function initMenu(table,col,variable,wdth) {
   currentVar=variable;
   window.open('cgi.pl?FUNCTION=reference&TABLE='+table+'&COLUMN='+col,
               'Reference','width='+wdth+',height=450,scrollbars=yes,resizable=yes');
}

function menuSet(vl) {
   for(i=0;i< document.form.length;i++)
      if((document.form.elements[i]).name==currentVar)
      {
          (document.form.elements[i]).value=vl;
          break;
      }
}
/**********************************************************
 *             Popup Window Definition                     *
 * To add a popup window, add a string definition below.   *
 * To include the item in the printing friendly page,      *
 * modify the longStr by adding the item.                  *
 * Don't change anything else.                             *
 **********************************************************/


/***************************Tooltip Part Begins***************************/
  var NS4 = (document.layers) ? 1 : 0;
  var IE4 = (document.all) ? 1 : 0;

  var willtaketime=false;
  var waitwindow=null;

  function displayWait() {
      if(willtaketime) 
           waitwindow=window.open('../wait.html','JME','width=300,height=200,scrollbars=no'); 
  }

  function closeWait() {
      if(waitwindow!=null) {
            waitwindow.close();
            waitwindow=null;
      }; 
  }

  function clearEl() {}

  var style =1;
  var timerID = null;
  var padding = 3; // < 4 recommended
  var bgcolor = "beige";
  var borWid = 1; // for no border, assign null
  var borCol = "#0000cc";
  var borSty = "solid";
  var str = "<STYLE TYPE='text/css'>";
  var pinned=null;
  var moveByPos=0;

  str += ".tooltip {";
  str += "position: absolute;";
  str += "visibility: hidden;";
  str += "left: 0; top: 0; z-index: 400;";

  if (borWid > 0) { // if a border is specified

  str += "border-width: " + borWid + ";";
  str += "border-color: " + borCol + ";";
  str += "border-style: " + borSty + ";";

}

  if (NS4) {

  if (borWid > 0 && padding <= 3) {
    str += "padding: 0;";
    str += "layer-background-color: " + bgcolor + ";"; } 
    
    else if (borWid > 0 && padding > 3) {
    str += "padding: " + (padding - 3) + ";";
    str += "background-color: " + bgcolor + ";";

  } else if (borWid == 0) {
    str += "padding: " + padding + ";";
    str += "layer-background-color: " + bgcolor + ";";

  }

} else {
  str += "padding: " + padding + ";";
  str += "background-color: " + bgcolor + ";";
}

  str += "}";
  str += "</STYLE>";


  if (style) {
  document.write(str);
  if (NS4) window.onload = init;
}

/**************************************************
*        Making your tooltip text here            *
* This is the only place that need to be modified.*
* The first argument is the name of the tooltip.  *
* The second argument is the width and last one   *
* is the content of the tooltip.                  *
**************************************************/



/*************************End of making tooltip text*************************/

function init() {
  setTimeout("window.onresize = redo", 1000);
}

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

function makeEl(id, width, code) {
  if (!style) return;

  var str = "<STYLE TYPE='text/css'>\n";
  str += "#" + id + " {";
  str += "width: " + width + ";";
  str += "}";
  str += "</STYLE>\n";
  str += "<DIV CLASS='tooltip' ID='" + id + "'>"+
         "<A href='javascript:pclearEl()'>"+ 
         "<img ID='"+ id + "_BTN' src='../gifs/close.gif' width=10 height=10 "+
         "border=0 align=right></A>"+ 
         "<center>" + code + "</center></DIV>\n";

  document.write(str);
}

function displayEl(left, top) {

  //if (NS4) document.releaseEvents(Event.MOUSEMOVE);
  //document.onmousemove = null;
  var whichEl = (NS4) ? document[active] : document.all[active].style;
  var nleft=left-200;
  if(nleft<0) nleft=1;
  whichEl.left = nleft-0;
  whichEl.top = top;
  whichEl.visibility = (NS4) ? "show" : "visible";

  var imgEl = (NS4) ? document[active+"_BTN"] : document.all[active+"_BTN"].style;
  if(typeof(imgEl)!="undefined") {
     if(pinned!=active) { imgEl.visibility = (NS4) ? "hide" : "hidden"; } 
     else { imgEl.visibility = (NS4) ? "show" : "visible"; } 
  } 

}

function pclearEl() {
   pinned=null;
   clearEl();
}

function clearEl() {

  if (!style) return;
  if((typeof(active)!="undefined")&&(active != null)) {
  if(active==pinned) return;
  var whichEl = (NS4) ? document[active] : document.all[active].style;
  if(typeof(whichEl)!="undefined") {
     whichEl.visibility = (NS4) ? "hide" : "hidden";
  }
  var imgEl = (NS4) ? document[active+"_BTN"] : document.all[active+"_BTN"].style;
  if(typeof(imgEl)!="undefined") { imgEl.visibility = (NS4) ? "hide" : "hidden"; } 
  active = null; }

  if (timerID) clearTimeout(timerID);
  if (NS4) document.releaseEvents(Event.MOUSEMOVE);
  document.onmousemove = null;

}

function activateEl(id, e, pos) {
  if(pinned!=id) pinned=null;
  cactivateEl(id, e, pos);
}

function pactivateEl(id, e, pos) {
  pinned=id;
  cactivateEl(id, e, pos);
}

function cactivateEl(id, e, pos) {
  clearEl();
  if (!style) return;
  active = id;

  if (NS4) document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = checkEl;
  moveByPos=pos;
  checkEl(e);

  }

function checkEl(e) {
  if (timerID) clearTimeout(timerID);
  var left = ((NS4) ? e.pageX : ((event!=null)?event.clientX:0) + document.body.scrollLeft);
  var top = (NS4) ? e.pageY + 20 : ((event!=null)?event.clientY:0) + document.body.scrollTop + 20;
  left+=moveByPos;
  timerID = setTimeout("displayEl(" + left + ", " + top + ")", 300);
}



