<!--

//   Divers scripts

function OuvrirFenetre(url, nom, width, height, tbars)
{
   var options;

   if(width > 0)   options = "width=" + width;
   if(height > 0) {
      if(options.length > 0)   options = options + ", ";
      options = options + "height=" + height;
   }
   if(options.length > 0)   options = options + ", ";
   if(tbars == 0) {
      options = options + "scrollbars=yes, resizable=no, copyhistory=no";
   }
   else {
      options = options + "resizable=yes, scrollbars=yes";
   }

   window.open(url, nom, options)
}

function loadwindow(fichier, w, h)
{
   window.open(fichier, "fn0", "width=" + w + ", height=" + h);
}

function loadwindowpos(fichier, l, t, w, h)
{
   self.name = "main";
   if(navigator.appName.indexOf("Microsoft") >= 0) {
      chaine = "left=" + l + ", top=" + t + ", width=" + w + ", height=" + h + ", scrollbars=no, resizable=no, copyhistory=no";
   }
   else {
      chaine = "ScreenX=" + l + ", ScreenY=" + t + ", width=" + w + ", height=" + h + ", scrollbars=no, resizable=no, copyhistory=no";
   }

   window.open(fichier, "fn0", chaine);
}

function Atel_ValiderFormuInscr()
{
   document.formlogin.login.value    = document.forminscrip.fakelogin.value;
   document.formlogin.password.value = document.forminscrip.fakepassword.value;
   document.formlogin.valider.value  = "valider";

   document.formlogin.submit();
}

//   Scripts pour les menus déroulants

var IE4 = (document.all) ? true : false;
var objtmp = null;

function findWindowX()
{
   var larg;
   if(document.body) {
      larg = document.body.clientWidth;
   }
   else {
      larg = window.innerWidth;
   }

   return larg;
}

function findPosX(obj, position)
{
   var curleft = 0;
   var i = 0;
   if(obj.offsetParent) {
      while(obj.offsetParent && i == 0) {
         curleft += obj.offsetLeft;
	 obj = obj.offsetParent;
	 if (position == 'newbas') i = 1;
      }
   }
   else if(obj.x) {
      curleft += obj.x;
   }
   
   return curleft;
}

function findPosY(obj, position)
{
   var curtop = 0;
   var i = 0;
   if(obj.offsetParent) {
      while(obj.offsetParent && i == 0) {
	 curtop += obj.offsetTop;
	 obj = obj.offsetParent;
	 if (position == 'newbas') i = 1;
      }
   }
   else if(obj.y) {
      curtop += obj.y;
   }

   return curtop;
}

function Lobj(tmp)
{
   if(IE4) {
      return document.all[tmp];
   }
   else {
      return document.getElementById(tmp);
   }
}

function menu(o, tmp, flag, position, txt, bg)
{
   if(flag == 1) {

      objtmp = null;
      
      switch(position) {

         // les boutons cachés
         case 'right':
            posx = 3; posy = -5;
            break;

         // menu toolbar en vertical
         case 'speright':
            posx = parseInt(o.style.width);
            posy = (IE4) ? -2 : -1;
            break;

         // menu hierarchie petite taille et toolbar en horizontal
         case 'bas':
            posx = 0; posy = 15;
            break;

	// toolbar principale horizontale nouveau site
	case 'newbas':
	    posx = 0; posy = 5;
	    break;
      }

      if(IE4) {
         if(position == 'right') {
            objwidth = parseInt(document.all['l' + tmp].value);
            /* :XXX: IE BUG FIX */
            Lobj(tmp).style.width = objwidth + 30;

            if(findPosX(o) + objwidth > findWindowX()) {
               posx = -objwidth;
            }
         }
         Lobj(tmp).style.posLeft = findPosX(o, position) + posx;
         Lobj(tmp).style.posTop  = findPosY(o, position) + posy;
      }
      else {
         if(position == 'right') {
            objwidth = parseInt(document.getElementById('l' + tmp).value);

            if(findPosX(o) + objwidth > findWindowX()) {
               posx = -objwidth;
            }
         }
         if(IE4)
      {
         if(position == 'right')
            objwidth = parseInt(document.all['l' + tmp].value);
         if(position == 'right' && findPosX(o)+objwidth > findWindowX())
            posx = -objwidth;
         Lobj(tmp).style.left = findPosX(o, position) + posx;
         Lobj(tmp).style.top  = findPosY(o, position) + posy;
      }
      else
      {
         if(position == 'right')
            objwidth = parseInt(document.getElementById('l' + tmp).value);
         if(position == 'right' && findPosX(o)+objwidth > findWindowX())
            posx = -objwidth;
         Lobj(tmp).style.left = findPosX(o, position) + posx + 'px';
         Lobj(tmp).style.top  = findPosY(o, position) + posy + 'px';
      }
      }
   }

   if(flag == 0) {
      Lobj(tmp).style.visibility = 'hidden';
      if(objtmp) {
         objtmp.className = '';
      }
   }
   
   else {
      Lobj(tmp).style.visibility = 'visible';
      if(flag == 3) {
         objtmp = Lobj('style' + tmp);
         Lobj('style' + tmp).className = 'tblink'
      }
   }
}

function rollover(id, tagvis)
{
   if(tagvis) {
      document.images[id + 'ico'].style.visibility = 'visible';
   }
   else {
      document.images[id + 'ico'].style.visibility = 'hidden';
   }
}

//   Affichage des explications

var explistyle = null;

function AttrapObj(idexpli)
{
   if(document.layers)                return document.layers[idexpli].style;
   else if(document.all)              return document.all[idexpli].style;
   else if(document.getElementById)   return document.getElementById(idexpli).style;
   else {
      alert("Vous n'avez pas la dernière version pour ce navigateur.\nPour que tout fonctionne bien, veuillez la télécharger");
      return 0;
   }
}

function AfficheExpli(idexpli)
{
   explistyle = AttrapObj(idexpli);
   if(explistyle) {
      explistyle.visibility = "visible";
      explistyle.display = "inline";
   }
}

function CacheExpli()
{
   explistyle.visibility = "hidden";
   explistyle.display = "none";
}

function activ_mult(bdg_conv,bdg_conv_otp1,bdg_conv_otp2,bdg_conv_otp3,bdg_conv_otp4)   // Dans formulaire de note de frais
  {
  if (bdg_conv.checked == true) 
    { 
    bdg_conv_otp1.disabled = false;
    bdg_conv_otp2.disabled = false;
    bdg_conv_otp3.disabled = false;
    bdg_conv_otp4.disabled = false;
    }
  if (bdg_conv.checked == false)
    {
    bdg_conv_otp1.value="";
    bdg_conv_otp1.disabled=true;
    bdg_conv_otp2.value="";
    bdg_conv_otp2.disabled=true;
    bdg_conv_otp3.value="";
    bdg_conv_otp3.disabled=true;
    bdg_conv_otp4.value="";
    bdg_conv_otp4.disabled=true;
    }
  }

function activ_suite(val1, val2)  // Dans formulaire de note de frais
  {
  if (val1.checked == true) 
    { 
    val2.disabled=false
    }
  if (val1.checked == false)
    {
    val2.value="";
    val2.disabled=true
    }
  }
//-->
