// Author: Jean-Paul Ines 2002 - 2007
  //
	// menuActive - acts as a queue for all the visible sub menus
	//              required in order to to show/hide multiple menus.
	// menuActive[0] - contains the menu's menuId
  // menuActive[1] - contains the menu's timer
  // menuActive[2] - contains the menu's active status

  var menuActive = new Array( new Array(), new Array(), new Array() );

  // function displayMenu (obj, menuId, position)
  //                       obj - used in order to calculate the relative position and dimensions of the calling button.
  //                       menuID - id of the menu to be displayed
  //                       position - where to place the menu relative to the calling button.
  //
  // Function that determines the location of a menu and corretly places a child menu

  function displayMenu(obj, menuId, position, clear) {

		//LogMessage("Show: "+obj.id+ " Menu: " +menuId+ " Clear: " + clear);

    var cX, cY;
    var mX = 0, mY = 0;
    var found = false;

    // Clear all active sub menus
    if ( clear ) {
	    	for ( x in menuActive[0] ) {
	      		document.getElementById(menuActive[0][x]).style.display = 'none';
        		clearTimeout(menuActive[1][x]);
        		menuActive[1][x] = null;
     	 		 menuActive[2][x] = null;
	    	}
		}

		// Mark the menu as active
		for ( x in menuActive[0] ) {
      		if ( menuActive[0][x] == menuId ) {
      	 		menuActive[2][x] = 1;
      	 		found = true;
         		break;
			}
    	}

		if ( found == false ) {
      // Menu was not found in the collection, add it
      menuActive[0].push(menuId);
      menuActive[1].push(null);
      menuActive[2].push(1);
		}

    // Make the item as visible
    var menuObj = document.getElementById(menuId);
  	menuObj.style.visibility = 'hidden';
  	menuObj.style.display    = 'block';

    // clientHeight/clientWidth does not include border size
    // use offsetHeight/offsetWidth instead
    oX = obj.offsetWidth;
    oY = obj.offsetHeight;
    moX = menuObj.offsetWidth;
    moY = menuObj.offsetHeight ;

    // Calculate sub menu offset based on the requested position
    var margin = 0;
  	switch( position ) {
      case 1: /*** Above Left ***/
        cX = - moX - margin;
        cY = - moY - margin;
        break;
      case 2: /*** Above Center***/
        cX = 0;
        cY = - moY - margin;
        break;
      case 3: /*** Above Right ***/
        cX =    oX + margin;
        cY = - moY - margin;
        break;
      case 4: /*** Center Right ***/
        cX = oX + margin;
        cY = 0;
        break;
      case 5: /*** Below Right ***/
        cX = oX + margin;
        cY = oY + margin;
        break;
      case 6: /*** Below Center ***/
        cX = 0;
        cY = oY + margin;
        break;
      case 7: /*** Below Left ***/
        cX = - moX - margin;
        cY = oY + margin;
        break;
      case 8: /*** Center Left ***/
        cX = - moX - margin;
        cY = 0;
        break;
    }

    // Get location of calling button relative to the page
    while ( obj ) {
      mX += obj.offsetLeft;
      mY += obj.offsetTop;
      obj=obj.offsetParent;
    }

    // Display the sub menu in the correct location
    menuObj.style.left       = (mX+cX) + 'px';
  	menuObj.style.top        = (mY+cY) + 'px';
  	menuObj.style.visibility = 'visible';

  }

  // function clearMenu(status, menuId)
  //                    status - 'TRUE' indicates a hide request
  //                           - 'FALSE' indicates a CANCEL hide request
  //                    menuId - id of the sub menu acted upon
  //
  // Initiate a request to hide the sub menu

  function clearMenu(status, menuId) {

    var menuObj=document.getElementById(menuId);
		var x, activeId;

    for ( x in menuActive[0] ) {
      if ( menuActive[0][x] == menuId ) break;
    }
    activeId = x;

		//LogMessage("Hide: "+status+ " Menu: " +menuId+ " Timer: " + menuActive[1][activeId]);

    // Check if the sub menu is visible
    if ( menuActive[2][x] == 1) {

        // Hide the submenu if its timer has expired
        if ( status && menuActive[1][activeId] ) {
            menuObj.style.display = 'none';
            clearTimeout( menuActive[1][activeId] );
            menuActive[1][activeId] = null;
            menuActive[1][activeId] = null;
        }
        // Set the timer period in milliseconds
        else if ( status ) {
          menuActive[1][activeId] = setTimeout('clearMenu(true,\''+menuId+'\')',400);
        }
        // Cancel the hide request
        else {
          clearTimeout(menuActive[1][activeId]);
          menuActive[1][activeId] = null;
          menuActive[2][activeId] = 1;
        }
    }

  }
//another function added in here to house the display date function for the header
function curYear() {
  var d = new Date();
  document.write(d.getFullYear());
}  
//added a blank function for the 'blank' hyperlink in the side menu
function doNothing(){
	
}
