// this function repositions a menu to the speicified offset from center
function repositionMenu(menu, offset)
{
	// the new left position should be the center of the window + the offset
	var width = jQuery(document).outerWidth();
	//var width = getWindowWidth();

	var newLeft = width / 2 + offset;
	jQuery('#debug').text(width+' width, new "Left" = '+newLeft);

	// setting the left position in netscape is a little different than IE
	menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
}
 
// this function calculates the window's width - different for IE and netscape
function getWindowWidth()
{
	return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}

/* Slide-out menu control */
jQuery(document).ready(function(){
	jQuery("a[@rel].slideoutMenuLink").mouseover(
		function()
		{
			if( jQuery("#"+this.rel+"Container").html() != null )
			{
				ypSlideOutMenu.showMenu(this.rel);
			}
		}
	);
	
	jQuery("a[@rel].slideoutMenuLink").mouseout(
		function()
		{
			if( jQuery("#"+this.rel+"Container").html() != null )
			{
				ypSlideOutMenu.hideMenu(this.rel);
			}
		}
	);
	
	jQuery('#menus div.slideoutMenu').hover(
		function()
		{
			//first, get the ID of the div container.  we need to determine the button that is 'attached' to this slideout menu, and we can
			//	find that from the ID of the div container
			var theID = jQuery(this).attr('id');
			if(theID.indexOf('Container') > 0)
			{
				var theRel = theID.substring(0, theID.length - 'Container'.length);
				jQuery('a[@rel='+theRel+']').addClass('overMenu');
			}
			
		},
		function()
		{
			var theID = $(this).attr('id');
			if(theID.indexOf('Container') > 0)
			{
				var theRel = theID.substring(0, theID.length - 'Container'.length);
				jQuery('a[@rel='+theRel+']').removeClass('overMenu');
			}
		}
	)
});
