function mycarousel_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    jQuery.get(
	
        ajaxLinks.gallery_carousel,
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
        },
        'xml'
    );
};

function mycarousel_itemAddCallback(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('foto', xml).each(function(i) {
        carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text(), jQuery(this).attr('rel'), jQuery('image_width', xml).text(), jQuery('image_height', xml).text(), jQuery(this).attr('class')));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url, link, w, h, cls)
{
	var active = '';
	if(cls == 'active')
		active = ' class="active"';
	
    return '<div style="width: '+w+'px; height: '+h+'px;"'+active+'><a href="'+link+'"><img src="' + url + '" alt="" border="0" width="'+w+'" height="'+h+'" /></a></div>';
};
