function scrollNav() {
    //Get our elements for faster access and set overlay width
    var div = jQuery('div#header-right'),
		li = jQuery('ul#main-nav li:first-child');

	//Remove scrollbars
    div.css({overflow: 'hidden'});
	
	// Set initial scroll
	div.scrollLeft(li.outerWidth());
	
	// Start animation
	startScroll();
	
	// Stop animation when user moves mouse over menu
    div.mousemove(function(e){
		stopScroll();
    });
	
	// Start animation again after mouseout
    div.mouseout(function(e){
		startScroll();
	});
}

function startScroll() {
    var div = jQuery('div#header-right'),
		li = jQuery('ul#main-nav li:first-child');
	
	// Animation time 
	var animationTime = 4000 - (4000 * (li.outerWidth() - div.scrollLeft()) / li.outerWidth());
	
	div.animate({scrollLeft: 0}, animationTime, "linear", function() {
		startAgain();
	});
}

function startAgain() {
    var div = jQuery('div#header-right'),
		ul = jQuery('ul#main-nav'),
		li = jQuery('ul#main-nav li:last-child');
	ul.prepend(li);
	div.scrollLeft(li.outerWidth());
	startScroll();
}

function stopScroll() {
    jQuery('div#header-right').stop();
}


