// JavaScript Document
$(document).ready(function(){
	
	var a = $("div.ticker ul li").length, //Gets the amount of articles.
		b = width_array(), //Gets the width of all the articles.
		c = b * 25, //Sets the speed to animate the articles at.
		d = (a - 1) * 31; //Add the padding onto the width of articles.
	
	//Create an function to return an array of article widths.
	function width_array(){
		var e = 0;
		$("div.ticker ul li").each(function(){
			var width = $(this).width();
			e += width;
		});
		return e;
	};
	
	//Create the function to animate the articles.
	function animate_articles(){
		$("div.ticker ul").animate({
			"left": "-" + (b + d) + "px"
		}, c, "linear", function(){
			reset_articles();
		});
	};
	
	//Create the function to reset the articles to animate round again.
	function reset_articles(){
		$("div.ticker ul").css({
			"left": 940 + "px"
		});
		animate_articles();
	};
	
	//Set the width of the <ul>
	$("div.ticker ul").css({
		"width": b + d
	});
	
	//Initiate the animation.
	reset_articles();
	
});
