// floating commercial
var agFloater =
	new Class(
	{
		initialize:
			function(item) {
				this.item = item;
				this.initial = this.item.getCoordinates().top;
				this.height = this.item.getCoordinates().height;
				this.maximal = $("li-footer").getCoordinates().top;
				this.effect = new Fx.Tween(this.item, { property: 'margin-top', wait: false, duration: 1200, transition: Fx.Transitions.linear });


				window.addEvent("scroll", function() { this.move() }.bind(this)	);
			},

		setHeight:
			function(height) {
				this.height = height;
			},
			
		move:
			function() {
				var scrolltop = window.getScrollTop();

				if (scrolltop <= this.initial)
				{
					to = 0;
				}
				else
				{
					if (window.getScrollTop() + this.height > this.maximal)
					{
						to = -1;
					}
					else
					{
						to = (window.getScrollTop() - this.initial);
					}
				}

				if (to > 0)
				{
					this.effect.start.delay(0, this.effect, to);
				}
			}
	});

// globals
agFloaters = new Array();

// loader
window.addEvent("domready",
	function() {
		var floaters = $$("div.agFloater");

		for (var i = 0; i < floaters.length; i++) {
			agFloaters.push(new agFloater(floaters[i]));
		}
	}
);
