// JavaScript Document
var menuInitialized = true;
var subMenus = ['subMenuHockey','subMenuCourses','subMenuFootball', 'subMenuGolf', 'subMenuBaseball', 'subMenuSoccer', 'subMenuAutres'];

function initTopMenu(){
	menuInitialized = true;
}

function showSubMenu(parentElement, subMenuId){
	if(menuInitialized){
		hideSubMenus();
		parentMenu = $(parentElement);
		parentHeight = parentMenu.getHeight();
		parentWidth = parentMenu.getWidth();
		childWidth = $(subMenuId).getWidth();
		parentPos = parentMenu.cumulativeOffset();
		parentCentralPoint =  parentPos.left + parseInt((parentWidth / 2));
		childLeft = parentCentralPoint - parseInt(childWidth / 2);
		//childLeft = parentPos.left;
		childTop = parentPos.top + parentHeight;
		//alert(parentPos.left + "px, " + parentPos.top + "px");
		$(subMenuId).style.top =  childTop + "px";
		$(subMenuId).style.left =  childLeft + "px";
		$(subMenuId).className = "topSubMenu shownSubMenu";
		$(subMenuId).style.display = 'block';
		
	}
}

function hideSubMenu(subMenuId){
	if(menuInitialized){
		$(subMenuId).style.display = 'none';
		$(subMenuId).className = "topSubMenu";
	}
}

function hideSubMenus(){
	if(menuInitialized){
		tmpSubMenus = $$('.topSubMenu');
		tmpSubMenus.each(function(subMenuId){
			hideSubMenu(subMenuId);					   
		});
	}
}
