var Programme = {
	getWidth: function(container) {
		var width = 0;
		container.select('li').each(function(li) {
			width += parseInt(li.style.width);
		});

		return width;
	},
	scroll: function(id, offset) {
		if (Programme.scrolling) {
			return;
		}

		var top = $(id + '_0'),
			bottom = $(id + '_1');

		if (!top || !bottom) {
			return;
		}

		var width = Programme.getWidth(bottom),
			left = parseInt(bottom.style.left);

		if (isNaN(left)) {
			left = 0;
			top.style.left = bottom.style.left = '0px';	// !@#$
		}

		if (offset < 0 && left >= 0) {
			return;		//!@#$
		}

		if (offset > 0 && (width + left) <= 828) {
			return;
		}

		Programme.scrolling = true;
		new Effect.Move(top, {x: -offset, duration: .7});
		new Effect.Move(bottom, {x: -offset, duration: .7, afterFinishInternal: function() { Programme.scrolling = false; }});
	}
}

var VerticalScroller = {
	scroll: function(element, offset, min) {
		if (VerticalScroller.scrolling) {
			return;
		}

		if (!(element = $(element))) {
			return;
		}

		element.style.top = element.style.top || '0px';		//!@#$

		if (offset < 0) {
			if (parseInt(element.style.top) >= 0) {
				return;
			}
		} else {
			var count = element.getElementsByTagName('li').length - Math.abs(parseInt(parseInt(element.style.top) / offset)) - min;
			if (count <= 0) {
				return;
			}
		}

		VerticalScroller.scrolling = true;
		new Effect.Move(element, {
			y: -offset,
			duration: .7,
			afterFinishInternal: function() {
				VerticalScroller.scrolling = false;
			}
		});
	}
}
