
var pos;
var menu;


function changeBG(id)
{
        var where = document.getElementById(id);
        where.style.className = "naviover";
}
function show(where,id)
{
        menu = 'subnavi'+where;
        pos = getPos('navi'+where);
        send('parts/submenu.php?where='+where+'&id='+id);
}

function hidden(where,id)
{
       if (document.getElementById(id)) {
        if (document.getElementById(id+'where').style.display != 'none') {
            document.getElementById(id+'where').style.display = 'none';
            document.getElementById(id).style.display = 'block';
        }
        else {
            document.getElementById(id+'where').style.display = 'inline';
            document.getElementById(id).style.display = 'none';
        }
    }

}

function send(url)
{
        init();
        req.onreadystatechange = showRequest;
        req.open("GET", url, true);
        req.send(null);

}

function showRequest()
{
      switch(req.readyState)
          {
        case 4:
                        if(req.status!=200)
                        {
                                alert("Fehler:"+req.status);
                        }
                        else
                        {
                                document.getElementById("submenu").innerHTML = req.responseText;
                                document.getElementById("subnavi"+menu).style.left = pos.left+"px";
                                document.getElementById("subnavi"+menu).style.top = (parseInt(pos.top)+35)+"px";
                                document.getElementById("subnavi"+menu).style.visibility = "visible";
                        }
        break;

        default:
            return false;
        break;
        }
}

function getPos(id)
{
var obj = document.getElementById(id);
var pos = {left:0, top:0};

if(typeof obj.offsetLeft != 'undefined')
{
   while (obj)
   {
       pos.left += obj.offsetLeft;
       pos.top += obj.offsetTop;
       obj = obj.offsetParent;
   }
}
else
{
   pos.left = obj.left ;
   pos.top = obj.top ;
}
return pos;
}