function mycarousel_initCallback(carousel) {
        // Pause autoscrolling if the user moves with the cursor over the clip.
        // carousel.clip.hover(function() {
        //     carousel.stopAuto();
        // }, function() {
        //     carousel.startAuto();
        // });
        $('p.shortComment a').each(function () {
            $(this).bind('click', function (e) {
                carousel.stopAuto();
                return false;
            });
        });
        
        $('p.fullComment a').bind('click', function (e) {
            carousel.startAuto();
            return false;
        }); 
        
        $('.jcarousel-next').bind('click', function() {
            if ($('.jcarousel-item').css('height', 'auto')) {
                $('.jcarousel-item').css('height', '55px');
                $('p.fullComment').hide();
                $('p.shortComment').show();
            };
            carousel.next();
            return false;
        });

        $('.jcarousel-prev').bind('click', function() {
            if ($('.jcarousel-item').css('height', 'auto')) {
                $('.jcarousel-item').css('height', '55px');
                $('p.fullComment').hide();
                $('p.shortComment').show();                
            };
            carousel.prev();
            return false;
        });

}

jQuery(document).ready(function() {
	
	$("#link-azienda span, #link-candidato span, .presentazione a span, h2.tab a span").animate({
		opacity: "0"
	}, 0 );

	var randomnumber=Math.floor(Math.random()*2);

	if(randomnumber==0){
	} else if (randomnumber==1){
		$("#video-container").css("margin-left", "-280px");
		$("#link-candidato").removeClass("active");
		$("#link-azienda").addClass("active");
	};
	
	$("#link-azienda").click(function(e){
		e.preventDefault();
		$f("player").stop();
		$("#video-container").animate({ 
			marginLeft: "-280px"
		}, 500 );
		$("#link-candidato").removeClass("active");
		$("#link-azienda").addClass("active");
		if($("#video-container").css("marginLeft") == "-280px") {
			$f("player_2").play();
		}
	});
	
	$("#link-candidato").click(function(e){
		e.preventDefault();
		$f("player_2").stop();
		$("#video-container").animate({ 
			marginLeft: "0px"
		}, 500 );
		$("#link-azienda").removeClass("active");
		$("#link-candidato").addClass("active");
		if($("#video-container").css("marginLeft") == "0px") {
			$f("player").play();
		}
	});
	
	$('#link-azienda, #link-candidato, .presentazione a, h2.tab a').bind("mouseenter",function(){
		$("span",this).animate({
			opacity: "1"
			}, 300 );
		}).bind("mouseleave",function(){
			$("span",this).animate({
			opacity: "0"
			}, 300 );
	});
	
    jQuery('#carousel-candidato').jcarousel({
        vertical: true,
        scroll: 2,
        auto: 2,
        wrap: "last",
        initCallback: mycarousel_initCallback
    });
    jQuery('#carousel-azienda').jcarousel({
        vertical: true,
        scroll: 2,
        auto: 2,
        wrap: "last",
        initCallback: mycarousel_initCallback
    });         

    $('p.fullComment').hide()
    
    $('p.fullComment a').each(function () {
        $(this).bind('click', function (e) {
            $(this).closest('.jcarousel-item').css({
                height: '55px'
            });
            $(this).parent().siblings('p.shortComment').show();
            $(this).parent().hide();
            return false;
        });
    }); 
    
    $('p.shortComment a').each(function () {
        $(this).bind('click', function () {
            $(this).closest('.jcarousel-item').css({
                height: 'auto'
            });
            $(this).parent().siblings('p.fullComment').show();
            $(this).parent().hide();
            return false;
        });        
    });


    
 /*   function mycarousel_initCallback(carousel) {
        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    };*/

    
    if($.browser.msie && (parseInt($.browser.version, 10) < 8)){
         $('#carousel-azienda li:last-child').addClass("last-child");
         $('#carousel-candidato li:last-child').addClass("last-child");
     };


	

    
});