//Simle Animated Menu for Mootools 1.2 v1
//Released June 2008 
//Dedicated to the public domain by www.consideropen.com

var navArrowSlider = function(navWrap,div, navElementsArray, activeID, arrowY, leftOffset) {	
	var youAreHere = new Fx.Tween($(navWrap), { 
		duration: 1200,
		transition: Fx.Transitions.Elastic.easeOut  
	});
	 
	var youAreHere2 = new Fx.Tween(div, { 
		duration: 1200,
		transition: Fx.Transitions.Elastic.easeOut  
	});

	
	$$(navElementsArray).each(function(item){		
		if( item.getSize().x > 30){
		item.addEvent('mouseenter', function() { 
			var thisPos = item.getPosition(navWrap).x  ; 
			youAreHere2.cancel();
	
			youAreHere2.set('display', 'inline');
			youAreHere2.set('width', item.getSize().x -4 + 'px');
			
			youAreHere2.start('margin-left', thisPos + 2 + 'px ' );
			
			
			
			youAreHere.cancel();
			youAreHere.start('background-position', thisPos + 'px ' + arrowY + 'px');
		});
		}
	});
	
	var currentArrow = function() {
		youAreHere2.cancel();
		youAreHere2.start('display','none');
		
	};
	
	//correct IE rendering problem (without this, it wont go to the active nav onload)
	nome = '.'+activeID;
	activeID = $$(nome);
	
	
	
	
	if(activeID.length > 0){
		
		activeID.each(function(item){
		
			var activePos = item.getPosition(navWrap).x  ; 			
			
			//$(navWrap).setStyle('background-position', activePos + 'px ' + arrowY );
		
			$(div+'Fixo').setStyle('margin-left', activePos + 2 );
			$(div+'Fixo').setStyle('width', item.getSize().x -4 );
			$(div+'Fixo').setStyle('display', 'inline');
			//works to set image to starting position in other browsers
			currentArrow(); 
			
			$(navWrap).addEvent('mouseleave', currentArrow);
		});
	}else{
		$(div+'Fixo').setStyle('display', 'none');
		$(div).setStyle('display', 'none');
		
	}
	
}; 
	
	
