preloadImage('../images/tabs/tab.jpg');
preloadImage('../images/tabs/tabSelected.jpg');

var origColor;
var origBkgnd;
function tabHover(target)
{
  if (target.className == 'tab')
  {
    origColor=target.style.color;
//    origBkgnd=target.style.backgroundColor;

    target.style.color="#ffff00";
//    target.style.backgroundColor="#0000ff";
  }
}

function tabDeHover(target)
{
  if (target.className == 'tab')
  {
    target.style.color=origColor;
//    target.style.backgroundColor=origBkgnd;
  }
}

var selected = "";
function selectTab(select, tabNbr, folder)
{
  if (tabNbr != null)
  {
    setCookie("tabSelected", tabNbr);
  }
  if (select.className == 'tab')
  {
    tabDeHover(select);
    if (folder == null)
    {
      folder = select.innerHTML;
    }
    else
    {
      top.document.getElementById('navi').src=folder+'/navigation.html';
    }
    select.className='tabSelected';

    selected.className='tab';
    selected = select;
  }
}

var cnt = 0;
function makeTab(name, folder)
{
  theTab  = "<td class='tab' onclick='selectTab(this, "+cnt+", \""+folder+"\");' onmouseover='tabHover(this);' onmouseout='tabDeHover(this);'>"+name+"</td>";
  theTab += "<td class='tabSpacer'></td>";
  document.write(theTab);
  cnt += 2;
}

function setup()
{
  var tabSelected = getCookie("tabSelected");
  if ((tabSelected == null)
  ||  (tabSelected.length <= 0))
  {
    tabSelected = 0;
  }

  selectTab(document.getElementById('tabTable').rows[0].cells[tabSelected]);
}