function _itemLoadCallBack(carousel, state) {
	$.ajax({
  		url:'/item.xml',
  		async:true,
		cache:false,
		dataType:'xml',
		success: function(data){ _xmlLoadSuccessHandler( carousel, carousel.first, carousel.last, data ) },
		error: _errorHandler
	});
}
  
function _xmlLoadSuccessHandler( carousel, first, last, data){	
  	var items = [];
  	
  	$(data).find('item').each(function(i){
  		var title = $(this).find('title').text();
  		var img = $(this).find('image').text();
  		var context = $(this).find('context').text();
  		var link = $(this).find('link').text();
  		var target = $(this).find('target').text();
  		items.push(createHTML(img, title, context, link, target));
  		carousel.add(i+1, items[i]);
  	});
  	
  	carousel.size(items.length);
  	items = null;
}
  
  
function createHTML(url, title, context, link, target){
	var result;
	if( link ) {
		result = '<li><div class="topRecommendList"><a href="'+ link + '" target="' + target + '"><img src="' + url + '" width="110" height="110" alt="' + title  + 
		  		 '" /></a><br /><p><a href="' + link + '" target="' + target + '">' + context + '</p></a></div></li>';
	}
	else {
		result = '<li><div class="topRecommendList"><img src="' + url + '" width="110" height="110" alt="' + title  + 
	    		 '" /><br /><p>' + context + '</p></div></li>';
	}
	
  	return result;
}
  
function _errorHandler(){
	//エラーハンドリング
}
  
$(document).ready(function(){
	$('#mycarousel').jcarousel({
  		scroll:6,
  		itemLoadCallback:_itemLoadCallBack
  	});
});
