/**************************************************************************************
N.B. For each drop down you'll need to add the menu to array of drop downs (qv)
**************************************************************************************/
			
function highlightParentLink(id) {
	var id_link = id+"_link";
	document.getElementById(id_link).className = "menuHi";
}
	
function lowlightParentLink(id) {
	var id_link = id+"_link";
	document.getElementById(id_link).className = "";
}

/* Drop down menu - now moved into dynamic systems 
var dropDownArray = new Array();
dropDownArray[0] = "ibsDropDown"; 
dropDownArray[1] = "ibsjDropDown";
dropDownArray[2] = "linksDropDown";
dropDownArray[3] = "subscribeDropDown";
dropDownArray[4] = "onlineDropDown";
dropDownArray[5] = "userdetailsDropDown";
dropDownArray[6] = "eventsDropDown";
*/

function showMenu(code,orientation,offset) {
	var menuID = code + 'DropDown_menu';
	var elementID = code + 'DropDown';
	var linkelement = document.getElementById(menuID);
	if (orientation == 'horizontal') {
		document.getElementById(elementID).style.left = linkelement.offsetLeft + 'px';
		document.getElementById(elementID).style.top = (linkelement.offsetTop + linkelement.offsetHeight + offset) + 'px';
	}
	else {
		document.getElementById(elementID).style.top = (linkelement.offsetTop) + 'px';
		document.getElementById(elementID).style.left = (linkelement.offsetLeft + linkelement.offsetWidth + offset) + 'px';
	}
	showDivMenu(elementID);
}

function showMenuAbsolute(code,orientation,offset) {
	var menuID = code + 'DropDown_link';
	var elementID = code + 'DropDown';
	var linkelement = getElementPosition(menuID);
	offset = typeof(offset) != 'undefined' ? offset : 0;
	orientation = typeof(orientation) != 'undefined' ? orientation : 'horizontal';
	
	/*
	var xy = YAHOO.util.Dom.getXY(menuID); 
    linkelement.left = xy[0];
	linkelement.top = xy[1];
	*/
	/*
	alert(linkelement.top);*/
	debug('Left = ' + linkelement.left);
	debug('width of element = ' + linkelement.width);
	
	if (orientation == 'horizontal') {
		document.getElementById(elementID).style.left = linkelement.left + 'px';
		document.getElementById(elementID).style.top = (linkelement.top + linkelement.height + offset) + 'px';
	}
	else {
		
		document.getElementById(elementID).style.top = (linkelement.top) + 'px';
		document.getElementById(elementID).style.left = (linkelement.left + linkelement.width + offset) + 'px';
	}
	showDivMenu(elementID);
}

function show(id) {
	document.getElementById(id).style.visibility = 'visible';
	var temp = document.getElementById(id);
	debug('Left = ' + temp.style.left);
	debug('Top = ' + temp.style.top);
}

function hide(id) {
	document.getElementById(id).style.visibility = 'hidden';
}

function showDivMenu(id) {
	show(id);
	highlightParentLink(id);
	if (typeof( window['jsTimeout'] ) != "undefined") { clearTimeout(jsTimeout); }
}

function hideDivMenu(id) {
	jsTimeout = setTimeout("hide('"+id+"'); lowlightParentLink('"+id+"');", 750);
	
}

function hideAllDivs() {
	for (i = 0; i <= (dropDownArray.length-1); i++){
		if (document.getElementById(dropDownArray[i]) != null) { 
			hide(dropDownArray[i]);
			lowlightParentLink(dropDownArray[i]);
		}
	}
}

function positionElement(menuID,elementID,offsetx,offsety) {
	var pos = getElementPosition(menuID);
	var left = pos.left + offsetx;
	var top = pos.top + offsety;
	document.getElementById(elementID).style.left = left + 'px';
	document.getElementById(elementID).style.top = top + 'px';
}
