﻿ var myScroller = new Class({
 Extends:Scroller,
 scroll: function(){
    var size = this.element.getSize(), scroll = this.element.getScroll(), pos = this.element.getOffsets(), scrollSize = this.element.getScrollSize(), change = {'x': 0, 'y': 0};
    for (var z in this.page){
      if (this.page[z] < (this.options.area + pos[z]) && scroll[z] != 0)
        change[z] = (this.page[z] - this.options.area - pos[z]) * this.options.velocity;
      else if (this.page[z] + this.options.area > (size[z] + pos[z]) && scroll[z] + size[z] != scrollSize[z])
        change[z] = (this.page[z] - size[z] + this.options.area - pos[z]) * this.options.velocity;
    }
    if (change.y || change.x) this.fireEvent('change', [scroll.x + change.x, scroll.y + change.y]);
  }
});
var imageSwitcher = new Class({
    initialize:function(panelId,obj){
        this.panel = $(panelId);
        this.imgObj = obj;
        this.images = new Asset.images(obj);
        this.cur = 0;
        if(obj.length > 1) this.panel.setStyle("cursor","pointer").addEvent("click",this.getNext.bind(this));
    }, 
    getNext: function(){
        this.panel.empty();
        this.cur = (this.cur + 1) % this.images.length;
        this.images[this.cur].inject(this.panel);
    }
});