window.addEvent("load", function() {
	$(document.body).removeClass("cssanim");
	
	// Set up news rotator.
	startRotator("news-pod");
	
	// Set up uses images scroller
	(function () {
		var usesBoxes = $$(".scroll-images");
		
		if (!usesBoxes) {
			return;
		}
		
		usesBoxes.each(function(usesBox) {
			var con = $E(".container", usesBox);
			var images = $ES("img", usesBox);
			
			var totalWidth = 0;
			images.each(function(i) {
				totalWidth += i.offsetWidth + 2; // 2px margin
			});
			totalWidth -= 2;
			totalWidth -= usesBox.getStyle("width").toInt();
			
			var forward = true;
			
			function next() {
				slideFx.start(-totalWidth)
			}
			
			var slideFx = new Fx.Style(con, "left", {
				duration: totalWidth/0.02,
				transition: Fx.Transitions.linear,
				onComplete: function() {
					// Images are arranged in HTML so that resetting at the end
					// appears continuous.
					con.setStyle("left", 0);
					next();
				}
			});
			
			next();
		});
	})();
});
