window.onerror = null;
document.onmouseover = hideCurrent;
document.onclick = hideCurrent;

current_menu = null;
current_header = null;

//==================================
// Hides a menu
// Parameters:
//    objectID = the object to be hidden
function hideCurrent(){
   if (current_menu != null)
      changeObjectVisibility(current_menu, 'hidden');
   if (current_header != null){
      flipColor(current_header.parentNode, '#4a6381');
      flipText(current_header, '#ffffff');
   }
   current_menu = null;
   current_header = null;
}
//==================================

//==================================
// Changes the background color of an object
// Parameters:
//    objectID = the DOM object's ID
//    color = the background color to change to
function flipColor(objectID, color){
   objectID.style.backgroundColor = color;
}
//==================================

//==================================
// Changes the background color of an object
// Parameters:
//    objectID = the DOM object's ID
//    color = the background color to change to
function flipText(objectID, color){
   objectID.style.color = color;
}
//==================================

//==================================
// 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
//    headerID = the header A tag's DOM ID
//    eventObj = the event that was fired on the menu header
function show(menuID, headerID, eventObj){
	eventObj.cancelBubble = true;
   hideCurrent();
   if(changeObjectVisibility(menuID, 'visible')){
      current_menu = menuID;
      if(headerID){
         current_header = headerID;
         flipColor(current_header.parentNode, '#01365e');
         flipText(current_header, '#b9d1af');
      }
 	   return true;
   }

   return false;
}
//==================================

function opener(url,pop,w,h){
   sh=(screen.height-h)/2
   sw=(screen.width-w)/2
   NewWin=window.open(url,pop,'width='+w+',height='+h+',top='+sh+',left='+sw+',scrollbars=yes');
   NewWin.focus();
}
//=================================
