var timer = null;
var curr = 0;
var speed = 10;
var run = 1;

/* scroll to the right */
function scrollit () {
	var start = What.Position.getViewportSize ()[0];
	var twidth = 1259;
	var scrollby = (twidth-start);
	if (scrollby > 0) {
		doScroll (scrollby);
	}
};

function doScroll (total) {
	if (timer) {
		clearTimeout (timer);
	}
	// first run (from left to right)
	if (run < 2) {
		if (curr < total) {
			curr += 10;
			var amount = Math.abs ((total - curr) * speed);
			window.scrollTo (curr,0);
			timer = setTimeout (function(){doScroll(total);},20);
		} else {
			run = 2;
			doScroll (0);
		}
	// second run (from right back to left)
	} else {
		if (curr > total) {
			curr -= 10;
			var amount = Math.abs ((total - curr) * speed);
			window.scrollTo (curr,0);
			timer = setTimeout (function(){doScroll(total);},20);
		}
	}
}

What.Event.add (window,'load',scrollit);
