var Vn_Slider=new Class({stage:0,itemsList:0,initialize:function(domNode){var totInc=0;this.domNode=domNode;this.stage=this.domNode.getElement('.vn_slider_stage');this.itemsList=this.stage.getElement('.vn_slider_list');this.prevButton=this.domNode.getElement('.vn_slider_prev');this.nextButton=this.domNode.getElement('.vn_slider_next');var stageW=this.stage.getStyle('width').toInt();var itemW=this.itemsList.getElement('div.vn_slider_item').getStyle('width').toInt();var sumEl=this.itemsList.getElements('div.vn_slider_item').length;var maxW=itemW*(sumEl);this.itemsList.setStyle('width',maxW);var inc=itemW;if(inc==itemW){var maxInc=-(sumEl-(stageW/itemW).floor())*inc;}
if(inc==stageW){var maxInc=-(sumEl/(stageW/itemW).floor()).floor()*inc;}
var myFx=new Fx.Tween(this.itemsList,{duration:1000,transition:Fx.Transitions.Bounce.easeOut,wait:true});this.prevButton.addClass('disabled');if(maxInc==0){this.nextButton.addClass('disabled');}
var _that=this;_that.prevButton.addEvents({'click':function(event){if(totInc<0){totInc=totInc+inc;event.stop();myFx.start('margin-left',totInc);_that.prevButton.removeClass('disabled');_that.nextButton.removeClass('disabled');}
if(totInc==0){_that.prevButton.addClass('disabled');}}});_that.nextButton.addEvents({'click':function(event){if(totInc>maxInc){totInc=totInc-inc;event.stop();myFx.start('margin-left',totInc);_that.nextButton.removeClass('disabled');_that.prevButton.removeClass('disabled');}
if(totInc==maxInc){_that.nextButton.addClass('disabled');}}});}});window.addEvent('domready',function(){$(document.body).getElements('.vn_slider').each(function(element){new Vn_Slider(element);});});
