
 /* - - - - - - - - - - - - - - - - - - - - - - -
 Fichier JavaScript
 Créé le lundi 7 avril 2003 09:46:14
  - - - - - - - - - - - - - - - - - - - - - - - */
function set_obj_value(champs,val)
  {
   document.getElementById(champs).value=val
  }
function get_obj_value(champs)
  {
   return document.getElementById(champs).value
  }
  
function NotYet()
 {
  alert('Cartes non disponibles')
}
function OuvreFenetre(AdresseFenetre)
  {
   window.open(AdresseFenetre,"agrandir","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=450,height=510")
  }   



function Calculer_Adresse(theURL,hauteur,largeur,Type,rep_rac)
  {
    document.form.AdresseImage.value=theURL // input caché servant de dépot
    //namew = 'BIG'+model
    SplittedURL = theURL.split("_sma.gif")
    BigURL      = SplittedURL[0]+'_big.gif'
    var model = TestExisteChamps ('Model');

    //document.form.AdresseImage.value=BigURL
    //var ValType = document.form.Type.value
    //alert("BigURL : "+BigURL);	// DEBUG

    BigURL=str_replace  ( 'sma'  , 'big',BigURL );



    return BigURL;


    AdresseFenetre=rep_rac+"_agrandir.php?H="+hauteur+"&L="+largeur +"&Type="+Type

	if (Type=="pp"){ /* HB le 3/07/07 si l'on est dans la partie privée on ne retaille pas les images, elles sont affichée tel quel sans les AASQA*/

	  window.open(BigURL,"","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=650,height=650")

        /*  $.ajax({
            url: AdresseFenetre,
            cache: false,
            success: function(html){
             $("#results").append(html);
            }
           });
        */

	} else{

          window.open(AdresseFenetre,"","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=630,height=650")
	}



  }

function Agrandir(theURL,hauteur,largeur,Type,rep_rac)
  {
    document.form.AdresseImage.value=theURL // input caché servant de dépot
    //namew = 'BIG'+model
    SplittedURL = theURL.split("_sma.gif")
    BigURL      = SplittedURL[0]+'_big.gif'
    var model = TestExisteChamps ('Model');
    //document.form.AdresseImage.value=BigURL
    //var ValType = document.form.Type.value
	  //alert("BigURL : "+BigURL);	// DEBUG
    AdresseFenetre=rep_rac+"_agrandir.php?H="+hauteur+"&L="+largeur +"&Type="+Type
	if (Type=="pp"){ /* HB le 3/07/07 si l'on est dans la partie privée on ne retaille pas les images, elles sont affichée tel quel sans les AASQA*/
	  window.open(BigURL,"","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=650,height=650")
	} else{
      window.open(AdresseFenetre,"","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=630,height=650")
	}
  }

function agrandir_img(num_img,Type,rep_rac)
  {
    //document.form.AdresseImage.value=theURL
    //namew = 'BIG'+model
    //SplittedURL = src.split("_sma.gif")
    //BigURL      = SplittedURL[0]+'_big.gif'
    //document.form.AdresseImage.value=BigURL
    //var ValType = document.form.Type.value  
 
    AdresseFenetre=rep_rac+"_agrandir_2.php?&Type="+Type+"&num_img='"+num_img+"'"
    
    window.open(AdresseFenetre,"","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=630,height=650")
  }/**/

function TestExisteChamps (NomChamps)
  {

   var Evaluer ='var Champs=document.form.'+NomChamps
   eval(Evaluer);
   TypeElement = Champs.type
   
   if (TypeElement=='select-one')
    {
     ValChamps     = Champs.options[Champs.selectedIndex].value
    }
    else
       {if( ( TypeElement=='hidden') || (TypeElement=='text'))
          {ValChamps    = Champs.value

          }
          else{//pour les check
               var longh =Champs.length

                if (longh>0)
                  {for(i = 0; i < longh; i++)
                     {
                      if(Champs[i].checked == true)
                        {ValChamps=Champs[i].value;
                         
                         break;
                        }
                     }
                  }
              }
       }
  
   return  ValChamps
  }


function init_form(Repertoire,species,type,today_day,today_month,today_year)
 {
  if ((type=='p') || (type=='')){increment=0 ; }
  if (type=='a'){increment =-1;}
  today_date = today_year+today_month +today_day

  var tog = TestExisteChamps ('Tog')            
  var model = TestExisteChamps ('Model')        
  if (type=='p')
    { 
     model=DeterminModelPrevision(today_day,today_month,today_year,species,model)
     
     if ( (species=='O3')&&(model == 'CFM'))
        {
         model='ASCFM'
        }  
     if (species == 'DESDUST')
        {
         model='MOCAG'
        } 
     //alert(model)
     AfficheCarteP(Repertoire,today_date,species,model,tog)
    }

  if (type=='a')
    {model=DeterminModelAnalyse(today_day,today_month,today_year)
     AfficheCarteA(Repertoire,today_date,species,model,tog)
    }
  /*document.form.Model.value = model //à cause de l'agrandissement 
  mais génére erreur lors de la séléction de france pour prevision */  
}
function change_image_index(var_src,num)
  {
   var var_eval='document.'+num+'.src = \''+var_src+'\'' ;
   eval(var_eval);
  }

function ChangeMaps(Repertoire,species,type)
  {     
   day   = TestExisteChamps ('Day')
   month = TestExisteChamps ('Month')
   year  = TestExisteChamps ('Year')

   Iyear  =parseInt(year,10);
   Imonth =parseInt(month,10);
   Iday   =parseInt(day,10);
   
   if (Iday<10){Iday ='0'+Iday ;}
   if (Imonth<10){Imonth ='0'+Imonth ;}
   
   var tog = TestExisteChamps ('Tog')
   var model = TestExisteChamps ('Model')
   
   today_date = Iyear+''+Imonth+''+Iday
   var int_today_date = parseInt(today_date)

   if (type=='p') // prévision
     {
      MaJ_VideoSimulation(species,model); // ajout 07/09 - JGu // en commentaire pour absence video
      if ((model != 'CFM') && (model !='MOCAG') && (species!='DESDUST') 
           && model != 'AFM'     && model != 'AWM' 
         )
        {
         model=DeterminModelPrevision(Iday,Imonth,Iyear,species,model)
        } 
       //alert(model)
      if ( (int_today_date>=20060601) && (species=='O3')
            &&(model == 'CFM') /*&& (tog=='PMAP') commenté 21/06/2006*/)
        {
         model='ASCFM'
        }   
      if ( (int_today_date>=20070601) && (species=='O3')
            &&(model == 'ASCFM') /*&& (tog=='PMAP') commenté 21/06/2006*/)
        {
         model='ASAFM'
        }

      if ( (int_today_date>=20070601) && (species=='NO2')&& (model == 'CFM'))
        {
         model='AFM'
        } 
          
      //alert(model)     
        
      set_obj_value('id_Model_Ok_click',model)           
      
      AfficheCarteP(Repertoire,today_date,species,model,tog)
     }

  if (type=='a') // analyse
    {model=DeterminModelAnalyse(Iday,Imonth,Iyear)    
     set_obj_value('id_Model_Ok_click',model); // ajout JGu 06/09
     AfficheCarteA(Repertoire,today_date,species,model,tog)
    }

   if (type=='pp') // prévision privé
    {
      //alert ('prévision privé');
     var indicateurstat;
     var seuil;
     var typestation;

      //alert(model);

      /*
      if ( (int_today_date>=20070601) && (species=='O3')
            &&(model == 'ASCFM') )
        {
         model='ASAFM'
        }  */     
      if ( (int_today_date>=20070601) && ((species=='NO2') || (species=='O3'))
          && (model == 'CFM'))
        {    
         model='AFM'
        }

      /* gestion de la page cartes AOT différente des pages prévisions*/
      if (species=='AOT')
        {
            model='AWM'
            AfficheCartePP_AOT(Repertoire,species,model,tog,day,month,year,today_date)
        }else {
            
            AfficheCartePP(Repertoire,species,model,tog,day,month,year,today_date)
        }
    } // type = pp

   if (type=='pv') // vérification privé
    {//model=DeterminModelAnalyse(Iday,Imonth,Iyear)
     ChangeMaps_verif_priv(Repertoire,species,type)
    }
    
   if (type=='ps') // Série temporelle privé
    {//model=DeterminModelAnalyse(Iday,Imonth,Iyear)
     ChangeMaps_Serie(Repertoire,species,type)
    }    
  
  //document.form.Model.value=model //à cause de l'agrandissement
}

function ImageDefautIma0(rep_img)
  {//var lang=lang();
   //document.Ima0.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima0.src=rep_img+'imagedefautprev'+'.gif'
   
  }
function ImageDefautIma1(rep_img)
  {//var lang=lang();
   //document.Ima1.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima1.src=rep_img+'imagedefautprev'+'.gif' 

  }
function ImageDefautIma2(rep_img)
  {//var lang=lang();
   //document.Ima2.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima2.src=rep_img+'imagedefautprev'+'.gif'
  }
function ImageDefautIma3(rep_img)
  {//var lang=lang();    
   //document.Ima3.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima3.src=rep_img+'imagedefautprev'+'.gif'
  }

function ImageDefautIma4(rep_img)
  {//var lang=lang();    
   //document.Ima4.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima4.src=rep_img+'imagedefautprev'+'.gif'
  }
  
  
function ImageDefautIma5(rep_img)
  {//var lang=lang();    
   //document.Ima5.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima5.src=rep_img+'imagedefautprev'+'.gif'
  }
  
 function ImageDefautIma6(rep_img)
  {//var lang=lang();    
   //document.Ima5.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima6.src=rep_img+'imagedefautprev'+'.gif'
  }
  
function ImageDefautIma7(rep_img)
  {//var lang=lang();    
   //document.Ima5.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima7.src=rep_img+'imagedefautprev'+'.gif'
  }

function ImageDefautIma8(rep_img)
  {//var lang=lang();    
   //document.Ima5.src=rep_img+'imagedefautprev_'+lang+'.gif'
   document.Ima8.src=rep_img+'imagedefautprev'+'.gif'
  }  
//Pour cartes modele ENSEMBLE - new 06/09

function ImageDefautIma9(rep_img)
{
 document.Ima9.src=rep_img+'imagedefautprev'+'.gif'
}  

function ImageDefautIma10(rep_img)
{
 document.Ima10.src=rep_img+'imagedefautprev'+'.gif'
}  

function ImageDefautIma11(rep_img)
{
 document.Ima11.src=rep_img+'imagedefautprev'+'.gif'
}  
// affiche carte Analyse
function AfficheCarteA(Repertoire,today_date,species,model,tog)
  {
   //tog='PMAP'
   var int_today_date = parseInt(today_date)
   var VDateAujourdhui = document.form.DateAujourdhui.value
   var int_VDateAujourdhui = parseInt(VDateAujourdhui)

   if ((int_today_date < 20040616 ) )
     {
      model='AWM' 
     }
     else{
          model='CFM'
          }
   var Increment

   if (int_today_date < int_VDateAujourdhui)
     {Increment='D-1'
     }
     else {Increment='D+0'
     }

   if (species=='PM10')
   {model='AWM'; h=300; l=269;/*21/06/2006*/ }

   if (int_today_date >= 20070601 )
     {model=TestExisteChamps('Model'); // sera AFM (France) ou AWM (Europe) @JGu
     }
   else {model='CFM';
   }

   mapp0   = Repertoire+today_date+'/'+species+'_Kinnov_prediction_'+model+'_'+tog+'_'+Increment+'_sma.gif'
   mapp1   = Repertoire+today_date+'/'+species+'_model+obs_'+model+'_'+tog+'_'+Increment+'_sma.gif'
  // mapp2   = Repertoire+today_date+'/'+species+'_Kinnov_erreur_'+model+'_'+tog+'_'+Increment+'_sma.gif'
   
   document.Ima0.src = mapp0
   document.Ima1.src = mapp1
  // document.write(mapp0)
  //alert(mapp0+'\n http://www.prevair.org/analyse_peak/carte/20060418/O3_Kinnov_prediction_CFM_PMAP_D+0_sma.gif')
  //awm_dave
   if ((model=='CFM'))
      {
       h=300; l=269;
       document.Ima0.width=l
       document.Ima1.width=l
       document.Ima0.height=h
       document.Ima1.height=h 
      }

/*   document.Ima0.width=l
   document.Ima1.width=l
   
   document.Ima0.height=h
   document.Ima1.height=h 
*/
  }

//affiche 3 cartes de Prévision : jour, lendemain, surlendemain
function AfficheCarteP(Repertoire,today_date,species,model,tog)
  {
   set_obj_value('id_Model_Ok_click',model) //car pb agrandissement 2006/07/03
   var int_today_date = parseInt(today_date)
   
   //today_date='20060717'
   day   = TestExisteChamps ('Day')
   month = TestExisteChamps ('Month')
   year  = TestExisteChamps ('Year')
   
   

   if (today_date>=20060101)
     {
      mapp0   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+0_sma.gif'
      mapp1   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+1_sma.gif'
      mapp2   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+2_sma.gif'
     }
     else{
          if (model=='CFM')
            {model='AWM'                      
            }
          var d0=donnerdate2(day,month,year,0)
          var d1=donnerdate2(day,month,year,1)
          var d2=donnerdate2(day,month,year,2)

          mapp0   = '/simulation/'+d0+'/'+species+'_'+model+'_'+tog+'_sma.gif'
          mapp1   = '/simulation/'+d1+'/'+species+'_'+model+'_'+tog+'_sma.gif'
          mapp2   = '/simulation/'+d2+'/'+species+'_'+model+'_'+tog+'_sma.gif'
          //alert(mapp0)  
          //document.write(mapp2) 
         }
          
   document.Ima0.src = mapp0
   document.Ima1.src = mapp1
   document.Ima2.src = mapp2

   //gestion de la taille des cartes
   /*if ((int_today_date < 20020101 ) )
     {h=300; l=291;
     
     }
     else
      {if ((int_today_date < 20040420 ) )
         {h=240; l=300;
         }
         else{h=300; l=290.5;
             }
      }*/
   //
   //h=300; l=291; // europe ; 2 cartes par ligne
   h=227; l=220; // europe ; 3 cartes sur une ligne depuis 07/09 - JGu // en commentaire pour absence video
   
   //ajout  (model=='ASCFM') 2006/06/03
   if ((model=='CFM') || (model=='ASCFM') || (model=='AFM') || (model=='ASAFM')) // JGu le 07/07/09 ajout AFM & ASAFM
      {//h=300; l=269;
	   h=245; l=220; // france ; 3 cartes sur une ligne depuis 07/09 - JGu // en commentaire pour absence video
      }

   if ((model=='MOCAG'))
      {//h=215; l=300; // JGu le 07/07/09 passé de h de 209 à 215 taille réélle global prévision
	   h=158; l=220; // monde ; 3 cartes sur une ligne depuis 07/09 - JGu // en commentaire pour absence video
      }
   
   document.Ima0.height=h
   document.Ima1.height=h
   
   document.Ima0.width=l
   document.Ima1.width=l  
  
   //2006/06/03
   document.Ima2.width = l
   document.Ima2.height = h     
  }

function DeterminModelAnalyse(today_day,today_month,today_year)
  {
  Itoday_year  =parseInt(today_year,10);
  Itoday_month =parseInt(today_month,10);
  Itoday_day   =parseInt(today_year,10) ;

  if (Itoday_year>2003 )
      { model='AWM'
      }
      else{
           if ((Itoday_year>=2003) && (Itoday_month ==11) && (Itoday_day >=24))
             {  model='AWM'
             }
             else
                 {if ((Itoday_year>=2003) && (Itoday_month > 11) )
                   { model='AWM'
                   }
                   else{model='CCM'
                   }
                 }
          }
   return model ;
  }
function DeterminModelPrevision(today_day,today_month,today_year,species,model)
  {  
   Itoday_year  =parseInt(today_year,10);
   Itoday_month =parseInt(today_month,10);
   Itoday_day   =parseInt(today_day,10) ;
   
   if ((Itoday_year==2003) && (Itoday_month ==11))
      { 
       if (Itoday_day <25)
         {model='CCM' 
         }
      if (Itoday_day >=25)
         {model='AWM' 
         }
      }
  if (Itoday_year<2003 )
     { model='CCM'
     }
  if ((Itoday_year==2003 ) && (Itoday_month <11))
     { model='CCM'
     }
  if ((Itoday_year==2003 ) && (Itoday_month >11))
     { model='AWM'
     }
  if (Itoday_year>2003 )
     { model='AWM'
     }
 
  return model ;
  }   




function ChangeMaps_verif_priv(Repertoire,species,type)
  {
   day   = TestExisteChamps ('Day')
   month = TestExisteChamps ('Month')
   year  = TestExisteChamps ('Year')
   today_date = year+month+day

   var indicateurstat = TestExisteChamps ('INDIC_STAT')
   var seuil          = TestExisteChamps ('SEUIL')
   var model          = TestExisteChamps ('Day')
   var typestation    = TestExisteChamps ('TYPA_STAT')
   var tog            = TestExisteChamps ('Day')

   Iyear  =parseInt(year,10);
   Imonth =parseInt(month,10);
   Iday   =parseInt(day,10)   ;

   if (Iday<10){Iday ='0'+Iday ;}
   if (Imonth<10){Imonth ='0'+Imonth ;}

   var tog = TestExisteChamps ('Tog')
   var model = TestExisteChamps ('Model')
 
   AfficheCarteVerif(Repertoire,species,indicateurstat,seuil,model,typestation,tog,day,month,year)

   document.form.Model.value=model //? cause de l'agrandissement
   
   //ajout 20060720
   if ((model=='CFM'))
      {
       h=300; l=269;
      }

   if ((model=='AWM'))
      {
       h=300; l=290.5;
      }
   
   document.Ima0.width=l
   document.Ima1.width=l
   document.Ima2.width=l
   document.Ima3.width=l
   //FIN ajout 20060720   
   
  }

function AfficheCarteVerif(Repertoire,species,indicateurstat,seuil,model,typestation,tog,day,month,year)
  {
//    var Part1  = Repertoire +  species + '_' + model + '_' + tog
//     Part1 += '_' + indicateurstat + '_' + seuil + '_'+year
   var Date=  year+''+month+''+day
   var Part1  = Repertoire +  species + '_' + indicateurstat + '_' + seuil
       Part1 += '_' + model + '_' + typestation +'_' + tog
   
   mapp0 = Part1 +'_D-1_sma.gif'
   mapp1 = Part1 +'_D+0_sma.gif'
   mapp2 = Part1 +'_D+1_sma.gif'
   mapp3 = Part1 +'_D+2_sma.gif'
   
   document.Ima0.src = mapp0
   document.Ima1.src = mapp1
   document.Ima2.src = mapp2
   document.Ima3.src = mapp3
  }


// séries temporelles / privé
function ChangeMaps_Serie(Repertoire,species,type)
  {
   var annee  = TestExisteChamps ('ANNEE');
   var indicateurstat = TestExisteChamps ('INDIC_STAT');
   var seuil          = TestExisteChamps ('SEUIL');
   var typestation    = TestExisteChamps ('TYPA_STAT');
   var tog = TestExisteChamps ('Tog');
   var model = TestExisteChamps ('Model');
 
   AfficheCarte_Serie(Repertoire,species,indicateurstat,seuil,model,typestation,tog,annee)

   document.form.Model.value=model //? cause de l'agrandissement
  }

// séries temporelles / privé
function AfficheCarte_Serie(Repertoire,species,indicateurstat,seuil,model,typestation,tog,annee)
  {   
   /*
   * Modification HB du 29_02_2008
   * prise en compte de la modification du
   * nom de modèle à partie de l'année 2007      
   */
   if((annee==2007) && model=='CFM-MOCAF-ASCFM-ASMOCAF')
     { 
       model='AFM-MOCAF'
     }
     
   var Part1  = Repertoire +  species + '_' + model + '_' + tog
       Part1 += '_' + indicateurstat + '_' + seuil + '_'+annee
   var Date=  year+''+month+''+day

    if ((annee>2009) || ((annee==2009) && (seuil=='Hiver'))) // à partir de l'hiver 2009'
        {
            document.Ima0.height=247;// taille images 247x600
            document.Ima1.height=247;
            document.Ima2.height=247;
            document.Ima3.height=247;
        }
    else // avant l'hiver 2009'
        {
            document.Ima0.height=358; // taille images 358x600
            document.Ima1.height=358;
            document.Ima2.height=358;
            document.Ima3.height=358;
        }

   mapp0 = Part1 +'_D-1.gif'
   //alert("mapp0 : "+mapp0); // DEBUG
   mapp1 = Part1 +'_D+0.gif'
   //alert("mapp1 : "+mapp1) // DEBUG
   mapp2 = Part1 +'_D+1.gif'
   mapp3 = Part1 +'_D+2.gif'
   document.Ima0.src = mapp0
   document.Ima1.src = mapp1
   document.Ima2.src = mapp2
   //alert(mapp2)   
   //document.write(mapp2)
   document.Ima3.src = mapp3
   
  }

function ChangeMaps_bilen_Stat(Repertoire,spec,type2) 
  {
   var type1    = TestExisteChamps ('TYPE1')
   //type1    = document.ChooseType.TYPE1.options[document.ChooseType.TYPE1.selectedIndex].value
   image='scores-CCM-'+type1+'_'+type2+'00-23_FRANCE_'+spec+'.gif'
   image1   =Repertoire+image
//   document.write(image1)
   document.Ima0.src = image1
  } 

/*function ChangeMaps_serie_temp(Repertoire,species,type)
  {//alert('555')
   day   = TestExisteChamps ('Day')
   month = TestExisteChamps ('Month')
   //year  = TestExisteChamps ('Year')  
   year  = TestExisteChamps ('ANNEE')
   today_date = year+month+day
   //alert(year)
   var indicateurstat = TestExisteChamps ('INDIC_STAT')
   var seuil          = TestExisteChamps ('SEUIL')
   var model          = TestExisteChamps ('Day')
   var typestation    = TestExisteChamps ('TYPA_STAT')
   var tog            = TestExisteChamps ('Day')

   Iyear  =parseInt(year,10);
   Imonth =parseInt(month,10);
   Iday   =parseInt(day,10)   ;

   if (Iday<10){Iday ='0'+Iday ;}
   if (Imonth<10){Imonth ='0'+Imonth ;}

   var tog = TestExisteChamps ('Tog')
   var model = TestExisteChamps ('Model')
   //alert(Repertoire+species+type)
   AfficheCarteVerif(Repertoire,species,indicateurstat,seuil,model,typestation,tog,day,month,year)

   document.form.Model.value=model //? cause de l'agrandissement
  }   */


  function EnregiComment()
  {
   Champs=document.formcommentaire_aasqa.ESTIMATION
   var Nombre= Champs.length ;
   

   var ValChamps = 0
   //alert(Evaluer+longh)

   if (Nombre>0)
     {for(i = 0; i < Nombre ; i++)
       {
        if(Champs[i].checked == true)
          {ValChamps=Champs[i].value;
           //alert(ValChamps)
           break;
          }
       }
      }

  /* if (ValChamps==0)
      {alert('Vouz devez cocher l\'une des case "Sous Estimée" ou  "Sur Estimée"')
      }
      else{*/
           document.formcommentaire_aasqa.ENVOYER.value='envoyer' ;
           document.formcommentaire_aasqa.submit();
          //}
  }


//affiche carte prévision privé
function AfficheCartePP(Repertoire,species,model,tog,day,month,year,today_date)
{
   var l,h 
   h=200; l=179;
   
   var int_today_date = parseInt(today_date) 
   var model_origin;
   
   model_origin=model;

	//init var model pour modele CHIMERE pour FranceAdaptStat
	if ((int_today_date>=20070601) && (model=='ASCFM'))
	{
	 model='ASAFM'
	}
	// Nom de cartes pour Modele CHIMERE
	if (today_date>=20060101)
	{
		mapp0   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+0_sma.gif'
		mapp1   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+1_sma.gif'
		mapp2   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+2_sma.gif'
	 } else {
		var d0=donnerdate2(day,month,year,0)
		var d1=donnerdate2(day,month,year,1)
		var d2=donnerdate2(day,month,year,2)
		
		if (model=='CFM')
		{
			model='AWM'
		}
		mapp0   = '/simulation'+d0+'/'+species+'_'+model+'_'+tog+'_sma.gif'
		mapp1   = '/simulation/'+d1+'/'+species+'_'+model+'_'+tog+'_sma.gif'
		mapp2   = '/simulation/'+d2+'/'+species+'_'+model+'_'+tog+'_sma.gif'
	}
	// init var model pour MOCAGE si France
	if ((model=='CFM') ||(model=='AFM'))
	{
		model='MOCAF';
	}
	// init var model pour MOCAGE si Europe
	if (model=='AWM'){
		model='MOCAE'; 
	}
	// init var model pour MOCAGE si France-AdaptStat
	if ((model=='ASCFM') || (model=='ASAFM'))
	{
		model='ASMOCAF';
	}
	
	// Nom de cartes pour Modele MOCAGE
	if (today_date>=20060101)
	{
		mapp3   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+0_sma.gif'
		mapp4   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+1_sma.gif'
		mapp5   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+2_sma.gif'
	}else{
		var d0=donnerdate2(day,month,year,0)
		var d1=donnerdate2(day,month,year,1)
		var d2=donnerdate2(day,month,year,2)
		if (model=='CFM')
		{
			model='AWM'                      
		}
		mapp3   = '/simulation/'+d0+'/'+species+'_'+model+'_'+tog+'_sma.gif'
		mapp4   = '/simulation/'+d1+'/'+species+'_'+model+'_'+tog+'_sma.gif'
		mapp5   = '/simulation/'+d2+'/'+species+'_'+model+'_'+tog+'_sma.gif'         
	}

	// init var model pour ARPEGE CHIMERE si Europe
	if (model_origin=='AWM')
	{
		model='AWMA'; 
	}
	// init var model pour ARPEGE CHIMERE si France
	if (model_origin=='AFM'){
		model='AFMA'; 
	}
	// init var model pour ARPEGE CHIMERE si France-AdaptStat
	if (model_origin=='ASCFM'){
		model='ASAFMA'; 
	}

	// Nom de cartes pour Modele ARPEGE/CHIMERE - new 06/09
	if (today_date>=20060101)
	{
		mapp6   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+0_sma.gif'
		mapp7   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+1_sma.gif'
		mapp8   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+2_sma.gif'
	} else{
		var d0=donnerdate2(day,month,year,0)
		var d1=donnerdate2(day,month,year,1)
		var d2=donnerdate2(day,month,year,2)
		
		if (model=='CFM')
		{
			model='AWM'
		}
		mapp6   = '/simulation/'+d0+'/'+species+'_'+model+'_'+tog+'_sma.gif'
		mapp7   = '/simulation/'+d1+'/'+species+'_'+model+'_'+tog+'_sma.gif'
		mapp8   = '/simulation/'+d2+'/'+species+'_'+model+'_'+tog+'_sma.gif'
	}
//	console.debug("model_origin avant carte ENSEMBLE : %s",model_origin);
	// init var model pour ENSEMBLE si Europe
	   if (model_origin=='AWM')
	   {
			model='EnsEUR_RRD'; 
		}
		// init var model pour ENSEMBLE si France
	   if (model_origin=='AFM'){
			model='EnsFRA_RRD'; 
		}
		// init var model pour ENSEMBLE si France-AdaptStat
		if (model_origin=='ASCFM'){
			model='ASEnsFRA_RRD'; 
		}
	
	// Nom de cartes pour le modele ENSEMBLE
	mapp9   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+0_sma.gif'
	mapp10   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+1_sma.gif'
	mapp11   = Repertoire+today_date+'/'+species+'_'+model+'_'+tog+'_D+2_sma.gif'
	
	// MaJ des cartes dans la page
	document.Ima0.src = mapp0;
	document.Ima1.src = mapp1;
	document.Ima2.src = mapp2;
	document.Ima3.src = mapp3;
	document.Ima4.src = mapp4;
	document.Ima5.src = mapp5;
	document.Ima6.src = mapp6;
	document.Ima7.src = mapp7;
	document.Ima8.src = mapp8;
	document.Ima9.src = mapp9;
	document.Ima10.src = mapp10;
	document.Ima11.src = mapp11;
   
   var lar= document.Ima0.width;
/*
    console.log("largeur : %d",lar);
   console.info("lar : "+lar);
   console.warn("lar : "+lar);
   console.error("lar : "+lar);
   console.debug("lar : "+lar);
*/
   var haut= document.Ima0.height; 
//   console.log(haut);
   
   /* on fixe la largeur de la page à	 650*/
   l=640/4; // la largeur d'une image
   //rap=lar/l
   h=haut/(lar/l); //applique à la hauteur originale, le même ratio qu'a la largeur
   // hauteur largeur modele CHIMERE
   document.Ima0.height=h
   document.Ima0.width=l
   document.Ima1.height=h
   document.Ima1.width=l
   document.Ima2.height=h
   document.Ima2.width=l
   // hauteur largeur modele MOCAGE
   document.Ima3.height=h
   document.Ima3.width=l
   document.Ima4.height=h
   document.Ima4.width=l
   document.Ima5.height=h
   document.Ima5.width=l
   // hauteur largeur modele ARPEGE/CHIMERE
   document.Ima6.height=h
   document.Ima6.width=l
   document.Ima7.height=h
   document.Ima7.width=l
   document.Ima8.height=h
   document.Ima8.width=l
   // hauteur largeur modele ENSEMBLE
   document.Ima9.height=h
   document.Ima9.width=l
   document.Ima10.height=h
   document.Ima10.width=l
   document.Ima11.height=h
   document.Ima11.width=l

} // fct AfficheCartePP

//affiche carte (prévision) privé AOT ; new 03/10
function AfficheCartePP_AOT(Repertoire,species,model,tog,day,month,year,today_date)
{
   var l,h 
   var int_today_date = parseInt(today_date) 
   var model_origin;
   
   model_origin=model;

    mapp0   = Repertoire+today_date+'/'+species+'_SAT1_'+model+'_D-1_sma.gif'
    mapp1   = Repertoire+today_date+'/'+species+'_SAT2_'+model+'_D-1_sma.gif'
    mapp2   = Repertoire+today_date+'/'+species+'_SAT3_'+model+'_D-1_sma.gif'
    mapp3   = Repertoire+today_date+'/'+species+'_SAT1_POLDER_D-1_sma.gif'
    mapp4   = Repertoire+today_date+'/'+species+'_SAT2_MODIS_D-1_sma.gif'
    mapp5   = Repertoire+today_date+'/'+species+'_SAT3_OMI_D-1_sma.gif'
	
	// MaJ des cartes dans la page
	document.Ima0.src = mapp0;
	document.Ima1.src = mapp1;
	document.Ima2.src = mapp2;
	document.Ima3.src = mapp3;
	document.Ima4.src = mapp4;
	document.Ima5.src = mapp5;
   
   var lar= document.Ima0.width;
   var haut= document.Ima0.height; 
   /* on fixe la largeur de la page à	 650*/
   l=291; // la largeur d'une image
   //rap=lar/l
   h=300; //applique à la hauteur originale, le même ratio qu'a la largeur
   // hauteur largeur modele CHIMERE
   document.Ima0.height=h
   document.Ima0.width=l
   document.Ima1.height=h
   document.Ima1.width=l
   document.Ima2.height=h
   document.Ima2.width=l
   // hauteur largeur Satellites
   document.Ima3.height=h
   document.Ima3.width=l
   document.Ima4.height=h
   document.Ima4.width=l
   document.Ima5.height=h
   document.Ima5.width=l

} // fct AfficheCartePPAOT

// modifie lien video simulation et son titre
// si video n'existe pas masquer le <div>
// si video manquant mettre startimage
// species=polluant ; model=domaine
function MaJ_VideoSimulation(species,model) {
	
	switch(species) {
		case "DESDUST":
			//iln'y a pas de div video pour poussières;
			return; // quitte fct
			break;
		default:
			polluant = species;
			break;
	} // switch
	switch(model) {
		case "CFM":
			domaine ="France";
			document.getElementById("divVideo").style.visibility="visible"; // affiche objet video
			break;
		case "AFM":
			domaine ="France";
			document.getElementById("divVideo").style.visibility="visible"; // affiche objet video
			break;
		case "AWM":
			domaine ="Europe";
			document.getElementById("divVideo").style.visibility="visible"; // affiche objet video
			break;
		case "MOCAG":
			domaine ="Global";
			// pas de video pour global
			document.getElementById("divVideo").style.visibility="hidden"; // masque objet video
			break;
		default:
			domaine = species;
			break;
	} // switch
	
	//video = "http://www.prevair.org/animations/"+polluant+"_"+domaine+"_Heure_4j.flv";
	video = "http://www.prevair.org/animations/"+polluant+"_"+domaine+"_Heure_4j.flv";
	titre_video = "Simulation\ndes concentrations\n$"+polluant+"\nsur "+domaine+".\n\nAnimation de la veille\njusqu'au surlendemain";
	
	// change fichier video suivi d'un play et stop pour rafraichir image
	document.getElementById("myFlash").SetVariable("player:jsUrl", video);
	document.getElementById("myFlash").SetVariable("player:jsPlay", "");
	document.getElementById("myFlash").SetVariable("player:jsStop", "");
} // fct MaJ_VideoSimulation

// source : http://www.webdeveloper.com/forum/showthread.php?t=165298
function isThere(url) {
	var req= getHTTPObject(); // XMLHttpRequest object
	try {
		req.open("GET", url, false);
		req.send(null);		
		return req.status== 200 ? true : false;
	}
	catch (er) {
		return false;
	}
} // fct isThere

/* Fonction  generique XmlHTTPRequest */
function getHTTPObject() {
  var xmlhttp;
  if(window.XMLHttpRequest) // Firefox
    xmlhttp = new XMLHttpRequest();
  else if(window.ActiveXObject) // Internet Explorer
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  else { // XMLHttpRequest non supporté par le navigateur
       xmlhttp = false;
       //alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...\nChangez de navigateur.");
  }
  return xmlhttp;
} // getHTTPObject
