<!--
//Region Global Variables
var crab_SelectedMenuStyleInfos=new Object();
var crab_UnselectedMenuStyleInfos=new Object();
var crab_UnselectedTopMenuStyleInfos= new Object();
var crab_MenuFadeDelays=new Object();
var crab_clockValue=0;
var crab_ticker;
var crab_images=new Array();
var crab_OpenMenuItems = new Array();
//EndRegion

//Registers the selected styles of the menu
function crab_registerMenu(menuID, selectedStyleInfo, unselectedStyleInfo, menuFadeDelay, unselectedTopStyleInfo){
	crab_SelectedMenuStyleInfos[menuID]=selectedStyleInfo;
	crab_UnselectedMenuStyleInfos[menuID]=unselectedStyleInfo;
	crab_MenuFadeDelays[menuID]=menuFadeDelay;
	crab_UnselectedTopMenuStyleInfos[menuID]=unselectedTopStyleInfo;
}
//Region The methods and contructor of the crab_styleInfo object.
function crab_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.style.className=this.className;
}
function crab_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=crab_applyStyleInfoToElement;
}
//Region MouseEventHandlers
function crab_mousedOverMenu(menuID,elem,parent,displayedVertically,imageSource){
	crab_stopTick();
	crab_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';
		crab_OpenMenuItems = crab_OpenMenuItems.concat(childID);
		// Set the child menu's left and top attributes according to the menu's offsets
		document.getElementById(childID).style.left=crab_getAscendingLefts(elem)+'px';
		document.getElementById(childID).style.top=crab_getAscendingTops(parent)+parent.offsetHeight+'px';
		if (document.getElementById(childID).offsetWidth<elem.offsetWidth){
			document.getElementById(childID).style.width=elem.offsetWidth;
		}
	}
	
	if (crab_SelectedMenuStyleInfos[menuID] != null) crab_SelectedMenuStyleInfos[menuID].applyToElement(elem);
	
	if (imageSource!=''){
		setimage(elem,imageSource)
	}
}
function crab_mousedOverClickToOpen(menuID,elem,parent,imageSource){
	crab_stopTick();
	if (crab_SelectedMenuStyleInfos[menuID] != null) crab_SelectedMenuStyleInfos[menuID].applyToElement(elem);

	if (imageSource!=''){
		setimage(elem,imageSource)
	}
}
function crab_mousedOverSpacer(menuID,elem,parent){
	crab_stopTick();
}
function crab_mousedOutMenu(menuID,elem,imageSource){
	crab_doTick(menuID);
	//if the element is a parent element, apply the UnselecedTopStyle else apply the UnselectedStyle
	if (elem.id.indexOf('-subMenu') < 0){
		if (crab_UnselectedTopMenuStyleInfos[menuID] != null) crab_UnselectedTopMenuStyleInfos[menuID].applyToElement(elem);	
	}else {
		if (crab_UnselectedMenuStyleInfos[menuID] != null) crab_UnselectedMenuStyleInfos[menuID].applyToElement(elem);
	}

	if (imageSource!=''){
		setimage(elem,imageSource)
	}
}
function crab_mousedOutSpacer(menuID, elem){
	crab_doTick(menuID);
}
//Region Utility Functions
function crab_closeSubMenus(parent){
	if (crab_OpenMenuItems == "undefined") return;
	for (var i=crab_OpenMenuItems.length-1; i>-1;i--) {
		if (parent.id.indexOf(crab_OpenMenuItems[i]) != 0) {
			document.getElementById(crab_OpenMenuItems[i]).style.display = 'none';
			crab_shimSetVisibility(false, crab_OpenMenuItems[i]);
			crab_OpenMenuItems = new Array().concat(crab_OpenMenuItems.slice(0, i), crab_OpenMenuItems.slice(i+1));
  		} 
	}
}
function crab_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 crab_IsSubMenu(id){
	if(typeof(crab_subMenuIDs)=='undefined') return false;
	for (var i=0;i<crab_subMenuIDs.length;i++)
	  if (id==crab_subMenuIDs[i]) return true;
	return false;
}
function crab_getAscendingLefts(elem){
	if (elem==null)
		return 0;
	else
	{
		if ((elem.style.position=='absolute' || elem.style.position=='relative') && !crab_IsSubMenu(elem.id)) return 0;
		return elem.offsetLeft+crab_getAscendingLefts(elem.offsetParent);
	}
}
function crab_getAscendingTops(elem){
	if (elem==null)
		return 0;
	else {
		if ((elem.style.position=='absolute' || elem.style.position=='relative') && !crab_IsSubMenu(elem.id)) return 0;
		return elem.offsetTop+crab_getAscendingTops(elem.offsetParent);
	}
}
//Region Fade Functions
function crab_doTick(menuID){
	if (crab_clockValue>=crab_MenuFadeDelays[menuID]){
		crab_stopTick();
		crab_closeSubMenus(document.getElementById(menuID));
	} else {
		crab_clockValue++;
		crab_ticker=setTimeout("crab_doTick('"+menuID+"');", 500);
	}
}
function crab_stopTick(){
	crab_clockValue=0;
	clearTimeout(crab_ticker);
}

function setimage(elem,imageSource){
	var i=elem.getElementsByTagName("img")[0];
	i.src=imageSource;
}
//-->