//==================================
// The Pop-up Menu Block
//==================================
window.onerror = null;
document.onmouseover = hideCurrent;
document.onclick = hideCurrent;

current_menu = null;
current_header = null;
header_return_src = null;
var menu_timer = null;

//==================================
function emptyMenuTimer(){
   menu_timer = null;
}

//==================================
// Hides a menu
function hideCurrent(){
   if (menu_timer) return;
   if (current_menu != null){
      changeObjectVisibility(current_menu, 'hidden');
      current_menu = null;
   }
   if (current_header != null){
      current_header.src = header_return_src;
      current_header = header_return_src = null;
   }
}
//==================================

//==================================
// Cross-browser function to get an object's style object
// Parameters:
//    objectID = the DOM object's ID
function getStyleObject(objectId){
   if(document.getElementById && document.getElementById(objectId)){
	   return document.getElementById(objectId).style; // W3C DOM
   }else if (document.all && document.all(objectId)){
	   return document.all(objectId).style; // MSIE 4 DOM
	}else if (document.layers && document.layers[objectId]){
	   return document.layers[objectId]; // NN 4 DOM
   }else{
	   return false;
   }
}

//==================================
// Change an objects visibility
// Parameters:
//    objectID = the object's ID
//    newVisibility = 'hidden' | 'visible'
function changeObjectVisibility(objectId, newVisibility){
   // get a reference to the cross-browser style object and make sure the object exists
   var styleObject = getStyleObject(objectId);
   if(styleObject){
	   styleObject.visibility = newVisibility;
	   return true;
   }

	return false; // object not found
}

//==================================
// Shows a menu
// Parameters:
//    menuID = the menu object's ID
//    eventObj = the event that was fired on the menu header
// Optional Parameters:
//    headerID = the header tags DOM ID
//    headerSrc = if the headerID is an IMG tag ID then new picture src
//    headerOldSrc = if the headerID is an IMG tag ID then old picture src
function show(menuID, eventObj, headerID, headerSrc, headerOldSrc){
	eventObj.cancelBubble = true;
   menu_timer = null;
   hideCurrent();
   if(changeObjectVisibility(menuID, 'visible')){
      current_menu = menuID;
 //     menu_timer = setTimeout("emptyMenuTimer()", 3000);
      if(headerID){
         current_header = headerID;
         if (headerSrc){
            current_header.src = headerSrc;
            header_return_src = headerOldSrc;
         }
      }
 	   return true;
   }

   return false;
}

/*  dont need this code block

function show(menu2ID, eventObj, header2ID, headerSrc, headerOldSrc){
	eventObj.cancelBubble = true;
   menu_timer = null;
   hideCurrent();
   if(changeObjectVisibility(menu2ID, 'visible')){
      current_menu = menu2ID;
 //     menu_timer = setTimeout("emptyMenuTimer()", 3000);
      if(header2ID){
         current_header = header2ID;
         if (headerSrc){
            current_header.src = headerSrc;
            header_return_src = headerOldSrc;
         }
      }
 	   return true;
   }

   return false;
}*/
//==================================
