// index.js 
// copyright http://meteo.deltafox.net

function coucouBill() {  if (navigator.appName.substring(0,9) == "Microsoft")         
// pour les fonctions non prises en compte par IE...  
  {  alert ("Attention... vous utilisez un navigateur de Bill Gates qui ne respecte pas les standards du Web ! Faites un reload manuel (CTRL + R) pour avoir les photos satellites à jour. Pour avoir accès aux cartes personnalisées, utilisez Firefox, Mozilla ou tout autre navigateur 100% compatible W3C... vous pouvez les télécharger gratuitement sur le site http://frenchmozilla.org");
  }
};

function DatumTxtSondage(Retard) {    
// pour sondage réel  
  ModelDelayHours = 1;
  Datum = new Date();
  Datum.setTime(Datum.getTime() - Retard * 86400000 + Datum.getTimezoneOffset() * 60000 - ModelDelayHours * 3600000);
  var Res = new Array("","","","");
  var Day = Datum.getDate();
  if (Day == 0) Day = 1;
  if (Day < 10) Res[0] = "0" + String(Day) + "00";
  if (Day >= 10) Res[0] = String(Day) + "00";
  if (Day < 10) Res[1] = "0" + String(Day) + "12";
  if (Day >= 10) Res[1] = String(Day) + "12";
  Res[2] = Datum.getMonth() + 1;
  var Year = String(Datum.getFullYear());
  Res[3]+= Year;
  return Res;
};

function DoMap3(which) {      
// pour sondage réel  
  var Retard = which.Retard.options[which.Retard.selectedIndex].value;
  var Res = new Array("","","","");
  Res = DatumTxtSondage(Retard);
  which.STNM.value = document.Sondage2.STNM.options[document.Sondage2.STNM.selectedIndex].value;
  which.FROM.value = Res[0];
  which.TO.value = Res[1];
  which.MONTH.value = Res[2];
  which.YEAR.value = Res[3];
  which.submit();
};

function changeImg(nom,url) {   
// change une image par une autre 
  document.images[nom].src=url;
} 

// fonctions suivantes pour images sat wetter.com

function conversionUTC(date) {   
// convertit une date UTC à la dernière demi-heure en "aaaammddhhmm"  
  var aaaa = String(date.getUTCFullYear());
  var mm = String("0" + (date.getUTCMonth() + 1)).slice(-2);
  var dd = String("0" + date.getUTCDate()).slice(-2);
  var hh = String("0" + date.getUTCHours()).slice(-2);
  var mn = date.getUTCMinutes();
  if (mn >= 30) mn = "30";
  else mn = "00";
  return aaaa + mm + dd + hh + mn;
};

function conversion(date) {   
// convertit une date  à la dernière demi-heure en "aaaammddhhmm"  
  var aaaa = String(date.getFullYear());
  var mm = String("0" + (date.getMonth() + 1)).slice(-2);
  var dd = String("0" + date.getDate()).slice(-2);
  var hh = String("0" + date.getHours()).slice(-2);
  var mn = date.getMinutes();
  if (mn >= 30) mn = "30";
  else mn = "00";
  return aaaa + mm + dd + hh + mn;
};
function conversion2(date) {   
// convertit une date en "aaaammdd"  
  var aaaa = String(date.getFullYear());
  var mm = String("0" + (date.getMonth() + 1)).slice(-2);
  var dd = String("0" + date.getDate()).slice(-2);
  return aaaa + mm + dd;
};
function getWetterCom(type, taille, ani, loc) {  
// ouvre un popup d'animation satellite wettercom  
  var color = "_b";
  var locurl = "METEOSAT";  
  if (!type) type = "ir";
  if (!taille) taille = "l";
  if (!ani) taille = "xl";
  if (!loc) loc = "eur";
// loc = ful, eur, afr, arg, usa, moy, ext ou aus...  
  var car = "width=420,height=740,resizable,scrollbars,left=0,top=0";
  if (taille == "xl") car = "width=740,height=740,resizable,scrollbars,left=280,top=0";
  switch (loc) {
    case "ful":      
      locurl = "METEOSAT-FULL";
      color = "_c";
      type="ir";
      break;
    case "eur":
      locurl = "METEOSAT";
      color = "_c";
      break;
    case "afr":
      locurl = "METEOSAT-AF";
      color = "_b";
      type="ir";
      break;
    case "arg":
      locurl = "GOES-E-SA";
      color = "_b";
      type="ir";
      break;
    case "usa":
      locurl = "GOES-E";
      color = "_b";
      break;
    case "moy":
      locurl = "INDOEX";
      color = "_b";
      break;
    case "ext":
      locurl = "GMSFO";
      color = "_b";
      break;
    case "aus":
      locurl = "GMSAS";
      color = "_b";
      break;
    default:
      locurl = "METEOSAT";
      color = "_c";
      break;
    } // switch   
  var url = "http://www.wetter.com/home/content/DE_sat_" + locurl + "_";
  url += type;
  url += color + "_popup_";
  if (ani)  url +="ani_";
  url += taille;
  url += ".php?date=";
  var last = new Date();
  url += conversion2(last);
  w = open(url, taille, car);
  w.focus();
}

function imgWetterCom() { 
  var source = "http://www.wetter.com/home/img/sat/METEOSAT_ir_c/xl/";
// fichier image en heure UTC 
  var last = new Date();
  last.setTime(last.getTime() - 30 * 60000);
  source += conversionUTC(last) + ".jpg";
  return source;
} // function

// fin index.js
