jQuery.fn.scrollElements = function() {
	var interval = 10;
	var speed    = 100;
	var rate     = 5;
	if (arguments[0]) {
		interval = arguments[0].interval;
		if (!interval) interval = interval;
		speed = arguments[0].speed;
		if (!speed) speed = 10;
		rate = arguments[0].rate;
		if (!rate) rate = speed;
	}
	var pps = rate;
	var scrollable = $(this);
	var first = $(scrollable.children().get(0));
	scrollable.append(first.clone());
	var distance = first.outerWidth(true);
	var travelled = 0;
	var paused = false;
	var startPos = scrollable.css('margin-left');
	setInterval(doTheScroll = function()
	{
		if (!paused) {
			if (pps < speed) {
				pps += rate;
				if (pps > speed) pps = speed;
			}
		} else {
			pps -= rate;
			if (pps < 0) pps = 0;
		}
		if (pps > 0) {
			scrollable.animate({marginLeft:'-=' + parseInt(pps /100)}, 0);
			travelled += parseInt(pps / 100);
			if (travelled > distance) {
				var next = first.next().clone();
				first.remove();
				scrollable.append(next);
				scrollable.animate({marginLeft: startPos}, 0);
				first = $(scrollable.children().get(0));
				distance = first.outerWidth(true);
				travelled = 0;
			}
		}
	}, interval);
	scrollable.hover(function() { paused = true; }, function() { paused = false; });
}
