$(function(){ 
	//Paragraphes depliables
	//---------------------------------------------
	if($(".paragraph_dyn_table").length>0){
		$(".paragraph_dyn_table").each(function(){
			$table = $(this);
			$table.children().children(".reponse").hide();
			$table.children().children(".opened").parent().children(".reponse").show();
			$table.children().children(".question").click(function(){
				$(this).toggleClass("opened").toggleClass("closed");
				$(this).parent().children(".reponse").toggle();
			});
		});
	}
	
	//Front news
	//---------------------------------------------
	if($(".front_news_table").length>0){
		$(".front_news_table").each(function(){
			$table = $(this);
			$items = $table.children().children().children(".items");
			$top = $table.children().children().children(".boutons").children(".front_news_top");
			$bottom = $table.children().children().children(".boutons").children(".front_news_bottom");
			//init
			$items.children(".news_teaser").each(function(i){
				if(i==0 || i==1){
					$(this).show();
					if(i==0){
						$(this).addClass("selected");
					}
					if(i==1){
						$(this).addClass("mod_opacity");
					}
				}else{
					$(this).hide();
				}
			});
			//action
			$top.click(function(){
				if($items.children(".selected").prev(".news_teaser").length>0){
					$items.children(".selected").next(".news_teaser").removeClass("mod_opacity").hide();
					$items.children(".selected").addClass("mod_opacity").removeClass("selected").prev(".news_teaser").show().addClass("selected");
				}
			});
			$bottom.click(function(){
				if($items.children(".selected").next(".news_teaser").next(".news_teaser").length>0){
					$items.children(".selected").next(".news_teaser").next(".news_teaser").addClass("mod_opacity").show();
					$items.children(".selected").next(".news_teaser").removeClass("mod_opacity").addClass("selected").show().prev(".news_teaser").removeClass("selected").hide();
				}
			});
		});
	}
	
	
	//Teaser : place du titre
	//---------------------------------------------
	if($(".personal_right .teaserstandard_table .teaserstandard_table_textes .title").length>0){
		$(".personal_right .teaserstandard_table .teaserstandard_table_textes .title").each(function(){
			$(this).parent().parent().parent().parent().before('<p class="title">'+$(this).html()+'</p>');
			$(this).remove();
		});
	}

	//Glossaire : filtre
	//---------------------------------------------
	//deplace dans le template
	
	//Annuaire : tablesorter et pager
	//---------------------------------------------
	if($("#annuaire_table").length>0){
		$("#annuaire_table").tablesorter({ 
	        // sort on the first column, order asc 
	        sortList: [[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0]]
    	});
	}
	if($("#annuaire_table_paginated").length>0){
		$("#annuaire_pager").show();
		$("#annuaire_pager .pagesize").hide();
		$("#annuaire_table_paginated").tablesorter({ 
	        // sort on the first column, order asc 
	        sortList: [[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0]],
	        // pagination
	        widthFixed: true, widgets: ['zebra']
    	}).tablesorterPager({
    		container: $("#annuaire_pager"),
    		positionFixed: false 
    	});
	}
	
	
	//Lightbox
	//---------------------------------------------
	if($("a.lightbox").length>0){
		$("a.lightbox").lightBox();
	}
	
	
	
}); 
