function relatedcarousel_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 relatedcarousel_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 idxy = carousel.index(i, relatedcarousel_itemList.length);
	carousel.add(i, relatedcarousel_getItemHTML(relatedcarousel_itemList[idxy - 1]));
};

function relatedcarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
	carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function relatedcarousel_getItemHTML(item)
{
	return '<a href="' + item.link + '" target="' + item.target + '"><img src="' + item.url + '" width="150" height="80" /></a>';
};
