	var filtrePhotoTest = 0;
	var rechVisible = 0;
	var infoMapPosX = 0;
	var infoMapPosY = 0;
	var firstPlan=0;
	var currentMap = "carteFrance.gif";

 	var xmlDocEte;
	var xmlDocHiver;
	
	var xmlDoc;
	
	var rssFeedEte = "xml/carte_ete.xml";
	var rssFeedHiver = "xml/carte_hiver.xml";
	
	var currentZone = ""
	var jg;
	var pathCarte = "img/carte/";
	
	
	function openAllXmlDoc(){
		xmlDocEte = openXml(rssFeedEte);
		xmlDocHiver = openXml(rssFeedHiver);
	}
	
	function transition(id){
		masquerPromo(id)
	}	
	
	function changerSaison(saisonMain){
		
		if(saisonMain == 0){
			pathCarte = "img/carte/";
			xmlDoc = xmlDocHiver;
		}else{
			pathCarte = "img/carte/ete/";
			xmlDoc = xmlDocEte;
		}
		currentMap = "carteFrance.gif";
		zonePhotoMap("");
		chargerMapFrance();
	}
	
	function afficherPromo(id){
		new Effect.Appear('photo' + id,{duration:1.0});
	}
	function masquerPromo(id){
		new Effect.Fade('photo' + id,{afterFinish:setTimeout("afficherPromo("+ (id + 1) +")",900),duration:1.0});
	}
	
	function openXml(){
		if (window.ActiveXObject)
		{
			var errorHappendHere = "Check Browser and security settings";
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.load(rssFeed);
		}
		else if(window.XMLHttpRequest)
		{
			var errorHappendHere = "Error handling XMLHttpRequest request";
			var d = new XMLHttpRequest();
			d.open("GET", rssFeed, false);
			d.send(null);
			xmlDoc=d.responseXML;
		} else {
			var errorHappendHere = "Error.";
			xmlDoc = document.implementation.createDocument("","",null);
			xmlDoc.async=false;
			xmlDoc.load(rssFeed);
		}

     	xmlDoc.async=false;
	}
	
	function openXml(xmlPath){
		var xmlDocTemp;
		if (window.ActiveXObject)
		{
			var errorHappendHere = "Check Browser and security settings";
			xmlDocTemp = new ActiveXObject("Microsoft.XMLDOM");
			xmlDocTemp.async=false;
			xmlDocTemp.load(xmlPath);
		}
		else if(window.XMLHttpRequest)
		{
			var errorHappendHere = "Error handling XMLHttpRequest request";
			var d = new XMLHttpRequest();
			d.open("GET", xmlPath, false);
			d.send(null);
			xmlDocTemp=d.responseXML;
		} else {
			var errorHappendHere = "Error.";
			xmlDocTemp = document.implementation.createDocument("","",null);
			xmlDocTemp.async=false;
			xmlDocTemp.load(xmlPath);
		}

     	xmlDocTemp.async=false;
		
		xmlDoc = xmlDocTemp;
		return xmlDocTemp;
	}
	
	
	function hideFiltreBlanc(){
		var filtre;
		filtre = document.getElementById("mainFiltre");
		if(filtre != null){
			filtre.style.display = "none";
		}
	}
	
	function showFiltreBlanc(){
		var filtre;
		filtre = document.getElementById("mainFiltre");
		if(filtre != null){
			filtre.style.display = "";
		}
	}

	function chargerMain(){
		var fr,world;
		if(xmlDoc!=null){
			fr = xmlDoc.getElementsByTagName('carte')[0];
			world = xmlDoc.getElementsByTagName('carte')[1];
			if(fr!=null && world !=null){
				document.getElementById("mapFrance").src=pathCarte + fr.getAttribute("src");
				document.getElementById("mapMonde").src=pathCarte + world.getAttribute("src");
			}
		}
	}

	function fermerRegion(){
		clearRegion()
		new Effect.Appear('mainPhoto');
		document.getElementById("mainPhoto").style.display ="";
		document.getElementById("mapFrance").src = pathCarte +"carteFrance.gif";
	}
	
	function chargerMapFrance(){
		var docTemp;
		var s;
		if (pathCarte == "img/carte/"){
			docTemp = xmlDocHiver;
			s = 0;
		}else{
			docTemp = xmlDocEte;
			s = 1;
		}
	
			var k=0;
			var i=0;
			var str = "";
			var mazone,carte;
			for(k=0;k<docTemp.getElementsByTagName('carte').length;k++){
				if(docTemp.getElementsByTagName('carte')[k] != null){
						carte = docTemp.getElementsByTagName('carte')[k];
						str += "<MAP name=\"map"+ carte.getAttribute("id") +"\" id=\"map"+ carte.getAttribute("id") +"\">";
						for(i=0;i<carte.childNodes.length;i++){
								mazone = carte.childNodes[i];
								if(mazone.tagName=="zone"){
										if(mazone.getAttribute("coord") != null && mazone.getAttribute("coord") != ""){
												str +=" <AREA shape=POLY ";
												str += " coords=\""+ mazone.getAttribute("coord") + "\" ";
												str +=" onMouseOver=\"chargerLibRegion('" + mazone.getAttribute("libelle") + "');zonePhotoMap('"+ mazone.getAttribute("survol") +"');cursorHand();return escape('blo');\"";
												str +=" onMouseOut=\"cacherLibRegion();cursorDefaut();\"";
												str +="  onClick=\"if(!existInXml('" + mazone.getAttribute("survol")+"')){return false;};afficherPoint('" + mazone.getAttribute("id") + "');changerPhoto(false,'"+ mazone.getAttribute("src")  +"','"+ mazone.getAttribute("survol") +"','map" + mazone.getAttribute("id") + "');chargerLib('" + mazone.getAttribute("libelle") + "');\"";
												str +=" </AREA>";
										}
								}
						}
						str +="</MAP>";
				}
			}
			document.getElementById("mapAll").innerHTML="";
			document.getElementById("mapAll").innerHTML= str;

			//document.getElementById("mapFrance").useMap="mapFrance";
	}
	
	function chargerLib(lib){
		document.getElementById("libRegion").innerHTML = lib;
		document.getElementById("libRegion").style.display = "";
	}
	function clearLib(){
		document.getElementById("libRegion").innerHTML = "";
		document.getElementById("libRegion").style.display = "none";
	}
	
	function cacherLibRegion(){
			document.getElementById("regLibSmall").style.display = "none";
	}
	
	function majCoorRegion(x,y){
			document.getElementById("regLibSmall").style.left = x + 10 + "px";
			document.getElementById("regLibSmall").style.top = y + 10 + "px";
	}
	
	function chargerLibRegion(lib){
		if(existLibInXml(lib)){
			document.getElementById("regLibSmall").innerHTML = "&nbsp;" + lib +"&nbsp;"; 
			document.getElementById("regLibSmall").style.display = "";
		}
	}
	
	function existInXml(nomphoto){
			var mazone,carte;
			for(k=0;k<xmlDoc.getElementsByTagName('carte').length;k++){
				if(xmlDoc.getElementsByTagName('carte')[k] != null){
						carte = xmlDoc.getElementsByTagName('carte')[k];
						for(i=0;i<carte.childNodes.length;i++){
								mazone = carte.childNodes[i];
								if(mazone.tagName=="zone"){
										if(mazone.getAttribute("survol") == nomphoto){
											return true;
										}
								}
						}
				}
			}
			return false;
	}
	
	function existLibInXml(lib){
			var mazone,carte;
			for(k=0;k<xmlDoc.getElementsByTagName('carte').length;k++){
				if(xmlDoc.getElementsByTagName('carte')[k] != null){
						carte = xmlDoc.getElementsByTagName('carte')[k];
						for(i=0;i<carte.childNodes.length;i++){
								mazone = carte.childNodes[i];
								if(mazone.tagName=="zone"){
										if(mazone.getAttribute("libelle") == lib){
											return true;
										}
								}
						}
				}
			}
			return false;
	}
	
	function changerPhoto(recherche,nomphoto,survol,usemap){
			var zone;
			currentZone = nomphoto;
			if(survol!=""){
				currentMap =  survol;
			}
			hidePopup();
			document.getElementById("mapFrance").src= pathCarte + currentMap;
			if(nomphoto!=""){
				hideFiltreBlanc()
				document.getElementById("zonePhoto").src = "img/carte/region/" + nomphoto;
				new Effect.Appear('zonePhoto');
			}else{
				showFiltreBlanc()
				document.getElementById("mainFiltre").style.display = "";
				new Effect.Appear('zonePhoto');
			}
			document.getElementById("mainPhoto").style.display ="none";
			showFiltreBlanc();
			filtrePhotoTest = 0;
	}
	
	function transition(image){
		document.getElementById("filtrePhoto").src=image;
		new Effect.Appear('filtrePhoto');
	}
	
	function cursorDefaut(){
		document.body.style.cursor = 'default';
	}
		
	function cursorHand(){
		document.body.style.cursor = 'pointer';
	}
	
	function prechargimg() { 
		var doc=document; 
		if(doc.images){ if(!doc.precharg) doc.precharg=new Array();
		var i,j=doc.precharg.length,x=prechargimg.arguments; for(i=0; i<x.length; i++)
		if (x[i].indexOf("#")!=0){ doc.precharg[j]=new Image; doc.precharg[j++].src=x[i];}}
	}
	
	function critere(){
			var valeur = "";
			document.getElementById("critplus").style.display  = "none";
			document.getElementById("frmplus").style.display  = "none";
	}
	
	sfHover = function() {
		if(document.getElementById("menu")!=null){
		   var sfEls = document.getElementById("menu").getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
					sfEls[i].onmouseover=function() {
							this.className+=" sfhover";
					}
					sfEls[i].onmouseout=function() {
							this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
					}
			}
		}
	}

	function hideMap(){
		new Effect.Fade('mapForm',{afterFinish:showZone()});
	}
	function showMap(){
		setTimeout('afficherMap()',750);
	}
	function afficherMap(){
		new Effect.Appear('mapForm');
		document.getElementById("imgSearchPlus").src ="img/btnrech1.gif";
	}
	function showFrm(){
		setTimeout('montrerFormulaire()',250);
	}
	function montrerFormulaire(){
		new Effect.Appear('frmplus');
		document.getElementById("imgSearchPlus").src ="img/btnrech3.gif";
		
	}
	function hideFrm(){
		new Effect.Fade('frmplus',{afterFinish:hideZone()});
	}
	function hideZone(){
		setTimeout('masquerFormulaire()',700);
	}
	function masquerFormulaire(){
		new Effect.Shrink('critplus',showMap());
	}
	function showZone(){
		setTimeout("afficherZone()",750);
	}
	function afficherZone(){
		new Effect.Grow('critplus',{afterFinish:showFrm()});
	}	

	function zonePhotoMap(region){
				if(region.length == 0){
						if(firstPlan == 0){
							document.getElementById("mapFrance").src=pathCarte + currentMap;
						}else{
							document.getElementById("mapMonde").src=pathCarte + currentMap;
						}
				}else{
					if(existInXml(region)){
						if(firstPlan == 0){
							document.getElementById("mapFrance").src=pathCarte + region;
						}else{
							document.getElementById("mapMonde").src=pathCarte + region;
						}
					}
				}
	}
	
	function clearRegion(){
		document.getElementById("cartepoint").innerHTML = "";
		new Effect.Fade('zonePhoto');
		hidePopup()
		clearLib()
		hideFiltreBlanc();
		jg.clear();
	}
	
	function inverserMondeFrance(){
		clearRegion()
		if(firstPlan == 0){
			currentMap = xmlDoc.getElementsByTagName('carte')[1].getAttribute("src");
			document.getElementById("mapMonde").src=pathCarte+ currentMap;
			if (document.getElementById("mapMonde").style.display == "none"){
				if (window.XMLHttpRequest) {
					new Effect.Appear('mapMonde');
					new Effect.Fade('mapFrance');
					new Effect.Appear('mapFranceSmall');
					new Effect.Fade('mapMondeSmall');		
				} else {
					document.getElementById('mapMonde').style.display="";
					document.getElementById('mapFrance').style.display="none";
					document.getElementById('mapFranceSmall').style.display="";
					document.getElementById('mapMondeSmall').style.display="none";
				}
				firstPlan = 1;
			}
		}else{
			currentMap = xmlDoc.getElementsByTagName('carte')[0].getAttribute("src");
			document.getElementById("mapFrance").src=pathCarte+ currentMap;
			if (document.getElementById("mapFrance").style.display == "none"){
				if (window.XMLHttpRequest) {
					new Effect.Appear('mapFrance');
					new Effect.Fade('mapMonde');
					new Effect.Appear('mapMondeSmall');
					new Effect.Fade('mapFranceSmall');
				}else{
					document.getElementById('mapMonde').style.display="none";
					document.getElementById('mapFrance').style.display="";
					document.getElementById('mapFranceSmall').style.display="none";
					document.getElementById('mapMondeSmall').style.display="";
				}
				firstPlan = 0;
			}	
		}
		
	}
	
	function chargerDepartement(dept){
		if(dept!=""){
			document.getElementById("zonePhoto").src = "img/" + dept;
		}else{
			document.getElementById("zonePhoto").src = "img/" + currentZone;
		}
	}
	
	function chargerImg(){
			var k,l;
			k=0;
			l=0;
			var noeud,noeuxZone,noeudDept;
			if(xmlDoc.getElementsByTagName('carte')!=null){
				for(k=0;k<xmlDoc.getElementsByTagName('carte').length;k++){
					noeud = xmlDoc.getElementsByTagName('carte')[k];
					if(noeud.getAttribute("src")!= ""){
						prechargimg('img/carte/'+noeud.getAttribute("src"),'img/carte/'+noeud.getAttribute("src"));
						prechargimg('img/carte/'+noeud.getAttribute("small"),'img/carte/'+noeud.getAttribute("small"));
					}
				}
			
				if(xmlDoc.getElementsByTagName('carte')[0].getElementsByTagName('zone')!=null){
					
					for(k=0;k<xmlDoc.getElementsByTagName('carte')[0].getElementsByTagName('zone').length;k++){
						noeuxZone = xmlDoc.getElementsByTagName('carte')[0].getElementsByTagName('zone')[k];
						if(noeuxZone.getAttribute("src")!=""){
							prechargimg('img/carte/region/'+noeuxZone.getAttribute("src"),'img/carte/region/'+noeuxZone.getAttribute("src"));
						}
						if(noeuxZone.getAttribute("survol")!=""){
							prechargimg('img/carte/'+noeuxZone.getAttribute("survol"),'img/carte/'+noeuxZone.getAttribute("survol"));
							prechargimg('img/carte/ete/'+noeuxZone.getAttribute("survol"),'img/carte/ete/'+noeuxZone.getAttribute("survol"));
						}
						//if(xmlDoc.getElementsByTagName('carte')[0].getElementsByTagName('zone')[k].getElementsByTagName('departement')!=null){
						//	for(l=0;l<xmlDoc.getElementsByTagName('carte')[0].getElementsByTagName('zone')[k].getElementsByTagName('departement').length;l++){
						//		noeudDept = xmlDoc.getElementsByTagName('carte')[0].getElementsByTagName('zone')[k].getElementsByTagName('departement')[l];
						//		if(noeudDept.getAttribute("survol")!=""){
						//			prechargimg('img/carte/'+noeudDept.getAttribute("survol"),'img/carte/'+noeudDept.getAttribute("survol"));
						//			alert('img/carte/'+noeudDept.getAttribute("survol"));
						//		}
						//	}
						//}
					}
				}
			}
	}
	

	
		
	function initAdultesFamilles(){
		//document.getElementById("infoMap").display="none";
		jg = new jsGraphics("carteligne");
		chargerMain();
		chargerMapFrance();
		var ouvert = 0;
	}
	
	function showhide(monid)
	{
		if (monid.style.visibility=="hidden")
		{
			monid.style.visibility="visible";
		}
	}
	function afficheCurrent(id,x,y,xlib,ylib,lieu)
	{
		document.getElementById("xText").value = x;
		document.getElementById("cmblieu").value = lieu
		document.getElementById("yText").value = y;
		document.getElementById("currentPoint").value = id;
		document.getElementById("xTextLib").value = xlib;
		document.getElementById("yTextLib").value = ylib;
	}

	function afficherPoint(zoneno){
		var str;
		var i;
		var noeudPoint;
  			jg.setColor("#000000");
			var str = "";
			i = 0;
			jg.clear();  
			for(i=0;i<xmlDoc.getElementsByTagName('point').length;i++){
				noeudPoint = xmlDoc.getElementsByTagName('point')[i];
				if(noeudPoint.getAttribute("zone")==  zoneno){
					str += "<div id=\"" + noeudPoint.getAttribute("id") + "\" style=\"POSITION:absolute;visibility:visible;z-index:300;width:8px;height:7px; z-index:300;top:";
					str += parseInt(noeudPoint.getAttribute("coory")) + "px;left:" + parseInt(noeudPoint.getAttribute("coorx")) + "px;\">";
					str += "<a href=\"#\"><img style=\"z-index:300\" src=\"img/point.gif\" onClick=\"chargerPopup('" + noeudPoint.getAttribute("lieu_no") + "')\"></a>";
					str += "</div>";
					str += "<div onClick=\"chargerPopup('" + noeudPoint.getAttribute("lieu_no") + "')\" class=\"point\" id=\"lib" + noeudPoint.getAttribute("id") + "\" style=\"POSITION: absolute;z-index:300;width:200px;font-size:10px;";
					str += "left:" + parseInt(noeudPoint.getAttribute("coorlibx")) + "px;top:" + parseInt(noeudPoint.getAttribute("coorliby")) + "px;";
					str += "\"><a href=\"#\" style=\"color:#000000;\">" + noeudPoint.getAttribute("lieu_lib") + "</a></div>";
					if(parseInt(noeudPoint.getAttribute("coorx")) < parseInt(noeudPoint.getAttribute("coorlibx"))){
						jg.drawLine(parseInt(noeudPoint.getAttribute("coorx")) + 3 ,parseInt(noeudPoint.getAttribute("coory")) + 3,parseInt(noeudPoint.getAttribute("coorx")) + 3, parseInt(noeudPoint.getAttribute("coorliby")) + 6);
						jg.drawLine(parseInt(noeudPoint.getAttribute("coorx")) + 3, parseInt(noeudPoint.getAttribute("coorliby")) + 6 , parseInt(noeudPoint.getAttribute("coorlibx")) - 3 , parseInt(noeudPoint.getAttribute("coorliby")) + 6); 
					}else{
						jg.drawLine(parseInt(noeudPoint.getAttribute("coorx")) + 3 ,parseInt(noeudPoint.getAttribute("coory")) + 3,parseInt(noeudPoint.getAttribute("coorlibx")) -3 , parseInt(noeudPoint.getAttribute("coory")) + 3 );
						jg.drawLine(parseInt(noeudPoint.getAttribute("coorlibx")) - 3,parseInt(noeudPoint.getAttribute("coory")) + 3 ,parseInt(noeudPoint.getAttribute("coorlibx")) -3,parseInt(noeudPoint.getAttribute("coorliby")) + 6);
					}
					
				}
			}
			jg.paint();
			if(document.getElementById("cartepoint") != null ){
				document.getElementById("cartepoint").innerHTML = str;
			}
			
			
	}
	
	
	function chargerPopup(lieuno){
		var k,heb,str,lien,nb;
		str = "";
		lien = "";
		k=0;
		nb=0;
		for(k=0;k<xmlDoc.getElementsByTagName('heb').length;k++){
			heb = xmlDoc.getElementsByTagName('heb')[k];
			if(parseInt(heb.getAttribute("lieu_no")) == parseInt(lieuno)){
				str += "<a class=\"lib_bulle\" href=\"descriptions/article" + heb.getAttribute("ref_web_no") + ".asp\" style=\"font-size:12px;\">" + heb.getAttribute("nom_centre") + "</a><br>";	
				lien = "descriptions/article" + heb.getAttribute("ref_web_no") + ".asp";
				nb = nb + 1;
			}
		}	
		if(nb == 1){
			window.location.href= lien;
		}else{
			majCoorPopup(mouse_x,mouse_y);
			document.getElementById("popup").style.display=""; 
			document.getElementById("popuplib").innerHTML = str;
		}
	}
	
	function hidePopup(){
		document.getElementById("popup").style.display="none"; 
	}


	function majCoorPopup(x,y){
			document.getElementById("popup").style.left = x  + "px";
			document.getElementById("popup").style.top = y  + "px";
	}

	function underLineLib(id){
		document.getElementById(id).style.textDecoration = "underline";
	}
	function notUnderLineLib(id){
		document.getElementById(id).style.textDecoration = "";
	}

	function couleurTexte(couleur,lien){
		lien.style.color = couleur;
	}
	
	if (window.attachEvent) window.attachEvent("onload", sfHover);

