var currentOpen=0;		// used to keep track of submenus that are open
var mainFlag=false;			// used to indicate if you are over the main menu
var subFlag=false;			// used to indicate if you are over any of the submenus
var menuCoords = new Array(0,43,95,164,248,315,384,468,524,608); // Coordinates defining the right bound position of each Menu Item and ending with the farthest right position	

function overMenu(whichMain,hasSub){
  //hideDiv("mainMenuHover"); // for Mac compatibility
  //clipDiv("mainMenuHover",0,menuCoords[whichMain],21,menuCoords[whichMain-1]);
  //showDiv("mainMenuHover");
  if (currentOpen > 0){
    hideSub(currentOpen);
  } 
  if (hasSub){
    showSub(whichMain)
    currentOpen = whichMain;
  }
  mainFlag = true;
}

function overSubMenu(whichSub,index){
  subFlag = true;
  //hideDiv("subMenu"+whichSub+"Hover");
  //eval('clipDiv("subMenu'+whichSub+'Hover",(index-1)*15,150,index*15,0)');
  showDiv("subMenu"+whichSub);
}

function offMenu(){
  mainFlag = false;
  eval("setTimeout('delayIt()',100)");
}

function offSubMenu(){
  subFlag = false;
  eval("setTimeout('delayIt()',100)");
}

function delayIt() {
  if (!mainFlag && !subFlag){
    //clipDiv('mainMenuHover',0,0,0,0);
    if (currentOpen > 0){
      hideSub(currentOpen);
    }
  }
}

// shows a submenu *************** 
function showSub(index) {
  showDiv("subMenu" + index);
  //eval('showDiv("subMenu'+ index +'Map")');
}

// hides a submenu and resets the flag *************
function hideSub(index) {
  hideDiv("subMenu"+ index);
  //eval('hideDiv("subMenu'+ index +'Hover")');
  //eval('hideDiv("subMenu'+ index +'Map")');
  currentOpen=0;
}

