	function launchInterval() {
		// relanzamos 
		setInterval(function() {
		// recargamos dades.js
		loadDades();
		},TIEMPO_CRON);		
	}	
	function load(){		
		
		document.getElementById("data").innerHTML=dades[dia]["data"];
		loadSelector();
		loadLlegenda();		
		var estContainer=document.getElementById("estacions");
		while(estContainer.hasChildNodes())
		{
		    estContainer.removeChild(estContainer.lastChild);
		}
		var estacions=dades[dia]["estacions"];
		
		for(key in estacions){
			var idEst=key;
			var divEst=document.createElement("div");
			divEst.className="est-trans";
			divEst.id=idEst;			
			divEst.onmouseover=function(){showEstacioInfo(this.id);};
			divEst.onmouseout=function(){showFinestra('estacioInfo',false)};
			divEst.onclick=function(){showFitxa(this.id);};
			divEst.style.position="absolute";
			divEst.style.top=(estacions[key]["top"]-7)+"px";
			divEst.style.left=(estacions[key]["left"]-7)+"px";
			estContainer.appendChild(divEst);			
		}	
		divEst=null;		
		estContainer=null;
		document.getElementById("mapImage").src=webroot+"/"+dades[dia]["vars"][variable]["imgCatalunya"]+"?radn=" + (new Date()).getTime();		
		document.getElementById("missatge-info").innerHTML = idiomes['MISSATGE_INFO'];
		
	}
	
	function showEstacioInfo(idEst){				
		var estacio=dades[dia]["estacions"][idEst];		
		document.getElementById("codiEst").innerHTML=estacio["codi"];
		document.getElementById("nomEst").innerHTML=estacio["nom"];
		document.getElementById("nomMuni").innerHTML=estacio["nomMunicipi"];
		document.getElementById("nomComarca").innerHTML=estacio["nomComarca"];
		showFinestra('estacioInfo',true);
	}
		
		
	function destacar(obj, val)
	{
    	obj.className = (val==1) ? "meteorover" : "";
	}
	
	function loadSelector(){
		
		var codiSelector="";
		for(v in dades[dia]["vars"]){
			var classVar="meteor";
			if(v==variable){
				classVar+=" meteorchecked";
			}
			codiSelector+='<div id="selector_'+v+'" class="'+classVar+'">'; 			 	
	        codiSelector+='<div style="width:50px;"><img src="'+webroot+'/imatges/llegenda/'+v+'.png" style="width:40px; height:30px;"  /></div>';
			codiSelector+='<div style="margin-top:10px;">';
	        codiSelector+='<a href="'+v+'_'+dia+'.html" onmouseover="destacar(this,1)" onmouseout="destacar(this,0)">'+idiomes["VAR_"+v]+'</a>';
			codiSelector+='</div>';
	        codiSelector+='</div>';
		}
		document.getElementById("contselMeteor").innerHTML=codiSelector;
				
	}
	
	function goDiaAhir(){		
		document.location.href=variable+"_ahir.html"
	}
	
	function goDiaAvui(){
		if(dades[dia]["vars"][variable]["nomesAhir"]=="true"){
			document.location.href="octes8h_avui.html";
		}else{
			document.location.href=variable+"_avui.html";
		}
		
	}	
	
	
	function loadLlegenda(){	
		height = ((variable == 'mar8h') || (variable == 'tempsPresent8h') || (variable == 'tempsPassat')) ? 72 : ((variable == 'octes8h') ? 45 : 25);
    	width = ((variable == 'tempsPresent8h') || (variable == 'tempsPassat'))?905:585;
    	var llegendaCode='<div style="position:absolute; top:610px; width:'+width+'px; height:'+height+'px; border:1px solid #CCCCCC; padding:5px; margin-top:10px; font-size:10pt;">';
		if(variable == 'octes8h'){
			llegendaCode+=getLlegendaOctes8h();
		}else if(variable=='temp8h'){
			llegendaCode+=getLlegendaTemp8h();
		}else if(variable=='vent8h'){
			llegendaCode+=getLlegendaVent8h();
		}else if(variable=='tempmax'){
			llegendaCode+=getLlegendaTempmax();
		}else if(variable=='tempmin'){
			llegendaCode+=getLlegendaTempmin();
		}else if(variable=='mar8h'){
			llegendaCode+=getLlegendaMar8h();
		}else if(variable=='tempsPresent8h'){
			llegendaCode+=getLlegendaTempsPresent8h();
		}else if(variable=='humitat8h'){
			llegendaCode+=getLlegendaHumitat8h();
		}else if(variable=='precipitacioPluvio'){
			llegendaCode+=getLlegendaPrecipitacioPluvio();
		}else if(variable=='gruixmax'){
			llegendaCode+=getLlegendaGruixmax();
		}else if(variable=='tempsPassat'){
			llegendaCode+=getLlegendaTempsPassat();
		}else if(variable=='ventmax'){
			llegendaCode+=getLlegendaVentmax();
		}
		
		llegendaCode+='<div style="float:left; width:140px; height:25px;">';
		llegendaCode+='<div style="float:left; margin-top:8px; width:8px; height:8px; border: 1px solid black; background-color:gray;"><img src="'+webroot+'/imatges/void.gif" width="1" height="1" /></div>';		
        
        llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="5" height="25" style="vertical-align:middle;" />';
        llegendaCode+=idiomes['ESTACIO']+'</div></div>';


		document.getElementById("llegenda").innerHTML=llegendaCode;
	}
	
	function getLlegendaOctes8h(){
		var llegendaCode="";
		for(var i=0;i<9;i++)
    	{        	
					
			llegendaCode+='<div style="float:left; width:100px; height:25px;">';
            llegendaCode+='<img src="'+webroot+'/imatges/llegenda/octes8h_'+i+'.png" style="vertical-align:middle;" />';
            llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="1" height="25" style="vertical-align:middle;" />';
            llegendaCode+=(i==1) ? "1 "+idiomes['OCTA'] : i+" "+idiomes['OCTES'];
        	llegendaCode+='</div>';
    	}
    	return  llegendaCode;
	}
	
	function getLlegendaTemp8h(){
		var llegendaCode="";
		llegendaCode+='<div style="float:left; width:240px; height:25px;">';
        llegendaCode+='<div style="float:left; margin-left:10px; margin-top:5px; font-weight:bold; color:#FF9900;">' + idiomes['TEMP8H'] + '</div>';
        llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="1" height="25" style="vertical-align:middle;" />';
    	llegendaCode+='</div>';
    	return llegendaCode;
	}
	
	function getLlegendaVent8h(){
		var llegendaCode="";
		llegendaCode+='    <div style="float:left; width:240px; height:25px; margin-left:10px;">';
        llegendaCode+='<img src="'+webroot+'/imatges/llegenda/vent.png" width="25" height="25" style="vertical-align:middle;" />';
		llegendaCode+=idiomes['VENT8H'];
    	llegendaCode+='</div>';
    	return llegendaCode;
	}
	
	function getLlegendaTempmax(){
		var llegendaCode="";
		llegendaCode+='<div style="float:left; width:240px; height:25px;">';
        llegendaCode+='<div style="float:left; margin-left:10px; margin-top:5px; font-weight:bold; color:red;">' + idiomes['TEMPMAX'] + '</div>';
        llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="1" height="25" style="vertical-align:middle;" />';
    	llegendaCode+='</div>';
    	return llegendaCode;
	}
	
	function getLlegendaTempmin(){
		var llegendaCode="";
		llegendaCode+='    <div style="float:left; width:240px; height:25px;">';
        llegendaCode+='<div style="float:left; margin-left:10px; margin-top:5px; font-weight:bold; color:blue;">' + idiomes['TEMPMIN'] + '</div>';
        llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="1" height="25" style="vertical-align:middle;" />';
    	llegendaCode+='</div>';
    	return llegendaCode;
	}
	
	function  getLlegendaMar8h(){
	 
		var llegendaCode="";
	    var llegendamar =new  Array(idiomes['MARPLANA'], idiomes['MARARRISADA'], idiomes['MAREJOL'],idiomes['MAROR'], idiomes['FORTAMAROR'], idiomes['MAREGRASSA'], idiomes['MARBRAVA'], idiomes['MARDESFETA'],idiomes['MARMOLTALTA'],idiomes['MARENORME']);    
	    for(var i=0;i<10;i++)
	    {
	
	        llegendaCode+='<div style="float:left; width:140px; height:25px;">'
	        llegendaCode+='    <img src="'+webroot+'/imatges/llegenda/mar8h_'+i+'.png" width="30" height="25" style="vertical-align:middle;" />'
	        llegendaCode+=llegendamar[i];
	        llegendaCode+='</div>';
	
	    }
	    return llegendaCode;

	}
	
	function getLlegendaTempsPresent8h(){
		var llegendaCode="";
		
		var llegendatemp =new  Array(idiomes['NEU'],idiomes['AIGUANEU'],idiomes['PLUJAGELANT'],idiomes['PEDRA'],idiomes['CALAMARSA'],idiomes['TEMPESTA'],idiomes['PLUJA'],idiomes['PLUJADEFANG'],idiomes['PLUGIM'],idiomes['TORNADO'],idiomes['BOIRA'],idiomes['BOIRINA'],idiomes['CALITJA']);    
    	for(var i=0;i<13;i++)
    	{
	        llegendaCode+='<div style="float:left; width:180px; height:25px;font-size:0.9em">';
	        llegendaCode+='<img src="'+webroot+'/imatges/llegenda/tempsPresent8h_'+i+'.png" width="25" height="25" style="vertical-align:middle;" />';
	        llegendaCode+=llegendatemp[i];
	        llegendaCode+='</div>';

    	}
		
		return llegendaCode;
	}
	
	function getLlegendaHumitat8h(){
		var llegendaCode="";
		llegendaCode+='<div style="float:left; width:240px; height:25px;">';
        llegendaCode+='<div style="float:left; margin-left:10px; margin-top:5px; font-weight:bold; color:#2222FF;">' + idiomes['HUMITAT8H'] + '</div>';
        llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="1" height="25" style="vertical-align:middle;" />';
    	llegendaCode+='</div>';
		return llegendaCode;
	}
	
	function getLlegendaPrecipitacioPluvio(){
		var llegendaCode="";
		llegendaCode+='<div style="float:left; width:240px; height:25px;">';
        llegendaCode+='<div style="float:left; margin-left:10px; margin-top:5px; font-weight:bold; color:blue;">' + idiomes['PRECIPDIAPLUVIO'] + '</div>';
        llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="1" height="25" style="vertical-align:middle;" />';
    	llegendaCode+='</div>';
		return llegendaCode;
	}
	
	function getLlegendaGruixmax(){
		var llegendaCode="";
		llegendaCode+='    <div style="float:left; width:240px; height:25px;">';
        llegendaCode+='<div style="float:left; margin-left:10px; margin-top:5px; font-weight:bold; color:#333333;">' + idiomes['GRUIXMAX'] + '</div>';
        llegendaCode+='<img src="'+webroot+'/imatges/void.gif" width="1" height="25" style="vertical-align:middle;" />';
    	llegendaCode+='</div>';
		return llegendaCode;
	}
	
	function getLlegendaTempsPassat(){
		var llegendaCode="";		
		var llegendatemp =new Array(idiomes['NEU'],idiomes['AIGUANEU'],idiomes['PLUJAGELANT'],idiomes['PEDRA'],idiomes['CALAMARSA'],idiomes['TEMPESTA'],idiomes['PLUJA'],idiomes['PLUJADEFANG'],idiomes['PLUGIM'],idiomes['TORNADO'],idiomes['BOIRA'],idiomes['BOIRINA'],idiomes['CALITJA']);
    	for(var i=0;i<13;i++)
    	{
	        llegendaCode+='<div style="float:left; width:180px; height:25px;font-size:0.9em">';
	        llegendaCode+='<img src="'+webroot+'/imatges/llegenda/tempsPresent8h_'+i+'.png" width="25" height="25" style="vertical-align:middle;" />';
	        llegendaCode+=llegendatemp[i];
	        llegendaCode+='</div>';

    	}
		return llegendaCode;
	}
	
	function getLlegendaVentmax(){
		var llegendaCode="";
		llegendaCode+='    <div style="float:left; width:380px; height:25px; margin-left:10px;">';
        llegendaCode+='<img src="'+webroot+'/imatges/llegenda/vent.png" width="25" height="25" style="vertical-align:middle;" />';
        llegendaCode+=idiomes['VENTMAX'];
    	llegendaCode+='</div>';
		return llegendaCode;
	}