$(document).ready(function() {
	//AUTO SCROLL 
	
	//SLIDER AUTO
	//$('.coda-slider').codaSlider({
	//   		autoSlide: true,
	//		autoSlideInterval: 4000,
	//			dynamicArrows: false,
	//			dynamicTabs: false
	//			});
		
	//$("p").hide();
	$('.menuSlide').animate({top: '-380'}, 200, function(){});
	//Navigation au sein des menus 
	$("a.menuDisplay").click(function(){
		//animation d'ouverture
		$('.menuSlide').animate({top: '0'}, 200, function(){});
		
		//target = $(this);
		//buttonHTML = $(target).attr("id");
		//buttonTarget = buttonHTML.replace("target-","#");
		//Disparition de tout les <p>
		//$("#menuSlide p").removeClass("hidden");
		//$("p").hide();
		//$(buttonTarget).toggleFade({speedIn : "fast"});
		});
	
	   
	//ANIMATION DES ELEMENTS DE MENUS
	$('.menuClose').click(function() {
		//animation de fermeture
		$('.menuSlide').animate({top: '-380'}, 200, function(){});
		
		//target = $(this);
		//buttonHTML = $(target).attr("id");
		//buttonTarget = buttonHTML.replace("target-","#");
		//$("p").hide();
		//$(buttonTarget).toggleFade({speedIn : "fast"});
		
		
		
		
  		//$('#menuSlide').parent().animate({top: '-350'}, 500, function() {});
	});
	
	//$('#menuOpen').click(function() {
	//	$('#menuSlide').animate({top: '0'}, 200, function(){});
	//});
	
	//FANCY LIGTHBOX
	$(".various5").fancybox({
		
       'width'             : 396,
       'height'            : 560,
       
        //'autoScale'         : 'false',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'type'              : 'iframe'
    });
    
    
    //FANCY LIGTHBOX
	 $(".videobox").click(function() {
        $.fancybox({
            'padding'       : 0,
            'autoScale'     : false,
            'transitionIn'  : 'none',
            'transitionOut' : 'none',
            'title'         : this.title,
            'width'         : 680,
            'height'        : 495,
            'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'          : 'swf',
            'swf'           : {
                'wmode'             : 'transparent',
                'allowfullscreen'   : 'true'
            }
        });

        return false;
    });
	
	//ACCORDION
	//$("#accordion").accordion({ autoHeight: false , clearStyle: true });
	 
	
		
	
	//SLIDER 
    function slidePanel( newPanel, direction ) {
        // define the offset of the slider obj, vis a vis the document
        var offsetLeft = $slider.offset().left;

        // offset required to hide the content off to the left / right
        var hideLeft = -1 * ( offsetLeft + $slider.width() );
        var hideRight = $(window).width() - offsetLeft;

        // change the current / next positions based on the direction of the animation
        if ( direction == 'left' ) {
            currPos = hideLeft;
            nextPos = hideRight;
        }
        else {
            currPos = hideRight;
            nextPos = hideLeft;
        }

        // slide out the current panel, then remove the active class
        $slider.children('.slide-panel.active').animate({
            left: currPos
        }, 500, function() {
            $(this).removeClass('active');
        });

        // slide in the next panel after adding the active class
        $( $sliderPanels[newPanel] ).css('left', nextPos).addClass('active').animate({
            left: 0
        }, 500 );
    }

    var $slider = $('#full-slider');
    var $sliderPanels = $slider.children('.slide-panel');

    var $navWrap = $('<div id="full-slider-nav"></div>').appendTo( $slider );
    var $navLeft = $('<div id="full-slider-nav-left"></div>').appendTo( $navWrap );
    var $navRight = $('<div id="full-slider-nav-right"></div>').appendTo( $navWrap );

    var currPanel = 0;

    $navLeft.click(function() {
        currPanel--;

        // check if the new panel value is too small
        if ( currPanel < 0 ) currPanel = $sliderPanels.length - 1;

        slidePanel(currPanel, 'right');
    });

    $navRight.click(function() {
        currPanel++;

        // check if the new panel value is too big
        if ( currPanel >= $sliderPanels.length ) currPanel = 0;

        slidePanel(currPanel, 'left');
    });
    
   
   $('.side a[value="0"]').click(function(){
   	currPanel = 0;
   	slidePanel(currPanel, 'left');
   	});
   	
   $('.side a[value="1"]').click(function(){
   currPanel = 1;
   slidePanel(currPanel, 'left');
   });
   
   $('.side a[value="2"]').click(function(){
   currPanel = 2;
   slidePanel(currPanel, 'left');
   });
   $('.side a[value="3"]').click(function(){
   currPanel = 3;
   slidePanel(currPanel, 'left');
   
   });
   
});
