/************************************/
/*Librairies de fonctions JavaScript*/
/************************************/
var Prototype = {
  Version: '1.0',
  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
  emptyFunction: function() {},
  K: function(x) {return(x);}
}
var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}
Object.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return(destination);
}

function inherit(superCl)
{
   var introspect=""+superCl;
   var F=null;
   introspect=introspect.substring(introspect.indexOf("(")+1);
   introspect=introspect.substring(0, introspect.indexOf(")"));
   var args=introspect.split(",");
   var str="new Function(";
   for(var i=0; i<args.length;i++)
      str += '\"'+args[i]+'\", ';
   str +='\"this.superCl=\"+superCl+\";this.superCl(';
   for(var i=0; i<args.length; i++)
   {
      str +=""+args[i];
      if(i<args.length-1)
         str +=", ";
   }
   str +=');\");';
   F = eval(str);
   for (property in superCl)
      F[property] = superCl[property];
   return(F);
}

Object.extend(navigator,
{
   dom:function(){return(document.getElementById ? true : false);},
   ie:function(){return(document.all ? true : false);},
   ie4:function(){return(document.all && !this.dom() ? true : false);},
   ns4:function(){return(document.layers ? true : false);},
   nav_ok:function(){return(this.dom() || this.ie() || this.ns4());},
   netscape:function(){return(this.appName=="Netscape");},
   isMSIE:navigator.userAgent.indexOf('MSIE')>=0
});
//arguments.callee rappelle récursivement la fonction
/********Définitions de prototype****/
//Sur les chaînes de caractères
Object.extend(String.prototype,
{
   rate:6.55957,
   isArray:false,
   patternDate:'^([1-9]|0[1-9]|[12][0-9]|3[01])[^0-9]*([1-9]|0[1-9]|1[0-2])[^0-9]*([0-9]{2,4})([ ]*([01][0-9]|2[0-3]|[0-9])[^0-9]*([0-4][0-9]|5[0-9]|[0-9])[^0-9]*([0-4][0-9]|5[0-9]|[0-9]))?$',
   HTML_ENTITIES: "&amp;&agrave;&aacute;&auml;&acirc;&egrave;&eacute;&euml;&ecirc;&igrave;&iacute;&iuml;&icirc;&ograve;&oacute;&ouml;&ocirc;&ugrave;&uacute;&uuml;&ucirc;&nbsp;&copy;&quot;&ccedil;&lt;&gt",
   TEXT_ENTITIES: "&àáäâèéëêìíïîòóöôùúüû ©\"ç<> ",
   isDate: function()
   {
      var rexp=new RegExp(this.patternDate);
      return(rexp.test(this));
   },
   before:function(s)
   {
      var aTmp=this.split(s);
      return(aTmp[0]);
   },
   after:function(s)
   {
      var aTmp=this.split(s);
      aTmp.shift();
      return(aTmp.join(s));
   },
   toDate: function()
   {
      var dDate=new Date();
      var rexp=new RegExp(this.patternDate, "gi");
      if(this.isDate())
         return(dDate.set(this.replace(rexp, "$1\/$2\/$3 $4:$5:$6")));
      return(null);
   },
   isUpper:function(l)
   {
      var tmp1=this.toLowerCase();
      if(l==null || l.length==0)
         return(true);
      var tmp2=(new String(l)).toLowerCase();
      var i=0;
      while(i<tmp1.length && i<tmp2.length && tmp1.charCodeAt(i)==tmp2.charCodeAt(i))
         i++;
      if(i>=tmp1.length)
         return(tmp1.charCodeAt(i-1)>tmp2.charCodeAt(i-1));
      else
      if(i>=tmp2.length)
         return(tmp1.charCodeAt(i-1)>=tmp2.charCodeAt(i-1));
      else
         return(tmp1.charCodeAt(i)>=tmp2.charCodeAt(i));
/*
      var tmp1=this.toLowerCase();
      if(l==null || l.length==0)
         return(true);
      var tmp2=l.toLowerCase();
      var i=0;
      while(i<tmp1.length && i<tmp2.length && tmp1.charCodeAt(i)==tmp2.charCodeAt(i))
         i++;
      if(tmp1.charCodeAt(i)==tmp2.charCodeAt(i))
         return(tmp1.length>=tmp2.length)
      else
         return(tmp1.charCodeAt(i)>=tmp2.charCodeAt(i));
*/
   },
   isLogin: function()
   {
      var rexp=new RegExp("^[0-9a-zA-Z]{3,10}$", "g");
      return(rexp.test(this));
   },
   isPasswd: function()
   {
      var rexp=new RegExp("^[0-9a-zA-Z\$\*\%@çéèêëàä!\§ïîù]{6,20}$", "gi");
      return(rexp.test(this));
   },
   toRep: function()
   {
      var rexp=new RegExp("([\\\\|\/|\/|\:|\*|\"|\<|\>])", "gi");
      var sTmp=this.replace(rexp, "");
      return(this.replace(/\&/gi, "et"));
   },
   ucWords: function() //Première lettre de chaque mot en majuscule
   {
      var tmp=new String(this);
      var tab=tmp.split(" ");
      for (var i=0; i<tab.length; i++)
         tab[i]=tab[i].charAt(0).toUpperCase() + tab[i].substring(1);
      tmp=tab.join(" ");
      tab=tmp.split("-");
      for (var i=0; i<tab.length; i++)
         tab[i]=tab[i].charAt(0).toUpperCase() + tab[i].substring(1);
      return(tab.join("-"));
   },
   getWordCount: function() //Retourne le nombre de mots
   {
      return(this.split(" ").length);
   },
   getSubstrCount: function (s) //Nombre d'occurence du parametre
   {
      return(this.split(s).length-1);
   },
   nl2br: function()
   {
      return(this.replace(/(\r\n|\r|\n)/g, "<br />"));
   },
   br2nl: function()
   {
      var reg=new RegExp("<br( /)?>", "g");
      return(this.replace(reg, "\n"));
   },
   escapeRegexp: function() //Ajoute un \ devant tous les caractères suceptibles d'êtres interprétés à l'intérieur d'une expression régulière : \, +, *, [, ], (, ), {, } et -.
   {
      var reg=new RegExp("([\\.\\\\\\+\\-\\*\\[\\]\\{\\}\\(\\)\\?\\$\\^])", "g");
      return(this.replace(reg, "\\$1"));
   },
   unescapeRegexp: function() //Effectue le contraire de la fonction escapeRegex, c'est-à-dire qu'elle efface les \ avant les caractères suceptibles d'être interprétés par une expression régulière.
   {
      var reg=new RegExp("\\\\([\\.\\\\\\+\\-\\*\\[\\]\\{\\}\\(\\)\\?\\$\\^])", "g");
      return(this.replace(reg, "$1"));
   },
   matches: function(s)
   {
      var reg=new RegExp(s);
      return(reg.test(this));
   },
   insert: function(intIndex, strChar)
   {
      if (isNaN(intIndex)) {return this;}
      if (intIndex < 0) {return this;}
      if (!strChar) {return this;}

      strChar += '';
      intIndex = parseInt(intIndex, 10);
      return(this.substr(0, intIndex) + strChar + this.substr(intIndex, this.length));
   },
   remove: function(intIndex, intLength)
   {
      if (isNaN(intIndex) || isNaN(intLength)) {return this;}
      if (intIndex < 0 || intLength < 0) {return this;}
      intIndex = parseInt(intIndex, 10); intLength = parseInt(intLength, 10);
      return(this.substr(0, intIndex) + this.substr(intIndex + intLength, this.length));
   },
   startsWith: function(strChar)
   {
      if (!strChar) {return false;}
      strChar += '';
      var intLength = strChar.length;
      return(this.substr(0, intLength) == strChar);
   },
   endsWith: function(strChar)
   {
      if (!strChar) {return false;}
      strChar += '';
      var intLength = strChar.length;
      return(this.substr(this.length - intLength, intLength) == strChar);
   },
   extractPage:function()
   {
      var tmp=this;
      tmp=tmp.substr(tmp.lastIndexOf("/")+1);
      tmp=tmp.substr(tmp.lastIndexOf("\\")+1);
      return(tmp.before("?"));
   },
   extractParam:function()
   {
      var bSessID=arguments.length>0 ? arguments[0] : false;
      if(bSessID)
         return(this.after("?").replace(/phpsessid=[a-z0-9]*/gi, "").replace(/\&\&/gi, "&").replace(/^\&/, "").replace(/\&$/, ""));
      else
         return(this.after("?").replace(/\&\&/gi, "&").replace(/^\&/, "").replace(/\&$/, ""));
   },
   equalsIgnoreCase: function(s)
   {
      return(this.toLowerCase()==s.toLowerCase());
   },
   reverse: function()
   {
      return(this.split("").reverse().join(""));
   },
   escapeEntities: function()
   {
      var tab = "".HTML_ENTITIES.split(";");
      var str = ""+this+"";
      for (var i=0; i<tab.length; i++)
      {
         var a="".TEXT_ENTITIES.charAt(i);
         var b=tab[i]+";";
         str=str.split(a).join(b);
      }
      return(str);
   },
   unescapeEntities: function()
   {
      var tab = "".HTML_ENTITIES.split(";");
      var str = ""+this+"";
      for (var i=0; i < tab.length; i++)
      {
         var b = "".TEXT_ENTITIES.charAt(i);
         var a = tab[i]+";";
         str = str.split(a).join(b);
      }
      return(str);
   },
   removeAccents: function()
   {
      var str=""+this+"";
      var a="àâäáÀÁÄÂëèéêÊÉÈËïîíìÌÍÎÏüùûúÚÙÛÜãõñÃÕÑç";
      var b="aaaaAAAAeeeeEEEEiiiiIIIIooooOOOOuuuuUUUUaonAONc";
      for (var i=0; i<a.length; i++)
         str=str.split(a.charAt(i)).join(b.charAt(i));
      return(str);
   },
   isEmail: function()
   {
      return(this.matches("^[-a-zA-Z0-9\\._]{3,}@[-a-zA-Z0-9_]{2,}\\.[a-z]{2,4}$"));
   },
   isNumber: function()
   {
      var reg=new RegExp("^[0-9]+$", "g");
      return(reg.test(this));
   },
   isFloat: function()
   {
      var n=(arguments.length>0) ? "{0,"+arguments[0]+"}" : "*";
      var reg=new RegExp("^[0-9]+[\.|,]?[0-9]"+n+"$", "g");
      return(reg.test(this.trim()));
   },
   PGCD: function(n)
   {
      var x=this, y=n, z=0;
	   if(this.isNumber() && n.isNumber())
	   {
	      while(y != 0)
      	      {
      		z = x%y;
      		x = y;
      		y = z;
      	      }
      }
      else
         x=0;
      return(x);
   },
   PPMC: function(n)
   {
      if(this.isNumber() && n.isNumber())
         return((this*n)/this.PGCD(n));
      else
         return(0);
   },
   convertEF:function()
   {
      var cTo=arguments.length>0 ? arguments[0] : "E";
      if(!this.isFloat())
         return("");
      else if(cTo=="E")
         return(this/this.rate);
      else
         return(this*this.rate);
   },
   toE: function() //Conversion FF=>€
   {
      return(this.convertEF("E"));
   },
   toF: function() //Conversion €=>FF
   {
      return(this.convertEF("F"));
   },
   lpad: function(nb)
   {
      var caractere=arguments.length>1 ? (arguments[1].length>0 ? arguments[1] : " ") : " ";
      var tmp=this;
      while (tmp.length < nb)
      tmp=caractere+tmp;
      return(tmp);
   },
   rpad: function(nb)
   {
      var caractere=arguments.length>1 ? (arguments[1].length>0 ? arguments[1] : " ") : " ";
      var tmp=this;
      while (tmp.length < nb)
      tmp+=caractere;
      return(tmp);
   },
   ltrimZ: function(){return(this.replace(/(^0*)/, ""));},
   ltrim: function(){return(this.replace(/^\s*/g, ''));},
   rtrim: function(){return(this.replace(/\s*$/g, ''));},
   trim: function () {/*return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");*/return this.replace(/(^\s+)|(\s+$)/ig, '');},
   trimCr: function()
   {
      for(var f=0,nChaine="",zb="\n\r"; f<this.length; f++)
      {
         if (zb.indexOf(this.charAt(f))==-1)
            nChaine+=this.charAt(f);
      }
      return(nChaine);
   },
   replaceAll: function(sOld, sNew){return(this.split(sOld).join(sNew));},
   encodeSQL: function(){return(this.replaceAll(chr(92), chr(92)+chr(92)).replaceAll("'", "\\'"));},
   addSlashes: function(){return(this.replace(/("|'|\\)/g, '\\$1'));},
   stripSlashes: function(){return(this.replace(/\\("|'|\\)/g, '$1'));},
//   addSlashes: function(){return(this.replace(/([""\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1'));},
//   stripSlashes: function(){return(this.replace(/([""\\\.\|\[\]\^\*\+\?\$\(\)])/g, '$1'));},
   toBase10: function() //Passage de base décimale en base "10" (par défaut 16)
   {
      var base=(arguments.length>0) ? arguments[0]:16;
      return(parseInt(this, base));
   },
   toBase: function() //Passage de base décimale en base "b" (par défaut 16) et renvoie au moins 2 caractères
   {
      var b=(arguments.length>0) ? arguments[0]:16;
      if(parseInt(b)>36)
         return(null);
      var digits=new Number(this).toString(b);
      if(this<b)
         digits='0'+digits;
      return(digits.toUpperCase());
   },
   encodeUTF8: function()
   {
     var string=this.replace(/\r\n/g,"\n");
     var utftext="";
     for (var n=0; n<string.length; n++)
     {
       var c=string.charCodeAt(n);
       if (c<128){utftext+=String.fromCharCode(c);}

       else if((c>127) && (c<2048)){utftext+=String.fromCharCode((c >> 6) | 192);utftext+=String.fromCharCode((c & 63) | 128);}
       else {utftext+=String.fromCharCode((c >> 12) | 224);utftext+=String.fromCharCode(((c >> 6) & 63) | 128);utftext+=String.fromCharCode((c & 63) | 128);}
     }
     return(utftext);
   },
   decodeUTF8: function ()
   {
     utftext = this;
     var string = "";
     var i = 0;
     var c=c1=c2=0;
     while ( i < utftext.length )
     {
       c = utftext.charCodeAt(i);
       if (c < 128){string += String.fromCharCode(c);i++;}
       else if((c > 191) && (c < 224)){c2 = utftext.charCodeAt(i+1);string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));i+=2;}
       else{c2 = utftext.charCodeAt(i+1);c3 = utftext.charCodeAt(i+2);string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));i+=3;}
     }
     return(string);
   },
   encode64: function() //Encodage en base64
   {
      var tmp=this;
      var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
      var output="";
      var chr1, chr2, chr3;
      var enc1, enc2, enc3, enc4;
      var i=0;
      do {
         chr1=tmp.charCodeAt(i++);
         chr2=tmp.charCodeAt(i++);
         chr3=tmp.charCodeAt(i++);
         enc1=chr1 >> 2;
         enc2=((chr1 & 3) << 4) | (chr2 >> 4);
         enc3=((chr2 & 15) << 2) | (chr3 >> 6);
         enc4=chr3 & 63;
         if (isNaN(chr2)) {enc3=enc4=64;}
         else if (isNaN(chr3)) {enc4=64;}
         output=output+keyStr.charAt(enc1)+keyStr.charAt(enc2) +
            keyStr.charAt(enc3)+keyStr.charAt(enc4);
      } while(i < tmp.length);
      return(output);
   },
   decode64: function() //Décodage en base64
   {
      if(this.length==0)
         return("");
      var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
      var output="";
      var chr1, chr2, chr3;
      var enc1, enc2, enc3, enc4;
      var i=0;
      // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
      var tmp=this.replace(/[^A-Za-z0-9\+\/\=]/g, "");
      do {
         enc1=keyStr.indexOf(tmp.charAt(i++));
         enc2=keyStr.indexOf(tmp.charAt(i++));
         enc3=keyStr.indexOf(tmp.charAt(i++));
         enc4=keyStr.indexOf(tmp.charAt(i++));
         chr1=(enc1 << 2) | (enc2 >> 4);
         chr2=((enc2 & 15) << 4) | (enc3 >> 2);
         chr3=((enc3 & 3) << 6) | enc4;
         output=output+String.fromCharCode(chr1);
         if (enc3 != 64) {output=output+String.fromCharCode(chr2);}
         if (enc4 != 64) {output=output+String.fromCharCode(chr3);}
      } while(i < tmp.length);
      return(output);
   },
   camelize: function()
   {
      var oStringList = this.split('-');
      if (oStringList.length == 1) return(oStringList[0]);
      var camelizedString=(this.indexOf('-')==0) ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
      for (var i=1, len=oStringList.length; i<len; i++)
      {
         var s=oStringList[i];
         camelizedString+=s.charAt(0).toUpperCase()+s.substring(1);
      }
      return(camelizedString);
   },
   stripTags: function()
   {
      return(this.replace(/<\/?[^>]+>/gi, ''));
   },
   stripScripts: function()
   {
      return(this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''));
   },
   toUrl:function(){return(arguments.length>0 ? arguments[0]+"="+this.encode64() : this.encode64());},
   encodeUrl:function(){return(this.replaceAll("+", "%2B"));},
   toNumber: function(signe)
   {
      if(signe==null)
         signe=true;
      var ret=this.replace(/[^0-9]/gi, "");
      ret=ret.ltrimZ();
      if(ret=="")
         ret=0;
      else
      {
         if(signe && this.startsWith("-"))
            ret=this.charAt(0)+ret;
      }
      return(parseInt(ret));
   },
   toTel: function()
   {
      var tmp=this.toNumber(false);
      if((tmp.length>0) && (!tmp.startsWith("0")))
         tmp="0"+tmp;
      tmp=tmp.replace(/([0-9]{0,2})/gi, "$1\.");
      while(tmp.endsWith("."))
         tmp=tmp.substr(0, tmp.length-1);
      return(tmp.substr(0, 14));
   },
   toArray:function()
   {
      return(this.split(""));
   },
   extension:function()
   {
      return(this.replace(/^.*\.([^\.]*)$/gi, "$1").toLowerCase());
   },
   nameFile:function()
   {
      return(this.replace(/\.[^\.]*$/gi, ""));
   },
   isImage:function()
   {
      var ex=this.extension().toLowerCase();
      return(ex=="gif" || ex=="jpe" || ex=="jpg" || ex=="jpeg" || ex=="bmp" || ex=="png" || ex=="ico" || ex=="pcx" || ex=="tif" || ex=="tiff");
   }
});

//Sur les nombres
Object.extend(Number.prototype,
{
   isDate:function(){return(new String(this).isDate());},
   toDate:function(){return(new String(this).toDate());},
   isArray:String.prototype.isArray,
   isUpper:function(a){return(this>a);},
   before:function(s){return(new String(this).before(s));},
   after:function(s){return(new String(this).after(s));},
   sign:function(){return((this < 0) ? -1 : 1);},
   rate:String.prototype.rate,
   ucWords: function(){return(new String(this).ucWords());},
   getWordCount: function(){return(new String(this).getWordCount());},
   getSubstrCount: function(){return(new String(this).getSubstrCount());},
   nl2br: function(){return(new String(this).nl2br());},
   br2nl: function(){return(new String(this).br2nl());},
   escapeRegexp: function(){return(new String(this).escapeRegexp());},
   unescapeRegexp: function(){return(new String(this).unescapeRegexp());},
   matches: function(s){return(new String(this).matches(s));},
   startsWith: function(s){return(new String(this).startsWith(s));},
   endsWith: function(s){return(new String(this).endsWith(s));},
   equalsIgnoreCase: function(s){return(new String(this).equalsIgnoreCase(s));},
   reverse: function(){return(new String(this).reverse());},
   escapeEntities: function(){return(new String(this).escapeEntities());},
   unescapeEntities: function(){return(new String(this).unescapeEntities());},
   removeAccents: function(){return(new String(this).removeAccents());},
   isLogin: function(){return(new String(this).isLogin());},
   isPasswd: function(){return(new String(this).isPasswd());},
   isEmail: function(){return(new String(this).isEmail());},
   isNumber: function(){return(new String(this).isNumber());},
   isFloat: function(){return(new String(this).isFloat());},
   PGCD:function(n){return(new String(this).PGCD(n));},
   PPMC:function(n){return(new String(this).PPMC(n));},
   toE:function(){return(new String(this).toE());},
   toF:function(){return(new String(this).toF());},
   toBase10: function(){return(new String(this).toBase10((arguments.length>0)?arguments[0]:16));},
   toBase: function(){return(new String(this).toBase((arguments.length>0)?arguments[0]:16));},
   lpad: function(nb){var caractere=arguments.length>1 ? (arguments[1].length>0 ? arguments[1] : "0") : "0";return(new String(this).lpad(nb, caractere));},
   rpad: function(nb){var caractere=arguments.length>1 ? (arguments[1].length>0 ? arguments[1] : "0") : "0";return(new String(this).rpad(nb, caractere));},
   ltrim: function(){return(new String(this).ltrim());},
   rtrim: function(){return(new String(this).rtrim());},
   trim: function (){return(new String(this).trim());},
   trimCr: function(){return(new String(this).trimCr());},
   replaceAll: function(sOld, sNew){return(new String(this).replaceAll(sOld, sNew));},
   encodeSQL: function(){return(new String(this).encodeSQL());},
   addSlashes: function(){return(new String(this).addSlashes());},
   stripSlashes: function(){return(new String(this).stripSlashes());},
   encodeUTF8: function(){return(new String(this).encodeUTF8());},
   decodeUTF8: function(){return(new String(this).decodeUTF8());},
   encode64: function(){return(new String(this).encode64());},
   decode64: function(){return(new String(this).decode64());},
   camelize: function(){return(this);},
   stripTags: function(){return(this);},
   stripScripts: function(){return(this);},
   toUrl:function(){return(arguments.length>0 ? new String(this).toUrl(arguments[0]) : new String(this).toUrl());},
   toNumber: function() {return(this);},
   toTel: function(){return(new String(this).toTel());},
   toArray:function() {return(new String(this).toArray());},
   extension:function() {return(new String(this).extension());},
   nameFile:function() {return(new String(this).nameFile());},
   isImage:function() {return(new String(this).isImage());}
});
//Sur les dates
//o : Décalage par rapport à l'heure internationale exprimé en minutes
//O : décalage par rapport à l'heure internationale, exprimé en heures
//d : Numéro du jour du mois, précédé d'un 0 si nécessaire
//D : Numéro du jours du mois
//m : Numéro du mois de l'année, précédé d'un 0 si nécessaire
//M : Nom du mois de l'année
//y : Année sur 2 chiffres
//Y : année sur 4 chiffres
//h : Heure sur 12 heures, précédés d'un 0 si nécessaire
//H : heures sur 24 heures, précédés d'un 0 si nécessaire
//i : minutes précédés d'un 0 si nécessaire
//s : secondes précédés d'un 0 si nécessaire
//x : millisecondes précédés d'un 0 si nécessaire
//w : Numéro du jour de la semaine entre 0 et 6
//W : Nom du jour de la semaine
Date.prototype.oldToString=Date.prototype.toString;
Date.prototype.toString=function()
{
   motif=(arguments.length>0) ? arguments[0] : null;
   if (!motif)
      return(this.oldToString());
   var xa = ["o", "O", "d", "D", "m", "y", "Y", "H", "h", "i", "s", "w", "x", "W", "M"];
   var xb = [ "this.getTimezoneOffset();", "Math.floor(this.getTimezoneOffset()/60);", "this.getDate().lpad(2);", "this.getDate();", "new String(parseInt(this.getMonth())+1).lpad(2, \"0\");", "this.getYear();", "this.getFullYear();", "this.getHours().lpad(2);", "this.getHours12().lpad(2);", "this.getMinutes().lpad(2)", "this.getSeconds().lpad(2);",
              "this.getDay();", "this.getMilliseconds();", "this.getDayName();", "this.getMonthName();"];
   var str=motif+"";
   var xx="(";
   for (var i=0; i<xa.length; i++)
   {
      xx += xa[i];
      if (i<xa.length-1)
         xx+=";";
   }
   xx+=")";
   str = str.replace(new RegExp(xx, "g"), "%$1");
   for (var i=0; i<xa.length; i++)
   {
      if (str.indexOf(xa[i])!=-1)
      {
         var t = eval(xb[i]);
         var r = new RegExp("%"+xa[i], "g");
         str = str.replace(r, t);
      }
   }
   return(str);
};

Object.extend(Date.prototype,
{
   isDate:function(){return(true);},
   isArray:String.prototype.isArray,
   isUpper:function(a){return(this>a);},
   MONTH_NAMES: new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"),
   DAY_NAMES: new Array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"),
   TIME_DAY:1000*3600*24,
   IsOuvertPentecote:false,
   replaceAll:function(sOld, sNew){return((this.toString()==sOld.toString()) ? sNew : this);},
   set: function(sDate)
   {
      if(arguments.length==1)
      {
         var h=sDate.after(" ").split(":");
         var tmp=sDate.before(" ").split("/");
         this.setYear(tmp[2]);
         this.setDate(1);
         this.setMonth(parseFloat(tmp[1])-1);
         this.setDate(parseFloat(tmp[0]));
         if(h.length>=3)
         {
            this.setHours(h[0]);
            this.setMinutes(h[1]);
            this.setSeconds(h[2]);
         }
      }
      if(arguments.length>=3)
      {
         this.setYear(arguments[2]);
         this.setDate(1);
         this.setMonth(parseFloat(arguments[1])-1);
         this.setDate(parseFloat(arguments[0]));
      }
      if(arguments.length>=6)
      {
         this.setHours(arguments[4]);
         this.setMinutes(arguments[5]);
         this.setSeconds(arguments[6]);
      }
      return(this);
   },
   //Ajoute nb jours
   addDay:function(nb){return(new Date(this.getFullYear(), this.getMonth(), this.getDate()+parseInt(nb)));},
   //Ajoute nb jours ouvrés
   addNDay:function(nb){
      var j=Math.abs(parseInt(nb));
      var s=parseInt(nb).sign();
      while(j>0)
      {
         this.setDate(this.getDate()+s);
         if(this.isOuvert()=="O")
            j--;
      }
      return(this);
   },
   isOuvert:function(){
      var annee=this.getFullYear();
      var date_paque=this.getEasterDate(annee);
      var LundiPaque=date_paque.addDay(1).toString("%d/%m/%Y");
      var Ascension=date_paque.addDay(39).toString("%d/%m/%Y");
      var LundiPentecote=date_paque.addDay(50).toString("%d/%m/%Y");
      var aTester=this.toString("%d/%m/%Y");
      if((aTester==LundiPaque) || (aTester==Ascension) || (this.IsOuvertPentecote && (aTester==LundiPentecote)) || (aTester=="01/01/"+annee) || (aTester=="01/05/"+annee) || (aTester=="08/05/"+annee) || (aTester=="14/07/"+annee) || (aTester=="15/08/"+annee) || (aTester=="11/11/"+annee) || (aTester=="25/12/"+annee))
         return("F");
      else if(this.getDay()==0 || this.getDay()==6)
         return("W");
      else
         return("O");
   },
   trunc: function ()
   {
      return(new Date(this.getFullYear(), this.getMonth(), this.getDate()));
   },
   getEasterDate: function()
   {
      var annee=arguments.length>0 ? parseInt(arguments[0]) : parseInt(this.getFullYear());
      var date_paques = null;
      var b = annee - 1900;
      var c = annee % 19;
      var d = Math.floor((7*c+1)/19);
      var e = (11*c+4-d) % 29;
      var f = Math.floor(b/4);
      var g = (b+f+31-e) % 7;
      var avril = 25-e-g;
      if (avril > 0) date_paques = new Date(annee, 3, avril);
      else date_paques = new Date(annee, 2, avril + 31);
      return date_paques;
   },
   before:function(s){return(this);},
   after:function(s){return(this);},
   getDayName: function(){return(Date.prototype.DAY_NAMES[this.getDay()]);},
   getMonthName: function(){return(Date.prototype.MONTH_NAMES[this.getMonth()]);},
   getHours12: function()
   {
      var n = this.getHours();
      if (n<=12) return(n);
      else return(n%12);
   },
   getPrevSunday: function()
   {
      var x = this.getDay();
      if (x==0)
         x=7;
      return(new Date(this.getTime()-(this.TIME_DAY*x)));
   },
   getNextSunday: function()
   {
      return(new Date(this.getTime()+(this.TIME_DAY*(7-this.getDay()))));
   },
   getLastSunday: function()
   {
      var d = new Date(this.getTime());
      var x = this.getMonth();
      while ((z=d.getNextSunday()).getMonth()==x) {d=z;}
      return(d);
   },
   getFirstSunday: function()
   {
      var d = new Date(this.getTime());
      var x = this.getMonth();
      while ((z = d.getPrevSunday()).getMonth()==x) {d=z;}
      return(d);
   },
   encode64: function(){return(this.toString("%D/%m/%Y %H:%i:%s").encode64());},
   decode64: function(){return(this);},
   camelize: function(){return(this);},
   stripTags: function(){return(this);},
   stripScripts: function(){return(this);},
   toUrl:function(){return(arguments.length>0 ? arguments[0]+"="+this.encode64() : this.encode64());},
   toNumber: function() {return(this);},
   datediff: function (per,dDate)
   {
      var d = Math.abs((dDate.getTime()-this.getTime()))/1000;
      switch(per) {
         case "yyyy": d/=12;
         case "m": d*=12*7/365.25;
         case "ww": d/=7;
         case "d": d/=24;
         case "h": d/=60;
         case "n": d/=60;
      }
      return parseInt(d);
   }
});
//Sur les tableaux
Object.extend(Array.prototype,
{
   isArray:true,
   inArray: function(sVal){for(var i=0; i<this.length; i++){if(this[i]==sVal) return(true);} return(false);},
   getKey: function(sVal){for(var i=0; i<this.length; i++){if(this[i]==sVal) return(i);} return(-1);},
   ucWords: function(){for(var i=0; i<this.length; i++){this[i]=this[i].ucWords();} return(this);},
   getWordCount: function(){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].getWordCount();} return(ret);},
   getSubstrCount: function(){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].getSubstrCount();} return(ret);},
   before: function(s){for(var i=0; i<this.length; i++){this[i]=this[i].before(s);} return(this);},
   after: function(s){for(var i=0; i<this.length; i++){this[i]=this[i].after(s);} return(this);},
   nl2br: function(){for(var i=0; i<this.length; i++){this[i]=this[i].nl2br();} return(this);},
   br2nl: function(){for(var i=0; i<this.length; i++){this[i]=this[i].br2nl();} return(this);},
   escapeRegexp: function(){for(var i=0; i<this.length; i++){this[i]=this[i].escapeRegexp();} return(this);},
   unescapeRegexp: function(){for(var i=0; i<this.length; i++){this[i]=this[i].unescapeRegexp();} return(this);},
   matches: function(s){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].matches(s);} return(ret);},
   startsWith: function(s){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].startsWith(s);} return(ret);},
   endsWith: function(s){var ret=new Array();for(var i=0; i<this.length; i++){this[i]=ret[i].endsWith(s);} return(ret);},
   equalsIgnoreCase: function(s){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].equalsIgnoreCase(s);} return(ret);},
   reverseString: function(){for(var i=0; i<this.length; i++){this[i]=this[i].reverse();} return(this);},
   escapeEntities: function(){for(var i=0; i<this.length; i++){this[i]=this[i].escapeEntities();} return(this);},
   unescapeEntities: function(){for(var i=0; i<this.length; i++){this[i]=this[i].unescapeEntities();} return(this);},
   removeAccents: function(){for(var i=0; i<this.length; i++){this[i]=this[i].removeAccents();} return(this);},
   isEmail: function(){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].isEmail();} return(ret);},
   isNumber: function(){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].isNumber();} return(ret);},
   isFloat: function(){var ret=new Array();for(var i=0; i<this.length; i++){ret[i]=this[i].isFloat();} return(ret);},
   toE: function(){for(var i=0; i<this.length; i++){this[i]=this[i].toE();} return(this);},
   toF: function(){for(var i=0; i<this.length; i++){this[i]=this[i].toF();} return(this);},
   toBase10: function(){for(var i=0; i<this.length; i++){this[i]=this[i].toBase10(arguments.length>0)?arguments[0]:16;} return(this);},
   toBase: function(){for(var i=0; i<this.length; i++){this[i]=this[i].toBase(arguments.length>0)?arguments[0]:16;} return(this);},
   lpad: function(nb){var caractere=arguments.length>1 ? arguments[1] : "";for(var i=0; i<this.length; i++){this[i]=this[i].lpad(nb, caractere);} return(this);},
   rpad: function(nb){var caractere=arguments.length>1 ? arguments[1] : "";for(var i=0; i<this.length; i++){this[i]=this[i].rpad(nb, caractere);} return(this);},
   ltrimZ: function(){for(var i=0; i<this.length; i++){this[i]=this[i].ltrimZ();} return(this);},
   ltrim: function(){for(var i=0; i<this.length; i++){this[i]=this[i].ltrim();} return(this);},
   rtrim: function(){for(var i=0; i<this.length; i++){this[i]=this[i].rtrim();} return(this);},
   trim: function() {for(var i=0; i<this.length; i++){this[i]=this[i].trim();} return(this);},
   trimCr: function(){for(var i=0; i<this.length; i++){this[i]=this[i].trimCr();} return(this);},
   //toString: function()
   decale: function()
   {
      var iNb=arguments.length>0 ? Math.abs(arguments[0]) : 0, sWhat=arguments.length>1 ? arguments[1] : "", sWhere=arguments.length>2 ? arguments[2].toUpperCase() : "F";
      sWhere=(sWhere=="D" || sWhere=="F") ? sWhere : "F";
      while(iNb>0)
      {
         iNb--;
         if(sWhere=="F")
            this.push(sWhat);
         else
            this.unshift(sWhat);
      }
      return(this);
   },
   insertBefore: function(nKey, sVal)
   {
      if(this.length<=nKey)
      {
         this[this.length]=sVal;
         return;
      }
      for(var i=this.length;i>=nKey;i--)
         this[i]=this[i-1];
      this[nKey]=sVal;
      return;
   },
   insertAfter: function(nKey, sVal)
   {
      if(this.length<=nKey)
      {
         this[this.length]=sVal;
         return;
      }
      for(var i=this.length;i>nKey;i--)
         this[i]=this[i-1];
      this[nKey+1]=sVal;
      return;
   },
   sortCol: function (iCol)
   {
      var bSort=arguments.length>1 ? arguments[1] : 0;
      var sType=arguments.length>2 ? arguments[2] : "";
      var aTmp=new Array();
      var a="", b="";
      for(var i=0;i<this.length;i++)
      {
         if(this[i][iCol].trim()=="")
         {
            iCol=0;
            bSort=0;
         }
         if(this[i][iCol])
         {
            b=eval("new String('"+this[i][iCol]+"')"+sType);
            j=0;
            var bFound=false;
            while((j<aTmp.length) && !bFound)
            {
               if(sType!="")
                  a=eval("new String('"+aTmp[j][iCol]+"')"+sType);
               else
                  a=aTmp[j][iCol];
               if(a.isUpper)
                  if((bSort==0 && a.isUpper(b)) || (bSort>0 && !a.isUpper(b)))
                     bFound=true;
                  else
                     j++;
               else
                  if((bSort==0 && a>b) || (bSort>0 && a<b))
                     bFound=true;
                  else
                     j++;
            }
            aTmp.insertBefore(j, this[i]);
         }
         else
            aTmp[i]=this[i];
      }
      return(aTmp);
   },
   replaceAll: function(sOld, sNew){for(var i=0; i<this.length; i++){this[i]=this[i].replaceAll(sOld, sNew);} return(this);},
   encodeSQL: function(){for(var i=0; i<this.length; i++){this[i]=this[i].encodeSQL();} return(this);},
   addSlashes: function(){for(var i=0; i<this.length; i++){this[i]=this[i].addSlashes();} return(this);},
   stripSlashes: function(){for(var i=0; i<this.length; i++){this[i]=this[i].stripSlashes();} return(this);},
   encodeUTF8: function(){for(var i=0; i<this.length; i++){this[i]=this[i].encodeUTF8();} return(this);},
   decodeUTF8: function(){for(var i=0; i<this.length; i++){this[i]=this[i].encodeUTF8();} return(this);},
   encode64: function(){for(var i=0; i<this.length; i++){this[i]=this[i].encode64();} return(this);},
   decode64: function(){for(var i=0; i<this.length; i++){this[i]=this[i].decode64();} return(this);},
   camelize: function(){for(var i=0; i<this.length; i++){this[i]=this[i].camelize();} return(this);},
   stripTags: function(){for(var i=0; i<this.length; i++){this[i]=this[i].stripTags();} return(this);},
   stripScripts: function(){for(var i=0; i<this.length; i++){this[i]=this[i].stripScripts();} return(this);},
   toUrl: function(s){var ret="";for(var i=0; i<this.length; i++){if(i>0){ret+="&";}ret+=this[i].toUrl(s+"["+i+"]");} return(ret);},
   toNumber:  function(){var ret=arguments.length>0 ? arguments[0] : true;for(var i=0; i<this.length; i++){this[i]=this[i].toNumber(ret);} return(this);},
   toTel:  function(){for(var i=0; i<this.length; i++){this[i]=this[i].toTel();} return(this);},
   extension: function(){for(var i=0; i<this.length; i++){this[i]=this[i].extension();} return(this);},
   nameFile: function(){for(var i=0; i<this.length; i++){this[i]=this[i].nameFile();} return(this);},
   isImage: function(){for(var i=0; i<this.length; i++){this[i]=this[i].isImage();} return(this);},
   del: function(i){for(var j=i;j<this.length-1;j++){this[j]=this[j+1];}if(i<this.length){this.pop();}return;},
   removeValue:function(x)
      {
         var trouvee = false;
         for(var i=0; i+2<=this.length; i++)
         {
          if(this[i] == x)
           trouvee = true;
          if(trouvee)
           this[i] = this[i+1];
         }
         // suppression du dernier element
         if(trouvee || this[this.length-1] == x)
         {
          this.pop();
          return true;
         }
         else
          return false;
      }
});

// Prototype de Math
Object.extend(Math,
{
   isArray:String.prototype.isArray,
   oldRandom: Math.random,
   /*
   _________________________________________
   | Nb |     Retour de la fonction        |
   |---------------------------------------|
   |  0 | nombre entre 0 et 1.             |
   |  1 | nombre entre 0 et 1er argument   |
   |  2 | nombre entre 1er et 2eme argument|
   |____|__________________________________|
   */
   random: function()
   {
     var min=0;
     var max=1;
     var n=Math.oldRandom();
     if(arguments.length==1)
        max=arguments[0];
     if(arguments.length==2)
     {
        min=arguments[0];
        max=arguments[1];
     }
     return((n*(max-min))+min);
   },
   oldRound:Math.round,
   round: function(nb)
   {
      var n=arguments.length>1 ? arguments[1] : 0;
      return(Math.oldRound(nb*Math.pow(10,n))/Math.pow(10,n));
   }
});

/********Fin définitions de prototype****/
//Affichage de caractères à partir de caractères ASCII
function chr()
{
   var ret="";
   for(var i=0; i< arguments.length; i++)
      ret+=String.fromCharCode(arguments[i]);
   return(ret);
}

//Récupération du nom du fichier
function getFileName()
{
   var ret="";
   var rexp=new RegExp("(ht|f)tps?://.*/([0-9a-z_]*(.html?|.php))\\??.*", "i");
   if(arguments.length>0)
      ret=arguments[0];
   else
      ret=window.location.href;
   return(ret.match(rexp)[2]);
}
//Récupération des données URL
function getUrlVars()
{
   var ret="";
   if(arguments.length>0)
   {
      ret=arguments[0];
      if(ret.indexOf(chr(63))>0)
         ret=ret.substring(ret.indexOf(chr(63))+1);
   }
   else
      ret=window.location.search.substring(1);
   return(ret);
}
function getUrlVar(nomVariable)
{
   var sUrl=(arguments.length>1) ? getUrlVars(arguments[1]) : getUrlVars();
   var infos=sUrl.split(chr(38));
   for(var i=0; i<infos.length; i++)
   {
      var ind=infos[i].indexOf(chr(61));
      var key=infos[i].substring(0, ind);
      if (key==nomVariable)
         return(infos[i].substring(ind+1));
   }
   return(null);
}
function replaceUrl(nomVariable, newVal)
{
   var sUrl=(arguments.length>2) ? getUrlVars(arguments[2]) : getUrlVars();
   if(getUrlVar(nomVariable, sUrl)==null)
      return((sUrl.length>0 ? sUrl+chr(38) : "")+nomVariable+chr(61)+newVal);
   var ret="";
   var infos=sUrl.split(chr(38));
   for(var i=0; i<infos.length; i++)
   {
      var ind=infos[i].indexOf(chr(61));
      var key=infos[i].substring(0, ind);
      var val=infos[i].substring(ind+1);
      if (key==nomVariable)
         val=newVal;
      if(key!="")
      {
         if(ret=="")
            ret=key+chr(61)+val;
         else
            ret+=chr(38)+key+chr(61)+val;
      }
   }
   return(ret);
}
//Fin récupération des données URL

//Librairies de fonctions pour les cookies
function setCookie(name, value)
{
   var argv=arguments;
   var argc=arguments.length;
   var expires=(argc > 2) ? argv[2] : null;
   var path=(argc > 3) ? argv[3] : null;
   var domain=(argc > 4) ? argv[4] : null;
   var secure=(argc > 5) ? argv[5] : false;
   document.cookie=name+"="+escape(value)+
      ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
      ((path==null) ? "" : ("; path="+path))+
      ((domain==null) ? "" : ("; domain="+domain))+
      ((secure==true) ? "; secure" : "");
}
function getCookieVal(offset)
{
   var endstr=document.cookie.indexOf (";", offset);
   if (endstr==-1)
      endstr=document.cookie.length;
   return(unescape(document.cookie.substring(offset, endstr)));
}
function getCookie(name)
{
   var arg=name+"=";
   var alen=arg.length;
   var clen=document.cookie.length;
   var i=0;
   while (i<clen)
   {
      var j=i+alen;
      if (document.cookie.substring(i, j)==arg)
         return(getCookieVal(j));
      i=document.cookie.indexOf(" ",i)+1;
      if (i==0) break;
   }
   return(null);
}

//Fonction d'intégration d'un fichier JavaScript
function include(file)
{
   var rep=(arguments.length==1) ? "http://www.placeojeunes.fr/sondage/_javascript" : arguments[1];
   document.write("<script type=\"text/javascript\" src=\""+rep+"/"+file+"\" xml:space=\"preserve\"></script>");
}
//Opérations sur les popups
function ouvre_popup(fichier)
{
   var w=(arguments.length > 1) ? arguments[1] : "";
   var h=(arguments.length > 2) ? arguments[2] : "";
   var s=(arguments.length > 3) ? arguments[3] : "no";
   var r=(arguments.length > 4) ? arguments[4] : "no";
   s=((s==1) || (s=="yes")) ? "yes" : "no";
   r=((r==1) || (r=="yes")) ? "yes" : "no";
   var win=null;
   win=window.open(fichier, "poj", "location=no,menubar=no,status=no,scrollbars="+s+",resizable="+r+",width="+w+",height="+h);
   if(win)
      win.focus();
   return(win);
}

function sendToZip(sPath, aRet, sLibelle)
{
   var w=(arguments.length > 3) ? arguments[3] : "";
   var h=(arguments.length > 4) ? arguments[4] : "";
   var s=(arguments.length > 5) ? arguments[5] : "no";
   var r=(arguments.length > 6) ? arguments[6] : "no";
   s=((s==1) || (s=="yes")) ? "yes" : "no";
   r=((r==1) || (r=="yes")) ? "yes" : "no";
   var win=ouvre_popup("", w, h, s, r);
   win.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\" lang=\"fr\">\n");
   win.document.write("<head><title>Famille Coste [T&#233;l&#233;chargement de fichier ZIP]</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../_style/framework.css\" media=\"all\"></link>\n");
   win.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"../_style/framework.css\" media=\"all\"></link>\n");
   win.document.write("</head>\n<body onload=\"document.forms[0].submit();\">\n<div id=\"contenu\">");
   win.document.write("<p id=\"titrepage\" class=\"zip\">Pr&#233;paration du t&#233;l&#233;chargement.</p><form name=\"poj\" action=\"../_php/zip.php\" method=\"POST\">\n");
   win.document.write("<input type=\"hidden\" name=\"nom\" value=\""+sLibelle+"\" />");
   win.document.write("<input type=\"hidden\" name=\"path\" value=\""+sPath+"\" />");
   for(var i=0; i<aRet.length; i++)
      win.document.write("<input type=\"hidden\" name=\"p[]\" value=\""+aRet[i]+"\" />");
   win.document.write("\n<input type=\"submit\" value=\"T&#233;l&#233;charger\" class=\"envoi\" />\n");
   win.document.write("<p id=\"end\"><a id=\"close\" onclick=\"javascript:window.close();\" title=\"Fermer la fenêtre\" href=\"javascript:void(0);\">Fermer</a></p>\n");
   win.document.write("</form></div></body></html>");
   win.document.close();
}

//Fermeture d'une fenêtre
function wClose(){opener=self;self.close();}

//Récupération d'un élément par son identifiant
function GetID(sID)
{
   var dhtml=(document.getElementById) ? "dhtml" : ( (((document.all)&&(!document.getElementById)) ? "ie4" : ((document.layers) ? "ns4" : "old") ) );
   var ret=null;
   switch(dhtml)
   {
   case "dhtml":
      if (document.getElementById(sID))
        ret=document.getElementById(sID);
      break;
   case "ie4":
      if (document.all(sID))
         ret=document.all(sID);
      break;
   case "ns4":
      if (document.layers(sID))
        ret=document.layers(sID);
      break;
   }
   return(ret);
}
//Retourne un élément ou plusieurs
function $()
{
  var elements=new Array();
  for (var i=0; i<arguments.length; i++)
  {
    var element=arguments[i];
    if (typeof element=='string')
      element=GetID(element);
    if (arguments.length==1)
      return(element);
    elements.push(element);
  }
  return(elements);
}
function affDiv(sid)
{
   var gid=GetID(sid);
   var aff="";
   if(gid!=null)
   {
      aff=(arguments.length>1) ? arguments[1] : gid.style.display=="none";
      gid.style.display=(aff) ? "block" : "none";
   }
   return(true);
}

function roll(elem, balise, dossierImage)
{
   if(elem.parentNode.getElementsByTagName(balise).length==0)
   {
      if(elem.tagName!="html")
         roll(elem.parentNode, balise, dossierImage);
   }
   else
   {
      var p=elem.parentNode.getElementsByTagName(balise);
      for(var i=0;i<p.length;i++)
      {
         var aff=(arguments.length>3) ? arguments[3] : p[i].style.display=="none";
         p[i].style.display=(aff) ? "block" : "none";
         var img=elem.getElementsByTagName("img");
         if(img[0])
            img[0].src=(p[i].style.display=="none") ? dossierImage+"_images/b_right2.ico" : dossierImage+"_images/b_down2.ico";
      }
   }
   return(true);
}

//Objet permettant d'exécuter des fonctions
function loading()
{
   this.nb=0;
   this.add=add;
   this.exec=exec;
   this.toString=function(){var ret="";for(var i=0; i<this.nb; i++) ret+="FCT : "+this[i].fct+" -  ARG : "+this[i].arg.toString()+"\n";return(ret);}
   function add(fct_name)
   {
      if (fct_name!=null)
      {
         var m=new Object();
         m.arg=new Array();
         m.fct=fct_name;
         for(var i=1; i< arguments.length; i++)
            m.arg.push(arguments[i]);
         this[this.nb]=m;
         this.nb++;
      }
   }
   function exec()
   {
      for(var i=0; i < this.nb; i++)
      {
         try{this[i].fct(this[i].arg);}
         catch(e)
         {
            try{eval(this[i].fct+"("+this[i].arg.replaceAll("\n", "\\n").replaceAll("\"", "\\\"").toString()+");");}
            catch(e)
            {
               try{eval(this[i].fct+"('"+this[i].arg.replaceAll("\n", "\\n").replaceAll("\"", "\\\"").toString()+"');");}
               catch(e)
               {
                  try{this[i].fct;}
                  catch(e){var ret=""; for(var i in e) ret+="\n"+i.lpad(12)+" : "+e[i];debug("Erreur !\n"+ret);}
               }
            }
         }
      }
   }
}

//Simulation du doubleclick
var tempsDernierClick=null;
var dernierClick=null;
var tempsEntreDeuxClics=500;
function verifDoubleClic()
{
   var elem=arguments.length>0 ? arguments[0] : this;
   var tempsClicEnCours = (new Date()).getTime();
   if ( (dernierClick == elem) && (tempsClicEnCours < tempsDernierClick + tempsEntreDeuxClics) )
   {
      dernierClick = null; // on remet à zéro
      return true; // c'est bien un double-clic sur le même objet
   }
   else
   {
      dernierClick = elem;
      // pour être sûr de cliquer sur le même objet
      tempsDernierClick = tempsClicEnCours;
      return false; // c'est un simple clic pour le moment)
   }
}

//Opération sur les touches tapées
function recupCode(o_key)
{
   if (o_key.keyCode)
      return(o_key.keyCode);
   else
      return(o_key.which);
}

function isSpecialKey(o_key)
{
   var rec=recupCode(o_key);
   return((rec==8) || (rec==9) || (rec==13) || ((rec>=33) && (rec<=40)) || (rec==116) );
   //37: left arrow, 39: right arrow, 33: page up, 34: page down, 36: home, 35: end, 13: enter, 9: tab, 27: esc, 16: shift
   //17: ctrl, 18: alt, 20: caps lock, 8: backspace, 46: delete, 38: up arrow, 40: down arrow
}

function returnCode(o_key, tst)
{
   if (o_key.returnValue)
   {
      o_key.returnValue=tst;
      return(true);
   }
   else
   {
      if (isSpecialKey(o_key))
         return(true);
      else
         return(tst);
   }
}

//Vérification de la lettre tapée
//o_key    : evenement
//element  : champ texte
function verifString(o_key, element)
{
   var N = new RegExp("^[éèêëàâäïîçùôöa-zA-Z0-9 '-.%]");
   return(returnCode(o_key, N.test(String.fromCharCode(recupCode(o_key)))));
}
//Vérification de la lettre tapée
//o_key    : evenement
//element  : champ texte
function verifIdent(o_key, element)
{
   var N = new RegExp("^[a-zA-Z0-9]");
   return(returnCode(o_key, N.test(String.fromCharCode(recupCode(o_key)))));
}
//Mise en majuscule de la lettre tapée
//o_key    : evenement
//element  : champ texte
function toUpper(o_key, element)
{
   var N = new RegExp("^[a-zA-Z --'0-9]");
   if (N.test(String.fromCharCode(recupCode(o_key))))
   {
      recupCode(o_key) = String.fromCharCode(recupCode(o_key)).toUpperCase().charCodeAt(0);
      return(returnCode(o_key, true));
   }
   else
      return(returnCode(o_key, true));
}
//Empeche la saisie de caractères autres que des nombres entiers
//o_key    : evenement
//element  : champ texte
function verifNumber(o_key, element)
{
   var N = new RegExp("^[0-9]");
    if((element.value.length==0) && (recupCode(o_key) == 45))
      return(returnCode(o_key, true));
   return(returnCode(o_key, N.test(String.fromCharCode(recupCode(o_key)))));
}
//Empeche la saisie de caractères autres que des nombres décimaux
//o_key    : evenement
//element  : champ texte
function verifFloat(o_key, element)
{
    var N = new RegExp("^[0-9.]");
    var tmp=element.value.split(".");
    if((element.value.length==0) && (recupCode(o_key) == 45))
      return(returnCode(o_key, true));
    if (N.test(String.fromCharCode(recupCode(o_key))))
        if ((tmp.length>1) && (recupCode(o_key) == 46))
      return(returnCode(o_key, false));
        else
      return(returnCode(o_key, true));
    else
        return(returnCode(o_key, false));
}
//Empeche la saisie de caractères autres que des nombres hexadécimaux
//o_key    : evenement
//element  : champ texte
function verifHexa(o_key, element)
{
   var N = new RegExp("^[0-9a-fA-F%]");
   return(returnCode(o_key, N.test(String.fromCharCode(recupCode(o_key)))));
}

function createField()
{
   var elem=new Object();
   elem.type="input";
   elem.frm=(document.forms.length>0) ? document.forms[0] : document.body;

   if(arguments.length>0)
      elem=arguments[0];
   var detail=arguments.length>1 ? arguments[1] : new Object();
   var _input=document.createElement(elem.type);
   Object.extend(_input, detail);
   elem.frm.appendChild(_input);
}

function removeChildren(gid, balise)
{
   for(var i=gid.childNodes.length-1;i>=0;i--)
      if(gid.childNodes[i].nodeName.toLowerCase()==balise.toLowerCase())
         gid.removeChild(gid.childNodes[i]);
/*
   var childrens=gid.getElementsByTagName(balise);
   if(childrens.length>0)
   {
      for(var i=childrens.length-1;i>=0;i--)
         gid.removeChild(childrens[i]);
   }
*/
}

function createChildren(gid, balise)
{
   var sHtml=arguments.length>2 ? arguments[2] : "";
   var aAttributes=arguments.length>3 ? arguments[3] : Array();
   var sWhere=arguments.length>4 ? arguments[4] : 1;
   if(!aAttributes)
      aAttributes=new Array();
   if(sWhere==null)
      sWhere=1;
   //sWhere=1 si à la fin, 0 si au début
   var p=document.createElement(balise);
   for(var i=0;i<aAttributes.length;i++)
   {
      if(aAttributes[i][0]=="style" && navigator.ie())
         p.style.setAttribute("cssText", aAttributes[i][1]);
      else
      if(aAttributes[i][0]=="class")
         p.className=aAttributes[i][1];
      else
         p.setAttribute(aAttributes[i][0], aAttributes[i][1]);
   }
   if(sHtml)
      p.innerHTML=sHtml;
   if((gid.getElementsByTagName(balise).length==0) || (sWhere==1))
      gid.appendChild(p);
   else
      gid.insertBefore(p, getChild(gid, balise));
   return(p);
}

function getChild(gid, balise)
{
   if(gid.getElementsByTagName(balise).length>0)
      return(gid.getElementsByTagName(balise)[0]);
   else
      return("");
}

function getParent(elem, nodename)
{
   if(!nodename)
      nodename="div";
   nodename=nodename.toLowerCase();
   if(elem.nodeName.toLowerCase()==nodename)
      return(elem);
   else
      return(getParent(elem.parentNode, nodename));
}

//Affichage pour débugage
function debug()
{
   var rsp=(arguments.length>0) ? arguments[0] : "";
   var arg=(arguments.length>1) ? arguments[1] : "a";
   var sid=(arguments.length>2) ? arguments[2] : "debug";
   var gid=$(sid);
   if(gid)
   {
      if(gid.getElementsByTagName("dl").length>0)
         gid=gid.getElementsByTagName("dl")[0];
      if(rsp=="")
      {
         removeChildren(gid, "dd");
         affDiv(sid, false);
      }
      else
      {
         affDiv(sid, true);
         if(arg!="a")
            removeChildren(gid, "dd");
         createChildren(gid, "dd", rsp);
      }
   }
   else
      alert(rsp);
}

/*Gestion des objets*/
if (!window.Element) {
  var Element = new Object();
}

Object.extend(Element, {
  visible: function(element) {
    return $(element).style.display != 'none';
  },

  toggle: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      Element[Element.visible(element) ? 'hide' : 'show'](element);
    }
  },

  hide: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      element.style.display = 'none';
    }
  },

  show: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      element.style.display = 'block';
    }
  },

  remove: function(element) {
    element = $(element);
    element.parentNode.removeChild(element);
  },

  update: function(element, html) {
    $(element).innerHTML = html.stripScripts();
  },

  getHeight: function(element) {
    element = $(element);
    return(element.offsetHeight);
  },

  empty: function(element) {
    return $(element).innerHTML.match(/^\s*$/);
  },

  scrollTo: function(element) {
    element = $(element);
    var x = element.x ? element.x : element.offsetLeft,
        y = element.y ? element.y : element.offsetTop;
    window.scrollTo(x, y);
  },

  getStyle: function(element, style) {
    element = $(element);
    var value = element.style[style.camelize()];
    if (!value) {
      if (document.defaultView && document.defaultView.getComputedStyle) {
        var css = document.defaultView.getComputedStyle(element, null);
        value = css ? css.getPropertyValue(style) : null;
      } else if (element.currentStyle) {
        value = element.currentStyle[style.camelize()];
      }
    }
    return((value=='auto') ? null:value);
  },

  setStyle: function(element, style) {
    element = $(element);
    for (name in style)
      element.style[name.camelize()] = style[name];
  },

  getDimensions: function(element) {
    element = $(element);
    if (Element.getStyle(element, 'display') != 'none')
      return {width: element.offsetWidth, height: element.offsetHeight};
    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = '';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
    els.display = 'none';
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
  },

  makePositioned: function(element) {
    element = $(element);
    var pos = Element.getStyle(element, 'position');
    if (pos == 'static' || !pos) {
      element._madePositioned = true;
      element.style.position = 'relative';
      // Opera returns the offset relative to the positioning context, when an
      // element is position relative but top and left have not been defined
      if (window.opera) {
        element.style.top = 0;
        element.style.left = 0;
      }
    }
  },

  undoPositioned: function(element) {
    element = $(element);
    if (element._madePositioned) {
      element._madePositioned = undefined;
      element.style.position =
        element.style.top =
        element.style.left =
        element.style.bottom =
        element.style.right = '';
    }
  },

  makeClipping: function(element) {
    element = $(element);
    if (element._overflow) return;
    element._overflow = element.style.overflow;
    if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
      element.style.overflow = 'hidden';
  },

  undoClipping: function(element) {
    element = $(element);
    if (element._overflow) return;
    element.style.overflow = element._overflow;
    element._overflow = undefined;
  }
});

/****Gestion des événements*/
if (!window.Event)
  var Event = new Object();

Object.extend(Event, {
  KEY_BACKSPACE: 8,
  KEY_TAB:       9,
  KEY_RETURN:   13,
  KEY_ESC:      27,
  KEY_LEFT:     37,
  KEY_UP:       38,
  KEY_RIGHT:    39,
  KEY_DOWN:     40,
  KEY_DELETE:   46,
  element: function(event) {
    return(event.target || event.srcElement);
  },

  isLeftClick: function(event) {
    return (((event.which) && (event.which == 1)) ||
            ((event.button) && (event.button == 1)));
  },

  pointerX: function(event) {
    return event.pageX || (event.clientX +
      (document.documentElement.scrollLeft || document.body.scrollLeft));
  },

  pointerY: function(event) {
    return event.pageY || (event.clientY +
      (document.documentElement.scrollTop || document.body.scrollTop));
  },

  // find the first node with the given tagName, starting from the
  // node the event was triggered on; traverses the DOM upwards
  findElement: function(event, tagName) {
    var element = Event.element(event);
    while (element.parentNode && (!element.tagName ||
        (element.tagName.toUpperCase() != tagName.toUpperCase())))
      element = element.parentNode;
    return element;
  },
  addEvent: function(oElem, sEvType, fn, bCapture)
  {
    return((oElem.addEventListener) ?
            oElem.addEventListener(sEvType, fn, bCapture) :
            (oElem.attachEvent) ?
                oElem.attachEvent('on' + sEvType, fn) :
                oElem['on' + sEvType] = fn);
  },
  removeEvent: function(oElem, sEvType, fn, bCapture)
  {
    if (oElem.removeEventListener)
      return(oElem.removeEventListener(sEvType, fn, bCapture));
    else if (oElem.detachEvent)
      return(oElem.detachEvent('on'+sEvType, fn));
    else
      return(false);
  }
});

var Position = {
  // set to true if needed, warning: firefox performance problems
  // NOT neeeded for page scrolling, only if draggable contained in
  // scrollable elements
  includeScrollOffsets: false,

  // must be called before calling withinIncludingScrolloffset, every time the
  // page is scrolled
  prepare: function() {
    this.deltaX =  window.pageXOffset
                || document.documentElement.scrollLeft
                || document.body.scrollLeft
                || 0;
    this.deltaY =  window.pageYOffset
                || document.documentElement.scrollTop
                || document.body.scrollTop
                || 0;
  },

  realOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.scrollTop  || 0;
      valueL += element.scrollLeft || 0;
      element = element.parentNode;
    } while (element);
    return [valueL, valueT];
  },

  cumulativeOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
    } while (element);
    return [valueL, valueT];
  },

  positionedOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
      if (element) {
        p = Element.getStyle(element, 'position');
        if (p == 'relative' || p == 'absolute') break;
      }
    } while (element);
    return [valueL, valueT];
  },

  offsetParent: function(element) {
    if (element.offsetParent) return element.offsetParent;
    if (element == document.body) return element;

    while ((element = element.parentNode) && element != document.body)
      if (Element.getStyle(element, 'position') != 'static')
        return element;

    return document.body;
  },

  // caches x/y coordinate pair to use with overlap
  within: function(element, x, y) {
    if (this.includeScrollOffsets)
      return this.withinIncludingScrolloffsets(element, x, y);
    this.xcomp = x;
    this.ycomp = y;
    this.offset = this.cumulativeOffset(element);

    return (y >= this.offset[1] &&
            y <  this.offset[1] + element.offsetHeight &&
            x >= this.offset[0] &&
            x <  this.offset[0] + element.offsetWidth);
  },

  withinIncludingScrolloffsets: function(element, x, y) {
    var offsetcache = this.realOffset(element);

    this.xcomp = x + offsetcache[0] - this.deltaX;
    this.ycomp = y + offsetcache[1] - this.deltaY;
    this.offset = this.cumulativeOffset(element);

    return (this.ycomp >= this.offset[1] &&
            this.ycomp <  this.offset[1] + element.offsetHeight &&
            this.xcomp >= this.offset[0] &&
            this.xcomp <  this.offset[0] + element.offsetWidth);
  },

  // within must be called directly before
  overlap: function(mode, element) {
    if (!mode) return 0;
    if (mode == 'vertical')
      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
        element.offsetHeight;
    if (mode == 'horizontal')
      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
        element.offsetWidth;
  },
/*
  clone: function(source, target) {
    source = $(source);
    target = $(target);
    target.style.position = 'absolute';
    var offsets = this.cumulativeOffset(source);
    target.style.top    = offsets[1] + 'px';
    target.style.left   = offsets[0] + 'px';
    target.style.width  = source.offsetWidth + 'px';
    target.style.height = source.offsetHeight + 'px';
  },
*/
  page: function(forElement) {
    var valueT = 0, valueL = 0;

    var element = forElement;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;

      // Safari fix
      if (element.offsetParent==document.body)
        if (Element.getStyle(element,'position')=='absolute') break;

    } while ((element=element.offsetParent)!=null);

    element = forElement;
    do {
      valueT -= element.scrollTop  || 0;
      valueL -= element.scrollLeft || 0;
    } while ((element = element.parentNode)!=null);

    return [valueL, valueT];
  },

  clone: function(source, target) {
    var options = Object.extend({
      setLeft:    true,
      setTop:     true,
      setWidth:   true,
      setHeight:  true,
      offsetTop:  0,
      offsetLeft: 0
    }, arguments[2] || {})

    // find page position of source
    source = $(source);
    var p = Position.page(source);

    // find coordinate system to use
    target = $(target);
    var delta = [0, 0];
    var parent = null;
    // delta [0,0] will do fine with position: fixed elements,
    // position:absolute needs offsetParent deltas
    if (Element.getStyle(target,'position') == 'absolute') {
      parent = Position.offsetParent(target);
      delta = Position.page(parent);
    }

    // correct by body offsets (fixes Safari)
    if (parent == document.body) {
      delta[0] -= document.body.offsetLeft;
      delta[1] -= document.body.offsetTop;
    }

    // set position
    if(options.setLeft)   target.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
    if(options.setTop)    target.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
    if(options.setWidth)  target.style.width = source.offsetWidth + 'px';
    if(options.setHeight) target.style.height = source.offsetHeight + 'px';
    return null;
  },

  absolutize: function(element) {
    element = $(element);
    if (element.style.position == 'absolute') return;
    Position.prepare();

    var offsets = Position.positionedOffset(element);
    var top     = offsets[1];
    var left    = offsets[0];
    var width   = element.clientWidth;
    var height  = element.clientHeight;

    element._originalLeft   = left - parseFloat(element.style.left  || 0);
    element._originalTop    = top  - parseFloat(element.style.top || 0);
    element._originalWidth  = element.style.width;
    element._originalHeight = element.style.height;

    element.style.position = 'absolute';
    element.style.top    = top + 'px';;
    element.style.left   = left + 'px';;
    element.style.width  = width + 'px';;
    element.style.height = height + 'px';;
  },

  relativize: function(element) {
    element = $(element);
    if (element.style.position == 'relative') return;
    Position.prepare();

    element.style.position = 'relative';
    var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
    var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);

    element.style.top    = top + 'px';
    element.style.left   = left + 'px';
    element.style.height = element._originalHeight;
    element.style.width  = element._originalWidth;
  }
}

// Safari returns margins on body which is incorrect if the child is absolutely
// positioned.  For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
  Position.cumulativeOffset = function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      if (element.offsetParent == document.body)
        if (Element.getStyle(element, 'position') == 'absolute') break;

      element = element.offsetParent;
    } while (element);

    return [valueL, valueT];
  }
}

function createActiveXObject(id)
{
   var error;
   var control = null;
   try
   {
      if (window.ActiveXObject)
         control = new ActiveXObject(id);
      else if (window.GeckoActiveXObject)
         control = new GeckoActiveXObject(id);
      else if(navigator.mimeTypes)
         control=navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;
   }
   catch (error)
   {
      ;
   }
   return(control);
}

function delVar(oVar)
{
   oVar=null;
   return(true);
}

var onLoaded=new loading();
Event.addEvent(window, "load", function () {onLoaded.exec();}, false);
var onClosed=new loading();
Event.addEvent(window, "unload", function () {onClosed.exec();}, false);

function msgError(nouvelle,fichier,ligne)
{
  erreur="Message d'erreur:\n"+nouvelle+"\n"+fichier+"\n"+ligne;
  affiche_Erreur();
  return(true);
}

function affiche_Erreur()
{
   if($("debug"))
      debug(window.erreur, "a");
   else if(window.erreur)
      alert(window.erreur);
   else
      alert("Erreur");
}

function getVal(elem)
{
   if(elem["value"])
      return(elem["value"]);
   if(elem["text"])
      return(elem["text"]);
   if(elem["textContent"])
      return(elem["textContent"]);
   if(elem["innerText"]!=null)
      return(elem["innerText"]);
   if(elem["nodeType"])
   {
      if(elem["nodeValue"]!=null)
         return(elem["nodeValue"]);
      else
         return("");
   }
   if(elem)
      return(elem);
   return("");
}
function setVal(elem, txt)
{
   if(elem["value"])
      return(elem["value"]=txt);
   if(elem["text"])
      return(elem["text"]=txt);
   if(elem["textContent"])
      return(elem["textContent"]=txt);
   if(elem["innerText"]!=null)
      return(elem["innerText"]=txt);
   if(elem["nodeType"])
   {
      if(elem["nodeValue"]!=null)
         return(elem["nodeValue"]=txt);
      else
         return(false);
   }
   if(elem)
      return(elem);
   return("");
}
//Préchargement d'images
var tabImg=new Array();
function preloadImages()
{
   if(arguments[0].length>0)
   {
      for(var i=0;i<arguments[0].length;i++)
      {
         var img=new Image();
         img.src="./"+arguments[0][i];
         tabImg.push(img);
     }
     setTimeout("isImageComplete()",200);
   }
}

function isImageComplete()
{
   if (document.images)
   {
      for (var i=0;i<tabImg.length;i++)
      {
         if (tabImg[i].complete)
         {
            tabImg.del(i);
            i--;
         }
      }
   }
   if (tabImg.length>0)
      setTimeout("isImageComplete()",200);
}
//Fin de préchargement d'images
if(!posMouse)
   var posMouse;
posMouse=Array(0,0);
function mouseMoved(evt)
{
  var DocRef;
  var Mouse_X;
  var Mouse_Y;
  var e=(window.event) ? window.event : evt;
  if(navigator.netscape()){
    Mouse_X = e.pageX;
    Mouse_Y = e.pageY;
  }
  else{
    if( document.documentElement && document.documentElement.clientWidth)
      DocRef = document.documentElement;
    else
      DocRef = document.body;

    Mouse_X = e.clientX+DocRef.scrollLeft;
    Mouse_Y = e.clientY+DocRef.scrollTop;
  }
  posMouse=[Mouse_X,Mouse_Y];
  //window.status="X="+Mouse_X+", Y="+Mouse_Y;
}

var onMoved=new loading();
onMoved.add("mouseMoved");
onLoaded.add(lanceMouseMove);
function lanceMouseMove()
{
   Event.addEvent(document, "mousemove", function (e)
      {
         for(var i=0;i<onMoved.nb; i++)
            eval(onMoved[i].fct+"(e)");
      }, true);
}
/*détection click droit
function droite(e)
	{
	if ((!document.all && e.which == 3) || (document.all && event.button==2))
		{
		// CLIC DROIT DETECTE, ON AFFICHE UN PETIT MESSAGE
		alert('Clic droit detecté');
		}
	return true;
}
document.onmousedown = droite;
*/
//Récupération des éléments d'un formulaire à envoyer en url
function ElemToUrl(frm, sSep, bReplace)
{
   if(sSep==null)
      sSep="&";
   if(bReplace==null)
      bReplace=false;
   var elem;
   var i = 0;
   var chaine = new Array();
   for (var i=0; i<frm.elements.length; i++)
   {
      elem = frm.elements[i];
      switch (elem.type)
      {
         case "radio":
            if (elem.checked)
               chaine.push(elem.name+"="+elem.value.encode64());
            break;
         case "select-one":
            chaine.push(elem.name+"="+elem.value.encode64());
            break;
         case "submit":
            break;
         case "button":
            break;
         default:
            chaine.push(elem.name+"="+elem.value.encode64());
            break;
      }
   }
   if(bReplace)
      return(chaine.join(sSep).encodeUrl());
   else
      return(chaine.join(sSep));
}

var saveFct=null;
function replaceEvent(elem)
{
   if(elem.onclick!=null)
   {
      saveFct=elem.onclick;
      elem.onclick=null;
   }
   else
      elem.onclick=saveFct;
}

//Déplacement de div
function deplaceDiv(sid)
{
   this.sid=sid;
   this.isMoved=false;
   this.lancedeplace=lancedeplace;
   this.deplace=deplacer;
   this.agrandit=agrandir;
   this.posX=0;
   this.posY=0;
   this.width=0;
   this.height=0;
   this.dX=0;
   this.dY=0;
   this.toString=function()
   {
      return("sid="+this.sid+"\nisMoved="+this.isMoved+"\nposX="+this.posX+"\nposY="+this.posY+"\nwidth="+this.width+"\nheight="+this.height+"\ndX="+this.dX+"\ndY="+this.dY+"\n");
   }

   function lancedeplace(bDeplace, elem)
   {
      if(elem==null)
         elem=$(this.sid);
      this.isMoved=bDeplace;
      if(bDeplace && (elem!=null))
      {
         var pos=Position.positionedOffset($(this.sid));
         var posElem=Position.positionedOffset(elem);
         this.posX=posElem[0].toNumber();
         this.posY=posElem[1].toNumber();
         this.width=this.posX-pos[0].toNumber();
         this.height=this.posY-pos[1].toNumber();
         this.dX=posMouse[0].toNumber()-this.posX.toNumber()+5;
         this.dY=posMouse[1].toNumber()-this.posY.toNumber()+5;
      }
   }

   function deplacer(evt)
   {
      var gid=$(this.sid);
      if(gid!=null)
      {
         var pos=Position.positionedOffset(gid);
         if(this.isMoved==1)
         {
            gid.style.left=this.posX+"px";
            gid.style.top=this.posY+"px";
            this.posX=posMouse[0].toNumber()-this.dX;
            this.posY=posMouse[1].toNumber()-this.dY;
         }
      }
   }

   function agrandir(evt)
   {
      if($(this.sid)!=null)
      {
         var pos=Position.positionedOffset($(this.sid));
         if(this.isMoved==1)
         {
            this.width=this.width+posMouse[0]-this.posX-this.dX;
            $(this.sid).style.width=this.width+"px";
            this.posX=posMouse[0].toNumber()-this.dX;
            this.posY=posMouse[1].toNumber()-this.dY;
         }
      }
   }
}

//Bulle qui suit la souris
function ObjShow( div_, x_, y_, z_){
  var Decal_X=arguments.length>4 ? arguments[4] : 0;
  var Decal_Y=arguments.length>5 ? arguments[5] : 0;
  x_+=Decal_X;
  y_+=Decal_Y;
  var Obj = $(div_);
  var DocRef;
  var MaxX, MaxY;
  var Top,  Left;
  var Haut, Larg;
  var SavY = y_;
  if( Obj){
    //-- Récup. dimension fenêtre et DIV
    if( navigator.netscape()){
      with( window){
        Left = pageXOffset;
        Top  = pageYOffset;
        MaxX = innerWidth;
        MaxY = innerHeight;
        //if( MaxX > document.width)  MaxX = document.width;
        //if( MaxY > document.height) MaxY = document.height;
        MaxX += Left;
        MaxY += Top;
      }
      if(navigator.ns4()){
        Larg = Obj.clip.width;
        Haut = Obj.clip.height;
      }
      else{
        Larg = Obj.offsetWidth;
        Haut = Obj.offsetHeight;
      }
    }
    else{
      if( document.documentElement && document.documentElement.clientWidth)
        DocRef = document.documentElement;
      else
        DocRef = document.body;

      with( DocRef){
        Left = scrollLeft;
        Top  = scrollTop;
        MaxX = Left + clientWidth;
        MaxY = Top  + clientHeight;
      }

      Larg = Obj.scrollWidth;
      Haut = Obj.scrollHeight;
    }
    //-- Réajuste dimension fenêtre
    MaxX -= Larg;
    MaxY -= Haut;

    //-- Application Bornage
    if( x_ > MaxX) x_ = MaxX;
    if( x_ < Left) x_ = Left;
    if( y_ > MaxY) y_ = MaxY;
    if( y_ < Top){ y_=Top;}
    //-- si en bas On réajuste
    //-- pour que la bulle ne prenne pas le focus
    if( y_== MaxY){
      var DeltaY = MaxY -SavY;
      y_ = MaxY - DeltaY -Haut -2*Decal_Y;
    }

    //-- On place la Bulle
    Obj.style.left=x_+"px";
    Obj.style.top=y_+"px";
  }
}
function auteur()
{
   alert("Cr"+chr(233)+"ateur du site : Paul-Marie Coste", "Créateur du site");
   return(false);
}
//Intégration des erreurs
include("error.js", "http://www.placeojeunes.fr/dev/sondage/_javascript");
