var obj_old="qwer";
var curr_id=0;

var dd_ad_map = new Array();

dd_ad_map[12] = 447;
dd_ad_map[13] = 448;
dd_ad_map[14] = 449;
dd_ad_map[15] = 450;
dd_ad_map[16] = 451;
dd_ad_map[17] = 452;
dd_ad_map[18] = 453;
dd_ad_map[19] = 454;

function findPos(el)
{
    var xPos    = 0;
    var yPos    = 0;
    if (document.layers)
    {
        xPos = el.x;
        yPos = el.y;
    }
    else
      {
        while(el)
        {
            xPos += el.offsetLeft;
            yPos += el.offsetTop;
            el  = el.offsetParent;
        }
    }
    return {xPos: xPos, yPos: yPos};
}

function ps_subnav(id)
{
      var ps_bildname="pul_"+id;
      var ps_divname="div_"+id;
      var dd_ad_id="dropdown_ad_"+id;
      var x=y=0;
      var ps_el = document.getElementById(ps_bildname);
      x = findPos(ps_el).xPos;
      y = findPos(ps_el).yPos;
      curr_id=id;

      if(obj_old!="qwer")
      {
        obj_old.style.display='none';
        obj_old="qwer";
      }

      if(document.getElementById(ps_divname))
      {
          x-=9;
          y+=8;
        
        var ps_div_el = document.getElementById(ps_divname);

        if (dd_ad_map[id] && !document.getElementById(dd_ad_id)) {

            var class_attr = ps_div_el.getAttribute('class');
            
            if (!/wide/.test(class_attr)) {
            
                ps_div_el.setAttribute('class', class_attr + ' wide');
            
            }
            
            var sid = (dd_ad_map[id]) ? dd_ad_map[id] : 447;
            var rand = Math.floor(Math.random() * 1000000);

            var dd_ad_el = document.createElement('div');
            dd_ad_el.setAttribute('class', 'dropdown_ad');
            dd_ad_el.setAttribute('id', dd_ad_id);

            var dd_rem_el = document.createElement('div');
            dd_rem_el.setAttribute('class', 'remark');

            var remark = document.createTextNode('Anzeige');
            dd_rem_el.appendChild(remark);
            
            dd_ad_el.appendChild(dd_rem_el);
            
            var dd_link_el = document.createElement('a');
            dd_link_el.setAttribute('href', 'http://ad.main-netz.de/oasisc.php?s=' + sid + '&w=300&h=250&rand=' + rand);
            dd_link_el.setAttribute('target', '_blank');

            var dd_img_el = document.createElement('img');
            dd_img_el.setAttribute('src', 'http://ad.main-netz.de/oasisi.php?s=' + sid + '&w=300&h=250&l=1&rand=' + rand);

            dd_link_el.appendChild(dd_img_el);
            dd_ad_el.appendChild(dd_link_el);
            ps_div_el.insertBefore(dd_ad_el, ps_div_el.firstChild);

        }
        
        if (dd_ad_map[id] && id > 14) {

            ps_div_el.style.left= (x - 301) + 'px';

        } else {

            ps_div_el.style.left=x+'px';

        }

        ps_div_el.style.top=y+'px';
        ps_div_el.style.display='inline';
        obj_old=ps_div_el;
        if(typeof ps_timer != "undefined")
        {
          window.clearTimeout(ps_timer);
          document.getElementById('subNavMenu'+curr_id).className="tab_nothover";
          ps_timer="";
        }
      }
}

function setactiv (id,classname) {
    if (obj = document.getElementById(id)) {
        obj.className = classname;
        ps_activ = 0;
    }
}
 

function hidediv()
{
  document.getElementById('subNavMenu'+curr_id).className="tab_nothover";
  if(obj_old!="qwer")
  {
    if(typeof ps_timer != "undefined")
    {
      obj_old.style.display='none';
      obj_old="qwer";
      reset_timer();
      window.clearTimeout(ps_timer);
      ps_timer="";
    }
  }
}

function reset_timer()
{
  if(obj_old!="qwer")
  {
    if(typeof ps_timer != "undefined")
    {
      window.clearTimeout(ps_timer);
    }
    document.getElementById('subNavMenu'+curr_id).className="tab_hover";
  } else {
    document.getElementById('subNavMenu'+curr_id).className="tab_nothover";
    curr_id=0;
  }    
}

function start_timer()
{
  document.getElementById('subNavMenu'+curr_id).className="tab_nothover";
  if(obj_old!="qwer")
  {
    ps_timer = window.setTimeout("hidediv()",50);
  }
}


