$(document).ready(
	function() {
		document.getElementById('search').focus();
		/*jQuery('#recommend').jcarousel({
			auto: 3,
			scroll: 1,
			wrap: 'last',
			animation: 'slow',
			easing: 'linear',
			vertical: true,
	        itemLoadCallback: itemLoadCallback
	    });*/
	}
);

function itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    jQuery.get(
        '/recommend',
		null,
        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('item', xml).each(function(i) {
        carousel.add(first + i, mycarousel_getItemHTML(jQuery(this)));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<a title="' + jQuery('title', item).text() + '" href="' + jQuery('url', item).text() + '"><img src="' + jQuery('image', item).text() + '" width="120" height="130" alt="" /></a>';
};
