function verif_date(f,nom) {
	
	annee = eval(f+'.annee_'+nom+'.options['+f+'.annee_'+nom+'.selectedIndex].value');
	mois = eval(f+'.mois_'+nom+'.options['+f+'.mois_'+nom+'.selectedIndex].value');
	les_jours = eval(f+'.jour_'+nom);

	if( (mois == 02) || (mois == 04) || (mois == 06) || (mois == 09) || (mois == 11) ){
		les_jours.options[31].value = "";
		les_jours.options[31].text = "--";
	}
	else{
		les_jours.options[31].value = "31";
		les_jours.options[31].text = "31";
	}


	if(mois == 02){
		les_jours.options[30].value = "";
		les_jours.options[30].text = "--";
	}
	else{
		les_jours.options[30].value = "30";
		les_jours.options[30].text = "30";
	}

	if((annee % 4) == 0){
		les_jours.options[29].value = "29";
		les_jours.options[29].text = "29";
	}
	else{
		if(mois == 02){
			les_jours.options[29].value = "";
			les_jours.options[29].text = "--";
		}
		else{
			les_jours.options[29].value = "29";
			les_jours.options[29].text = "29";
		}
	}
	
}

function exist_date(f,nom,message){
	annee = eval(f+'.annee_'+nom);
	mois = eval(f+'.mois_'+nom);
	jour = eval(f+'.jour_'+nom);
	ok=0;
	if (jour.options[jour.selectedIndex].text=="--"){
		alert(message);
		jour.focus();
		ok=1;
	}
	if (mois.options[mois.selectedIndex].text=="--"){
		alert(message);
		mois.focus();
		ok=1;
	}
	if (annee.options[annee.selectedIndex].text=="--"){
		alert(message);
		annee.focus();
		ok=1;
	}
	
	return ok;	
	
}

function verif_champ_text(f,nom,message){
	annee = eval('document.forms[0].annee_'+nom);
	mois = eval('document.forms[0].mois_'+nom);
	jour = eval('document.forms[0].jour_'+nom);
	ok=0;
	if (jour.options[jour.selectedIndex].text=="--"){
		alert(message);
		jour.focus();
		ok=1;
	}
	if (mois.options[mois.selectedIndex].text=="--"){
		alert(message);
		mois.focus();
		ok=1;
	}
	if (annee.options[annee.selectedIndex].text=="--"){
		alert(message);
		annee.focus();
		ok=1;
	}
	
	return ok;
	
}



function verif_nombre(zone_texte){
		if (isNaN(zone_texte.value)) {
			return false;
		}
	return true;
}

function vide_blanc(obj_ch)
{
if (obj_ch.value.length==1) {


	 	i=obj_ch.value.length;
} else {
 		i=obj_ch.value.length-1;
}


 nb=0;

 while ( (obj_ch.value.charAt(i) ==" ") && (i>0) )
 {
 nb++;
 i--; 
 }
 if(i>0) 
 obj_ch.value= obj_ch.value.substring(0,obj_ch.value.length-nb);
 else obj_ch.value=""
 
 i=0;
 nb=obj_ch.value.length;
 
 while ( (obj_ch.value.charAt(i) ==" ") && (i<nb) )
 {
 i++; 
 }
 if(i<nb) 
 obj_ch.value= obj_ch.value.substring(i,obj_ch.value.length);
 else obj_ch.value=""
}


function ReplaceWord(str) {
	var ms = "-" + "	 " + " " + " "  + " " + " " + " " + " "  + " " + " "  + " " + " " + " " + " " + " " + " "  + " " + " " + " " + " " + " "  + " " + " " + " " + " " + " "  + " " + " " + " " + " " 
	var msi = 0
	var i,c,rs,ts 
	while (msi < ms.length) {
		c = ms.charAt(msi)
		rs = ms.substring(++msi, msi +1)
		msi += 1
		i = 0
		while (true) { 
			i = str.indexOf(c, i)
			if (i == -1) break
			ts = str.substring(0, i)
			str = ts + rs + str.substring(++i, str.length)
		}
	}
	return str
}





// Fonction JavaScript qui transforme les carateres ascii dont le code > 128 en code html
function HtmlCode(str)
{
        i = 0;
        while (i < str.length)
        {
                ascii = str.charCodeAt(i);
                if (ascii > 128)
                        str = str.substring(0, i) + '&#' + ascii + ';' + str.substring(i+1, str.length);
          i++;
        }
        return ReplaceWord(str);
}

//Encode en HTML touts les champs d'un formaulaire
//en utilisant la fonction HtmlCode ci-dessus
function FormHTMLEncode(formulaire) {
    for (fhe_i=0; fhe_i<formulaire.elements.length; fhe_i++) {
       if (formulaire.elements[fhe_i].type!="select-one") {
          formulaire.elements[fhe_i].value = HtmlCode(formulaire.elements[fhe_i].value);
       }
       else {
          for (fhe_j=0; fhe_j<formulaire.elements[fhe_i].options.length; fhe_j++) {
               formulaire.elements[fhe_i].options[fhe_j].value = HtmlCode(formulaire.elements[fhe_i].options[fhe_j].value);
          }
      }
   }
}

// redimensionne les popup à l'ouverture
function new_size() {
	var hauteur;
	var largeur;
	var version=navigator.appVersion;
	var haut_ecran=window.screen.height;
	//var larg_ecran=window.screen.width;

	if (version.lastIndexOf('Win') != -1) {
		if (navigator.appName=="Netscape") {
			hauteur=document.height;
			if (haut_ecran>=768)
			{
				if (hauteur>=768) {hauteur=708}
			} else {
				if (hauteur>=600) {hauteur=540}
			}
			largeur=document.width;
			window.setResizable(true);
			window.resizeTo(largeur,hauteur);
			window.setResizable(false);
		} else {
			hauteur=window.document.body.scrollHeight+29+16;
			if (haut_ecran>=768)
			{
				if (hauteur>=768) {hauteur=738}
			} else {
				if (hauteur>=600) {hauteur=570}
			}
			largeur=window.document.body.scrollWidth+10+16;
			window.resizeTo(largeur,hauteur);
		}
	} else {
		if (navigator.appName=="Netscape") {
			hauteur=document.height;
			if (haut_ecran>=768)
			{
				if (hauteur>=768) {hauteur=708}
			} else {
				if (hauteur>=600) {hauteur=540}
			}
			largeur=document.width;
			window.setResizable(true);
			window.resizeTo(largeur,hauteur);
			window.setResizable(false);
		} else {
			hauteur=document.height;
			largeur=document.width;
			window.alert(hauteur + '\n' + largeur);
			window.resizeTo(largeur,hauteur);
		}
	}
}