//Simle Animated Menu for Mootools 1.2 v1
//Released June 2008 
//Dedicated to the public domain by www.consideropen.com
var navArrowSlider = function(navWrap, navElementsArray, activeID, arrowX, topOffset) { 

var youAreHere = new Fx.Tween($(navWrap), { 
duration: 10,
		transition: Fx.Transitions.Sine.easeInOut 
}); 

$$(navElementsArray).each(function(item){ 
item.addEvent('mouseenter', function() {
if(item.getSize().y > 55){
var thisPos = item.getPosition(navWrap).y + item.getSize().y - topOffset - topOffset - 6;
//var thisPos = item.getPosition(navWrap).y + 31;
}else{
var thisPos = item.getPosition(navWrap).y + item.getSize().y - topOffset;
//var thisPos = item.getPosition(navWrap).y + 31;
}
youAreHere.cancel(); 
youAreHere.start('background-position', arrowX + 'px ' + thisPos + 'px'); 
}); 
}); 

var currentArrow = function() { 
youAreHere.cancel(); 
var activePos = $(activeID).getPosition(navWrap).y + $(activeID).getSize().y - topOffset; 
//var activePos = $(activeID).getPosition(navWrap).y + 31; 
$(navWrap).setStyle('background-position', arrowX + 'px ' + '10px'); //Fixes positioning in Firefox 2 
youAreHere.start('background-position',  arrowX + 'px ' + activePos + 'px'); 
}; 

//correct IE rendering problem (without this, it wont go to the active nav onload) 
//var activePos = $(activeID).getPosition(navWrap).y + $(activeID).getSize().y - topOffset; 
var activePos = $(activeID).getPosition(navWrap).y + 31; 
$(navWrap).setStyle('background-position', arrowX + 'px ' + activePos + 'px' ); 
//works to set image to starting position in other browsers 
currentArrow(); 

$(navWrap).addEvent('mouseleave', currentArrow); 
};


window.addEvent('domready', function() {
	
	if ($(document.body).getElement('a.nodeSel')){
		var found = $(document.body).getElement('a.nodeSel');
		var foundId = $(found).get('id');
		var findNodeSel = foundId;
		}else{
			var findNodeSel = 'salbumTree0';
			};
	navArrowSlider(
		'hideRevealOnMouseEnter', // ID of nav wrap
		'#mainMenu a', // Array selector of nav elements 
		findNodeSel, // ID of current nav element
		'0', //  Background position x of background image
		'24' //  INT ONLY - How far down from the top edge of the nav element that the image settles
	); 
	//find all images in wraptocenter div tags and center them inside their pwraptocenter divs
	$$('div.wraptocenter').each(function(item){  
		var parent = item.getParent();
		var ah = item.getSize().y;
		var ph = parent.getSize().y;
		var mh = (ph - ah) / 2;
		item.setStyle('margin-top', mh + 'px');
		//if(ph == ah){}else{item.setStyle('margin-top', mh + 'px');}
	});
	$$('div.wraptocenterDescription').each(function(item){  
		var parent = item.getParent();
		var ah = item.getSize().y;
		var ph = parent.getSize().y;
		var mh = (ph - ah) / 2;
		item.setStyle('margin-top', mh + 'px');
	});
	//find all a tags inside div.clip and set the top padding (padding-top:0.231em;)
	/*$$('div.clip a').each(function(item){  
		item.setStyle('padding-top', '0.231em');
	});*/
});  