function mycarousel_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    jQuery.get(
        '/modules/gallery/gallery_box_xml.php?cmd=top24',
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
        },
        'xml'
    );
};
function mycarousel_itemLoadCallback2(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    jQuery.get(
        '/modules/gallery/gallery_box_xml.php?cmd=new',
        {
            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('image', xml).each(function(i) {
		carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text(), jQuery(this).attr("pid")));

    });
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url, pid)
{
    return '<a href="/modules.php?name=gallery&file=displayimage&pid=' + pid + '"><img src="' + url + '" width="75" height="75" alt="" /></a>';
};

$(document).ready(function(){
    jQuery('#mycarousel').jcarousel({
        itemLoadCallback: mycarousel_itemLoadCallback
    });
    jQuery('#mycarousel2').jcarousel({
        itemLoadCallback: mycarousel_itemLoadCallback2
    });
		// initialize scrollable 
	$("div.scrollable").scrollable({
		size: 3,
		items: '#thumbs',  
		hoverClass: 'hover'
	});	
		// initialize scrollable 
	$("div.scrollable2").scrollable({
		size: 3,
		items: '#thumbs2',  
		hoverClass: 'hover'
	});	
	
	$("div.scrollable_recipe").scrollable({
		size: 3,
		items: '#thumbs_recipe',  
		hoverClass: 'hover'
	});	

});

