function Image_gallery() {
  var self = this;
  
  this.thumbs = this.root.children('div.thumbs').children('a');
  this.basin_holder = this.root.children('div.basins');
  this.basins = this.basin_holder.children();
  this.active_index = 0;
  
  this.start_up = function() {
    self.basin_setup();
    self.auto_play();
    self.thumbs.bind('click', self.slide_basin);
  }
  
  this.basin_setup = function() {
    for (var i = 0; i < self.thumbs.length; i++) {
      if (i === self.active_index) {self.thumbs.eq(i).addClass('active'); continue}
      var new_basin = self.basins.eq(0).clone();
      new_basin.attr('src', self.thumbs.eq(i).attr('href'));
      self.basins.push(new_basin[0]);
    }
  }
  
  this.auto_play = function() {
    if (self.auto_time) {clearTimeout(self.auto_time);}
    self.auto_time = setTimeout(function(){self.basin_switch(self.active_index + 1);}, 5000);
  }
  
  this.slide_basin = function(e) {
    e.preventDefault();
    self.basin_switch($(e.currentTarget).prevAll().length);
  }
  
  this.basin_switch = function(new_index) {
    if (new_index >= self.thumbs.length) {new_index = 0;}
    else if (new_index < 0) {new_index = self.thumbs.length - 1}
    self.old_acitve_index = self.active_index;
    self.active_index = new_index;
    self.thumbs.eq(self.old_acitve_index).removeClass('active');
    self.thumbs.eq(self.active_index).addClass('active');
    self.basin_holder.prepend(self.basins.eq(self.active_index).css({opacity : 0, display : 'block'}));
    self.basins.eq(self.active_index).bind('reloaded', self.basin_visiual_switch);
    self.basins.eq(self.active_index).trigger('reloaded');
  }
  
  this.basin_visiual_switch = function(e) {
    if (!e.currentTarget.complete) { $(e.currentTarget).bind('load', self.basin_visiual_switch); return false;}
    self.basins.eq(self.active_index).unbind();
    self.skch(self.basins.eq(self.active_index), {opacity : 1}, function(){ self.basins.eq(self.old_acitve_index).remove()}, .85, 'easeOutCubic');
    self.skch(self.basins.eq(self.old_acitve_index), {opacity : 0}, null, .3, 'easeOutQuad');
    self.auto_play();
  }

  return this;
}

