var pendHide;
var hideIsPending=0;
var linkOverrideHide=0;
var lastRibbon;

function showMenu(menuObj){
	clearTimeout(pendHide);
	hideIsPending=0;
	menu = (menuObj.getAttribute("rel"));
	//check for ribbon visible
	if( $('ribbonContainer').style.display=='none'){		//if no, do SlideDown
		new Effect.SlideDown('ribbonContainer', {queue: 'front', duration:0.4});
		//#see if we can disable the div until it gets slid, or maybe just a timeout*/
	}
	//see if ribbon contents already match the click
	if(menu != lastRibbon){			//if yes, break out and do nothing
		new Ajax.Updater('ribbonMenu', "ribbonbars/" + menu + ".php");		//if no, which includes a clean new slidedown, call ajax function to get html for ribbon*/
		//alert($('ribbon').style.getPropertyValue('background-color'));
		//alert(document.body.background-color);
		//alert(document.body.background-image);
		//$('ribbon').background = "/2007/ani-eagle_flyLoading.gif";
		//alert($('ribbon').getStyle(this, 'background'));
		
		//alert(document.ie);
		//$(ribbon).setAttribute((this.ie ? 'className' : 'class'), menu);
		$('ribbon').setAttribute('className', menu);
		$('ribbon').setAttribute('class', menu);
	}
	
	lastRibbon = menu;
}

function hideMenu(){
	//alert("hideMenu");
	if( $('ribbonContainer').style.display!='none' && hideIsPending>0 && linkOverrideHide!=1){
		new Effect.SlideUp('ribbonContainer', {queue: 'end', duration:0.4} )
	}
	hideIsPending=0;
	linkOverrideHide=0;
}

// register event listeners on the Ajax requests to show/hide the processing indicator
Ajax.Responders.register({
	onCreate:
		function() {
			if (Ajax.activeRequestCount === 1) {
				$('loading').show();
			}
		},
	onComplete:
		function() {
			if (Ajax.activeRequestCount === 0) {
				$('loading').hide();
			}
		}
});
