var DH = 0;
var an = 0;
var al = 0;
var ai = 0;
var active_elem = 0;

if (document.getElementById)
{
  ai = 1;
  DH = 1;
}
else
{
  if (document.all) 
  {
    al = 1;
    DH = 1;
  }
  else
  {
    browserVersion = parseInt(navigator.appVersion);
    if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4))
    {
      an = 1;
      DH = 1;
    }
  }
}

function fd(oi,ws)
{
  if (ws == 1)
  {
    if (ai)
    {
      return (document.getElementById(oi).style);
    }
    else 
    {
      if (al)
      {
        return (document.all[oi].style);
      }
      else
      {
        if (an)
        {
          return (document.layers[oi]);
        }
      }
      ;
    }
  }
  else
  {
    if (ai) 
    {
      return (document.getElementById(oi));
    }
    else
    {
      if (al)
      {
        return (document.all[oi]);
      }
      else
      {
        if (an)
        {
          return (document.layers[oi]);
        }
      }
      ;
    }
  }
}

function pw()
{
  if (window.innerWidth != null)
    return window.innerWidth;

  if (document.body.clientWidth != null)
    return document.body.clientWidth;

  return (null);
}


function popUp(evt, oi, container)
{
  if (DH)
  {
    var wp = pw();
    ds = fd(oi,1);
    dm = fd(oi,0);
    st = ds.visibility;
    if (dm.offsetWidth)
      ew = dm.offsetWidth;
    else
      if (dm.clip.width)
        ew = dm.clip.width;
    if (st == "visible" || st == "show")
    {
      ds.visibility = "hidden";
    }
    else
    {
      tv = document.getElementById(container).style.top;// Y-Position
      lv = document.getElementById(container).style.left;// X-Position
      
      /*
      if (evt.y || evt.pageY)
      {
        if (evt.pageY)
        {
          tv = evt.pageY - 150;
          lv = evt.pageX - 180;
        }
        else
        {
          tv = evt.y + 10;
          lv = evt.x + 10;
        }
        if (lv < 2)
          lv = 2;
        else
          if (lv + ew > wp)
            lv -= ew/2;
        if (!an)
        {
          lv += 'px';
          tv += 'px'
        }
        ;
        ds.left = lv;
        ds.top = tv;
      }
        
      if (active_elem != 0)
        close_popUp(active_elem);

      ds.visibility = "visible";
      active_elem = oi;
        */
      
      //ds.left = (eval(lv.substr(0, lv.length-2)) + 20) + "px";
      ds.left = lv;
      //ds.top = tv;
      ds.top = (eval(tv.substr(0, tv.length-2)) + 20) + "px";
      ds.visibility = "visible";
      active_elem = oi;
      
      document.getElementById(container).style.backgroundColor='#000000'
      
    }
  }
}

function close_popUp(id, container)
{
  var elem = document.getElementById(id).style;

  if (elem.visibility != "hidden")
    elem.visibility = "hidden";
  active_elem = 0;
  
  document.getElementById(container).style.backgroundColor='#9F0002'
}
