var References = {
  
  carousels: [],
  
  init: function(id) {
    
    if (!$$("#carousel-switcher-" + id + " li a")[0])
      return;
    
    this.carousels[id] = new Carousel(
        $("carousel-holder-" + id),
        $$("#carousel-holder-" + id + " li"),
        $$("#carousel-switcher-" + id + " a.carousel-jumper"),
        { wheel: false, duration: 0.5 }
        );
    
    $$("#carousel-switcher-" + id + " li a")[0].addClassName("carousel-selected");
    
    return;
    
  },
  
  prev: function(id) {
    
    var actNode = $$("#carousel-switcher-" + id + " li a.carousel-selected")[0];
    var prevSiblings = Element.previousSiblings(actNode.parentNode);
    
    if (prevSiblings[0]) {
      
      actNode.removeClassName("carousel-selected");
      
      prevSiblings[0].select("a")[0].addClassName("carousel-selected");
      
    }
    
    return this.carousels[id].prev();
    
  },
  
  next: function(id) {
    
    var actNode = $$("#carousel-switcher-" + id + " li a.carousel-selected")[0];
    var nextSiblings = Element.nextSiblings(actNode.parentNode);
    
    if (nextSiblings[0]) {
      
      actNode.removeClassName("carousel-selected");
      
      nextSiblings[0].select("a")[0].addClassName("carousel-selected");
      
    }
    
    return this.carousels[id].next();
    
  }
  
};

var GalleryAds = {
  
  init: function(index) {
    
    this.galleryObj = new Carousel(
        $("gallery-holder"),
        $$("#gallery-holder li"),
        $$(".gallery-ads .link-prev", ".gallery-ads .link-next"),
        { wheel: false, duration: 0.5, visibleSlides: 5, slideAmount: 5 }
        );
    
    if (index > 0)
      this.moveToIndex(index);
    
    return;
    
  },
  
  moveToIndex: function(index) {
    
    return this.galleryObj.moveTo(this.galleryObj.slides[index]);
    
  }
  
};