var currentX;

$(document).ready(function() {
	addListeners();
	setCurrentChevPosition();
	animateMe($("#chevron"), currentX,0);
});

function setCurrentChevPosition() {
	var current = $("li.navcurrent");
	var pos = current.position();
	var width = current.width();
	currentX = pos.left + width/2 - 22;
	$("#chevron").addClass("navcurrentchevron");
	
};

function addListeners() {
	$('.navitem').mouseover(function() {
		var current = $(this);
		var pos = current.position();
		var width = current.width();
		animateMe($("#chevron"), pos.left + width/2 - 8);
	});
	
	$('.navitem').mouseout(function() {
		setCurrentChevPosition();
		animateMe($("#chevron"), currentX);
	});
}

function animateMe(target, x, time) {
	if (time == null) {
		time = 350;
	}
	
	$(target).animate( {
		left: x
	},{ 
		queue: false, 
		duration: time
	});
}

