/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */
function mycarousel_initCallback(carousel) {
	jQuery('.jcarousel-control a').bind('mouseover', function() {
		carousel.stopAuto();
		carousel.timer = 0;
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
	
	jQuery('.jcarousel-container').bind('mouseover', function() {
		carousel.stopAuto();
		carousel.timer = 0;
		return false;
	});
	
	jQuery('.jcarousel-clip').bind('mouseover', function() {
		carousel.stopAuto();
		carousel.timer = 0;
		return false;
	});
	
	jQuery('.jcarousel-control a').bind('click', function() {
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
	
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.stopAuto();
		carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.stopAuto();
		carousel.prev();
        return false;
    });
	
};
// contenu des différentes DIV dans les onglets
var divtableaudeco = null; 
divtableaudeco  = '<div class="tabdeco">';
divtableaudeco += '<span class="title">Tableaux d&eacute;co</span>';
divtableaudeco += '<p>D&eacute;couvrez notre gamme de peintures d&eacute;coratives peintes &agrave; la main par des artistes qualifi&eacute;s en s&eacute;rie limit&eacute;e. Un rendu esth&eacute;tique in&eacute;gal&eacute;, des rendus mati&egrave;res originaux, de la grande qualit&eacute; &agrave; des petits prix.</p>';
divtableaudeco += '<div class="meaproduits">';
divtableaudeco += '<a href="?ObjectPath=/Shops/284885/Products/2536-1A-7575"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/2536-1A-7575_car.jpg" /></a>';
divtableaudeco += '<a href="?ObjectPath=/Shops/284885/Products/1908-9090"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/1908_car.jpg" /></a>';
divtableaudeco += '<a href="?ObjectPath=/Shops/284885/Products/ST068H-9090"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/ST068H-9090_car.jpg" /></a>';
divtableaudeco += '</div>';
divtableaudeco += '</div>';

var divpeintures = null; 
divpeintures  = '<div class="peintures">';
divpeintures += '<span class="title">Peintures</span>';
divpeintures += '<p>D&eacute;couvrez nos peintures d&#39;artistes de talent, v&eacute;ritables &oelig;uvres d&#39;art uniques fournies avec un certificat d&#39;authenticit&eacute; de l&#39;artiste. S&eacute;lectionn&eacute;es pour leur fort potentiel de plus value, ces &oelig;uvres sont d&eacute;fiscalisables.</p>';
divpeintures += '<div class="meaproduits">';
divpeintures += '<a href="?ObjectPath=/Shops/284885/Products/TMT-0002"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/TMT-0002_car.jpg" /></a>';
divpeintures += '<a href="?ObjectPath=/Shops/284885/Products/TMT-0012"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/Image1.jpg" /></a>';
divpeintures += '<a href="?ObjectPath=/Shops/284885/Products/TMT-0013"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/Image2.jpg" /></a>';
divpeintures += '</div>';
divpeintures += '</div>';


var divsculptures = null;
divsculptures  = '<div class="sculptures">';
divsculptures += '<span class="title">Sculptures</span>';
divsculptures += '<p>D&eacute;couvrez les sculptures Artendeco, &oelig;uvres d&#39;art en bronze ou m&eacute;tal uniques ou num&eacute;rot&eacute;es &agrave; tirage limit&eacute; avec un fort potentiel de plus value. Vendues avec un certificat d&#39;authenticit&eacute; sign&eacute; par l&#39;auteur, ces &oelig;uvres sont d&eacute;fiscalisables.</p>';
divsculptures += '<div class="meaproduits">';
divsculptures += '<a href="?ObjectPath=/Shops/284885/Products/SC-0020"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/SC-0020_car.jpg" /></a>';
divsculptures += '<a href="?ObjectPath=/Shops/284885/Products/SC-0007"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/SC-0007_car.jpg" /></a>';
divsculptures += '<a href="?ObjectPath=/Shops/284885/Products/SC-0018"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/SC-0018_car.jpg" /></a>';
divsculptures += '</div>';
divsculptures += '</div>';


var divlithophoto = null;
divlithophoto  = '<div class="lithophoto">';
divlithophoto += '<span class="title">Lithographies et photographies d&#39;art</span>';
divlithophoto += '<p>Une s&eacute;rie de lithographies et photographies d&#39;art sign&eacute;es et num&eacute;rot&eacute;es &agrave; tirage tr&egrave;s limit&eacute;, r&eacute;alis&eacute;es par des artistes de talent pour la plupart c&ocirc;t&eacute;s.</p>';
divlithophoto += '<div class="meaproduits">';
divlithophoto += '<a href="?ObjectPath=/Shops/284885/Products/L-0006"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/L-0006_car.jpg" /></a>';
divlithophoto += '<a href="?ObjectPath=/Shops/284885/Products/L-0007"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/L-0009_car.jpg" /></a>';
divlithophoto += '<a href="?ObjectPath=/Shops/284885/Products/PH-0001"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/PH-0001_car.png" /></a>';
divlithophoto += '</div>';
divlithophoto += '</div>';


var divartfloral = null;
divartfloral  = '<div class="artfloral">';
divartfloral += '<span class="title">Art floral</span>';
divartfloral += '<p>D&eacute;couvrez notre gamme de compositions florales r&eacute;alis&eacute;es &agrave; base de plantes artificielles de tr&egrave;s haute qualit&eacute; pour une d&eacute;coration int&eacute;rieure intemporelle.</p>';
divartfloral += '<div class="meaproduits">';
divartfloral += '<a href="?ObjectPath=/Shops/284885/Products/CF-0001"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/CF-0001_car.jpg" /></a>';
divartfloral += '<a href="?ObjectPath=/Shops/284885/Products/CF-0008"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/CF-0008_car.jpg" /></a>';
divartfloral += '<a href="?ObjectPath=/Shops/284885/Products/CF-0005"><img src="/WebRoot/ce_fr3/Shops/284885/MediaGallery/img/car/CF-0005_car.jpg" /></a>';
divartfloral += '</div>';
divartfloral += '</div>';




// Implementation du carousel circulaire
var mycarousel_itemList = [
    {content: null},
    {content: null},
    {content: null},
    {content: null},
    {content: null}
];

mycarousel_itemList[0].content = divtableaudeco;
mycarousel_itemList[1].content = divpeintures;
mycarousel_itemList[2].content = divsculptures;
mycarousel_itemList[3].content = divlithophoto;
mycarousel_itemList[4].content = divartfloral;


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);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return item.content;
};

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
		// paramétrage du caractère circulaire du carousel
		wrap: 'last',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
		auto: 3,
		vertical: true,
		scroll: 1
    });
});
