$(document).ready(function () {
    $("#para_gauche").children('img').parallax({
        mouseport: $("#wrapper_gauche")
    }, {
        xparallax: -0.6,
        yparallax: 0,
        xorigin: 0.5,
        frameDuration : 90,
        xtravel: '1.5px'
    }, {
        xparallax: -1.8,
        yparallax: -1,
        xorigin: 0.5,
        frameDuration : 90,
        xtravel: '1.5px'
    }, {
        xparallax: -2,
        yparallax: 0,
        xorigin: 0.5,
        frameDuration : 90,
        xtravel: '1.5px'
    }, {
        xparallax: -6,
        yparallax: 0,
        xorigin: 0.5,
        frameDuration : 90,
        xtravel: '1.5px'
    }, {
        xparallax: -6,
        yparallax: 0,
        xorigin: 0,
        frameDuration : 90,
        xtravel: '10px'
    });
    $("#para_droite").children('img').parallax({
        mouseport: $("#wrapper_droite")
    }, {
        xparallax: -0.6,
        yparallax: 0,
        xorigin: 0,
        frameDuration : 90,
        xtravel: '.25px'
    }, {
        xparallax: -1.8,
        yparallax: -1,
        xorigin: 0,
        frameDuration : 90,
        xtravel: '.50px'
    }, {
        xparallax: -2,
        yparallax: 0,
        xorigin: 0,
        frameDuration : 90,
        xtravel: '1px'
    }, {
        xparallax: -2.5,
        yparallax: 0,
        xorigin: 0,
        frameDuration : 90,
        xtravel: '1.5px'
    }, {
        xparallax: -6,
        yparallax: 0,
        xorigin: 0,
        frameDuration : 90,
        xtravel: '10px'
    });
    $("#footer_gauche").children('img').parallax({
        mouseport: $("#wrapper_droite")
    }, {
        xparallax: 0.3,
        yparallax: 0,
        frameDuration : 90,
        xorigin: 0
    });
    $("#footer_droit").children('img').parallax({
        mouseport: $("#wrapper_gauche")
    }, {
        xparallax: 0.3,
        yparallax: 0,
        frameDuration : 90,
        xorigin: 0
    });
    $('#nav_videos .thumbs_slides').click(function () {
        var $b = $(this).children().attr('rel');
        $('#current').load($b);
        return false;
    });
    $('#current').load($('#first_video').attr('rel'));
    var $pos_vid_slider = 0;
    var maximumX = $('#nav_videos .thumbs_slides').size() * 132 - (132 * 3);
    $('#video_gauche').live("click", function () {
        if ($pos_vid_slider <= 0) {
            $pos_vid_slider = 0;
        }
        else {
            $pos_vid_slider -= 132;
        }
        slide_vids($pos_vid_slider);
        return false;
    });
    $('#video_droite').live("click", function () {
        if ($pos_vid_slider >= maximumX) {
            $pos_vid_slider = maximumX;
        }
        else {
            $pos_vid_slider += 132;
        }
        slide_vids($pos_vid_slider);
        return false;
    });

    function slide_vids($go) {
        $('#thumb_slider').animate({
            'left': -($go) + "px"
        }, 500, "easeInOutExpo");
    }
    var $pos_th_slider = 0;
    var maximumThX = $('.photo_slides').size() * 85 - (85 * 4);
    $('.photo_slides').mouseenter(function () {
        $(this).find('.lueur').stop().fadeIn();
    }).mouseleave(function () {
        $(this).find('.lueur').stop().fadeOut();
    }).click(function () {
        var $b = $(this).attr('rel');
        $('#current_photo_mid a').hide();
        $('a#mid_' + $b).show();
    });
    $('#photo_gauche').live('click', function () {
        if ($pos_th_slider == 0) {
            $pos_th_slider = 0;
        }
        else {
            $pos_th_slider -= 85;
        }
        slide_ths($pos_th_slider);
    });
    $('#photo_droite').live('click', function () {
        if ($pos_th_slider >= maximumThX) {
            $pos_th_slider = maximumThX;
        }
        else {
            $pos_th_slider += 85;
        }
        slide_ths($pos_th_slider);
    });

    function slide_ths($go) {
        $('#thumb_photo_slider').animate({
            'left': -($go) + "px"
        }, 500, "easeInOutExpo");
    }
    $('#current_photo_mid a').fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'overlayShow': true,
        'scrolling': 'no',
        'titleShow': false,
        'overlayColor': '#000',
        'showNavArrows': false,
        'overlayColor': '.8',
        'autoDimensions': true
    });
    
});
