function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
	{
	    // The index() method calculates the index from a
	    // given index who is out of the actual item range.
	    var idx = carousel.index(i, mycarousel_itemList.length);
	 	idx = idx - 1
	 	
	 	
	 	
	 	 carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx]));
	 	$('.jcarousel-skin-tango').find('img').css('opacity', '1');
	 	if(state != 'init')
	 	{
	 		set_border(carousel.get(i-3));
	 	}
	 	else
	 	{
	 		set_border(carousel.get(1));
	 	}
	   
	 	
	};
    
	function set_border(item, speed)
	{
		if(speed == 'fast')
		{
			$(item).find('img').css({'opacity':'1'});
		}
		else
		{
			$(item).find('img').animate({'opacity':'1','border':'2px solid white'});
		}
		
	}
	
	function remove_border(item, speed)
	{
		if(speed == 'fast')
		{
			$(item).find('img').css({'opacity':'0.5'});
		}
		else
		{
			$(item).find('img').animate({'opacity':'1','border':'1px solid white'});
		}
	}
	
	
	jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	};
	
	
	
    function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
	{
    	
    	
    	
	   	var idx = carousel.index(i, producten.length);

    	if(idx == producten.length)
    	{
    		idx = 0;
    	}
    	if(i == 65)
    	{
    		idx = 1;
    	}

    	var product = producten[idx];
    	
    	$('.item_titel').text(product.titel);
    	$('.item_titel').attr('href', product.link);
    	$('.item_prijs').text(product.prijs);
    	$('.item_text').text(product.txt);
    	$('.item_text').attr('href', product.link);
    	set_border(carousel.get(i+1));
	};
	
	
	
	function mycarousel_getItemHTML(item)
	{
	    return '<a  href=\"' + item.link + '\"><img src=\"' + item.url + '\" title=\"'  + item.title + '\" alt=\"' + item.title + '\" /></a>';
	};
	
	jQuery(document).ready(function() {
	
		//hier snel de gegevens van de product printen voor de eerste keer 
		var product = producten[0];
    	$('.item_titel').text(product.titel);
    	$('.item_titel').attr('href', product.link);
    	$('.item_prijs').text(product.prijs);
    	$('.item_text').text(product.txt);
    	$('.item_text').attr('href', product.link);
    	
    	//begin carousel
	    jQuery('#mycarousel').jcarousel({
			wrap: 'circular',
			auto: '5',
			scroll:1,
			animation: 'slow',
			visible: 4,
			buttonNextHTML: null,
			buttonPrevHTML: null,
			easing: 'BounceEaseOut',
			itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
		    itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
	   	});
	   
	});
