$(document).ready(function () {
	// wrap a span around all anchors in #marquee
	$('#marquee a').wrapAll(document.createElement('span'));
	
	// duplicate the span
	$('#marquee span').first().after($('#marquee span').first().clone());
	
	// absolute position both spans
	$('#marquee span').css({position: 'absolute', top: 0, left: 0});
	
	// absolute position the second span after the first one
	var width = $('#marquee span').first().width();
	$('#marquee span').last().css({left: width + 'px'});
	
	$('#marquee span').each(scroll);
	
	$('#marquee').hover(
		function () {
			$('#marquee span').stop();
		},
		function () {
			$('#marquee span').each(scroll);
		}
	);
});

function scroll()
{
	var scrolledLeft = 0 - $(this).position().left;
	var width = $(this).width();
	
	if(scrolledLeft > width)
	{
		var positionReset = width - (scrolledLeft - width);
		$(this).css({left: positionReset + 'px'});
	}
	
	$(this).animate({left: '-=100'}, 1000, 'linear', scroll);
}

