function mycarousel_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist

    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
    jQuery.post(
        system_base_url+'ajax/photos/_get_content_partner',
        {
            first1: 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()));

     $('data',xml).each(function(j){                                                                                    
            $('data_info',xml).each(function(i){
                carousel.add(first+i, mycarousel_getItemHTML($(this).find('id'+i).text(), $(this).find('image'+i).text(), $(this).find('display_name'+i).text()));
             });
      });   
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(id,url,name)
{

    name = decodeURIComponent(name).replace(/\+/g, ' ');
    return '<a href="'+system_base_url+'photos/'+id+'/_show_albums/" title="'+name+'"><img src="'+url+'" /></a>';
};

jQuery(document).ready(function() {
	var logged_in_user_id = document.getElementById('logged_in_user_id').value;
	if(logged_in_user_id == ''){
	    var view = document.getElementById('view').value;
	    var photo_id = document.getElementById('photo_id').value;
	    var postData = "view="+view+"&photo_id="+photo_id;
	    jQuery.ajax({
		    type: "POST",
			url: system_base_url+"ajax/photos/_update_view",
			data: postData,
			success: function(msg){
			var msg_value = msg.split("|");
			document.getElementById('main_photo_view').innerHTML=msg_value[0];
		    }
		});
	}

    jQuery('#mycarousel-horiz-photos').jcarousel({
        // Uncomment the following option if you want items
        // which are outside the visible range to be removed
        // from the DOM.
        // Useful for carousels with MANY items.

         //itemVisibleOutCallback: {
         //onAfterAnimation:function(carousel, item, i, state, evt) { carousel.remove(i); }},
        itemLoadCallback: mycarousel_itemLoadCallback,
          visible:4,
          scroll:4
    });

    $(function(){
	$('.roundbdr').wrap('<div class="roundbdrwrap"></div>');
      });
    $('#tabs').tabs();
    $('.round').corner("round 5px");
    $('.roundbdr').corner("round 5px").parent().css('padding', '1px').corner("round 5px");
    jQuery('#mycarousel-vert').jcarousel({
      vertical: true,
	  scroll:2
	  });
    $("#xlist").tagcloud({type:"list",sizemin:11,colormin:"3366cc",colormax:"3366cc"}).find("li");
  });
