var mycarousel_itemList = [
  {img_alt: 'TRURNIT // PROFIL', url: '../images/profil/profil_bilderleiste01.jpg'},
  {img_alt: 'TRURNIT // PROFIL', url: '../images/profil/profil_bilderleiste02.jpg'},
  {img_alt: 'TRURNIT // PROFIL', url: '../images/profil/profil_bilderleiste03.jpg'}	
];

function mycarousel_initCallback(carousel) {
    $('.stageControl').css({opacity: 0.7});
    $('.stageControl').hide();
    // pause autoscrolling and show the controls if the user moves with the cursor over the clip.
    carousel.clip.mouseenter(function(){
        //$('.stageControl').stop().fadeIn();
        carousel.stopAuto();
    }).mouseleave(function(){
        //$('.stageControl').fadeOut();
        carousel.startAuto();
    });
    
    $('#profilStageModule').mouseenter(function(){
      //$('.stageControl').fadeIn();
      carousel.stopAuto();
    }).mouseleave(function(){
      //$('.stageControl').fadeOut();
      carousel.startAuto();
    });
    
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.startAuto(0);
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.startAuto(0);
        carousel.prev();
        return false;
    });
};

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    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);
};

function mycarousel_getItemHTML(item)
{
	var tmpHtml = '<img alt="' + item.img_alt + '" src="' + item.url + '"/>';			  
	return tmpHtml;
};

// ride the carousel...
$(document).ready(function() {
    jQuery("#profilStageModule").jcarousel({
        scroll: 1,
        auto: 3,
        wrap: 'circular',
        animation: 8000,
        buttonNextHTML: '<a href="#" class="stageControl"></a>',
        buttonPrevHTML: '<a href="#" class="stageControl"></a>',
        initCallback: mycarousel_initCallback,
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });
});

