new Namespace("eu.mckinley.slider.product");
eu.mckinley.slider.product = Class.create({
	sliderlength : 612,
	pages : 0,
	active : 1,
	initialize : function (slider) {

		var childs = slider.getElementsBySelector("div.element");
		var counts = childs.length;
		this.pages = Math.ceil(counts / 4);
		try {
			$('productslider_prev').addClassName('lock');
		}
		catch (e) {
		}
	},
	slidePrev : function () {
		if (this.active == 1) {
			return;
		}

		var startpos = - (this.active - 1) * this.sliderlength;
		var endpos = - (this.active - 2) * this.sliderlength;
		this.active --;

		if (this.active == 1) {
			$('productslider_prev').addClassName('lock');
		}
		$('productslider_next').removeClassName('lock');

		var ani = new Animator();
		ani.addSubject(new NumericalStyleSubject($('slider'), 'left', String(startpos) + 'px', String(endpos) + 'px'));
		ani.play();
	},
	slideNext : function () {
		if (this.active == this.pages) {
			return;
		}
		var startpos = - (this.active - 1) * this.sliderlength;
		var endpos = - (this.active) * this.sliderlength;
		this.active ++;
		if (this.active == this.pages) {
			$('productslider_next').addClassName('lock');
		}
		$('productslider_prev').removeClassName('lock');

		var ani = new Animator();
		ani.addSubject(new NumericalStyleSubject($('slider'), 'left', String(startpos) + 'px', String(endpos) + 'px'));
		ani.play();
	}
});
