function mycarousel_itemAddCallback(carousel, xml)
{
	var $items = jQuery('item', xml);

	$items.each(function(i) {
		carousel.add(i + 1, mycarousel_getItemHTML(this));
	});

	carousel.size($items.size());

	// Unlock and setup.
	carousel.unlock();
	carousel.setup();
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
	return '<h3><a href="'+$('link', item).text()+'">'+$('title', item).text()+'</a></h3><p>'+mycarousel_truncate($('description', item).text(), 90)+'</p>';
};

/**
 * Utility function for truncating a string without breaking words.
 */
function mycarousel_truncate(str, length, suffix) {
	if (str.length <= length) {
		return str;
	}

	if (suffix == undefined) {
		suffix = '...';
	}

	return str.substr(0, length).replace(/\s+?(\S+)?$/g, '') + suffix;
};

$(document).ready(function() {
});

$(function(){
	$('#jmenu li #dspl').show();
	$('#jmenu li a').click(function(event){
		var elem = $(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			$('#jmenu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
	
			/**
	 * We show a simple loading indicator
	 * using the jQuery ajax events
	 */
	$().ajaxStart(function() {
		$(".jcarousel-clip-vertical").addClass('loading');
	});

	$().ajaxStop(function() {
		$(".jcarousel-clip-vertical").removeClass('loading');
	});

	$('#mycarousel').jcarousel({
		vertical: true,
		auto: 5, 
		wrap: 'both',  
		initCallback: mycarousel_initCallback,
		scroll: 1
	});

});
