//////////// News a la une /////////////
var tmp_interval = 10;	 //en seconde //
var n = 0;							  //
////////////////////////////////////////

var fch = 0;

$(document).ready(function(){

	$("#moreSearch").hide();
	
	$(".toggle").click(function () {
		$("#moreSearch").slideToggle("normal");
		
		if ( fch )
		{
			document.getElementById("fleche").src = '/design/fre/images/sageret/flecheRougeOff.gif';
			fch = 0;
		}
		else
		{
			document.getElementById("fleche").src = '/design/fre/images/sageret/flecheRougeOn.gif';
			fch = 1;
		}	
	
	});
	
	
	$("#envAmi").hide();
	$(".ami").click(function () {
		$("#envAmi").slideToggle("normal");	
	});

	
	
	
	// On cache les sous-menus
	// sauf celui qui porte la classe "open_at_load" :
	$(".navigation span.subMenu:not('.open_at_load')").hide();
	// On sélectionne tous les items de liste portant la classe "toggleSubMenu"
	
	
	
	$(".slideAgenda").click( function () {
								 
		// Si le sous-menu était déjà ouvert, on le referme :
		if ($(this).next("span.subMenu:visible").length != 0) {
			$(this).next("span.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") } );
			$(this).html("<img src='/design/fre/images/sageret/btDetailAgenda.gif' alt='Voir plus' class='posZero' border='0' />");
		}
		// Si le sous-menu est caché, on ferme les autres et on l'affiche :
		else {
			$(".navigation span.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") });
			$(".navigation a.slideAgenda").html("<img src='/design/fre/images/sageret/btDetailAgenda.gif' alt='Voir plus' class='posZero' border='0' />");
			$(this).next("span.subMenu").slideDown("normal", function () { $(this).parent().addClass("open") } );
			$(this).html("<img src='/design/fre/images/sageret/btFermerAgenda.gif' alt='Fermer' class='posZero' border='0' />");
	
		}
		// On empêche le navigateur de suivre le lien :
		return false;
	
	} ) ;
	
	
	$(".slide").click( function () {
								 
		// Si le sous-menu était déjà ouvert, on le referme :
		if ($(this).next().next("span.subMenu:visible").length != 0) {
			$(this).next().next("span.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") } );
			$(this).next("span.intro").show("fast", function () {$(this).parent().removeClass("close") });
			$(this).html("<img src='/design/fre/images/sageret/btDetail.gif' alt='Voir plus' class='posZero' border='0' />");
		}
		// Si le sous-menu est caché, on ferme les autres et on l'affiche :
		else {
			$(".navigation span.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") });
			$(".navigation span.intro").show("fast", function () { $(this).parent().removeClass("close") });
			$(".navigation a.slide").html("<img src='/design/fre/images/sageret/btDetail.gif' alt='Voir plus' border='0' class='posZero' />");
			$(this).next("span.intro").hide("fast", function () { $(this).parent().addClass("close") });
			$(this).next().next("span.subMenu").slideDown("normal", function () { $(this).parent().addClass("open") } );
			$(this).html("<img src='/design/fre/images/sageret/btFermer.gif' alt='Fermer' class='posZero' border='0' />");
	
		}
		// On empêche le navigateur de suivre le lien :
		return false;
	
	} ) ;
	

});


function montre(id) {
var d = document.getElementById(id);
	for (var i = 0; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}



function agenda(idAgenda)
{
	var d = document.getElementById('A'+idAgenda);
	var e = document.getElementById('fondA'+idAgenda);
	var f = document.getElementById('numPageHomeA'+idAgenda);
	for (var i = 0; i<=5; i++) {
		if (document.getElementById('A'+i)) {document.getElementById('A'+i).style.display='none';}
		if (document.getElementById('fondA'+i)) {document.getElementById('fondA'+i).style.backgroundColor='#FFFFFF';}
		if (document.getElementById('numPageHomeA'+i)) {document.getElementById('numPageHomeA'+i).style.color='#84226D';}
	}
if (d) {d.style.display='block';}
if (e) {e.style.backgroundColor='#84226D';}
if (f) {f.style.color='#FFFFFF';}


}


function news(idNews)
{
	var d = document.getElementById(idNews);
	var e = document.getElementById('fond'+idNews);
	var f = document.getElementById('numPageHome'+idNews);
	for (var i = 0; i<=5; i++) {
		if (document.getElementById(i)) {document.getElementById(i).style.display='none';}
		if (document.getElementById('fond'+i)) {document.getElementById('fond'+i).style.backgroundColor='#FFFFFF';}
		if (document.getElementById('numPageHome'+i)) {document.getElementById('numPageHome'+i).style.color='#7E9B1B';}
	}
if (d) {d.style.display='block';}
if (e) {e.style.backgroundColor='#7E9B1B';}
if (f) {f.style.color='#FFFFFF';}


}


function start_bt() {
	//alert (nbr());
	news(n); n++;
	if (n == nbr_actu) n=0;
	t= setTimeout("start_bt();",tmp_interval*1000)
}


function masqueSelect()
{
 if( window.attachEvent )
 {
	 document.getElementById('CodeOrganisme').style.visibility='hidden';
	 //document.getElementById('LibelleSavoirFaire').style.visibility='hidden';
	 //document.getElementById('CodeTheme').style.visibility='hidden';
 }
}

function montreSelect()
{
	 document.getElementById('CodeOrganisme').style.visibility='visible';
	 //document.getElementById('LibelleSavoirFaire').style.visibility='visible';
	 //document.getElementById('CodeTheme').style.visibility='visible';
}

function jour(nbr) {
	if (nbr == '24h')
	{
			document.getElementById("c1").src = 'http://www.meteoconsult.fr/image/meteodirect/md_grande_bretagne24h.gif';
			document.getElementById("c2").src = 'http://www.meteoconsult.fr/image/meteodirect/md_allemagne24h.gif';
			document.getElementById("c3").src = 'http://www.meteoconsult.fr/image/meteodirect/md_espagne24h.gif';
			document.getElementById("c4").src = 'http://www.meteoconsult.fr/image/meteodirect/md_italie24h.gif';
			document.getElementById("c5").src = 'http://www.meteoconsult.fr/image/meteodirect/md_maghreb24h.gif';
	}

	if (nbr == '48h')
	{
			document.getElementById("c1").src = 'http://www.meteoconsult.fr/image/meteodirect/md_grande_bretagne48h.gif';
			document.getElementById("c2").src = 'http://www.meteoconsult.fr/image/meteodirect/md_allemagne48h.gif';
			document.getElementById("c3").src = 'http://www.meteoconsult.fr/image/meteodirect/md_espagne48h.gif';
			document.getElementById("c4").src = 'http://www.meteoconsult.fr/image/meteodirect/md_italie48h.gif';
			document.getElementById("c5").src = 'http://www.meteoconsult.fr/image/meteodirect/md_maghreb48h.gif';
	}
}

function cache(){
	document.getElementById("anim").style.visibility='hidden';
}


var idPart = 0;
var maxPart = 0;

function start_slide_part(nbr)
{
	maxPart = nbr;
	timer = setInterval("slide_part()", 5000);
}

function slide_part()
{
	$('#part' + idPart).fadeOut(250, function() {
		idPart += 1;
		if (idPart == maxPart){idPart = 0;}
		$('#part' + idPart).fadeIn(250);
	});
}


























function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
