function mycarousel_initCallback(carousel) {
    $('#mycarousel-next').bind('click', function() {
        carousel.next();
        carousel.startAuto(0);
        return false;
    });

    $('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        carousel.startAuto(0);
        return false;
    });
   /* 
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });*/
};
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);
};

/**
 * Item html creation helper.
 */
 function mycarousel_getItemHTML(item)
{
	var ret='';
	    ret+='<table cellpadding="0" cellspacing="0" border="0"><tr><td valign="middle" width="82px" height="52px"><a href="'+item.blink+'" class="scrollerBrandsLink"><img src="'+item.link+'" alt="" id="imageScrolBrand"/></a></td></tr></table>';
    return ret;
};

// Ride the carousel...
$(document).ready(function() {
	if(mycarousel_itemList.length>1) {
	    $("#brandScroller").jcarousel({
	        scroll: 1,
	        auto: 2,
	        vertical: true,
	        wrap: 'circular',
	        initCallback: mycarousel_initCallback,
	        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
	        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},
	        // This tells jCarousel NOT to autobuild prev/next buttons
	        buttonNextHTML: null,
	        buttonPrevHTML: null
	    });
	}
});
