///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
* Scorre lo sfondo di un div Verticalmente da yfrom a yto
* Accetta le stesse opzioni di tutti gli Effect script.aculo.us
*/
Effect.BkgMoveY = Class.create();
Object.extend(Object.extend(Effect.BkgMoveY.prototype, Effect.Base.prototype), {
	initialize: function(element, yfrom, yto) {

		this.YFrom = yfrom;
		this.YTo = yto;
		this.YDelta = this.YTo - this.YFrom;
		this.YCurPos = this.YFrom;
	    this.options = arguments[3] || {};

		this.Element = $(element);

		this.Element.setStyle({backgroundPosition: '0px '+this.YCurPos+'px'});

		this.start(this.options);

	},
	update: function(position) {
		this.YCurPos = this.YFrom + this.YDelta*position;
		this.Element.setStyle({backgroundPosition: '0px '+this.YCurPos+'px'});

		$('debug').innerHTML = '0px '+this.YCurPos+'px';
	}
});

/**
* Scorre lo sfondo di un div Orizzontalmente da xfrom a xto
* Accetta le stesse opzioni di tutti gli Effect script.aculo.us
*/
Effect.BkgMoveX = Class.create();
Object.extend(Object.extend(Effect.BkgMoveX.prototype, Effect.Base.prototype), {
	initialize: function(element, xfrom, xto) {

		this.XFrom = xfrom;
		this.XTo = xto;
		this.XDelta = this.XTo - this.XFrom;
		this.XCurPos = this.XFrom;
	    this.options = arguments[3] || {};

		this.Element = $(element);

		this.Element.setStyle({backgroundPosition: ''+this.XCurPos+'px 0px'});

		this.start(this.options);

	},
	update: function(position) {
		this.XCurPos = this.XFrom + this.XDelta*position;
		this.Element.setStyle({backgroundPosition: ''+this.XCurPos+'px 0px'});
	}
});

/**
* Scorre lo sfondo di un div Orizzontalmente da xfrom a xto e Verticalmente da yfrom a yto
* Accetta le stesse opzioni di tutti gli Effect script.aculo.us
*/
Effect.BkgMoveXY = Class.create();
Object.extend(Object.extend(Effect.BkgMoveXY.prototype, Effect.Base.prototype), {
	initialize: function(element, xfrom, xto, yfrom, yto) {

		this.XFrom = xfrom;
		this.XTo = xto;
		this.XDelta = this.XTo - this.XFrom;
		this.XCurPos = this.XFrom;

		this.YFrom = yfrom;
		this.YTo = yto;
		this.YDelta = this.YTo - this.YFrom;
		this.YCurPos = this.YFrom;

		this.options = arguments[5] || {};

		this.Element = $(element);

		this.Element.setStyle({backgroundPosition: ''+this.XCurPos+'px '+this.YCurPos+'px'});

		this.start(this.options);

	},
	update: function(position) {
		this.XCurPos = this.XFrom + this.XDelta*position;
		this.YCurPos = this.YFrom + this.YDelta*position;
		this.Element.setStyle({backgroundPosition: ''+this.XCurPos+'px '+this.YCurPos+'px'});
	}
});