var IDfirstMenu = 5;
var numberElements = 8;
var submenu21Name="intro";
var submenu22Name="background";
var submenu23Name="story";
var submenu31Name="benefits_individuals";
var submenu32Name="tour1";
var submenu33Name="signup";
var submenu41Name="benefits_physicians";
var submenu42Name="transition";
var submenu43Name="suggestions";


function determineMenuNum () {
  switch(getFileName()) {
    case submenu21Name:
    case submenu22Name:
    case submenu23Name:
      whichSubmenu=2;
      break;
    case submenu31Name:
    case submenu32Name:
    case submenu33Name:
      whichSubmenu=3;  
      break;
    case submenu41Name:
    case submenu42Name:
    case submenu43Name:
      whichSubmenu=4;
      break;
    default:
      whichSubmenu=1;
      break;
  }
  return whichSubmenu;
}



function divHiddenOrVisible (value) {
  document.write('<div style="display:');
  document.write(value);
  document.write(';">');
}


function getFileName () {
  var filename=document.location.href.substring(document.location.href.lastIndexOf("/")+1, document.location.href.length); 
  return removeExtension(filename);
}


/* function hideOrShowSubmenu appears to only hide the menu, not show it.  In the use case as well 
(footer.php), it is only called if we want to hide the particular submenu that we are calling it from */
function hideOrShowSubmenu (id) {
  if (document.getElementById(id))
    document.getElementById(id).style.display='none';
}


function isTabActive (a, b) {
  var returnVal = "";
  if (a==b) returnVal="active";
  return returnVal;
}


function passOpenSubmenu(a) {
  document.write('<a onclick="submenu=');
  document.write(a);
  document.write(';" ');
}


function removeExtension(filename) {
  var pair = filename.split('.');
  return pair[0];
}

function resetBeenClicked() {
  for (var i=IDfirstMenu; i<=numberElements; i++) {
    if (document.getElementById(i)) {
      document.getElementById(i).beenClicked=false;
    }
  }
}


function setAllInactive () {
  for (var i=IDfirstMenu; i<=numberElements; i++) {
    if (document.getElementById(i)) {
      document.getElementById(i).className='';
    }
  }
}


function writeMenuLinkHalf (submenu, calledFrom) {
  document.write('<a class="');
  if (submenu==calledFrom)
    document.write('active');
  document.write('" onmouseover="this.className=\'active\';"');

/* IF IT HASN'T BEEN CLICKED AND IT'S NOT THE CURRENT URL, THEN reset CLASSNAME to BLANK when we mouseout
Note that if we click another link, we reset this one to be blank...think about modifying this behavior*/

  document.write(' onmouseout="if ( (!(this.beenClicked)) && ((determineMenuNum(getFileName()))!=');
  document.write(calledFrom + ')) {this.className=\'\';}"');

  document.write(' onclick="setAllInactive(); this.className=\'active\'; resetBeenClicked(); this.beenClicked=true; "'); 
}