var loaded = new Array();
var ns6 = document.getElementById && !document.all;
var ie4 = true && document.all;
var opr = navigator.userAgent.indexOf('Opera') > -1;
var hiElem = false;
var hiOn = false;
var hiStyle = false;
var ontab = 1;

if (opr) var dispcss = ">";
else var dispcss = " style='display:none'>";

function hi(e) {
   if (hiOn && (hiElem != e)) hiOff();
   hiStyle = (ns6 || ie4) ? e.offsetParent.style : e.offsetParent;
   hiStyle.backgroundColor = '#eef';
   hiElem = e;
   hiOn = true;
}

function hiOff() {
   hiStyle.backgroundColor = '#fff';
   hiOn = false;
}

function flip(button, dn)
{
  if (button && loaded[button.name]) {
    button.src = "/pictures/" + button.name + dn + ".gif";
  }
}

function button(nam, wid, hei, url)
{
  dn = new Image(wid, hei);
  dn.src="/pictures/" + nam + "dn.gif";
  if ((document.URL.indexOf(url) > 1) || (document.URL == url)) {
     document.images[nam].src = dn.src;
  } else {
     loaded[nam] = true;
  } 
}

function underline(lefs)
{
   if (ns6 || ie4 || opr) {
      for (i = 0; i < lefs.length; i++) {
         if (document.URL.indexOf(lefs[i]) > 0) {
            oura = document.getElementById(lefs[i]);
            oura.style.fontWeight = "bold";
         }
      }
   } 
}

function tab(t)
{
   if ((ns6 || ie4) && (ontab != t)) {
      document.getElementById('tabl' + t).src = "../pictures/tab_ul.gif";
      document.getElementById('tabm' + t).style.backgroundColor = "#F7B542";
      document.getElementById('tabr' + t).src = "../pictures/tab_ur.gif";
	    document.getElementById('tabl' + ontab).src = "../pictures/tab_dl.gif";
      document.getElementById('tabm' + ontab).style.backgroundColor = "#BA8832";
	    document.getElementById('tabr' + ontab).src = "../pictures/tab_dr.gif";
	    document.getElementById('pro' + ontab).style.display = "none";
	    document.getElementById('pro' + t).style.display = "block";
      ontab = t;
   }
}

function preload()
{
  button("abobut",  75, 50, "/about/");
  button("expbut", 105, 50, "/experience/");
  button("refbut", 110, 50, "/letters/");
  button("resbut",  87, 50, "/resumes/");
  button("annbut", 145, 50, "/announcements/");
  button("pubbut", 121, 50, "/energypub/");
  button("sofbut",  97, 50, "/software/");
  button("homebut", 60, 20, "http://www.b2epc.com/");
  button("contbut", 70, 20, "/contact");
  button("clibut",  70, 20, "/clients/");
  button("helpbut", 42, 20, "/help/");
}
