var idKateogriiC = null;

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_itemLoadCallbackdwa(carousel, state)
		{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    	}

    jQuery.get(
        ajaxLinks.gallery_carouseldwa,
        {
            first: carousel.first,
            last: carousel.last,
            id: idKateogriiC
        },
        function(xml) {
            mycarousel_itemAddCallbackdwa(carousel, carousel.first, carousel.last, xml);
        },
        'xml'
    );
};
function mycarousel_itemAddCallbackdwa(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_getItemHTMLdwa(jQuery(this).text(), jQuery(this).attr('rel'), jQuery('image_width', xml).text(), jQuery('image_height', xml).text(), jQuery(this).attr('class'), jQuery(this).attr('id'), jQuery(this).attr('root')));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTMLdwa(url, link, w, h, cls, id, id_kat)
{
	var active = '';
	if(cls == 'active')
		active = ' class="active"';

    return '<div style="width: '+w+'px; height: '+h+'px;"'+active+'><a id="'+id+'" onclick="javascript:zamienobrazekdwa('+id_kat+', '+id+'); return false;" href="'+link+'"><img src="' + url + '" alt="" border="0" width="'+w+'" height="'+h+'" /></a></div>';
};
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'), jQuery(this).attr('id')));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url, link, w, h, cls, id)
{
	var active = '';
	if(cls == 'active')
		active = ' class="active"';
	    else
		active = ' class="noactive"';
	
    return '<div style="width: '+w+'px; height: '+h+'px;"'+active+'><a id="'+id+'" onclick="javascript:zamienobrazek('+id+', '+id+', this); return false;" href="'+link+'"><img src="' + url + '" alt="" border="0" width="'+w+'" height="'+h+'" /></a></div>';
};


