﻿if ( document.all )
{
	n = 1 ;
	function blink_show()
	{
		blink_tags = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'visible';
		}
		if (n < 5) {
			window.setTimeout( 'blink_hide()', 700 );
			n++;
		}
	}
	function blink_hide()
	{
		blink_tags = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'hidden';
		}
		window.setTimeout( 'blink_show()', 250 );
	}
	window.onload = blink_show;
}

/******************************************/
/*  Verification des champs	de formulaire */
/******************************************/

/*------  Verification du numero SS  --------*/

function isNumeroSS(val)
{
	
	var decremente = 0 ;
	
	if (( val.substring (6,7) == "A")  || ( val.substring (6,7) == "a"))  {
		decremente = -1000000 ;
	}

	if (( val.substring (6,7) == "B") ||  ( val.substring (6,7) == "b")) {
		decremente = -2000000 ;
	}

	
	if ( decremente < 0) {
		lchar = "0"  ;
		var NumeroSS = parseFloat(val.substring (0,5) + val.substring(5,6) + lchar +  val.substring(7,13));
	} else {
		var NumeroSS = parseFloat( val.substring (0,13)) ;
	}

	var NumeroSS = parseFloat(NumeroSS) + decremente ;
	var sortie = true ;

	// longueur incorrecte
	if (val.length !=15) {
			sortie = false ;
	}

	// Test le sexe
	if ( (val.substring(0,1)) != 1 && (val.substring(0,1) != 2))
	{
			sortie = false ;
	}
	
	// Compare la clé 
	var CleSaisie  = val.substring(13);
	var CleBonne=97-(NumeroSS % 97);
	if (CleBonne != CleSaisie) {
		sortie = false;
	}
	return (sortie);
}

/*------ V?rification du code postal --------*/
function isZipCode(val)
	{
	//retourne true si val est un code postal Zip ? 5 chiffres
	var len
	if (val.length == 5)
		len=5 ;
	else
		return false;
	
	var test ="0123456789"
	
	for (var i=0; i < 5 ; i++)
		{
		if (test.indexOf(val.charAt(i)) < 0)
			return false ;
		}
	if (len == 5)
		return true
	}
	

/*------ V?rification du num?ro de t?l?phone --------*/
function isPhoneNumber(val)
	{
	//retourne true si val est un num?ro de t?l?phone au format XX XX XX XX XX
	var test="0123456789" ;
	var temp ;
	var k ;
	var l ;
	var test2 ;
	test2 =true;
	temp="";
	j=0;
	k=val.indexOf(" ",0) ;
	
	if ( k!= -1)
		{ 
		while ( test2 )
			{
				temp=temp + val.substring(j,k)
				j=k+1;
				k=val.indexOf(" ",k+1)		
				if (k == -1) 
				{
				temp= temp + val.substring(j,val.length)
				test2=false;
				}
			}
		}
	else
		temp=val ;
		
	for (var i = 0; i < temp.length; i++)
	 if (test.indexOf(temp.charAt(i)) < 0 )
		return false;
	if (temp.length < 9) 
		return false;
		
	return temp;
	}  

/*------  V?rification de la validit? d'une chaine alphab?tique + caract?res accentu?s--------*/
function IsChaine(val)
	{
	if (typeof(val)=='undefined')
		return false ;
	var test2 = "0123456789azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN-/éèçàîôê'. "
	for(var i=0;i<val.length;i++)
		{
		if (test2.indexOf(val.charAt(i)) < 0)
			return false ;
		}
	return true;
	}

/*------  V?rification du mot de passe -------------------*/
function IsPasse(val)
	{
	if (val.length == 0)
		return false ;
	var test2 = "0123456789azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN"
	for(var i=0;i<val.length;i++)
		{
		if (test2.indexOf(val.charAt(i)) < 0)
			return false ;
		}
	return true;
	}

/*------  V?rification de la validit? d'une chaine alphab?tique --------*/
function isLettre(val)
	{
	if (val.length == 0)
		return false ;
	var test2 = "azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN"
	for(var i=0;i<val.length;i++)
		{
		if (test2.indexOf(val.charAt(i)) < 0)
			return false ;
		}
	return true;
	}

/*------  V?rification de la validit? d'une chaine alphanum?rique --------*/
function isChaineAlphaNumerique(val)
	{
	if (val.length == 0)
		return false ;
	var test2 = "0123456789azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN' "

	for(var i=0;i<val.length;i++)
		{
		
		if (test2.indexOf(val.charAt(i)) < 0)
			return false ;
		}
	return true;
	}

/*------  V?rification de la validit? d'une chaine num?rique d?cimale --------*/
function VerifNumeric(val)
{	
		
	var test1 =".0123456789";
	var test2= ".0123456789";
	var c;
	var decimal=false;
	// alert("VerifNumeric teste la valeur :" + val);
	// le premier caract?re peut-?tre + -. ou un chiffre
	c=test1.indexOf(val.charAt(0));
	//etait ce un s?parateur d?cimal ?
	if (c == 0)
		decimal=true;
	else if (c < 1)
		return false;
		
	// les caract?res suivants peuvent ?tre seulement . ou un chiffre, mais un seule point d?cimal est permis
	for (var i=1; i < val.length;i++)
		{
		//alerte(val.charAt(i))
		c = test2.indexOf(val.charAt(i));
		//alerte(c)
		if (c < 0)
			return false;
		else
			if(c == 0)
				{
				if (decimal)
					return false;
				else
					decimal=true;
				}
		}
	return true;
}


/*------  V?rification de la validit? d'une chaine num?rique enti?re--------*/
function VerifInteger(val)
{	
	
	var test ="0123456789";		
	// les caract?res suivants peuvent ?tre seulement . ou un chiffre, mais un seule point d?cimal est permis
	for (var i=0; i < val.length;i++)
		{
		//alert('val=' + val.charAt(i));
		 
		if (test.indexOf(val.charAt(i)) < 0)
			return false;
		}
	return true;
}

/*------  V?rification de la validit? d'un num?ro d'URSSAF --------*/
function isNumeroURSSAF(val)
{
if (!VerifInteger(val))
	return false;
 if( val.length < 10 || val.length > 18)
	return false;
 return true;
}


/*------  V?rification des espaces  --------*/
function isBlanck(str)
{
	var i=0;
	while (str.charAt(str.length - 1)== " ")
			{
			str=str.substring(0,str.length-1);			
			}
		
	while (str.charAt(i)== " ")
			{
			str=str.substring(i+1,str.length);
			i=i+1			
			}
	return i;
}

/*------  V?rification du num?ro de Siren  --------*/

  function EstSirenValide(siren) {
    var estValide;
    if ( (siren.length != 9) || (isNaN(siren)) )
      estValide = false;
    else {
      // Donc le SIREN est un num?rique ? 9 chiffres
      var somme = 0;
      var tmp;
      for (var cpt = 0; cpt<siren.length; cpt++) {
        if ((cpt % 2) == 1) { // Les positions paires : 2?me, 4?me, 6?me et 8?me chiffre
          tmp = siren.charAt(cpt) * 2; // On le multiplie par 2
          if (tmp > 9) 
            tmp -= 9;  // Si le r?sultat est sup?rieur ? 9, on lui soustrait 9
        }
        else
          tmp = siren.charAt(cpt);
        somme += parseInt(tmp);
      }
      if ((somme % 10) == 0)
        estValide = true;  // Si la somme est un multiple de 10 alors le SIREN est valide 
      else
        estValide = false;
    }
    return estValide;
  }


/*------  V?rification du num?ro de Siret  --------*/

function IsSiret(val)
	{	
		var i,j,k,maxLen,valeur,car;
		var valide=true;

		
		var len=val.length;

		switch (len){
			case 14:
				maxLen = 14;break;
			default:
				maxLen = 14;break;}
		valeur = 0;
		if (len < maxLen)
		{
			valide=false;
		}
		else
		{
			for (i = maxLen - 1; i >= 0; i--)
			{
				car = val.charAt(i);
				if (!isNaN(parseInt(car)))
				{
					if (i < len)
					{
						k = maxLen - i;
						if (car >= '1' && car <= '9')
						{
							j = car - '0';
							if ((k % 2) == 0)
								valeur = (j > 4 ? (valeur + 1 + ((j * 2) - 10)) : (valeur + (j * 2)));
							else
								valeur += j;
						}
					}
				}
				else
				{
					valide=false;
				}
			}
			if ((valeur % 10)!=0)
				valide=false;
		}
		if (valide==false){return false;}
		return true;			
	
	}

/*------  V?rification du code APE  --------*/
function isCodeAPE(val)
	{
	var len ;
	if (val.length == 5)
		len=5 ;
	else
		return false;
	
	var test ="0123456789"
	
	for (var i=0; i < 4 ; i++)
		{
		if (test.indexOf(val.charAt(i)) < 0)
			return false ;
		}
	var test2 = "azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN0123456789"
	if (test2.indexOf(val.charAt(4)) < 0)
		return false ;
	return true;
	
	}
	
/*------  V?rification du champ email  --------*/
function isMail(emailAddr)
{
	// Cette fonction vérifie la bon format d'une adresse e-mail.
	// Comme :
	// user@domain.com ou user.perso@domain.com
	
	var i;
	
	// Recherche de @
	i = emailAddr.indexOf("@");
	if (i == -1) {
		return false;
	}
	
	// Séparation du nom de l'utilisateur et du nom de domaine.
	var username = emailAddr.substring(0, i);
	var domain = emailAddr.substring(i + 1, emailAddr.length)

	// Recherche des espaces au début du nom de l'utilisateur.
	i = 0;
	while ((username.substring(i, i + 1) == " ") && (i < username.length)) {
		i++;
	}
	// Les enlève s'il en trouve.
	if (i > 0) {
		username = username.substring(i, username.length);
	}

	// Recherche d'espaces à la fin du nom de domaine.
	i = domain.length - 1;
	while ((domain.substring(i, i + 1) == " ") && (i >= 0)) {
		i--;
	}
	// Les enlève s'il en trouve.
	if (i < (domain.length - 1)) {
		domain = domain.substring(0, i + 1);
	}

	// Vérifie que le nom de l'utilisateur et du domaine ne soit pas vide.
	if ((username == "") || (domain == "")) {
		return false;
	}
	
	// Vérifie s'il n'y a pas de caractères interdits dans le nom de l'utilisateur.
	var ch;
	for (i = 0; i < username.length; i++) {
		ch = (username.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}
	
	// Vérifie s'il n'y a pas de caractères interdits dans le nom de domaine
	for (i = 0; i < domain.length; i++) {
		ch = (domain.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}

// Ajouter ci-dessous de nouveaux noms de domaine.
// Voir tous les noms de domaine sur http://www.toulouse-renaissance.net/c_outils/c-nom-domaine.htm
//
var aSuffix = new Array("com","net","int","aero","biz","museum","name","info","coop","pro","eu","edu","org","gov","mil","bj","dz","de","ad","be","ca","bf","bi","cm","cf","cg","cd","ci","dj","fr","ga","gp","gf","lu","mg","ml","ma","mq","mr","mc","nc","pf","re","pm","sn","ch","td","tf","tn");
	var bFoundSuffix = false;
	i = 0;
	while (i < aSuffix.length) {
		if (("." + aSuffix[i]) == domain.substring(domain.length - aSuffix[i].length - 1, domain.length)) {
			return true;
		}
		i++;
	}
	// Si le nom de domaine est inconnu  : return false
	return false;
	
}	


/*------  V?rification de la cl? RIB --------*/
function isRIBvalid()
{

	if ( (isRIBvalid.arguments.length>=3) && ( IsPasse(isRIBvalid.arguments[2])) && ( VerifInteger(isRIBvalid.arguments[1])) &&( VerifInteger(isRIBvalid.arguments[0]))  )
		{
		var bqe=isRIBvalid.arguments[0];
		var gui=isRIBvalid.arguments[1];
		var cpt=isRIBvalid.arguments[2].toUpperCase();

                                // Conversion du numero de compte en chiffres
		var tab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		var tab1="123456789123456789234567890123456789".split("");
		
                                while (cpt.match(/\D/) != null)
			cpt=cpt.replace(/\D/, tab1[tab.indexOf(cpt.match(/\D/))]);
		var cp=parseInt	(cpt, 10);

		//Calcul clé RIB
		a=bqe%97;
		a=a*100000+parseInt(gui, 10);
		a=a%97;
		a=a*Math.pow(10, 11) + cp;
		a=a%97
		a=a*100;
		a=a%97
		a=97-a;
		if (isRIBvalid.arguments.length>3)
			return isRIBvalid.arguments[3]==a;
		else
			return a;
		}
	else
		{
		return false;
		}
}


/*------- Arrondi un nombre ? x d?cimales apres la virgule  --------*/
function arrondi_atantdedecimale(valeur,nombre_de_decimale)
{
	var position,newValeur,nvvaleur;
	nvvaleur=valeur;
	valeur=valeur.toString();
	position=valeur.indexOf(".");

	if(position!=-1)
	{
		newValeur=valeur.substring(0,position);
		newValeur=newValeur+valeur.substring(position,position+nombre_de_decimale);
		return newValeur;
	}
	return (nvvaleur);
}

/*------- Formate une date --------*/
function FormatDate(date)
{
		var jour,mois,annee;
		
		jour = date.substring(0,2);
		mois = date.substring(3,5);
		annee = date.substring(6,10);
		date = new Date(annee,mois,jour)
		return(date);
}

/*------- ????????????????????????????????????????  --------*/
function testJourMois(date)
{
	var flag,jour,mois;
	
	jour = date.substring(0,2);
	mois = date.substring(3,5);
	if(jour>31)
		return false;
	if(mois>12)
		return false;
	return true;
}
	
// Date Control JavaScript (C)1997 Cyril Pannetier - La Petite Boutique Java & JavaScript -
// web : http://www.mygale.org/08/pannetie
// e-mail : pannetie@mygale.org
// Ce script est librement utilisable. Merci de ne pas effacer ces commentaires.
function CheckDate(DateData,DateFormat)
 {
	correct = true;
	var test="0123456789/"
	if (DateData.length != 10 )
		return false;
		
	for(var i=0;i<10;i++)
		{
		if (test.indexOf(DateData.charAt(i)) < 0)
			return false ;
		}
		
	if (DateData.charAt(2)!="/" || DateData.charAt(5)!="/")
		return false;
	
	if ( (DateData.length < 11) && (DateData.length > 7) ) {
		if (DateFormat == "FR") {
			j = DateData.substring(0,2);
			m = DateData.substring(3,5);
		}
		else {
			j = DateData.substring(3,5);
			m = DateData.substring(0,2);
		}
	
		a = DateData.substring(6,DateData.length);
		bi = ((parseInt(a) % 4) == 0);
	
		if (  ( (m == "01") || (m == "03") || (m == "05") || (m == "07") || (m == "08") || (m == "10") || (m == "12") ) && ( (Math.round(j) >= 1) && (Math.round(j) <= 31) ) ) {
			correct = true;
		}
		else {
			if (  ( (m == "04") || (m == "06") || (m == "09") || (m == "11") ) && ( (Math.round(j) >= 1) && (Math.round(j) <= 30) ) ) {
				correct = true;
			}
			else {
				if (bi)  {
					correct = (  ( (Math.round(j) >= 1) && (Math.round(j) <= 29) ) && (m == "02") );
				}
				else {
					correct = ( ( (Math.round(j) >= 1) && (Math.round(j) <= 28) ) && (m == "02")  );
				}
			}
		}
	}
	else {
		correct = false;
	}
	
	return correct;
}

<!-- Retourne les jours fériés-->
function JoursFeries (an){ 
  var JourAn = new Date(an, "00", "01"); 
  var FeteTravail = new Date(an, "04", "01"); 
  var Victoire1945 = new Date(an, "04", "08"); 
  var FeteNationale = new Date(an,"06", "14"); 
  var Assomption = new Date(an, "07", "15"); 
  var Toussaint = new Date(an, "10", "01"); 
  var Armistice = new Date(an, "10", "11"); 
  var Noel = new Date(an, "11", "25"); 
  //**var SaintEtienne = new Date(an, "11", "26");**// 
  
  var G = an%19; 
  var C = Math.floor(an/100); 
  var H = (C - Math.floor(C/4) - Math.floor((8*C+13)/25) + 19*G + 15)%30; 
  var I = H - Math.floor(H/28)*(1 - Math.floor(H/28)*Math.floor(29/(H + 1))*Math.floor((21 - G)/11)); 
  var J = (an*1 + Math.floor(an/4) + I + 2 - C + Math.floor(C/4))%7; 
  var L = I - J; 
  var MoisPaques = 3 + Math.floor((L + 40)/44); 
  var JourPaques = L + 28 - 31*Math.floor(MoisPaques/4); 
  var Paques = new Date(an, MoisPaques-1, JourPaques); 
  //**var VendrediSaint = new Date(an, MoisPaques-1, JourPaques-2);**// 
  var LundiPaques = new Date(an, MoisPaques-1, JourPaques+1); 
  var Ascension = new Date(an, MoisPaques-1, JourPaques+39); 
  var Pentecote = new Date(an, MoisPaques-1, JourPaques+49); 
  var LundiPentecote = new Date(an, MoisPaques-1, JourPaques+50); 
  
  //**SaintEtienne et Vendredi Saint sont des fêtes exclusivement**// 
  //**alscacienne. On les ignore dans notre cas.**// 
  return new Array(JourAn, Paques, LundiPaques, FeteTravail, Victoire1945, Ascension, Pentecote, LundiPentecote, FeteNationale, Assomption, Toussaint, Armistice, Noel); 
} 

<!-- Calcul de jours ouvrables
function formatDate(chaine) {
  var ctl = /^(\d\d?)\/(\d\d?)\/(\d\d)(\d\d)?$/;
  var tab = ctl.exec(chaine);
  if (tab.length) {
     this.jour = tab[1];
     this.mois = tab[2] - 1;
     if (tab.length > 4) this.an = (tab[4]) ? tab[3] + tab[4] : 2000 + eval(tab[3]);
     else this.an = 2000 + eval(tab[3]);
     this.OK = true;
  }
  else this.OK = false;
}

function nombreJours(autreDate, jourscp) {
  if (this.OK) {
     var date1 = new Date(this.an, this.mois, this.jour);
     if (autreDate.OK)
        var date2 = new Date(autreDate.an, autreDate.mois, autreDate.jour);
     else return "erreur";
  }
  else return "erreur";
  if (date1.getTime() < date2.getTime())
     return calcJourTravail(date1.getTime(),date2.getTime(), jourscp);
  else  
     return calcJourTravail(date2.getTime(),date1.getTime(), jourscp);
}

<!-- Calcul du jour précédent
function VerifDix(nombre)
{
if (nombre > 9) {
		nouveaunombre = nombre ;
} else {
		nouveaunombre = '0' + nombre;
}

return (nouveaunombre);
}

function JourPrecedent(date) 
{ 

	var currjour = date.substring(0,2); 
    var currmois = date.substring(3,5); 
    var curran = date.substring(6,10); 

	var jour; 
    var mois; 
    var an; 
    var curjour = parseInt(currjour); 
    var curmois = parseInt(currmois); 
    var curan = parseInt(curran); 
    var fev; 
    if (curan%4 == 0 && curan%100 !=0 || curan%400 == 0) { 
        fev = 29; 
    } else { 
        fev = 28; 
    } 
    // Nombre de jours pour chaque mois 
    var nbJours = new Array(31,fev,31,30,31,30,31,31,30,31,30,31); 
    if (curmois == 12) { 
        if (curjour == 1) { 
            an = curan - 1; 
            mois = 12; 
            jour = nbJours[mois-1]; // mois en cours 
        } else { 
            an = curan;             
            jour = nbJours[curmois-2]; // mois précédent 
            mois = curmois; 
        } 
    } else { 
        if (curjour == 1) { 
            an = curan; 
            mois = curmois - 1; 
            jour = nbJours[curmois-2]; // mois précédent 
        } else { 
            jour = curjour - 1; 
            mois = curmois; 
            an = curan; 
        } 
    } 
dateretour = VerifDix(jour) + '/' + VerifDix(mois) + '/' + an ;
return (dateretour); 
} 

function JourSuivant(date) 
{ 
	var currjour = date.substring(0,2); 
    var currmois = date.substring(3,5); 
    var curran = date.substring(6,10); 
    var jour; 
    var mois; 
    var an; 
    var curjour = parseInt(currjour); 
    var curmois = parseInt(currmois); 
    var curan = parseInt(curran); 
    var fev; 
    if (curan%4 == 0 && curan%100 !=0 || curan%400 == 0) { 
        fev = 29; 
    } else { 
        fev = 28; 
    } 
    var nbJours = new Array(31,fev,31,30,31,30,31,31,30,31,30,31); 
    if (curmois == 12) { //décembre 
        if (curjour == nbJours[curmois-1]) { // dernier jour du mois 
            an = curan + 1; 
            mois = 1; 
            jour = 1; 
        } else { 
            an = curan;             
            jour = curjour + 1; 
            mois = curmois; 
        } 
    } else { 
        if (curjour == nbJours[curmois-1]) { 
            an = curan; 
            mois = curmois + 1; 
            jour = 1; // mois précédent 
        } else { 
            jour = curjour + 1; 
            mois = curmois; 
            an = curan; 
        } 
    } 
	
dateretour2 = VerifDix(jour) + '/' + VerifDix(mois) + '/' + an ;
return (dateretour2);
} 

/* Fonction Infos bulles */
var IB=new Object;
var posX=0;posY=0;
var xOffset=10;yOffset=10;
function AffBulle(texte) {
  contenu="<TABLE border=0 cellspacing=0 cellpadding="+IB.NbPixel+"><TR bgcolor='"+IB.ColContour+"'><TD><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='"+IB.ColFond+"'><TR><TD><FONT size='-1' face='arial' color='"+IB.ColTexte+"'>"+texte+"</FONT></TD></TR></TABLE></TD></TR></TABLE>&nbsp;";
  var finalPosX=posX-xOffset;
  if (finalPosX<0) finalPosX=0;
  if (document.layers) {
    document.layers["bulle"].document.write(contenu);
    document.layers["bulle"].document.close();
    document.layers["bulle"].top=posY+yOffset;
    document.layers["bulle"].left=finalPosX;
    document.layers["bulle"].visibility="show";}
  if (document.all) {
    //var f=window.event;
    //doc=document.body.scrollTop;
    bulle.innerHTML=contenu;
    document.all["bulle"].style.top=posY+yOffset;
    document.all["bulle"].style.left=finalPosX;//f.x-xOffset;
    document.all["bulle"].style.visibility="visible";
  }
  //modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
  else if (document.getElementById) {
    document.getElementById("bulle").innerHTML=contenu;
    document.getElementById("bulle").style.top=posY+yOffset;
    document.getElementById("bulle").style.left=finalPosX;
    document.getElementById("bulle").style.visibility="visible";
  }
}
function getMousePos(e) {
  if (document.all) {
  posX=event.x+document.body.scrollLeft; //modifs CL 09/2001 - IE : regrouper l'évènement
  posY=event.y+document.body.scrollTop;
  }
  else {
  posX=e.pageX; //modifs CL 09/2001 - NS6 : celui-ci ne supporte pas e.x et e.y
  posY=e.pageY; 
  }
}
function HideBulle() {
	if (document.layers) {document.layers["bulle"].visibility="hide";}
	if (document.all) {document.all["bulle"].style.visibility="hidden";}
	else if (document.getElementById){document.getElementById("bulle").style.visibility="hidden";}
}

function InitBulle(ColTexte,ColFond,ColContour,NbPixel) {
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
	if (document.layers) {
		window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=getMousePos;
		document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
	}
	if (document.all) {
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
		document.onmousemove=getMousePos;
	}
	//modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
	else if (document.getElementById) {
	        document.onmousemove=getMousePos;
	        document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
	}

}

// Fonctions pour mise en surbrillance des champs de formulaires
var currentlyActiveInputRef = false;
var currentlyActiveInputClassName = false;

function highlightActiveInput()
{
	if(currentlyActiveInputRef){
		currentlyActiveInputRef.className = currentlyActiveInputClassName;
	}
	currentlyActiveInputClassName = this.className;
	this.className = 'inputHighlighted';
	currentlyActiveInputRef = this;
	
	
}

function blurActiveInput()
{
	this.className = currentlyActiveInputClassName;
	
	
}


function initInputHighlightScript()
{
	var tags = ['INPUT','TEXTAREA'];
	
	for(tagCounter=0;tagCounter<tags.length;tagCounter++){
		var inputs = document.getElementsByTagName(tags[tagCounter]);
		for(var no=0;no<inputs.length;no++){
			if(inputs[no].className && inputs[no].className=='doNotHighlightThisInput')continue;
			
			if(inputs[no].tagName.toLowerCase()=='textarea' || (inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text')){
				inputs[no].onfocus = highlightActiveInput;
				inputs[no].onblur = blurActiveInput;
			}
		}
	}
}

function addslashes(ch) { 
	if (ch != '') {
		ch = ch.replace(/\\/g,"\\\\") 
		ch = ch.replace(/\'/g,"\\'") 
		ch = ch.replace(/\"/g,"\\\"") 
	} 
return ch 
}

// Gestion des tris dans tableaux
var tableWidget_tableCounter = 0;
var tableWidget_arraySort = new Array();
var tableWidget_okToSort = true;
var activeColumn = new Array();
var arrowImagePath = "img/";	// Path to arrow images

function addEndCol(obj)
{
	if(document.all)return;
	var rows = obj.getElementsByTagName('TR');
	for(var no=0;no<rows.length;no++){
		var cell = rows[no].insertCell(-1);
		cell.innerHTML = ' ';
		cell.style.width = '13px';
		cell.width = '13';

	}	
	
}

function highlightTableHeader()
{
	this.className='tableWigdet_headerCellOver';
	if(document.all){	// I.E fix for "jumping" headings
		var divObj = this.parentNode.parentNode.parentNode.parentNode;
		this.parentNode.style.top = divObj.scrollTop + 'px';

	}
		
}

function deHighlightTableHeader()
{
	this.className='tableWidget_headerCell';		
}

function mousedownTableHeader()
{
	this.className='tableWigdet_headerCellDown';
	if(document.all){	// I.E fix for "jumping" headings
		var divObj = this.parentNode.parentNode.parentNode.parentNode;
		this.parentNode.style.top = divObj.scrollTop + 'px';
	}		
}

function sortNumeric(a,b){
	
	a = a.replace(/,/,'.');
	b = b.replace(/,/,'.');
	a = a.replace(/[^\d\.\/]/g,'');
	b = b.replace(/[^\d\.\/]/g,'');
	if(a.indexOf('/')>=0)a = eval(a);
	if(b.indexOf('/')>=0)b = eval(b);
	return a/1 - b/1;
}


function sortString(a, b) {

  if ( a.toUpperCase() < b.toUpperCase() ) return -1;
  if ( a.toUpperCase() > b.toUpperCase() ) return 1;
  return 0;
}	
function cancelTableWidgetEvent()
{
	return false;
}

function sortTable()
{
	if(!tableWidget_okToSort)return;
	tableWidget_okToSort = false;
	/* Getting index of current column */
	var obj = this;
	var indexThis = 0;
	while(obj.previousSibling){
		obj = obj.previousSibling;
		if(obj.tagName=='TD')indexThis++;		
	}
	var images = this.getElementsByTagName('IMG');
	
	if(this.getAttribute('direction') || this.direction){
		direction = this.getAttribute('direction');
		if(navigator.userAgent.indexOf('Opera')>=0)direction = this.direction;
		if(direction=='ascending'){
			direction = 'descending';
			this.setAttribute('direction','descending');
			this.direction = 'descending';	
		}else{
			direction = 'ascending';
			this.setAttribute('direction','ascending');		
			this.direction = 'ascending';		
		}
	}else{
		direction = 'ascending';
		this.setAttribute('direction','ascending');
		this.direction = 'ascending';
	}
	
	
	
	if(direction=='descending'){
		images[0].style.display='inline';
		images[0].style.visibility='visible';
		images[1].style.display='none';
	}else{
		images[1].style.display='inline';
		images[1].style.visibility='visible';
		images[0].style.display='none';		
	}

	
	var tableObj = this.parentNode.parentNode.parentNode;
	var tBody = tableObj.getElementsByTagName('TBODY')[0];
	
	var widgetIndex = tableObj.id.replace(/[^\d]/g,'');
	var sortMethod = tableWidget_arraySort[widgetIndex][indexThis]; // N = numeric, S = String
	if(activeColumn[widgetIndex] && activeColumn[widgetIndex]!=this){
		var images = activeColumn[widgetIndex].getElementsByTagName('IMG');
		images[0].style.display='none';
		images[1].style.display='inline';
		images[1].style.visibility = 'hidden';
		if(activeColumn[widgetIndex])activeColumn[widgetIndex].removeAttribute('direction');			
	}

	activeColumn[widgetIndex] = this;
	
	var cellArray = new Array();
	var cellObjArray = new Array();
	for(var no=1;no<tableObj.rows.length;no++){
		var content= tableObj.rows[no].cells[indexThis].innerHTML+'';
		cellArray.push(content);
		cellObjArray.push(tableObj.rows[no].cells[indexThis]);
	}
	
	if(sortMethod=='N'){
		cellArray = cellArray.sort(sortNumeric);
	}else{
		cellArray = cellArray.sort(sortString);
	}
	
	if(direction=='descending'){
		for(var no=cellArray.length;no>=0;no--){
			for(var no2=0;no2<cellObjArray.length;no2++){
				if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
					cellObjArray[no2].setAttribute('allreadySorted','1');	
					tBody.appendChild(cellObjArray[no2].parentNode);				
				}				
			}			
		}
	}else{
		for(var no=0;no<cellArray.length;no++){
			for(var no2=0;no2<cellObjArray.length;no2++){
				if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
					cellObjArray[no2].setAttribute('allreadySorted','1');	
					tBody.appendChild(cellObjArray[no2].parentNode);				
				}				
			}			
		}				
	}
	
	for(var no2=0;no2<cellObjArray.length;no2++){
		cellObjArray[no2].removeAttribute('allreadySorted');		
	}

	tableWidget_okToSort = true;
	
	
}

function initTableWidget(objId,width,height,sortArray)
{
	width = width + '';
	height = height + '';
	var obj = document.getElementById(objId);
	obj.parentNode.className='widget_tableDiv';
	if(navigator.userAgent.indexOf('MSIE')>=0){
		obj.parentNode.style.overflowY = 'auto';
	}		
	tableWidget_arraySort[tableWidget_tableCounter] = sortArray;
	if(width.indexOf('%')>=0){
		obj.style.width = width;
		obj.parentNode.style.width = width;
	}else{
		obj.style.width = width + 'px';
		obj.parentNode.style.width = width + 'px';
	}
	
	if(height.indexOf('%')>=0){
		//obj.style.height = height;		
		obj.parentNode.style.height = height;			
		
	}else{
		//obj.style.height = height + 'px';		
		obj.parentNode.style.height = height + 'px';
	}
	obj.id = 'tableWidget' + tableWidget_tableCounter;
	addEndCol(obj);
	
	obj.cellSpacing = 0;
	obj.cellPadding = 0;
	obj.className='tableWidget';
	var tHead = obj.getElementsByTagName('THEAD')[0];
	var cells = tHead.getElementsByTagName('TD');
	for(var no=0;no<cells.length;no++){
		cells[no].className = 'tableWidget_headerCell';
		cells[no].onselectstart = cancelTableWidgetEvent;
		if(no==cells.length-1){
			cells[no].style.borderRight = '0px';	
		}
		if(sortArray[no]){
			cells[no].onmouseover = highlightTableHeader;
			cells[no].onmouseout =  deHighlightTableHeader;
			cells[no].onmousedown = mousedownTableHeader;		
			cells[no].onmouseup = highlightTableHeader;		
			cells[no].onclick = sortTable;	
			
			var img = document.createElement('IMG');
			img.src = arrowImagePath + 'arrow_up.gif';
			cells[no].appendChild(img);	
			img.style.visibility = 'hidden';
			
			var img = document.createElement('IMG');
			img.src = arrowImagePath + 'arrow_down.gif';
			cells[no].appendChild(img);	
			img.style.display = 'none';
			
			
		}else{
			cells[no].style.cursor = 'default';	
		}
		
		
	}		
	var tBody = obj.getElementsByTagName('TBODY')[0];
	if(document.all && navigator.userAgent.indexOf('Opera')<0){
		tBody.className='scrollingContent';
		tBody.style.display='block';			
	}else{
		tBody.className='scrollingContent';
		tBody.style.height = (obj.parentNode.clientHeight-tHead.offsetHeight) + 'px';
		if(navigator.userAgent.indexOf('Opera')>=0){
			obj.parentNode.style.overflow = 'auto';
		}
	}
	
	for(var no=1;no<obj.rows.length;no++){
		obj.rows[no].onmouseover = highlightDataRow;
		obj.rows[no].onmouseout = deHighlightDataRow;
		for(var no2=0;no2<sortArray.length;no2++){	/* Right align numeric cells */
			if(sortArray[no2] && sortArray[no2]=='N')obj.rows[no].cells[no2].style.textAlign='right';
		}
	}
	for(var no2=0;no2<sortArray.length;no2++){	/* Right align numeric cells */
		if(sortArray[no2] && sortArray[no2]=='N')obj.rows[0].cells[no2].style.textAlign='right';
	}		
	
	tableWidget_tableCounter++;
}


function highlightDataRow()
{
	if(navigator.userAgent.indexOf('Opera')>=0)return;
	this.className='tableWidget_dataRollOver';
	if(document.all){	// I.E fix for "jumping" headings
		var divObj = this.parentNode.parentNode.parentNode;
		var tHead = divObj.getElementsByTagName('TR')[0];
		tHead.style.top = divObj.scrollTop + 'px';
		
	}	
}

function deHighlightDataRow()
{
	if(navigator.userAgent.indexOf('Opera')>=0)return;
	this.className=null;
	if(document.all){	// I.E fix for "jumping" headings
		var divObj = this.parentNode.parentNode.parentNode;
		var tHead = divObj.getElementsByTagName('TR')[0];
		tHead.style.top = divObj.scrollTop + 'px';
	}			
}

function EnvoiDonnee(param, page, destinationid)
{
	if(document.all)
	{
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
	}//fin if
	else
	{
		//Mozilla
		var XhrObj = new XMLHttpRequest();
	}//fin else

	//définition de l'endroit d'affichage:
	var content = document.getElementById(destinationid);
	
	XhrObj.open("POST", page, true);

	//Ok pour la page cible
	XhrObj.onreadystatechange = function()
	{
		if (XhrObj.readyState == 4 && XhrObj.status == 200)
			content.innerHTML = XhrObj.responseText ;
	}
	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	XhrObj.send(param);

}//fin fonction Envoidonnee
