function faire_carte_emd() {
			cvi_instant.remove($('effet_emd'));
			cvi_instant.add($("effet_emd"), { shadow: 75, shade: 10, preserve: true});
			getData() ;
			getConfig() ;
			displayAllData() ;
			updateWithFile() ;
			
			setTimeout("faire_carte_emd()", 60000) ;
}
		
function updateWithFile(){
			var currentTime = new Date() ;
			var month = currentTime.getMonth() + 1 ;
			var url = './carte_emd/activity_message.html?'+currentTime.getMonth()+"_"+currentTime.getDate()+"_"+currentTime.getFullYear()+"_"+currentTime.getHours()+"h"+currentTime.getMinutes()+"m"+currentTime.getSeconds();
			var pars = '';
			var myAjax = new Ajax.Updater(
					'infos_emd', url, 
					{method: 'get', parameters: pars});
}
		
function getData() {
			var currentTime = new Date() ;
			var month = currentTime.getMonth() + 1 ;
			new Ajax.Request( './carte_emd/json/data.json?'+currentTime.getMonth()+"_"+currentTime.getDate()+"_"+currentTime.getFullYear()+"_"+currentTime.getHours()+"h"+currentTime.getMinutes()+"m"+currentTime.getSeconds() , {
													asynchronous: false, 
													method : "get",
													onSuccess: function(t) {
														jsonData = t.responseText.evalJSON();
													}
												} );			
}
		
function getConfig() {
			var currentTime = new Date() ;
			var month = currentTime.getMonth() + 1 ;
			new Ajax.Request( './carte_emd/json/config.json?'+currentTime.getMonth()+"_"+currentTime.getDate()+"_"+currentTime.getFullYear()+"_"+currentTime.getHours()+"h"+currentTime.getMinutes()+"m"+currentTime.getSeconds() , {
													asynchronous: false, 
													method : "get",
													onSuccess: function(t) {
														jsonConfigEMD = t.responseText.evalJSON();
													}
												} );			
}
		
function displayAllData() {
			if ( jsonData.alerte_rouge == "oui" ) {
				$("alerte_rouge").style.display="block"; 
				//Changement qui raccourci la prod du json lorsqu'il y a alerte rouge
				for (i=1; i < 6; i++) {
					$("t"+i).style.display="block"; 
				}
				for (i=1; i < 8; i++) {
					$("m"+i).style.display="block"; 
				}
			} else {
				displayDataEvnt("orage") ;
				displayDataEvnt("pluie") ;
				displayDataEvnt("vent") ;
				displayDataEvnt("houle") ;
			}
}
		
function displayDataEvnt(nom) {
			for (i=0; i < jsonData[nom].length; i++) {
				$(jsonData[nom][i].site).style.display="hidden"; 	
				if (jsonData[nom][i].alerte == "oui") {
					$(jsonData[nom][i].site).style.display="block"; 	
					createDiv(nom, i) ;
					createInfobulle(nom, i) ;
				}
			}
}
		
function createDiv(nom, i) {
			var newdiv = document.createElement('div');
			newdiv.setAttribute('id', jsonData[nom][i].site+"_"+nom);
			newdiv.style.position = "absolute";
			if (nom != "houle") {
				newdiv.style.left = jsonConfigEMD[jsonData[nom][i].site][jsonConfigEMD[nom].indice].left+"px";
				newdiv.style.top = jsonConfigEMD[jsonData[nom][i].site][jsonConfigEMD[nom].indice].top+"px";
			} else {
				newdiv.style.left = jsonConfigEMD[jsonData[nom][i].site].left+"px";
				newdiv.style.top = jsonConfigEMD[jsonData[nom][i].site].top+"px";
			}
			$("picto").appendChild(newdiv);
			$(jsonData[nom][i].site+"_"+nom).update("<a  onclick='javascript:popUp(\""+nom+"\");' href='#' "+
				"style='outline:0;'><img onMouseOver='javascript:montre(\""+jsonData[nom][i].site+"_"+nom+"bulle"+
				"\");' onMouseOut='javascript:cache(\""+jsonData[nom][i].site+"_"+nom+"bulle"+
				"\");' src='"+jsonConfigEMD[nom].image+"'  border='0px' ></a>") ;
}
		
function popUp(nom) {
			/*window.open('./emd/'+nom+'.html',''+nom+'','toolbar=0,menubar=0,location=0,'+
								'scrollbars=1,width=400,height=300,top='+(screen.availHeight-300)/2+',left='+(screen.availWidth-400)/2+'') ;*/
}
		
function createInfobulle(nom, i) {
			var newdiv = document.createElement('div');
			newdiv.setAttribute('id', jsonData[nom][i].site+"_"+nom+"bulle");
			newdiv.style.position = "absolute";
			newdiv.style.visibility = "hidden";
			newdiv.style.left = "15px";
			newdiv.style.top = "238px";
			newdiv.style.fontSize = "10px";
			newdiv.style.color = "gray";
			newdiv.style.fontFamily = "Sans-serif";
			newdiv.style.backgroundImage = "url('./carte_emd/images/infobulle.gif')";
			newdiv.style.border = "1px solid gray";
			newdiv.style.padding = "0px 3px 0px 3px";
			$("carte_emd").appendChild(newdiv);
}
		
var i=false;
function montre(div, text) {
				$(div).style.visibility="visible";
				$(div).update(text);
				i=true;
}
function cache(div) {
			if(i==true) {
				$(div).style.visibility="hidden";
				i=false;
			}
}

