//JavaScript utilities -- Copyright 2005 Sequoia Group, Inc.
//
//Designed exclusively for www.bioexpress.com -- All rights reserved.
//


//Determine browser type for use in later functions
//
var DHtml = 0; var bn = 0; var bl = 0; var bi = 0;
if (document.getElementById){ bi = 1; DHtml = 1; }
else{
  if (document.all){ bl = 1; DHtml = 1; }
  else{
    browserVersion = parseInt(navigator.appVersion);
    if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)){ bn = 1; DHtml = 1;
} } }

//Function to locate object by id
// Cross-browser function to return an object for a given object ID.
//
function FindId(ObjId, Which){
  if (bi) return Which ? document.getElementById(ObjId).style:document.getElementById(ObjId);
  if (bl) return Which ? document.all[ObjId].style: document.all[ObjId];
  if (bn) return document.layers[ObjId];
}

//Function to swap given image
// use to replace a given image as identified by the ID of the 
// destination (d) with a given src value (u).
//
function SwapImage(d, u){
  var d_Obj = FindId(d,0);
  d_Obj.src=u;
  return false;
  }

//Function to swap given text
// use to replace text from a given <div> section with that from 
// another given <div> section.  Pass the ID of the <div> sections
// for the destination (d) and source (s).
// 
function SwapText(d,s){
  var d_Obj = FindId(d,0);
  var s_Obj = FindId(s,0);
  d_Obj.innerHTML = s_Obj.innerHTML
  return false;
  }

//Function to determine window width
//
function GetWidth(){
  return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}

//Function to show/hide tooltip window
// use in onmouseover and onmouseout events to trigger display of
// previously defined tooltip.  Pass event value and the ID of the 
// <div> section containing the tooltip text.
//
function ToolTip(Event,ObjId){
  if (DHtml){
    var WinWidth = GetWidth();
    ObjStyle = FindId(ObjId,1);
    Obj = FindId(ObjId,0);
    Stat = ObjStyle.visibility;
    if (Obj.offsetWidth) ElementWidth = Obj.offsetWidth;
    else if (Obj.clip.width) ElementWidth = Obj.clip.width;
    if (Stat == "visible" || Stat == "show"){
      ObjStyle.visibility = "hidden";
    } else{
      if (Event.clientY || Event.pageY){
        if (Event.pageY){
          TopVal = Event.pageY + 20;
          LeftVal = Event.pageX - (ElementWidth/4);
        }
        else{ TopVal = Event.clientY + 20 + document.body.scrollTop;
          LeftVal = Event.clientX - (ElementWidth/4) + document.body.scrollLeft;
        }
        if (LeftVal < 2) LeftVal = 2;
        else if (LeftVal + ElementWidth > WinWidth) LeftVal -= ElementWidth/2;
        if (!bn){
          LeftVal += 'px';
          TopVal += 'px'
        };
        ObjStyle.left = LeftVal;
        ObjStyle.top = TopVal;
      }
      ObjStyle.visibility = "visible";
    }
  }
}

