function logo_carousel_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 logo_carousel_itemLoadCallback(carousel, state)
{
	// Check if the requested items already exist
	if (carousel.has(carousel.first, carousel.last)) {
		return;
	}

	jQuery.get(
		'/assets/uploads/logos/load.php',
		{
			first: carousel.first,
			last: carousel.last
		},
		function(xml) {
			logo_carousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
		},
		'xml'
	);
};

function logo_carousel_itemAddCallback(carousel, first, last, xml)
{
	// Set the size of the carousel
	carousel.size(parseInt(jQuery('total', xml).text()));

	jQuery('image', xml).each(function(i) {
		carousel.add(first + i, logo_carousel_getItemHTML(jQuery(this).text()));
	});
};

/**
 * Item html creation helper.
 */
function logo_carousel_getItemHTML(url)
{
	return '<img src="/assets/uploads/logos/' + url + '" height="75" width="150" alt="' + url + '" />';
};