


(function() {
  
  var YUD = YAHOO.util.Dom, 
      YUE = YAHOO.util.Event;
      
  YAHOO.namespace("invocal");
    
  // Create our version of the carousel
  YAHOO.invocal.Carousel = function(el, oAttr) {   
     
    oAttr = oAttr || {};
    el = YUD.get(el); 
         
    
    if (el.id) {oAttr.id = el.id; }
            
    YAHOO.invocal.Carousel.superclass.constructor.call(this, el, oAttr); 
    
      
       
  };

  //Make our version extend the YUI Carousel & start adding functionality
  YAHOO.extend(YAHOO.invocal.Carousel, YAHOO.util.Element, {
    container: null,
    carousel: null,
    init: function(el, oAttr)
    {

      var carousel_container = YUD.getElementsByClassName('carousel-container', 'div', this.container)[0];
      // Setup the carousel and create pointers to the navigation
      this.carousel = new YAHOO.widget.Carousel(carousel_container, oAttr);
   
      //Remove listeners from carousel so that interactions do not cause the autoPlay to stop unless we want it to
      //YUE.removeListener(carousel_container);
      
      //Draw the carousel and start it playing
      this.carousel.render();
      this.carousel.startAutoPlay();
    }    
  }); // end Extending Carousel
})(); // end and call function

// Call our carousel
YAHOO.util.Event.onDOMReady(
  
  function() 
  {
    if(YAHOO.util.Dom.get("home-page-carousel"))
    {
      
      var params = {
        autoPlayInterval: 10000, 
        isCircular: true, 
        animation: {
          speed: 1.0
        }, 
        numVisible: 1,
        revealAmount: 0
      };
      
      var carousel = new YAHOO.invocal.Carousel('home-page-carousel', params);
      
    }
  }, 
  YAHOO.invocal.Carousel,
  true
);
