/*************** Script functions in this file **************
Filename: menuFunctions.js; as of 12/16/2000
  FUNCTION:                                               LINE:
  fnSquareOn( whichOne )                                   11   
  fnSquareOff( whichOne )                                  17   
  fnMenuControl( whichOne )                                37   
  fnMenuExpand( whichOne )                                 52   
************ (end Script functions in this file) ***********/


function fnSquareOn( whichOne ) {
  whichOne = 'tocM_'+whichOne+'LEFT';
  if( document.all[whichOne].className == 'leftGray' ) {
    document.all[whichOne].className = 'leftYellow';
  };
};


function fnSquareOff( whichOne ) {
  
  // If this menu is locked, cancel function.
  if( _lockedMenu == whichOne ) return;

  // If the request was sent from a TOC detail page . . .
  if( whichOne == null ) {
    whichOne = _lockedMenu;
    _lockedMenu = -1;
  };

  // Build the DOM reference
  whichOne = 'tocM_'+whichOne+'LEFT';

  // Turn it Off

  if( document.all[whichOne].className == 'leftYellow' ) {
    document.all[whichOne].className = 'leftGray';
  };

};


function fnMenuControl( whichOne ) {

  // If a menu is already locked, unlock it.
  if( _lockedMenu != -1 ) {
    var elLockedCell =  'tocM_'+_lockedMenu+'LEFT';
    // Call Appropriate TOC
//    showTOC(null);
  };

  // Now, let's lock the one that we just clicked.
  _lockedMenu = whichOne;
//  showTOC(whichOne);
  openNewPage( whichOne );  
};



function fnMenuExpand( whichOne ) {
  var url = _tocPage + whichOne;
  parent.document.all.scrolling.src = '';
  parent.document.all.scrolling.src = url;
  parent.document.location.replace( url );
};

function XXXfnMenuExpand( whichOne ) {

  // Let's establish some ground rules
  var elTri = event.srcElement;
  var elChild = document.all['children'+whichOne];
  var elCell = document.all['tocM_'+whichOne+'LEFT'];
  var elRightCell = document.all['tocM_'+whichOne];

  // Is any menu open?
  if( _lockedMenu != -1 ) {
    // Yes, there is.  Let's close it. . .
    if( document.all['tocTri_'+_lockedMenu] ) {
      document.all['tocM_'+_lockedMenu+'LEFT'].className = 'tocBoffLeft';
      document.all['tocTri_'+_lockedMenu].src = _closedSrc;
      document.all['children'+_lockedMenu].style.display = 'none';
      document.all['tocM_'+_lockedMenu].style.background = 'FFFFFF';
      document.all['tocM_'+_lockedMenu].style.borderColor = 'CCCCCC';
    };
  };

  // Was that menu the one they clicked?
  if( whichOne == _lockedMenu ) {
     _lockedMenu = -1;
     return;
  };
  
  _lockedMenu = -1
  
  // Okay, we should now open the menu they clicked . . .\
  elChild.style.display = 'block';
  elTri.src = _openSrc;
  elCell.className = 'squareOn';
  elRightCell.style.background = 'EEEEEE';
  elRightCell.style.borderColor = 'FFCC00';
  _lockedMenu = whichOne;
};


function fnSubMenuExpand( whichOne,arg ) {

  if( arg % 2 == 0 ) {
    var bg = 'EEEEEE';
  } else {
    var bg = 'WHITE';
  };
  // I'll tell you what's what.
  var elChild = document.all['children'+whichOne];
  var elTri = document.all['tocTri_'+whichOne];

  var state = elChild.style.display;

  if( state == 'none' ) {
    elChild.style.display = 'block';
    elChild.style.background = bg;
    elChild.style.borderStyle = 'ridge';
    elChild.style.borderColor = 'FFCC00';
    elChild.style.borderWidth = 1;
    elTri.src = _openSrc;
  }else{
    elChild.style.display = 'none';
    elChild.style.background = 'EEEEEE';
    elTri.src = _closedSrc;
  };

};

