function mycarousel_itemLoadCallback(carousel, state) {
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
    jQuery.get(
        '/components/prop_thumbs_widget_process.php',        {
            first: carousel.first,
            last: carousel.last,
            user_id: u, 
username: uname

        },
        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('prop', xml).each(function(i) {
        carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).find('image').text(), jQuery(this).find('tooltip').text(), jQuery(this).find('url').text(), first + i-1));
    });
	$(function() {		
		$('#image_slider img').Tooltip({	
			track: true,	
			delay: 0,	
			showURL: false,	
			showBody: " - "	
		});

	});
//	alert(document.getElementById("image_slider").innerHTML);
    
};

function initTooltips(){
		$('#image_slider img').Tooltip({	
			track: true,	
			delay: 0,	
			showURL: false,	
			showBody: " - "	
		});
}
function mycarousel_getItemHTML(img, tooltip, url, order) {
   return '<a href="'+url+'" target="_top" onmouseover="handleResultRollover('+order+');" onmouseout="handleResultRollout('+order+');"><img tooltip="'+tooltip+'" src="/phpThumb/phpThumb.php?src=/'+img+'&w=65&h=65&zc=C" alt="" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#image_slider').jcarousel({
        // itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
        itemLoadCallback: mycarousel_itemLoadCallback,
        itemVisibleInCallback: {onAfterAnimation: function(){initTooltips}}
    });
});

