/*Horizontal Slider by Marc Bissegger @ colibri new media gmbh on February 2011
 *Init Example: Slider.init(10,'lc','960');
 *Argumets:number od Slide Object, prefix of the id of the SlideObjects,distance to move
 *
 */
var Slider = {
   
    max :0,//maximale Anzahl an Slide Objekte
    cnt:0,//Zähler
    ids : new Array(),//Liste mit ids der einzelnen Slide Objekten
    step:960,//Schritt wie Weit des Slide Objekt Horizontal bewegt werden muss
    init : function(num,prefix,step){
        this.max = num;
        this.step = step;
        for(var i=0;i<num;i++){
            this.ids.push(prefix+i);
        }
        this.showButtons();
    },
    next : function(){
        var outElem = $(this.ids[this.cnt]);
        this.cnt++;
        var inElem = $(this.ids[this.cnt]);
        var tweenOut = new Fx.Tween(outElem);
        tweenOut.start('left',-this.step+'px');
        var tweenIn =  new Fx.Tween(inElem);
        tweenIn.start('left','0');
        this.showButtons();

    },
    prev : function(){
        var outElem = $(this.ids[this.cnt]);
        var tweenOut = new Fx.Tween(outElem);
        tweenOut.start('left',this.step+'px');
        this.cnt--;
        var inElem = $(this.ids[this.cnt]);
        var tweenIn =  new Fx.Tween(inElem);
        tweenIn.start('left','0');
        this.showButtons();
    },
    showButtons : function(){
        var nxt = $('next');
        var pre = $('prev');
        if(this.cnt == 0){pre.fade('hide');}
        else{pre.fade('show');}
        if(this.cnt >= this.max-1){nxt.fade('hide');}
        else{nxt.fade('show');}
    }
    
}



