var ardSlider = new Class({
    initialize: function(slider,myDelay){
    	this.sliderDiv = $(slider);
        this.container = this.sliderDiv.getParent();
        this.itemDiv = this.sliderDiv.getChildren()[0];
        this.nbItems = this.sliderDiv.getChildren().length;
        this.curPos = 1;
        this.wStep = this.container.getStyle('width').toInt();
		var w = this.itemDiv.getStyle('width').toInt() * this.nbItems;
		this.sliderDiv.setStyle('width',w);
		//
		this.initArrows();
    },
	slideIt: function() {
		if (this.curPos < this.nbItems) { 
			var pos = -(this.curPos*this.wStep);
			(this.sliderDiv).tween('left', pos);
			this.curPos++; 
		} 
		else {
			this.sliderDiv.setStyle('left',0);
			this.curPos = 1;
			this.slideIt();
		};
	},
	skipToNext: function() {
		this.slideIt();
	},
	skipToPrev: function() {
		if (this.curPos>1) {
			this.curPos -= 2; this.slideIt();
		} else {
			var pos = -((this.nbItems-1)*this.wStep);
			this.sliderDiv.setStyle('left',pos);
			var myFx = new Fx.Tween(this.sliderDiv,{property:'left'});
			myFx.start(pos-this.wStep);
			this.curPos = this.nbItems-2;
			this.slideIt();
		}
	},
    initArrows: function(){
		var arrP = this.container.getParent().getChildren()[0];
		var arrN = this.container.getParent().getChildren()[1];
		
		var f1 = this.skipToNext.bind(this);
		arrN.addEvent('click', f1);
		var f2 = this.skipToPrev.bind(this);
		arrP.addEvent('click', f2);
    }
});
