<!--
function sur2chiffres(n) {
if (n > 9)
return ""+n;
return "0"+n;
}
function isBissextile(annee) {
if ( ((annee % 4 == 0) && ( annee % 100 != 0)) || (annee % 400 == 0) )
  return true;
return false;
}
function dernierJourDuMois(m, a) {
if (m=="02") {
  if (isBissextile(a))
    return "29";
  return "28";
}
if ((m=="04")||(m=="06")||(m=="09")||(m=="11"))
  return "30";
return "31";
}

function getMoisListe(obj) {
var mm = "";
for (var x = 0; x < obj.length; x++)
  if (obj.options[x].selected)
    mm = obj.options[x].value;
return mm;
}
function getAnneeListe(obj) {
var aa = "";
for (var x = 0; x < obj.length; x++)
  if (obj.options[x].selected)
    aa = obj.options[x].value;
return aa;
}
function getMoisDeb(obj) {
var jjmmaa = obj.value;
return jjmmaa.substring(2,4);
}
function getAnneeDeb(obj) {
var jjmmaa = obj.value;
return jjmmaa.substring(4);
}

/* pour graphComparePeriode.php + graphCompareStation.php */
function controleDates() {
var jjmmaa = document.fgraph.dateDeb.value;
aamm=jjmmaa.substring(4)+jjmmaa.substring(2,4);
if (Math.round(aamm) < 199901) {
  alert("Les relevés de la station Météo Frouzins commencent en 1999.\n");
  return false;
}
return true;
}

/* pour graphQuot.php */
function controleDatesParams() {
var jjmmaa = document.fgraph.dateDeb.value;
aamm=jjmmaa.substring(4)+jjmmaa.substring(2,4);
if ( !document.fgraph.isTempe.checked && !document.fgraph.isPrecip.checked &&
     !document.fgraph.isVent.checked && !document.fgraph.isPression.checked ) {
  alert("Il faut sélectionner au moins 1 paramètre.\n");
  return false;
}
if (Math.round(aamm) < 199901) {
  alert("Les relevés de la station Météo Frouzins commencent en 1999.\n");
  return false;
}
if ( (Math.round(aamm) < 200309) && (!document.fgraph.isTempe.checked && !document.fgraph.isPrecip.checked) &&
     (document.fgraph.isVent.checked || document.fgraph.isPression.checked) ) {
  alert("Les relevés de Vent et Pression de la station Météo Frouzins\nne commencent que le 01/09/2003.\n\nVeuillez rectifier la période SVP.\n");
  return false;
}
return true;
}

/* extremes.php */
function controleDatesParams2() {
var jjmmaa = document.fgraph.dateDeb.value;
aamm=jjmmaa.substring(4)+jjmmaa.substring(2,4);
/* if ( !document.fgraph.isTempe.checked && !document.fgraph.isPrecip.checked && !document.fgraph.isHumid.checked &&
     !document.fgraph.isVent.checked && !document.fgraph.isPression.checked ) {
  alert("Il faut s?lectionner au moins 1 param?tre.\n");
  return false;
} */
if (document.fgraph.valeurSeuil.value == "") {
  alert("Vous avez oublié de saisir le seuil!\n");
  document.fgraph.valeurSeuil.focus();
  return false;
}
if (Math.round(aamm) < 199901) {
  alert("Les relevés de la station Météo Frouzins commencent en 1999.\n");
  document.fgraph.dateDeb.focus();
  return false;
}
/* if ( (Math.round(aamm) < 200309) && (!document.fgraph.isTempe.checked && !document.fgraph.isPrecip.checked) &&
     (document.fgraph.isVent.checked || document.fgraph.isHumid.checked || document.fgraph.isPression.checked) ) {
  alert("Les relev?s de Vent, Humidit? et Pression de la station M?t?o Frouzins\nne commencent que le 01/09/2003.\n\nVeuillez rectifier la p?riode SVP.\n");
  return false;
} */
return true;
}

function initDateDeb() {
mm = getMoisListe(document.fgraph.mmois);
aa = getAnneeListe(document.fgraph.aannee);
document.fgraph.dateDeb.value = "01" + mm + aa;
}
function initDateFin() {
mm = getMoisListe(document.fgraph.mmois2);
aa = getAnneeListe(document.fgraph.aannee2);
document.fgraph.dateFin.value = dernierJourDuMois(mm,aa) + mm + aa;
}
function initDates() {
mm = getMoisListe(document.fgraph.mmois);
aa = getAnneeListe(document.fgraph.aannee);
document.fgraph.dateDeb.value = "01" + mm + aa;
document.fgraph.dateFin.value = dernierJourDuMois(mm,aa) + mm + aa;
}
function initDates2() {
mm = getMoisListe(document.fgraph.mmois2);
aa = getAnneeListe(document.fgraph.aannee2);
document.fgraph.dateDeb2.value = "01" + mm + aa;
document.fgraph.dateFin2.value = dernierJourDuMois(mm,aa) + mm + aa;
}

function changeAnnee(obj, n) {
max = obj.options.length;
cours = obj.options.selectedIndex;
if (n > 0) {
  if (cours < max-1)
    obj.options.selectedIndex++;
}
else if (n < 0) {
  if (cours > 0)
    obj.options.selectedIndex--;
} }

function changeMois(n, deuxDate) {
// alert("        deuxDate:"+deuxDate);
mm = getMoisDeb(document.fgraph.dateDeb);
aa = getAnneeDeb(document.fgraph.dateDeb);
m = Math.round(mm) + n;
a = Math.round(aa);
if (m == 13) {
  m = 1;
  a++;
}
else if (m == 0) {
  m = 12;
  a--;
}
if ((n < 0) && (a == 1998)) {
    alert("Pas plus loin !\nLes mesures commencent en 1999.\n");
    return;
}
mm = sur2chiffres(m);
aa = "" + a;
document.fgraph.dateDeb.value = "01" + mm + aa;
if (deuxDate)
  document.fgraph.dateFin.value = dernierJourDuMois(mm,aa) + mm + aa;
document.fgraph.mmois.options.selectedIndex=m-1;
document.fgraph.aannee.options.selectedIndex=a-1999;
}

function changeMois2(n, deuxDate) {
if (deuxDate) {
  mm = getMoisDeb(document.fgraph.dateDeb2);
  aa = getAnneeDeb(document.fgraph.dateDeb2);
}
else {
  mm = getMoisDeb(document.fgraph.dateFin);
  aa = getAnneeDeb(document.fgraph.dateFin);
}
m = Math.round(mm) + n;
a = Math.round(aa);
if (m == 13) {
  m = 1;
  a++;
}
else if (m == 0) {
  m = 12;
  a--;
}
mm = sur2chiffres(m);
aa = "" + a;
if (deuxDate) {
  document.fgraph.dateDeb2.value = "01" + mm + aa;
  document.fgraph.dateFin2.value = dernierJourDuMois(mm,aa) + mm + aa;
} else {
  document.fgraph.dateFin.value = dernierJourDuMois(mm,aa) + mm + aa;
}
document.fgraph.mmois2.options.selectedIndex=m-1;
document.fgraph.aannee2.options.selectedIndex=a-1999;
}

function initUnite(param) {
if (param.value.charAt(0) == 't')
  document.fgraph.unite.value="?C";
else if (param.value.charAt(0) == 'r')
  document.fgraph.unite.value="mm";
else if (param.value.charAt(0) == 'f')
  document.fgraph.unite.value="km/h";
else if (param.value.charAt(0) == 'u')
  document.fgraph.unite.value="%";
else if (param.value.charAt(0) == 'p')
  document.fgraph.unite.value="hPa";
else
  document.fgraph.unite.value="?";
}
// -->

