Ct_Page.loadComponentScript('Ct_Slider');

Ct_Page.scriptIsReady('Ct_Slider', function() {

	window.Ct_Slider_Img = Class.create(Ct_Slider, {

		_setNamespace: function() {
			this._namespace = 'ctSliderImg';
		},

		_toggleContent: function(container, prev, next, direction) {
			var d, nd;

			d = direction == this.PREV_PAGE ? '-' : '';
			nd = direction == this.PREV_PAGE  ? '' : '-';

			// Hide old
			new Effect.Parallel([
				new Effect.Opacity(prev, {sync: true, from: 1, to: 0.3}),
				new Effect.Morph(prev, {
					sync: true,
					style: 'left: ' + d + prev.getWidth() + 'px'
				})
			], {
				duration: 0.3,
				beforeSetup: function() {
					container.makePositioned();
					prev.absolutize();
				},
				afterFinish: function() {
					prev.remove();
				}
			});

			// Show new
			new Effect.Parallel([
				new Effect.Opacity(next, {sync: true, from: 0.3, to: 1}),
				new Effect.Morph(next, {
					sync: true,
					style: 'left: 0px'
				})
			], {
				duration: 0.3,
				delay: 0.2,
				beforeSetup: function() {
					container.setStyle({
						width: container.getWidth() + 'px',
						overflow: 'hidden',
						position: 'relative'
					});

					next.absolutize(); // width, height
					next.setStyle({left: nd + container.getWidth() + 'px', top: 0});
					next.show();
				}.bind(this),
				afterFinish: function() {
					container.setStyle({
						width: '100%',
						overflow: 'hidden',
						position: 'static'
					});
					next.setStyle({position: 'static', width: '100%'});
					this._isDone = true;
				}.bind(this)
			});
		},

		x: null

	});

	Ct_Page.registerScript('Ct_Slider_Img');

});
