/*DETECTION NAVIGATEUR : 
  n_dhtm : dhtml OK pour le navigateur en cours.
  n_IE  : Internet explorer
  n_NS4 : Netscape 4 (avec layers)
  n_NS6 : Netscape 6+
*/
if(navigator.userAgent.indexOf('Opera') != -1) 
{
  n_dhmt = false;
} 
else 
{ 
  n_dhmt = true;
  n_NS4=(document.layers)?true:false;
  n_IE=(document.all)?true:false;
  n_NS6=((document.getElementById)&&(!n_IE))?true:false;
}


function dhtmTrouveObjet(n, d) 
{     
  if (n_IE)  return document.all[n];
  if (n_NS6) return document.getElementById(n);
  
  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=dhtmTrouveObjet(n,d.layers[i].document);
  //alert(n + ':' + (x?'OK':'INTROUVALE'));
  return x;
}

function dhtmChangePropObj(obj, thePropIE,thePropNN, theValue) 
{
  var theProp = thePropIE;
  if (obj)
  {    
    if (!thePropNN)  
      {thePropNN = thePropIE;}
    if (obj) 
    {
      if (obj.style) 
        {theProp = "style." + thePropIE;} 
      else 
        {theProp = thePropNN};      
      eval("obj."+theProp+"='"+theValue+"'");
    }     
  }
}

function dhtmChangeProp(objName,thePropIE,thePropNN, theValue) 
//si thePropNN est vide, on prend thePropIE. 
{ 
  var obj = dhtmTrouveObjet(objName);  
  dhtmChangePropObj(obj,thePropIE,thePropNN, theValue) ;  
}

function dhtmGetXObj(obj)
{
  var iX = 0;
  if (obj)
  {
    if (obj.x) { iX = obj.x; }       
    else    
    if (obj.offsetLeft)
    {
      while ((obj) )
      {
        if (obj.offsetLeft) {iX += obj.offsetLeft;}        
        obj = obj.offsetParent;
      }
    }
  }
  return iX;
}  
function dhtmGetYObj(obj)
{
  var iY = 0;
  if (obj && obj.y) 
  { iY = obj.y; }
  else 
  {
    while (obj && obj.tagName != "BODY")
    {
      if (obj.offsetTop) {iY += obj.offsetTop};
      obj = obj.offsetParent;
    }
  }
  return iY;
}  

function dhtmSetPosObj(obj,  piLeft, piTop) 
{
  dhtmChangePropObj(obj, 'pixelLeft','left', piLeft);
  dhtmChangePropObj(obj, 'pixelTop','top', piTop);  
}

function dhtmSetPos(psNomObj, piLeft, piTop) 
{
  var obj = dhtmTrouveObjet(psNomObj);
  dhtmSetPosObj(obj, piLeft, piTop);
}

function dhtmGetVisibleObj(obj) 
{
  if (obj)
  {    
    if (obj.style)
    {
     return obj.style.visibility;
    }
    else
    {
     return obj.visibility;
    } 
  }
  else
  { return null; } 
}

function dhtmGetVisible(psNomObj) 
{
 var obj=dhtmTrouveObjet(psNomObj);
 return dhtmGetVisibleObj(obj) 
}

function dhtmSetVisibleObj(obj, pbOnOff) 
{
  var sValProp = (pbOnOff==true?'visible':'hidden');
  dhtmChangePropObj(obj,'visibility',null,sValProp);
}

function dhtmSetVisible(psNomObj, pbOnOff) 
{  
  var obj = dhtmTrouveObjet(psNomObj);
  dhtmSetVisibleObj(obj, pbOnOff);
}

function dhtmChangeHtmlObj(obj, psHtm)
{     
  if (obj) 
  {
    if (obj.innerHTML) 
    {
      obj.innerHTML = psHtm;
    }
    else 
    {
      obj = obj.document;
      if (obj)
      {
        obj.open();
        obj.write(psHtm);
        obj.close();
      }
    }
  }
}
function dhtmChangeHtml(psNomObj, psHtm)
{
  var obj = dhtmTrouveObjet(psNomObj);
  dhtmChangeHtmlObj(obj, psHtm);
}


