//FONCTIONS JAVASCRIPT DIVERSES
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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//INITIALISATION DE LA POSITION
var posX=0; posY=0;

//RECUPERATION DE LA POSITION DE LA SOURIS
function getMousePos(e) {
  posX=e.pageX; //NS6+
  posY=e.pageY;
}

//AFFICHE OU CACHE UN LAYER
function viewLayer(c,n){
	if(c=='over'){
		if(document.layers){
			window.captureEvents(Event.MOUSEMOVE);
			window.onmousemove = getMousePos;
			document.layers[n].top=posY+10;
			document.layers[n].left=posX+10;
    			document.layers[n].visibility='show';
		} else {
			if (navigator.userAgent.indexOf("Gecko")!=-1){
				document.onmousemove = getMousePos;
				eval('document.getElementById(\''+n+'\').style.top=posY+10;');
				eval('document.getElementById(\''+n+'\').style.left=posX+10;');
				eval('document.getElementById(\''+n+'\').style.visibility="visible";');
			} else {
				eval("document.all."+n).style.pixelTop=(document.body.scrollTop+event.y)+20;
				eval("document.all."+n).style.pixelLeft=(document.body.scrollLeft+event.x)+10;
				eval("document.all."+n).style.visibility='visible';
			}
		}
	FF_showHideSelectElements('hidden');
	} else {
		if(document.layers){
    			document.layers[n].top=0;
    			document.layers[n].left=0;
    			document.layers[n].visibility='hide';
		} else {
			if (navigator.userAgent.indexOf("Gecko")!=-1){
				eval('document.getElementById(\''+n+'\').style.top=0;');
				eval('document.getElementById(\''+n+'\').style.left=0;');
				eval('document.getElementById(\''+n+'\').style.visibility="hidden";');
			} else {
				eval("document.all."+n).style.top=0;
				eval("document.all."+n).style.left=0;
				eval("document.all."+n).style.visibility='hidden';
			}
		}
	FF_showHideSelectElements('visible');
	}
}

//CACHE L'ELEMENT HTML SELECT D'UN FORMULAIRE
function FF_showHideSelectElements(_visibility) {
	if(!document.forms)
		return;

	_visibility = (_visibility=='visible')?'hidden':(_visibility=='hidden')?'visible':_visibility;

	for(_f = 0; _f < document.forms.length ; _f++) {
		_currentForm = document.forms[_f];
		if(!_currentForm.elements)
			continue;

		for(_e = 0; _e < _currentForm.elements.length; _e++) {
			_currentElement = _currentForm.elements[_e];
			if(_currentElement.type && _currentElement.type.indexOf("select")!=-1) {
				_currentElement.style.visibility=_visibility;
			}
		}
	}
}
/*
if(navigator.appName =="Microsoft Internet Explorer") {
	if(navigator.userAgent.indexOf("Mac") == -1 && navigator.appVersion.indexOf("MSIE 5.0")<0) window.onresize = function(){window.document.location.reload();}
	else if(navigator.appVersion.indexOf("MSIE 5.0")>0) window.onresize = preload;
}*/

//REND LE MENU DISPO APRES CHARGEMENT DE LA PAGE
var PageLoaded='ko';


//SCRIPT MENU
var tID='';
function placeLayer(){
	pos.push("");
	for(i=1;i<5;i++){
		//pos.push(getAbsoluteLeft(i));
	}
}

function getAbsoluteLeft(objectId){

	var x = document.images['nav'+i];
	
	xLeft = x.offsetLeft;
	while(x.offsetParent!=null){
		xParent = x.offsetParent;
		xLeft += xParent.offsetLeft;
		x = xParent;
	}
	return xLeft;
}
var pos = []; // positions des layers
var menu = new Array();
for(i=0; i < 5; i++) menu[i] = new Array();

var menu = new Array();
menu[1] = new Array();
menu[2] = new Array();
menu[3] = new Array();
menu[4] = new Array();
menu[1][1] = 'Choisir le nom de famille de ses enfants|/dossiers_actualite/155095-choisir-le-nom-de-famille-de-ses-enfants.html^';
menu[1][2] = 'Des rayons aux ondes : et notre santé ?|/dossiers_actualite/180247-des-rayons-aux-ondes---et-notre-sante--.html^';
menu[1][3] = 'Dossier spécial impôts 2011|/dossiers_actualite/214034-dossier-special-impots-2011.html^';
menu[1][4] = 'La colocation en 16 Questions/Réponses|/dossiers_actualite/212897-la-colocation-en-16-questions-reponses.html^';
menu[1][5] = 'La protection juridique réformée|/dossiers_actualite/191529-la-protection-juridique-reformee.html^';
menu[1][6] = 'La sécurité dans votre assiette|/dossiers_actualite/144750-la-securite-dans-votre-assiette.html^';
menu[1][7] = 'L\'assurance vie : placement idéal?|/dossiers_actualite/205478-l-assurance-vie---placement-ideal-.html^';
menu[1][8] = 'Le divorce réformé|/dossiers_actualite/151783-le-divorce-reforme.html^';
menu[1][9] = 'Le parcours scolaire|/dossiers_actualite/155149-le-parcours-scolaire.html^';
menu[1][10] = 'Le Plan de relance de 2009|/dossiers_actualite/203310-le-plan-de-relance-de-2009.html^';
menu[1][11] = 'Le Revenu de Solidarité Active en urgence|/dossiers_actualite/191750-le-revenu-de-solidarite-active-en-urgence.html^';
menu[1][12] = 'Les 10 points clés de la réforme des successions|/dossiers_actualite/182064-les-10-points-cles-de-la-reforme-des-successions.html^';
menu[1][13] = 'Les juges de proximité|/dossiers_actualite/151384-les-juges-de-proximite.html^';
menu[1][14] = 'Les régimes spéciaux réformés|/dossiers_actualite/187273-les-regimes-speciaux-reformes.html^';
menu[1][15] = 'Mettre de l\'environnement dans sa vie|/dossiers_actualite/191703-mettre-de-l-environnement-dans-sa-vie.html^';
menu[1][16] = 'MOBILES, INTERNET NOUS TRAQUENT|/dossiers_actualite/214814-mobiles--internet-nous-traquent.html^';
menu[1][17] = 'NOUVEAUTÉ : LES GRANDS PROJETS DE LOIS DE L\'AUTOMNE|/dossiers_actualite/214848-nouveaute---les-grands-projets-de-lois-de-l-automne.html^';
menu[1][18] = 'Permis de construire : + simple, + rapide|/dossiers_actualite/185854-permis-de-construire-----simple----rapide.html^';
menu[1][19] = 'Pourquoi réformer l\'hôpital? ?|/dossiers_actualite/204327-pourquoi-reformer-l-hopital---.html^';
menu[1][20] = 'Salariés : les nouveaux droits à la formation|/dossiers_actualite/207974-salaries---les-nouveaux-droits-a-la-formation.html^';
menu[1][21] = 'Travaux dans le logement : nouvelles aides de l\'Agence Nationale de l\'Habitat|/dossiers_actualite/213837-travaux-dans-le-logement---nouvelles-aides-de-l-agence-nationale-de-l-habitat.html^';
menu[1][22] = 'Travaux écologiques dans la maison|/dossiers_actualite/208734-travaux-ecologiques-dans-la-maison.html^';
menu[1][23] = 'Un plan concerté pour l\'emploi des seniors|/dossiers_actualite/182911-un-plan-concerte-pour-l-emploi-des-seniors.html^';
menu[2][1] = 'Argent|/vos_droits/12-argent/^';
menu[2][2] = 'Consommation|/vos_droits/1-consommation/^';
menu[2][3] = 'Couple|/vos_droits/2-couple/^';
menu[2][4] = 'Droits du citoyen|/vos_droits/3-droits-du-citoyen/^';
menu[2][5] = 'Famille|/vos_droits/4-famille/^';
menu[2][6] = 'Impots|/vos_droits/5-impots/^';
menu[2][7] = 'Logement|/vos_droits/13-logement/^';
menu[2][8] = 'Santé|/vos_droits/7-sante/^';
menu[2][9] = 'Senior|/vos_droits/8-senior/^';
menu[2][10] = 'Transport|/vos_droits/10-transport/^';
menu[2][11] = 'Travail|/vos_droits/9-travail/^';
menu[2][12] = 'Vacances|/vos_droits/11-vacances/^';
menu[3][1] = 'Associations et entreprises|/modeles_lettres/21-associations-et-entreprises/^';
menu[3][2] = 'Consommation|/modeles_lettres/1-consommation/^';
menu[3][3] = 'Droits du citoyen|/modeles_lettres/3-droits-du-citoyen/^';
menu[3][4] = 'Famille|/modeles_lettres/4-famille/^';
menu[3][5] = 'Finances personnelles|/modeles_lettres/18-finances-personnelles/^';
menu[3][6] = 'Logement et Voisinage|/modeles_lettres/6-logement-et-voisinage/^';
menu[3][7] = 'Travail / Retraite|/modeles_lettres/20-travail---retraite/^';
menu[4][4] = 'Famille|/questions_reponses/4-famille/^';
menu[4][6] = 'Logement|/questions_reponses/6-logement/^';
menu[4][15] = 'Travail|/questions_reponses/15-travail/^';


//SCRIPT NAV
function titre(n){ return n.substring(0,n.indexOf("|")); }
function lien(n){ return n.substring(n.indexOf("|")+1,n.indexOf("^")); }
function myTarget(n){ return n.substring(n.indexOf("^")+1,n.length); }
function createMenu(id) {
	var idPos = id;
	var topVal = 112;
	var widthVal =199;
	var widthVal2 =190;
	if(idPos == 40){
		id = 4;
		//topVal = 300;
		topVal = document.getElementById("Layer3").offsetTop + 15;
		widthVal = 136;
		widthVal2 = 110;
	}else if(idPos == 400){
		id = 1;
		topVal = document.getElementById("Layer1").offsetTop + 15;
		widthVal = 136;
		widthVal2 = 110;
		posLeft = 423;
	}else if(idPos == 200){
		id = 2;
		topVal = document.getElementById("Layer2").offsetTop + 15;
		widthVal = 136;
		widthVal2 = 110;
		posLeft = 744;
	}
	
	
	FF_showHideSelectElements('visible');
	ch='<table cellpadding="0" cellspacing="0" border="0" width="'+widthVal+'" bgcolor="#E7E5E5"><tr><td width="'+widthVal+'"><img src="/images/pix.gif" width="'+widthVal+'" height="8"></td></tr>';
	for(i=1; i < menu[id].length; i++){
	  if(menu[id][i]){
		if(i < menu[id].length-1){ 
			ch+='<tr><td>';
			ch+='	<table cellpadding="0" cellspacing="0" border="0">';
			ch+='	<tr><td width="'+widthVal2+'"><div class="snav'+id+'" width="'+widthVal2+'" onmouseover="clearTimeout(tID);" onmouseout="clearTimeout(tID);tID=setTimeout(\'eteint();\',300);"><a href="'+lien(menu[id][i])+'" target="'+myTarget(menu[id][i])+'">'+titre(menu[id][i])+'</a></div></td></tr>';
			ch+='	</table>';
			ch+='</td></tr>';
			ch+='<tr><td width="'+widthVal+'"><img src="/images/menu_separation.gif" width="'+widthVal+'" border="0"></td></tr>';
		} else { 
			ch+='<tr><td>';
			ch+='	<table cellpadding="0" cellspacing="0" border="0">';
			ch+='	<tr><td width="'+widthVal2+'"><div class="snav'+id+'" width="'+widthVal2+'" onmouseover="clearTimeout(tID);" onmouseout="clearTimeout(tID);tID=setTimeout(\'eteint();\',300);"><a href="'+lien(menu[id][i])+'" target="'+myTarget(menu[id][i])+'">'+titre(menu[id][i])+'</a></div></td></tr>';
			ch+='	</table>';
			ch+='</td></tr>';
		}
	  }
	}
	ch+='<tr><td width="'+widthVal+'"><img src="/images/pix.gif" width="'+widthVal+'" height="8"></td></tr></table>';
	objL=(document.all)?document.all['menu']:(document.getElementById)?document.getElementById("menu"):document.layers["menu"];
	if(document.all){
		objL.style.posTop = topVal;
		if(idPos == 40){
			objL.style.posLeft=744;
			document.all['menu'].width=100;
		}else if(idPos == 400){
			objL.style.posLeft=posLeft;
		}else if(idPos == 200){
			objL.style.posLeft=posLeft;
		}else{
			objL.style.posLeft=pos[id];
			document.all['menu'].width=objL.offsetWidth+(objL.offsetWidth/5);
		}
		objL.innerHTML=ch;
		objL.style.visibility="visible";
	
	} else if(document.getElementById){
		objL.style.top = topVal;
		if(idPos == 40){
			objL.style.left=744;
		}else if(idPos == 400){
			objL.style.left=posLeft;
		}else if(idPos == 200){
			objL.style.posLeft=posLeft;
		}else{
			objL.style.left=pos[id];	
			
		}
		objL.innerHTML=ch;
		document.getElementById("menu").width=objL.offsetWidth+20;
		objL.style.visibility="visible";
	} else {
		if(idPos == 40){
			objL.left=744;
		}else if(idPos == 400){
			objL.left=posLeft;
		}else if(idPos == 200){
			objL.style.posLeft=posLeft;
		}else{
			objL.left=pos[id];
		}	
		objL.document.write(ch);objL.document.close();objL.visibility="show";
	}
}

function eteint() {
	FF_showHideSelectElements('hidden');
	vue=(document.layers)?'hide':'hidden';
	obj=(document.all)?document.all["menu"].style:(document.getElementById)?document.getElementById("menu").style:document.layers["menu"];
	obj.visibility=vue;
}
