verStr = navigator.appVersion;
app = navigator.appName;
version = parseFloat(verStr);
if( (app.indexOf('Netscape') != -1)&&(version <= 4.75) ) {
  // alert('netscape <= 4,75');
  var navigateur = "ecrit";
}
navigateur = navigator.appName;
x = null;
y = null;
function position(e) {
  var nH2, h2, v;
  x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x; //+document.body.scrollLeft;
  y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y; //+document.body.sc
}
function MM_reloadPage(init) { //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if  ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function OpenWindow(strPage, hauteur, largeur, strName, strStatus, strMenu)
{
  if( !strName ) strName = "_blank";
  if( !strStatus ) strStatus = "yes";
  if( !strMenu ) strMenu = "no";

  var hauteur_popup = 400;
  var largeur_popup = 520;
  if( typeof (hauteur) != 'undefined' ) hauteur_popup = hauteur; 
  if( typeof (largeur) != 'undefined' ) largeur_popup = largeur; 
  var H = (screen.height - hauteur_popup) / 2;
  var L = (screen.width - largeur_popup) / 2;

  if( !navigator.AlkOpener ) {
    navigator.AlkOpener = new Array();
  }
  if( !navigator.AlkOpener[strName] )
    navigator.AlkOpener.length = navigator.AlkOpener.length + 1;
  navigator.AlkOpener[strName] = window;
  popupWindow = window.open(strPage, strName, 
    "status="+strStatus+",menubar="+strMenu+
    ",scrollbars=yes,resizable=yes,height="+hauteur_popup+
    ",width="+largeur_popup+",top="+H+",left="+L);
  if( !popupWindow ) {
    alert("Attention, votre navigateur bloque l'ouverture de fenêtre popup.\n"+
          "Vous devez autoriser l'ouverture de popup pour ce site.");
  }
  
  return popupWindow;
}
function GetWindowOpener()
{
  return ( opener ? opener : navigator.AlkOpener[window.name] );
}
function AlkGoUrl(strUrl)
{
  window.location = strUrl;
}
function Confirmation(strLink, strMsg)
{
  var strTmp = "Do you confirm the delete ?";
  
  if( typeof(strMsg) != 'undefined' ) strTmp = strMsg;
  var res = window.confirm(strTmp);
  if( res ) document.location.href = strLink;
  return;
}

/**
 * @brief Gestion encodage de token
 * @todo A vÃ©rifier
 */

function TextEncode(strParam)
{
  var t = new String("test");
  if (!t.charCodeAt) return strParam;
  var strEncode = "";
  for(var i=0; i<strParam.length; i++) {
    strEncode += DecToHexa(strParam.charCodeAt(i));
  }
  return strEncode;
}

function TextDecode(strParam)
{  
  var test = "";
  var t = new String("test");
  if (!t.fromCharCode && !String.fromCharCode) return strParam;
  //dÃ©codage
  var strDecode = "";
  for(var i=0; i<strParam.length; i+=2 ) {
    strDecode = new String(strDecode) + String.fromCharCode( HexaToDec(strParam.substr(i, 2) ) ) ;
  }

  return strDecode;
}

function DecToHexa(integer, bIter){
  var tabConv = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
  if (integer<=15 ) {
    if( bIter) return tabConv[integer]; 
    return "0"+tabConv[integer];
  }
  var quotient = Math.floor(integer/16);
  var remainder = integer % 16;
  return new String(DecToHexa(quotient,true))+new String(DecToHexa(remainder,true));
}

function HexaToDec(hexa){
  var tabConv = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
  if (hexa.length==1){
    for (var j=0; j<tabConv.length; j++){
      if (tabConv[j].toLowerCase()==hexa.toLowerCase()) return j;
    }
    return 0;
  }
  var res = 0;
  for (var p=0; p<hexa.length; p++){
    res = new Number( new Number(res) + new Number(HexaToDec(hexa.charAt(p))*Math.pow(16, hexa.length - p -1)) );
  }
  return res;
}

if (!document.getElementById){
  function _getElementById(elt_id)
  {
    var oElt = null;
    if ( document.getElementById && document.getElementById( elt_id ) ) {// Pour les navigateurs récents
       oElt = document.getElementById( elt_id );
    }
    else if ( document.all && document.all[ elt_id ] ) {// Pour les veilles versions
      oElt = document.all[ elt_id ];
    }
    else if ( document.layers && document.layers[ elt_id ] ) {// Pour les très veilles versions
      oElt = document.layers[ elt_id ];
    }
    return oElt;
  }
  document.getElementById = _getElementById;
}

/**
 * Ajax - return the XHLHttpRequest object
 */
function GetXMLHttpRequest(){  
  var xhr = null; 
     
  if (window.XMLHttpRequest) // Firefox 
    xhr = new XMLHttpRequest(); 
  else if (window.ActiveXObject) // Internet Explorer 
    xhr = new ActiveXObject("Microsoft.XMLHTTP"); 
  else { // XMLHttpRequest non supporté par le navigateur 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
    return null; 
  } 
  return xhr;
}
