<!--
function removeAccents(strAccents){ 
	strAccents = strAccents.split(''); 
	strAccentsOut = new Array(); 
	strAccentsLen = strAccents.length; 
	var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; 
	var accentsOut = ['A','A','A','A','A','A','a','a','a','a','a','a','O','O','O','O','O','O','O','o','o','o','o','o','o','E','E','E','E','e','e','e','e','e','C','c','D','I','I','I','I','i','i','i','i','U','U','U','U','u','u','u','u','N','n','S','s','Y','y','y','Z','z'];
	
	for (var y = 0; y < strAccentsLen; y++) {
		if (accents.indexOf(strAccents[y]) != -1) {
			//alert("trouvé : "+strAccents[y]);
			strAccentsOut[y] = accentsOut[accents.indexOf(strAccents[y])];
		}
		else {
			strAccentsOut[y] = strAccents[y]; 
		}
	}

	strAccentsOut = strAccentsOut.join(''); 
	return strAccentsOut;
} 
	
	
/*****************
*      AJAX      *
******************/   
var arrayXhr = new Array () ;
function GetX (indice) {
    if(window.XMLHttpRequest) // Firefox et autres
        arrayXhr[indice] = new XMLHttpRequest();
    else if(window.ActiveXObject){ // Internet Explorer
        try {
            arrayXhr[indice] = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            arrayXhr[indice] = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    else { // XMLHttpRequest non support\351 par le navigateur
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
        arrayXhr[indice] = false;
    }
}


/*
function setActiveStyleSheet(title) {
	var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}
*/


function imprimer() {
    window.print();
}

function Trim(chaine) {
    var res = chaine;
    res = res.replace(/^\s+/, "");
    res = res.replace(/\s+$/, "");
    return res;
}

function TestChampText(champ, nom, langue) {
	nom = "'" + nom + "'";

    if (Trim(champ.value) == "") {
        if (langue == "fr") alert("Le champ " + nom + " est vide.");
        else alert("Field " + nom + " is empty.");
        try {
            champ.focus();
            champ.select();
        } catch (e) {}
        return false;
    }

    return true;
}

function TestChampEmail(champ, langue) {
	if (Trim(champ.value) == "") {
		if (langue == "fr") alert("Le champ de l'adresse email doit \352tre rempli.");
		else alert("The field of address email must be filled.");
		try {
            champ.focus();
            champ.select();
		} catch (e) {}
        return false;

	} else {
	
		var regEmail = /^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/;
		var OK = false;
		if(champ.value.toUpperCase().match(regEmail)){
			OK = true;
		}
		if (!OK) {
			if (langue == "fr") alert("V\351rifiez l\'adresse email,\nelle ne semble pas valide.");
			else alert("Check address email,\nit does not seem valid.");
			try {
			    champ.focus();
			    champ.select();
			} catch (e) {}
			return false;
		}
	}
	
	return true;
}

function TestComboBox(champ, nom, langue) {
	nom = "'" + nom + "'";
	
	if(champ.value==0 || Trim(champ.value)=="") {
		if (langue == "fr") alert("Le champ " + nom + " n'est pas renseign\351.");
        else alert("Field " + nom + " is not filled.");
        try {
            champ.focus();
        } catch (e) {}
        return false;
	}
	return true;
}

function TestComboBoxMultiple(champ, nom, langue) {
	nom = "'" + nom + "'";
	
	if(champ.length<=0) {
		if (langue == "fr") alert("Le champ " + nom + " n'est pas renseign\351.");
        else alert("Field " + nom + " is not filled.");
        try {
            champ.focus();
        } catch (e) {}
        return false;
	}
	return true;
}

function TestCheckBox(champ, nom, nb, langue) {
	var i, tmp;
	
	nom = "'" + nom + "'";
	tmp = false;
	for(i=0;i<nb;i++) {
		if(champ[i].checked) tmp = true;
	}
	if(!(tmp)) {
		if (langue == "fr") alert("Le champ " + nom + " n'est pas renseign\351.");
        else alert("Field " + nom + " is not filled.");
        return false;
	}
	return true;
}

function RadioValue(obj) {
	for(i=0;i<=obj.length-1;i++) {
		if(obj[i].checked)
			return(obj[i].value);
	}
	return "";
}

function fenetreCent(url,nom,largeur,hauteur,options) {
	var haut=(screen.height-hauteur)/2;
	var gauche=(screen.width-largeur)/2;
	fencent=window.open(url,nom,"top="+haut+",left="+gauche+",width="+largeur+",height="+hauteur+","+options);
}


// JD le 28/09/2009 !
// Fonctions pour contrôler la saisie de montant (avec décimale virgule), nombre entier et date

function verif_montant(champ)
{
 //alert(champ.value);

 var chiffres = new RegExp("[0-9\,]"); /* Modifier pour : var chiffres = new RegExp("[0-9]"); */
 var verif;
 var points = 0;
 var point = ",";  /* Le point décimal est la , (virgule) */

 for(x = 0; x < champ.value.length; x++)
 {
  verif = chiffres.test(champ.value.charAt(x));
  if(champ.value.charAt(x) == point ){points++;}
  if(points > 1){verif = false; points = 1;} 
  if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
 }

}


function verif_nombre(champ)
{
 var chiffres = new RegExp("[0-9]");  // Pas de point saisissable (contrairement à verif_montant)
 var verif;

 for(x = 0; x < champ.value.length; x++)
 {
  verif = chiffres.test(champ.value.charAt(x));
  if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
 }

}


function verif_date(champ)
{
 var chiffres = new RegExp("[0-9\/]");
 var verif;
 var seps = 0;
 var sep = "/";  /* Le spéarateur est le / (slash) */

 for(x = 0; x < champ.value.length; x++)
 {
  verif = chiffres.test(champ.value.charAt(x));
  if(champ.value.charAt(x) == sep ){seps++;}
  if(seps > 2){verif = false; seps = 2;} 
  if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
 }

}




function ValidDate(mdate,rb,i1,i2)
{
// JD : la saisie de la date n'est pas obligatoire !
if (mdate == "") return (true);

//CETTE FONCTION PERMET :
// CONTROLE LA VALIDITEE DE LA DATE SAISIE
// LA DATE PEUT ETRE SAISIE SOUS TOUTES FORMES DS L ORDRE JMA
// ON CONTROLE EGALEMENT LA VALIDITE PAR RAPPORT A UNE FOURCHETTE DE JOUR FOURNIS EN PARRAMETRE

// DEFINITION DES VARIABLES
var jjs = 86400000
var datej = new Date();
var dateMaxi = datej.getTime() + (jjs*i2)
var dateMini = datej.getTime() - (jjs*i1)
var dateMaxiTxt = new Date(dateMaxi);
var dateMiniTxt = new Date(dateMini);

var OLDmessretour = "La date saisie est incorrecte\n(Veuillez saisir sous la forme JJMMAA ou JJ/MM/AA)\nelle doit \352tre comprise entre le: "
+ dateMiniTxt.getDate() +'/' + (dateMiniTxt.getMonth()+1)+'/'+dateMiniTxt.getYear() + ' et le '
+ dateMaxiTxt.getDate() +'/' + (dateMaxiTxt.getMonth()+1)+'/'+dateMaxiTxt.getYear()

var messretour = "La date saisie est incorrecte\n(Veuillez saisir sous la forme JJMMAA ou JJ/MM/AA)"


// ON SUPPRIME LES SEPARATEURS DANS LA ZONE SAISIE
// LA CHAINE RESTANTE DOIT ETRE NUMERIQUE ET DE LONGUEUR EGALE A 6 OU 8
// --------------------------------------------------------------------
mdate=mdate.replace("/","");
mdate=mdate.replace("/","");
if (mdate.length != 6 && mdate.length != 8)
{alert(messretour);
//rb.value="";
rb.focus();
return (false);
}

if (IsNumeric(mdate) == false)
{alert(messretour);
//rb.value="";
rb.focus();
return (false);
}

// ON RECONSTITUE UNE DATE AU FORMAT JJ/MM/AAAA
// -------------------------------------------
var jj = mdate.substring(0,2);
var mm = mdate.substring(2,4);
if (mdate.length == 8) {var aaaa = mdate.substring(4,8);}
if (mdate.length == 6) {
if (mdate.substring(4,6) < '50') {var aaaa = '20' + mdate.substring(4,6);}
if (mdate.substring(4,6) >= '50') {var aaaa = '19' + mdate.substring(4,6);}
}
var mdatenew = jj+'/'+mm+'/'+aaaa;

// ON CONTROLE LA COHERENCE DE LA DATE
// -----------------------------------

if (isDateValid(mdatenew) == false)
{
alert(messretour);
//rb.value="";
rb.focus();
return false;
}

// ON CONTROLE LA COHERENCE DE LA DATE PAR RAPPORT OU BORNE MINI ET MAXI FOURNIE
// -----------------------------------------------------------------------------
var dates = new Date(aaaa,mm-1,jj);
var datesaisie =dates.getTime();

if (datesaisie >= dateMaxi || datesaisie <= dateMini)
{
alert(messretour);
//rb.value="";
rb.focus();
return false;
}
rb.value = mdatenew
}


function IsNumeric(x)
{
var checkOK = "0123456789-";
var checkStr = x;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
allNum += ch;
}
if (!allValid)
{
return (false);
}
return (true);

}
function isDateValid(chaineDate) {

// CONTROLE LA VALIDITE D UN CHAMP DATE
//alert(chaineDate);
if (chaineDate == "") return false;
var ladate = (chaineDate).split("/");

if ((ladate.length != 3) || isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2]))) return false;

var unedate = new Date(eval(ladate[2]),eval(ladate[1])-1,eval(ladate[0]));

var annee = unedate.getYear();
if ((Math.abs(annee)+"").length < 4) annee = annee + 1900;
//return(true);
return ((unedate.getDate() == eval(ladate[0])) && (unedate.getMonth() == eval(ladate[1])-1) && (annee == eval(ladate[2])))
}



//  End -->



