//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, arrowY, leftOffset) {

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

	$$(navElementsArray).each(function(item){
		item.addEvent('mouseenter', function() {
			//var thisPos = item.getPosition(navWrap).x  + item.getSize().x - leftOffset;
			var thisPos = item.getPosition(navWrap).x + 10;
			youAreHere.cancel();
			youAreHere.start('background-position', thisPos + 'px ' + arrowY + 'px');
		});
	});

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

	//correct IE rendering problem (without this, it wont go to the active nav onload)
	//var activePos = $(activeID).getPosition(navWrap).x  + $(activeID).getSize().x - leftOffset;
	var activePos = $(activeID).getPosition(navWrap).x  + 10;
	$(navWrap).setStyle('background-position', activePos + 'px ' + arrowY + 'px');

	//console.log($(navWrap).getStyle('background-position');

	//works to set image to starting position in other browsers
	currentArrow();

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