
currentSelection = -1;
currentTheme = 0;
previousSelection = -1;
previousTheme = 0;

previousIndex = -1;

//                            mouseOver             mouseOut               selected
//                        bgColor    fgColor    bgColor    fgColor    bgColor    fgColor
//
//colorTheme1 = new Array( "#008000", "#FFFFFF", "#00E800", "#000000", "#49C149", "#FFFFFF" );
colorTheme1 = new Array( "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000" );
colorTheme2 = new Array( "#999999", "#000000", "#c0c0c0", "#000000", "#80a6b9", "#000000" );
colorTheme3 = new Array( "#e0e0e0", "#000000", "#efefef", "#000000", "#8DBEEB", "#ffffff" );
colorArray = new Array( colorTheme1, colorTheme2, colorTheme3 )

var imgSTab    = new Image();
var imgETab    = new Image();
var imgSNavTab = new Image();
var imgENavTab = new Image();
var imgSSelTab = new Image();
var imgESelTab = new Image();

imgSTab.src    = '../proteus/images/tabstart.gif'
imgETab.src    = '../proteus/images/tabend.gif'
imgSNavTab.src = '../proteus/images/tabstartnav.gif'
imgENavTab.src = '../proteus/images/tabendnav.gif'
imgSSelTab.src = '../proteus/images/tabstartsel.gif'
imgESelTab.src = '../proteus/images/tabendsel.gif'

// handles mouseOver and mouseOut events

function setColors(pstrmoverBG,pstrmoverFG,pstrmoutBG,pstrmoutFG,pstrselBG,pstrselFG)
{
  colorTheme1[0]=pstrmoverBG
  colorTheme1[1]=pstrmoverFG
  colorTheme1[2]=pstrmoutBG
  colorTheme1[3]=pstrmoutFG
  colorTheme1[4]=pstrselBG
  colorTheme1[5]=pstrselFG
}

function nav( tableCellRef, cellIndex, hoverFlag, currentTheme ) 
{

  if ( currentSelection != tableCellRef )
  {

    tableCellRef.style.backgroundColor = hoverFlag ? colorArray[currentTheme][0] : colorArray[currentTheme][2];
    tableCellRef.style.color = hoverFlag ? colorArray[currentTheme][1] : colorArray[currentTheme][3];

//    if (hoverFlag) {
//      document['tabstart' + cellIndex].src=imgSNavTab.src;
//      document['tabend'   + cellIndex].src=imgENavTab.src;
//    }
//    else {
//      document['tabstart' + cellIndex].src=imgSTab.src;
//      document['tabend'   + cellIndex].src=imgETab.src;
//    }
  }
  else
  {
    tableCellRef.style.backgroundColor = colorArray[currentTheme][4];
    tableCellRef.style.color = colorArray[currentTheme][5];
//    document['tabstart' + cellIndex].src=imgSSelTab.src;
//    document['tabend'   + cellIndex].src=imgESelTab.src;
  }

}

// click events handled here

function navClick( tableCellRef, cellIndex, url, currentTheme ) 
{
  selectItem( tableCellRef, cellIndex, url, currentTheme )
  top.contentFrame.location.href = url;
}

// highlight the selected menu item

function selectItem( tableCellRef, cellIndex, url, currentTheme ) 
{
  previousSelection = currentSelection;
  currentSelection = tableCellRef;
  nav( tableCellRef, cellIndex, 0, currentTheme );
  if ( previousSelection != -1 ) {
    nav( previousSelection, previousIndex, 0, previousTheme );
  }
  previousIndex = cellIndex;
  previousTheme = currentTheme;
}
