/**
 * Functionality for the meerkat template, so that the main menus
 * show a nice transition effect. 
 * 
 * @version $Id:$
 * @author Sean Wedig <wedig_8@fisher.osu.edu>, Jason Hart <hart@fisher.osu.edu>
 */

function showLevelTwo(event){
	if (!event) // HACK - IE 7 doesn't properly pass the event in to the method   
		event = window.event;

	// this is the element that is actually handling the event;
	//	note that some child element may have actually triggered it!
	handlerOwningElement = this;
	
	subMenuElement = handlerOwningElement.select('.level2SubMenu').first();
	subMenuHeight = subMenuElement.getDimensions().height;

	// HACK: hard-code this to 35 pixels for the "flattened" height + 
	//	the top offset of the menu, which is added to the height of the submenu
	handlerOwningElementHeight = 35;
	newHeight = subMenuHeight + handlerOwningElementHeight;

	// stop all the effects in the queue, so that this takes precendence
	Effect.Queues.get(handlerOwningElement.id).invoke('cancel');
	
	// resize the event handler to make the level 2 menu visible
	new Effect.Morph(handlerOwningElement.id, 
			{
				style: "height: "+newHeight+"px;",
				duration: 0.2,
				queue: {scope: handlerOwningElement.id, limit: 2, position: 'end'}
			}
	);
	
	// also change the image src of the text image to the hover version
	var imageSrc = "/i/meerkat/" + handlerOwningElement.id + "-hover.png";
	$(handlerOwningElement.id+'-img').src = imageSrc;
}


function hideLevelTwo(event) {
	if (!event) // HACK - IE 7 doesn't properly pass the event in to the method   
		event = window.event;
	
	// this is the element that is actually handling the event;
	//	note that some child element may have actually triggered it!
	handlerOwningElement = this;

	// HACK: hard-code this to 35 pixels for the "flattened" height + the top offset of the menu
	newHeight = 35;

	// stop all the effects in the queue, so that this takes precendence
	Effect.Queues.get(handlerOwningElement.id).invoke('cancel');

	// resize the event handler to obscur the level 2 menu
	new Effect.Morph(handlerOwningElement.id, 
			{
				style: "height: "+newHeight+"px;",
				duration: 0.3,
				queue: {scope: handlerOwningElement.id, limit: 2, position: 'end'}
			}
	);
	
	// also change the image src of the text image to the normal version
	var imageSrc = "/i/meerkat/" + handlerOwningElement.id + ".png";
	$(handlerOwningElement.id+'-img').src = imageSrc;
}