/*
this is now setup in the Master Page

Shadowbox.init();
 
var mycarousel_itemList = [
    {url: 'i/jCarousel/moviepics/image1_sm.jpg', title: 'Movie 1'},
    {url: 'i/jCarousel/moviepics/image2_sm.jpg', title: 'Movie 2'},
	{url: 'i/jCarousel/moviepics/image3_sm.jpg', title: 'Movie 3'},
	{url: 'i/jCarousel/moviepics/image4_sm.jpg', title: 'Movie 4'},
	{url: 'i/jCarousel/moviepics/image5_sm.jpg', title: 'Movie 5'}
];*/ 

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

 
function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};
 
function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
    
    //This fixes the not opening in shadowbox problem
    Shadowbox.clearCache();
    Shadowbox.setup();

};
 
/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    var url_m = item.url;//.replace(/.jpg/g, '.flv&skinUrl=swf/skin.swf');
    //url_m = url_m.replace("uploads/moviethumbs", "swf/player.swf?flv=../uploads/movies");
    return '<a href="' + url_m + '" title="' + item.title + '" rel="shadowbox;width=' + item.width + ';height=' + item.height + ';options={Params:{menu:\'false\',wmode:\'transparent\'}}"><img src="' + item.file + '" width="48" height="48" border="0" alt="' + item.title + '" /></a>';

};
 
jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'circular', scroll: 1, auto: 2, 
        //visible: 5,
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},
		initCallback: mycarousel_initCallback
    });
});
