/**
 *  This variable is used below for when the ImageCarouselListener is
 *  created.  All of the substance of the above image_array, and this
 *  object would have been stuffed into an anonymouse object {} at
 *  point where the ImageCarouselListener constructor is used.  Instead,
 *  here the parts are broken out for readability, but in the case where
 *  multiple instances of the ImageCarouselListener are created it may
 *  be prudent to use an object at the call of the constructor so as
 *  not to have naming conflicts with 'listener_config' and 'image_list'.
 */
var listener_config =
    {   // This s/b an array of objects that can have a file, caption, and
        // url property even if the caption is simply the empty string ''.
        images              : image_list,

        // ID of the paging area where the paging elements will be added.
        // if this is not provided then pagin_on, even if set to true,
        // will be ignored by the ImageCarouselListener.
        paging_area_id      : 'carousel-paging',
        paging_on           : false,
        on_paging_class     : 'on_paging',
        off_paging_class    : 'off_paging',

        //  These properties are used to set the allowable area for an image
        //  in the carousel.  In effect scalling the image down to a size
        //  where the biggest dimension fits within the allowable area even
        //  if that area is not square.
        max_width           : 120,
        max_height          : 120,
        
        // custom html
        item_html :
        '<a href="#{url}">' +
        '<img id="#{image_id}" src="#{file}"/></a> <h2><a href="#{url}">#{caption}</a></h2>' +
        '<p>#{text}</p>'
    };

/**
 *  This call here handles the loading of the ImageCarousel and attaches the
 *  Carousel to the Controller once the onload event is called.  In addition,
 *  this the ImageCarouselController is set to point to the default
 *  first image.
 */
YAHOO.util.Event.addListener(window, 'load',
    function()
    {
        var listener = new ImageCarouselListener( listener_config );

        listener.carousel = new YAHOO.extension.Carousel("dhtml-carousel",
            {
                numVisible:                 3,
                animationSpeed:             0.4,
                animationMethod:            YAHOO.util.Easing.easeBoth,
                scrollInc:                  3,
                navMargin:                  50,
                size:                       18,
                loadInitHandler:            listener.initialize,
                prevElement:                "prev-arrow",
                nextElement:                "next-arrow",
                loadNextHandler:            listener.loadNextItems,
                loadPrevHandler:            listener.loadPrevItems,
                prevButtonStateHandler:     listener.handlePrevButtonState,
                nextButtonStateHandler:     listener.handleNextButtonState
            });
    },
    false);

