function mycarousel_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 mycarousel_itemLoadCallback(carousel, state)
{

      
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    jQuery.get(
        '/include/ajax/foto_ajax.php',
        {
            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) {
    //alert(jQuery('image',this).text());
        carousel.add(first + i, mycarousel_getItemHTML(jQuery('image',this).text(),jQuery('id_magazin',this).text()));
    });
};

/**'+info+'
 * Item html creation helper./image/image.php?image=../&w=193&h=234
 */
function mycarousel_getItemHTML(url,info)
{
    return '<a href="'+info+'/#promotii"><img src="/' + url + '"  width="193" height="234"  border="0"></a>';
};
