<!--
//Region Global Variables
var fql_SelectedMenuStyleInfos=new Object();
var fql_UnselectedMenuStyleInfos=new Object();
var fql_MenuFadeDelays=new Object();
var fql_clockValue=0;
var fql_ticker;
var fql_highlightTopMenus=new Object();
var fql_images=new Array();
var fql_OpenMenuItems = new Array();
//EndRegion
//Region Methods to hook up a menu to the global variables
function fql_registerMenu(menuID, selectedStyleInfo, unselectedStyleInfo, menuFadeDelay, highlightTopMenu){
	fql_SelectedMenuStyleInfos[menuID]=selectedStyleInfo;
	fql_UnselectedMenuStyleInfos[menuID]=unselectedStyleInfo;
	fql_MenuFadeDelays[menuID]=menuFadeDelay;
	fql_highlightTopMenus[menuID]=highlightTopMenu;
}
//Region The methods and contructor of the fql_styleInfo object.
function fql_applyStyleInfoToElement(element){
	element.style.backgroundColor=this.backgroundColor;
	element.style.borderColor=this.borderColor;
	element.style.borderStyle=this.borderStyle;
	element.style.borderWidth=this.borderWidth;
	element.style.color=this.color;
	if (this.fontFamily!='')
		element.style.fontFamily=this.fontFamily;
	element.style.fontSize=this.fontSize;
	element.style.fontStyle=this.fontStyle;
	element.style.fontWeight=this.fontWeight;
	if (this.className!='')
		element.className=this.className; /* 4QL: Applies className to element rather than Style */
}
function fql_styleInfo(backgroundColor,borderColor,borderStyle,borderWidth,color,fontFamily,fontSize,fontStyle,fontWeight,className){
	this.backgroundColor=backgroundColor;
	this.borderColor=borderColor;
	this.borderStyle=borderStyle;
	this.borderWidth=borderWidth;
	this.color=color;
	this.fontFamily=fontFamily;
	this.fontSize=fontSize;
	this.fontStyle=fontStyle;
	this.fontWeight=fontWeight;
	this.className=className;
	this.applyToElement=fql_applyStyleInfoToElement;
}
//Region MouseEventHandlers
function fql_mousedOverMenu(menuID,elem,parent,displayedVertically,imageSource,subMenuPlaceholderID){
	fql_stopTick();
	fql_closeSubMenus(elem);
	var childID=elem.id+"-subMenu";  // Display child menu if needed
	if (document.getElementById(childID)!=null){  // make the child menu visible and specify that its position is specified in absolute coordinates
		document.getElementById(childID).style.display='block';
		document.getElementById(childID).style.position='absolute';
		fql_OpenMenuItems = fql_OpenMenuItems.concat(childID);
		
		if (subMenuPlaceholderID) { // If this is being dislayed in a placeholder then the position is fixed
			var subMenuPlace = document.getElementById(subMenuPlaceholderID);
			if (subMenuPlace != null) {
				document.getElementById(childID).style.left=fql_getAscendingLefts(subMenuPlace);
				document.getElementById(childID).style.top=fql_getAscendingTops(subMenuPlace);
			}
		}else{
			if (displayedVertically){ // Set the child menu's left and top attributes according to the menu's offsets
				document.getElementById(childID).style.left=fql_getAscendingLefts(parent)+parent.offsetWidth;
				document.getElementById(childID).style.top=fql_getAscendingTops(elem);
				
			}else{  // Set the child menu's left and top attributes according to the menu's offsets
				document.getElementById(childID).style.left=fql_getAscendingLefts(elem);
				document.getElementById(childID).style.top=fql_getAscendingTops(parent)+parent.offsetHeight;
				if (document.getElementById(childID).offsetWidth<elem.offsetWidth)
					document.getElementById(childID).style.width=elem.offsetWidth;
			}
		}
		
		// Move the display so that it fits in the window width and height
		var visibleWidth=parseInt(window.outerWidth?window.outerWidth-9:document.body.clientWidth,10);
		if ((parseInt(document.getElementById(childID).offsetLeft,10)+parseInt(document.getElementById(childID).offsetWidth,10))>visibleWidth) {
			if (displayedVertically) {
				document.getElementById(childID).style.left=fql_getAscendingLefts(parent)-parseInt(document.getElementById(childID).offsetWidth,10);
			}else {
				document.getElementById(childID).style.left=visibleWidth-parseInt(document.getElementById(childID).offsetWidth,10);
			}
		}
		var visibleHeight=parseInt(window.outerHeight?window.outerHeight-9:document.body.clientHeight,10);
		if ((parseInt(document.getElementById(childID).offsetTop,10)+parseInt(document.getElementById(childID).offsetHeight,10))>visibleHeight) {
			if (displayedVertically) {
				document.getElementById(childID).style.top=visibleHeight-parseInt(document.getElementById(childID).offsetHeight,10);
			}else{
				document.getElementById(childID).style.top=fql_getAscendingTops(parent)-parseInt(document.getElementById(childID).offsetHeight,10);
			}
		}
	}
	if (fql_SelectedMenuStyleInfos[menuID] != null) fql_SelectedMenuStyleInfos[menuID].applyToElement(elem);
	if (elem.SelectedColour)
		elem.style.color = elem.SelectedColour
	if (fql_highlightTopMenus[menuID]){
		var eId=elem.id+'';
		var eElem;
		while (eId.indexOf('-subMenu')>=0){
			eId=eId.substring(0, eId.lastIndexOf('-subMenu'));
			eElem = document.getElementById(eId);
			if (eElem.SelectedColour)
				eElem.style.color = eElem.SelectedColour;
			else
				fql_SelectedMenuStyleInfos[menuID].applyToElement(document.getElementById(eId));
		}
	}	
	if (imageSource!=''){
		setimage(elem,imageSource)
	}
}
function fql_mousedOverClickToOpen(menuID,elem,parent,imageSource){
	fql_stopTick();
	if (fql_SelectedMenuStyleInfos[menuID] != null) fql_SelectedMenuStyleInfos[menuID].applyToElement(elem);
	if (elem.SelectedColour)
		elem.style.color = elem.SelectedColour
	if (fql_highlightTopMenus[menuID]){
		var eId=elem.id+'';
		var eElem;
		while (eId.indexOf('-subMenu')>=0){
			eId=eId.substring(0, eId.lastIndexOf('-subMenu'));
			eElem = document.getElementById(eId);
			if (eElem.SelectedColour)
				eElem.style.color = eElem.SelectedColour;
			else
				fql_SelectedMenuStyleInfos[menuID].applyToElement(document.getElementById(eId));
		}
	}	
	if (imageSource!=''){
		setimage(elem,imageSource)
	}
}
function fql_mousedOverSpacer(menuID,elem,parent){
	fql_stopTick();
}
function fql_mousedOutMenu(menuID,elem,imageSource){
	fql_doTick(menuID);
	if (fql_UnselectedMenuStyleInfos[menuID] != null) fql_UnselectedMenuStyleInfos[menuID].applyToElement(elem);
	if (elem.UnselectedColour)
		elem.style.color = elem.UnselectedColour
	if (fql_highlightTopMenus[menuID]){
		var eId=elem.id+'';
		var eElem;
		while (eId.indexOf('-subMenu')>=0){
			eId=eId.substring(0, eId.lastIndexOf('-subMenu'));
			eElem = document.getElementById(eId);
			if (eElem.UnselectedColour)
				eElem.style.color = eElem.UnselectedColour;
			else
				fql_UnselectedMenuStyleInfos[menuID].applyToElement(document.getElementById(eId));
		}
	}
	if (imageSource!=''){
		setimage(elem,imageSource)
	}
}
function fql_mousedOutSpacer(menuID, elem){
	fql_doTick(menuID);
}
//Region Utility Functions
function fql_closeSubMenus(parent){
	if (fql_OpenMenuItems == "undefined") return;
	for (var i=fql_OpenMenuItems.length-1; i>-1;i--) {
		if (parent.id.indexOf(fql_OpenMenuItems[i]) != 0) {
			document.getElementById(fql_OpenMenuItems[i]).style.display = 'none';
			fql_shimSetVisibility(false, fql_OpenMenuItems[i]);
			fql_OpenMenuItems = new Array().concat(fql_OpenMenuItems.slice(0, i), fql_OpenMenuItems.slice(i+1));
  		} 
	}
}
function fql_shimSetVisibility(makevisible, tableid){
	var tblRef=document.getElementById(tableid);
	var IfrRef=document.getElementById('shim'+tableid);
	if (tblRef!=null && IfrRef!=null){
		if(makevisible){
			IfrRef.style.width=tblRef.offsetWidth;
			IfrRef.style.height=tblRef.offsetHeight;
			IfrRef.style.top=tblRef.style.top;
			IfrRef.style.left=tblRef.style.left;
			IfrRef.style.zIndex=tblRef.style.zIndex-1;
			IfrRef.style.display="block";
		}else{
			IfrRef.style.display="none";
		}
	}
}
function fql_IsSubMenu(id){
	if(typeof(fql_subMenuIDs)=='undefined') return false;
	for (var i=0;i<fql_subMenuIDs.length;i++)
	  if (id==fql_subMenuIDs[i]) return true;
	return false;
}
function fql_getAscendingLefts(elem){
	if (elem==null)
		return 0;
	else
	{
		if ((elem.currentStyle.position=='absolute' || elem.currentStyle.position=='relative') && !fql_IsSubMenu(elem.id)) return 0;
		return elem.offsetLeft+fql_getAscendingLefts(elem.offsetParent);
	}
}
function fql_getAscendingTops(elem){
	if (elem==null)
		return 0;
	else {
		if ((elem.currentStyle.position=='absolute' || elem.currentStyle.position=='relative') && !fql_IsSubMenu(elem.id)) return 0;
		return elem.offsetTop+fql_getAscendingTops(elem.offsetParent);
	}
}
//Region Fade Functions
//Modified so that a delay of -1 means that the the menu never fades.
function fql_doTick(menuID){
	if (fql_MenuFadeDelays[menuID]!=-1 && fql_clockValue>=fql_MenuFadeDelays[menuID]){
		fql_stopTick();
		fql_closeSubMenus(document.getElementById(menuID));
	} else {
		fql_clockValue++;
		fql_ticker=setTimeout("fql_doTick('"+menuID+"');", 500);
	}
}
function fql_stopTick(){
	fql_clockValue=0;
	clearTimeout(fql_ticker);
}
function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		fql_images[i]=new Image();
		fql_images[i].src=preloadimages.arguments[i];
	}
}
function setimage(elem,imageSource){
	var i=elem.getElementsByTagName("img")[0];
	i.src=imageSource;
}
//-->