/**
 * @version $Id$
 * @package Joomla
 * @author ARTIO s.r.o., info@artio.net, http:://www.artio.net
 * @copyright Copyright (C) 2011 Artio s.r.o.. All rights reserved.
 * @license GNU/GPL http://www.gnu.org/licenses/gpl-2.0.html
 */

var BuyOracles = {
	direction : 0,
	position : 0,

	scroll : function(direction) {
		this.direction = parseInt(direction);
	},

	scroller : function(startup) {

		if (this.direction != 0 || startup != 0) {
			this.position += this.direction * 5;

			if (this.position > 0)
				this.position = 0;

			element = $('products');

			if (element && element.offsetWidth > element.parentNode.offsetWidth) {

				var width = element.offsetWidth - 10;

				if ((width + this.position) < element.parentNode.offsetWidth)
					this.position = element.parentNode.offsetWidth - width;

				element.style.left = this.position + 'px';
			}

			setTimeout(function() {
				BuyOracles.scroller(0);
			}, 50);

		} else {

			setTimeout(function() {
				BuyOracles.scroller(0);
			}, 100);

		}
	}
}
BuyOracles.scroller(1);
