jQuery(function(){ 
	
	// SUPERFISH //
	jQuery('ul.sf-menu').superfish();
	
	// ONGLETS //
	var tabs = $("#tabs");
	if(tabs.is(':visible')){ tabs.tabs(); }
	
	// ===================== 
	// ! CONTENU DEROULANT   
	// ===================== 
	
	var derouleur = $('#infos-deroule');
	derouleur.find('div.deroule-content').hide();

	$('#infos-deroule').delegate('a.derouleur', 'click', function(){
		var $this = $(this);
		if($this.next().is(':visible')){
			$this.next().slideUp();
		} else {
			$this.parent().parent().find("div.slided").slideUp().removeClass('slided');
			$this.next().addClass('slided').slideDown('normal', function(){
				$('html,body').animate({scrollTop: $this.offset().top-35},'slow');
			});
		}
		
		return false;
	});
	
	var contentR = $('#content-right');
	contentR.find('div.deroule-content').hide();
	
	var push = contentR.find('div.infos-deroule');
	push.delegate('a.derouleur', 'click', function(){
		
		if($(this).next().is(':visible')){
			$(this).next().slideUp();
		} else {
			$(this).next().addClass('slided').slideDown('normal', function(){
				$('html,body').animate({scrollTop: $(this).offset().top-35},'slow');
			});
		}
		
		return false;
	});
	
	if(window.location.hash != '' && window.location.hash != '#'){
		$(window.location.hash).find('.deroule-content').slideDown().addClass('slided');
	}
	
	// ================ 
	// ! PUBLICATIONS   
	// ================ 
	
	if($('#publis').is(':visible')){
		$('#publis').delegate('a.lien-pub', 'click', function(){
			var $this = $(this);
			var lien = $this.attr('href');
			
			$('#publis').find('a.actif').removeClass('actif');
			$this.addClass('actif');
			
			$('#publi-active').hide().load(lien + ' #content-to-load', function(){
				$(this).fadeIn('normal', function(){
				});
			});
			
			return false;
		});
	}
	
	// ================ 
	// ! INFOS BULLES   
	// ================ 
	if($('.bulle').is(':visible')){
		$(".bulle").tooltip({ offset: [-60, -40], effect: 'slide', relative: true  });
	}
	// ========= 
	// ! ACTUS   
	// ========= 
	
	if($('.actu-current').is(':visible')){
		$('html, body').animate({"scrollTop" : $('.actu-current').offset().top}, 0);
	}
	
	// ============== 
	// ! PRINT PLAN   
	// ============== 
	
	$("#print_plan").click(function() {
       	printElem({
       		overrideElementCSS:[
				'../css/plan2print.css']
       		});
       	return false;
    });
    function printElem(options){
	   $('#plan2print').printElement(options);
	}
	
	
	$("#imprimer").click(function() {
       	printContent({});
       	return false;
    });
    function printContent(options){
	   contentR.printElement(options);
	}
	
	// ================= 
	// ! SCROLL PUBLIS   
	// ================= 
	
	var contener = $('#publis').find('.slidecontener');
	var nbSlides = $('#publis .slidecontener > div.slider').length;
	var current = 1;
	
	$('#scroll-right').click(function(){
		if(current < nbSlides){
			var currentMargin = parseInt(contener.css('margin-left'));
			contener.animate({"margin-left": (currentMargin-630)});
			current += 1;
		}
		return false;
	});
	
	$('#scroll-left').click(function(){
		if(current > 1){
			var currentMargin = parseInt(contener.css('margin-left'));
			contener.animate({"margin-left": (currentMargin+630)});
			current -= 1;
		}
		return false;
	});
});














