





function deplie_menu_ssd() {
	$("#li_ssd").slideToggle("slow");
	};	
var vitesse = 600 ;
var idgrand = "a#menu3";
var idactif = "a#menu2";
var idactif2 = "a#menu1";
var idcache1 = "a#menu3b";
var idcache2 = "a#menu2b";
function filinfo(etape)
{
    switch(etape)
    {
       case 1 :
		$("#info3").fadeOut(500,function(){
				$("#info1").fadeIn(1000);
				});
          setTimeout("filinfo(2)",7000);
          break;
       case 2 :
	   $("#info1").fadeOut(500,function(){
				$("#info2").fadeIn(1000);
				});
          setTimeout("filinfo(3)",7000);
          break;
       case 3 :
       $("#info2").fadeOut(500,function(){
				$("#info3").fadeIn(1000);
				});
          setTimeout("filinfo(1)",7000);
          break;
    }
}
// agenda //

$(document).ready(function() {
//le secret //

// pour les blogs //
$(".form_comment").hide();
$(".affiche_comm").click(function(){
	$(this).next(".form_comment").toggle(400);
	//$(this).next("ul.sousitem").show(200);
	return false;
})


// gestion des tooltips //

$(".tips").eq(0).css("width","360px").children(".tooltip").show();
$(".tips").mouseover(function(){
	$(".tips").not(this).stop().animate({width:"180px"}, {duration: 400}).children(".tooltip").hide();
	$(this).stop().animate({width:"360px"}, {duration: 400}).children(".tooltip").show();
});

// ancres douces //
$('#conteneur').localScroll();


// gestion des popins //
$(".iframe").fancybox({
	'autoScale'			: true,
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'opacity': true,
	'overlayShow': true,
	'overlayOpacity': 0.8,
	'overlayColor': '#222',
	'hideonoverlayclick' :  false,
	'showCloseButton': true,
	'showNavArrows': true,
	'enableEscapeButton': true,
	'type'				: 'ajax'
});

$(".iframe_carto").fancybox({
	'autoScale'			: true,
	'width'				: '75%',
	'height'			: '80%',
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'hideonoverlayclick' :  false,
	'opacity': true,
	'overlayShow': true,
	'overlayOpacity': 0.8,
	'overlayColor': '#222',
	'hideonoverlayclick' :  false,
	'showCloseButton': true,
	'showNavArrows': true,
	'enableEscapeButton': true,
	'type'				: 'iframe'
});
$(".popvideo").fancybox({
	'padding'			: 0,
	'width'				: '65%',
	'height'			: '65%',
	'type'				: 'swf'
});
$(".iframe_autre").fancybox({
	'autoScale'			: true,
	'width'				: '50%',
	'height'			: '90%',
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe'
});
$(".ecarte").fancybox({
	'padding'			: 0,
	'autoScale'			: true,
	'width'				: '70%',
	'height'			: '95%',
	'type'				: 'iframe'
});
	if ($.browser.msie && $.browser.version < 7) {
	$("#survol1").hide();
	$("#survol2").hide();
	}
	else{
	$("a#menu2").css("backgroundPosition" ,"0 0").css("marginTop", "19px").css("width", "96px").css("height","322px");
	$("a#menu1").css("marginTop", "39px").css("width", "63px").css("height","282px");
	$("a#menu3").css("marginTop", "0px").css("width", "823px").css("height","360px");
	$("a#menu1 .ombre").hide();
	$("a#menu2 .ombre").hide();
	}
	if ($.browser.msie && $.browser.version < 7) {
		$("a#menu2").css("marginTop", "0");
		$("a#menu1").css("marginTop", "0");
	}
	/* réglage hauteur sommaire */
	var hauteur_bloc =$("#conteneur").height();
	var hauteur2 = $("#colonne2").height();
	var hauteur1 = $("#colonne1").height();
	var hauteur_new = hauteur1 - hauteur2;
	if (hauteur_new > 0){
		$("#colonne2 .bloc_calage_pres").height(Math.abs(hauteur_new)+ 26);
			}
	else if(hauteur_new < 0){
		$("#colonne1 .bloc_calage").height(Math.abs(hauteur_new)+ 26);
			}
	/* animation du totem */
	
$('#totem a.anime').click(function() {
	$(this).toggleClass('actif').next().toggle('slow');
	return false;
});
$('#totem li div.deplie').hide();

if($.cookie('contacter')=='open') $("#contacter").addClass('actif').next().show();
if($.cookie('informer')=='open') $("#informer").addClass('actif').next().show();
if($.cookie('facebook')=='open') $("#facebook").addClass('actif').next().show();
if($.cookie('cartes')=='open') $("#cartes").addClass('actif').next().show();
if($.cookie('air')=='open') $("#air").addClass('actif').next().show();
if($.cookie('travaux')=='open') $("#travaux").addClass('actif').next().show();
if($.cookie('annuaire')=='open') $("#annuaire").addClass('actif').next().show();

$('#contacter').click(function(){
	if ( $(this).hasClass("actif") ){
	$.cookie('contacter', 'open');
	}
	else
	{
	$.cookie('contacter', 'close');
	}
});
$('#facebook').click(function(){
	if ( $(this).hasClass("actif") ){
	$.cookie('facebook', 'open');
	}
	else
	{
	$.cookie('facebook', 'close');
	}
});
$('#informer').click(function(){
	if ( $(this).hasClass("actif") ){
	$.cookie('informer', 'open');
	}
	else
	{
	$.cookie('informer', 'close');
	}
});
$('#travaux').click(function(){
	if ( $(this).hasClass("actif") ){
	$.cookie('travaux', 'open');
	}
	else
	{
	$.cookie('travaux', 'close');
	}
});
$('#cartes').click(function(){
	if ( $(this).hasClass("actif") ){
	$.cookie('cartes', 'open');
	}
	else
	{
	$.cookie('cartes', 'close');
	}
});
$('#air').click(function(){
	if ( $(this).hasClass("actif") ){
	$.cookie('air', 'open');
	}
	else
	{
	$.cookie('air', 'close');
	}
});
$('#annuaire').click(function(){
	if ( $(this).hasClass("actif") ){
	$.cookie('annuaire', 'open');
	}
	else
	{
	$.cookie('annuaire', 'close');
	}
});

//animation des breves //
//filinfo(1);

//animation initial du coverflow 
function anim_cover(idgrand,idactif,idactif2,idcache1,idcache2){
$("#survol1").stop().animate(
			{backgroundPosition:"-0px 0px"},
			{duration:200});
$("#survol2").stop().animate(
			{backgroundPosition:"-0px 0px"},
			{duration:200});
$(idgrand+" .ombre").hide();		
if(idactif == "a#menu3b"){
	setTimeout('$("#lien").trigger("click")', vitesse);
	}
	$(idactif +" .ombre").fadeIn(2000);
  $(idactif).stop().css("backgroundPosition","0px 0px").animate({width: "823px",height: "360px",marginTop:"1px"}, {duration: vitesse});
	$(idgrand).stop().css("backgroundPosition","0px 0px").animate({width: "0px",height: "282px",marginTop:"1px"}, {duration: vitesse});
	$(idactif2).stop().css("backgroundPosition","0px 0px").animate({width: "96px",height: "322px",marginTop:"19px"}, {duration: vitesse});
	$(idcache1).stop().css("backgroundPosition","0px 0px").animate({width: "63px",height: "282px",marginTop:"39px"}, {duration: vitesse});
};
function anim_cover_survol(idactif,idgrand){
$(idactif).stop().animate(
	{backgroundPosition:"-500px 0px"},
	{duration:4000});
$("#survol1").stop().animate(
		{backgroundPosition:"-96px 0px"},
		{duration:500});
};

function anim_cover_out(idactif,idgrand){
$(idactif).stop().animate(
	{backgroundPosition:"0px 0px",width: "96px",height: "322px",marginTop:"19px"}, 
	{duration:500});
$("#survol1").stop().animate(
			{backgroundPosition:"-0px 0px"},
			{duration:500});
};

function anim_cover_survol2(idactif2,idactif,idgrand){
$(idactif2).stop().animate(
	{backgroundPosition:"-500px 0px"},
	{duration:4000});
$("#survol2").stop().animate(
		{backgroundPosition:"-63px 0px"},
		{duration:500});
};

function anim_cover_out2(idactif2,idactif,idgrand){
$(idactif2).stop().animate(
	{backgroundPosition:"0px 0px",width: "63px",height: "282px",marginTop:"39px"}, 
	{duration:500});
$("#survol2").stop().animate(
		{backgroundPosition:"-0px 0px"},
		{duration:500});
};
$("#survol1").click(function() {
	anim_cover(idgrand,idactif,idactif2,idcache1,idcache2);
	if (idactif == "a#menu2") {
		idactif= "a#menu1";
		idactif2 = "a#menu3b";
		idcache1 = "a#menu2b";
		idcache2 = "a#menu1b";
		idgrand ="a#menu2";
		}
	else if (idactif == "a#menu1") {
		idactif= "a#menu3b";
		idactif2 = "a#menu2b";
		idcache1 = "a#menu1b";
		idcache2 = "a#menu1b";
		idgrand ="a#menu1";
		}
	else if (idactif == "a#menu3b") {
		idactif= "a#menu2b";
		idactif2 = "a#menu1b";
		idcache1 = "a#menu1b";
		idgrand ="a#menu3b";
		}
	return false;
	});
$("#survol1").mouseover(function(){
		anim_cover_survol(idactif,idgrand);
	});
$("#survol1").mouseout(function(){
		anim_cover_out(idactif,idgrand);
	});
$("#survol2").click(function() {
	anim_cover(idgrand,idactif,idactif2,idcache1,idcache2);
	if (idactif == "a#menu2") {
		idactif= "a#menu1";
		idactif2 = "a#menu3b";
		idcache1 = "a#menu2b";
		idcache2 = "a#menu1b";
		idgrand ="a#menu2";
		}
	else if (idactif == "a#menu1") {
		idactif= "a#menu3b";
		idactif2 = "a#menu2b";
		idcache1 = "a#menu1b";
		idcache2 = "a#menu1b";
		idgrand ="a#menu1";
		}
	else if (idactif == "a#menu3b") {
		idactif= "a#menu2b";
		idactif2 = "a#menu1b";
		idcache1 = "a#menu1b";
		idgrand ="a#menu3b";
		}
	return false;
	})
	.mouseover(function(){
		anim_cover_survol2(idactif2,idactif,idgrand);
	})
	.mouseout(function(){
		anim_cover_out2(idactif2,idactif,idgrand);
	});
});
// animation du menu hover //
$(function () {
  if ($.browser.msie && $.browser.version < 8) return;
  $('#navigation li')
    .removeClass('lumiere')
    .find('a.effet')
    .append('<span class="hover" />').each(function () {
      var $span = $('> span.hover', this).css('opacity', 0);
      $(this).hover(function () {
        $span.stop().fadeTo(300, 1);
      }, function () {
        $span.stop().fadeTo(300, 0);
      });
    });
});
// pour l'organigramme //
function deplie(id_plie) {
	 $("#"+id_plie).toggle('slow');
}


