$(function(){
    var numtabs = $('.tabs').find('li').length, $current = 1;

    function showTab(activeTab){
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $('a[href|='+ activeTab+']').parent().addClass("active")
        $(".tab_content").hide(); //Hide all tab content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    }

    function diaporama(){
        $current++;
        if($current>numtabs){$current=1;}
        showTab('#tab'+ $current);
    }
    
    if ($('.auto').length > 0)
        setInterval(diaporama,10000);
    // tabs
//    numtabs=($('.tabs').find('li').length)
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content
    $("ul.tabs li").click(function() {
        var activeTab = $(this).find("a").attr("href");
        showTab(activeTab);
        return false;
    });

    // define easing once for all
    jQuery.easing.def = "easeOutQuint";

    // adapt kwick system to the number of elements
    numkwicks=($('.kwicks').find('li').length)
	if (numkwicks) {
        widthkwick=940/numkwicks;

        $('.kwicks li').css("width",widthkwick );

        $('.kwicks').kwicks({
            max : 500,
            spacing : 0,
            duration : 600
        });
	}

    // fast contact
    $('#fastcontact').mouseenter(function(){
        $(this).stop(true,true);
        $(this).animate({
            marginTop : '-=10px'
        },200, 'easeOutQuad');
    });
    $('#fastcontact'). mouseleave(function(){
        $(this).stop(true,true);
        $(this).animate({
            marginTop : "+=10px"
        },1000,  'easeOutElastic');
    });

    //zoomer zoomer
    $('.link.zoomed').hide();
    $("ul.thumb li").hover(function() {
        $(this).css({
            'z-index' : '150'
        }); /*Add a higher z-index value so this image stays on top*/
        $(this).find('a').css('opacity:100')
        $(this).find('a').delay(200).fadeIn(800);
         $(this).find('.magnify').stop(true,true).hide();
        $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
        .animate({
            marginTop: '-100px', /* The next 4 lines will vertically align this image */
            marginLeft: '-100px',
            top: '50%',
            left: '50%',
            width: '200px', /* Set new width */
            height: '200px', /* Set new height */
            padding: '0px'
        }, 300,'easeOutBack'); /* this value of "200" is the speed of how fast/slow this hover animates */
    } , function() {
        $(this).css({
            'z-index' : '149'
        }); /* Set z-index back to 0 */
        $(this).find('a').stop(true,true).fadeOut();
        $(this).find('.magnify').delay(400).fadeIn(800);
        $(this).find('img').removeClass("hover").stop(true)  /* Remove the "hover" class , then stop animation queue buildup*/
        .animate({
            marginTop: '0', /* Set alignment back to default */
            marginLeft: '0',
            top: '0',
            left: '0',
            width: '100px', /* Set width back to default */
            height: '100px', /* Set height back to default */
            padding: '0px'
        }, 400,'easeOutBack',function(){
            $(this).parent().parent().css({
                'z-index' : '0'
            });
        });
    })/*.click(function() {return false;})*/;
});
			
