// inTheWayIDs are id of objects that get in the way in I.E.: they will be ids of form elements
function MenuRolloverObj(timecount, rolloverIDsArray, inTheWayIDsArray,  onMouseoverFunctions, onMouseoutFunctions){
	this.timecount = timecount;
	this.rolloverIDsArray = rolloverIDsArray;
	this.inTheWayIDsArray = inTheWayIDsArray;

	this.onMouseoverFunctions = onMouseoverFunctions;
	this.onMouseoutFunctions = onMouseoutFunctions;

	this.timerID = null;
	this.isTimerOn = false;
} //end constructor



//MenuRollover_ToggleElementList(false,['select'],'tag') to hide MenuRollover_ToggleElementList(false,['select'],'tag')
//MenuRollover_ToggleElementList(true,['select'],'tag') to show
function MenuRollover_ToggleElementList(show,elList,toggleBy) {
	var HM_DOM = document.getElementById ? true : false;
	var HM_IE  = document.all ? true : false;
	var HM_NS4 = document.layers ? true : false;
  
	if(!(HM_DOM||HM_IE||HM_NS4)){
		return true;
	}

	if(HM_NS4 && (toggleBy=="tag") ) { 
		return true;
	}

	  for(var i=0; i<elList.length; i++) {
		 var ElementsToToggle = [];
		 switch(toggleBy) {
			case "tag":
			   ElementsToToggle = (HM_DOM) ? document.getElementsByTagName(elList[i]) :
								  document.all.tags(elList[i]);
			   break;
			case "id":
			   ElementsToToggle[0] = (HM_DOM) ? document.getElementById(elList[i]) :
									 (HM_IE) ? document.all(elList[i]) : 
									 document.layers[elList[i]];
			   break;
		 }
		 for(var j=0; j<ElementsToToggle.length; j++) {
			var theElement = ElementsToToggle[j];
			if(!theElement) continue;
			if(HM_DOM||HM_IE) {
			   theElement.style.visibility = show ? "inherit" : "hidden";
			} else if (HM_NS4) {
			   theElement.visibility = show ? "inherit" : "hide";
			}
		 }
	  }
	  return true;
} //end MenuRollover_ToggleElementList

function MenuRollover_ShowInTheWayIDs(mrObj){
	if (mrObj.inTheWayIDsArray != null)
	{
		MenuRollover_ToggleElementList(true, mrObj.inTheWayIDsArray, "id");
	}
	
} //end MenuRollover_ShowTags

function MenuRollover_HideInTheWayIDs(mrObj){
	if (mrObj.inTheWayIDsArray != null)
	{
		MenuRollover_ToggleElementList(false, mrObj.inTheWayIDsArray, "id");
	}
	
} //end MenuRollover_HideTags


function MenuRollover_onMouseoverFunctions(mrObj){
	if (mrObj.onMouseoverFunctions != null)
	{
		for(var i=0; i < mrObj.onMouseoverFunctions.length; i++)
		{
			mrObj.onMouseoverFunctions[i]();
		} //end for
	} //end if
}

function MenuRollover_onMouseoutFunctions(mrObj){
	if (mrObj.onMouseoutFunctions != null)
	{
		for(var i=0; i < mrObj.onMouseoutFunctions.length; i++)
		{
			mrObj.onMouseoutFunctions[i]();
		} //end for
	} //end if
}

function MenuRollover_HideAll(mrObj){
	var oDiv = null;
	
	var curr_id = null;
	//for(var i in mrObj.rolloverIDsArray){
	for(var i=0; i < mrObj.rolloverIDsArray.length; i++){
		curr_id = mrObj.rolloverIDsArray[i];
		oDiv = MenuRollover_GetObj(curr_id);
		oDiv.style.visibility = "hidden";
	} //end for

	MenuRollover_ShowInTheWayIDs(mrObj);
	MenuRollover_onMouseoutFunctions(mrObj);
}

function MenuRollover_GetObj(id){
	var oDiv = null;
		
	if (document.getElementById){
		oDiv = document.getElementById(id);
	}
	else if(document.all){
		oDiv = document.all[id];
	}
		
	return oDiv;
} //end GetObj(id)

function MenuRollover_ShowDiv(id){
	var oDiv = MenuRollover_GetObj(id);
	oDiv.style.visibility = "visible";
} //end ShowDiv



function MenuRollover_StartTime(mrObj){
	if( ! mrObj.isTimerOn){
		mrObj.timerID = setTimeout("MenuRollover_HideAll(mrObj);", mrObj.timecount);
		mrObj.isTimerOn = true;
	}
}

function MenuRollover_StopTime(mrObj){
	if( mrObj.isTimerOn){
		clearTimeout(mrObj.timerID);
		mrObj.timerID = null;
		mrObj.isTimerOn = false;
	}
}


function MenuRollover_MenuOnMouseOver(mrObj, dropdownID){
	MenuRollover_HideAll(mrObj);
	MenuRollover_ShowDiv(dropdownID);
	
	MenuRollover_HideInTheWayIDs(mrObj);
	
	MenuRollover_onMouseoverFunctions(mrObj);
	
	MenuRollover_StopTime(mrObj);
}

function MenuRollover_MenuOnMouseOut(mrObj){
	MenuRollover_StartTime(mrObj);
}

function MenuRollover_DropdownOnMouseOver(mrObj){
	MenuRollover_StopTime(mrObj);
}

function MenuRollover_DropdownOnMouseOut(mrObj){
	MenuRollover_StartTime(mrObj);
}
