// Current selected tab menu
// Changes whenever a menu tab is clicked
var curMenuName = 'none';
var curSubMenuIndex = 0;

//
// Function to rollover menu images on mouseover's
// @param menuName - a mnemonic for the menu tab. 
// I.e. 'cs' = Customer Support, 'cm' = Collection Management.
//
function rollmenu(menuName) {
    if ( menuName == 'none' ) {
    	return;
    }

   if (document.images) {
		// Make the tab under the mouse hilighted
	  document.images['tab_' + menuName].src = './images/tab_' + menuName + '-over.gif';
	  	// write the submenu for this tab into place
	  document.getElementById('sm').innerHTML = document.getElementById('sm_'+menuName).innerHTML;

		// All other tabs go to their normal state
      if ( menuName != 'cs' )
		  document.images['tab_cs'].src = './images/tab_cs.gif';
      if ( menuName != 'cm' )
		  document.images['tab_cm'].src = './images/tab_cm.gif';
      if ( menuName != 'mr' )
		  document.images['tab_mr'].src = './images/tab_mr.gif';
      if ( menuName != 'us' )
		  document.images['tab_us'].src = './images/tab_us.gif';
      if ( menuName != 'cx' )
		  document.images['tab_cx'].src = './images/tab_cx.gif';

   }
}

//  
// When entering a submenu, turn the desired main menu tab into its mouse-down state
//
function syncmainmenu(menuName) {
    if ( menuName == 'none' ) {
    	return;
    }
	if (document.images) {
		if ( menuName != 'cs' )
			document.images['tab_cs'].src = './images/tab_cs.gif';
		if ( menuName != 'cm' )
			document.images['tab_cm'].src = './images/tab_cm.gif';
		if ( menuName != 'mr' )
			document.images['tab_mr'].src = './images/tab_mr.gif';
		if ( menuName != 'us' )
			document.images['tab_us'].src = './images/tab_us.gif';
		if ( menuName != 'cx' )
			document.images['tab_cx'].src = './images/tab_cx.gif';

		document.images['tab_' + menuName].src = './images/tab_' + menuName + '-down.gif';
	}
}

//
// On menu click events, save the current menu and submenu selected
// so that we can return to this state after future rollover actions
// that do not do mouseclicks
//
function setmenu( menuName, subMenuIndex ) {
	curMenuName = menuName;
	curSubMenuIndex = subMenuIndex;
	
    if ( menuName == 'none' ) {
    	return true;
    }
	
	document.getElementById(curMenuName + '_' + curSubMenuIndex ).className = 'submenusel';
	
	return true;
}

//
// On mouse out of a menu rollover, restore the menu images to
// be in synch with the selected page.
//
function restoremenu() {
	rollmenu( curMenuName );
	syncmainmenu( curMenuName );
}

