// Menüsystem

var mousex,mousey;

var schliessen = true;
var menuCount=0;
var MicrosoftModel=0;

//**************************************************
function alleSchliessen(){
 if (document.all){
   document.all.pop1.style.visibility="hidden";
   document.all.pop2.style.visibility="hidden";
   document.all.pop3.style.visibility="hidden";
   document.all.pop4.style.visibility="hidden";
   document.all.pop5.style.visibility="hidden";
 } else {
   document.getElementById("pop1").style.visibility="hidden";
   document.getElementById("pop2").style.visibility="hidden";
   document.getElementById("pop3").style.visibility="hidden";
   document.getElementById("pop4").style.visibility="hidden";
   document.getElementById("pop5").style.visibility="hidden";
 }
}
//********** popup-menüs zumachen ******************
function ausblenden(){
 if (schliessen) {
  alleSchliessen();
 }
}

//********** maus wurde gedrückt ******************
function MouseDown(event){
 schliessen=true;
 setTimeout("ausblenden()",30);
}
//********** maus wurde bewegt ******************
function MouseMove(event)
{
  var mausx,mausy;
  if (typeof(event)!="object")              /* kein event? */
    return;

  if (MicrosoftModel)                     /* MSIE: ------- */
  {
    mausx=event.clientX;
    mausy=event.clientY;
    if (document.body.scrollLeft)
      mausx+=document.body.scrollLeft;
    if (document.body.scrollTop)
      mausy+=document.body.scrollTop;
  }
  else                                    /* Netscape: --- */
  {
    mausx=event.pageX;
    mausy=event.pageY;
  }
  //MouseAction(mausx,mausy);
  mousex = mausx;
  mousey = mausy;
}


//********** mausbehandlung initiieren ******************
function MouseInit()
{
  if (document.all)         /* MSIE, Konqueror, Opera: --- */
  {
    MicrosoftModel=1;
    //window.onmousemove=MouseMove;
    window.onmousedown=MouseDown;
    //runnerobject=document.all.runner.style;
  }
  if (!(MicrosoftModel))                  /* Netscape: --- */
  {
    if (typeof(document.addEventListener)=="function")
                                         /* Netscape6: --- */
    {
      //document.addEventListener("mousemove",MouseMove,true);
      document.addEventListener("mousedown",MouseDown,true);
      //runnerobject=document.getElementById("runner").style;
    }

    else                              /* anderer Browser : */
      alert("Dein Browser kann das nicht!");
  }
}


//********** menü-hintergrund ******************
function mousemoveint(i)
{
	document.getElementById(i).style.backgroundColor = "#ddddff";
}
function mouseoutint(i)
{
	document.getElementById(i).style.backgroundColor = "#aaaaaa";
}


//********** schließen der popups verhindern ******************
function nichtschliessen(){
 schliessen = false;
}

//********** maustaste wurde gedrückt ******************
function mousedownint(i){
 alleSchliessen();
 if (document.all){
   eval("document.all.pop"+i+".style.left = eval(\"document.all.men\"+i+\".offsetLeft\");");
   eval("document.all.pop"+i+".style.top = 17+eval(\"document.all.men\"+i+\".offsetTop\");");
   //eval("document.all.pop"+i+".style.top = 104;");
   eval("document.all.pop"+i+".style.visibility = \"visible\";");
 } else {
   oleft = document.getElementById("men"+i).offsetLeft;
   otop = document.getElementById("men"+i).offsetTop;

   oleft = oleft + "px";
   otop = otop+17 + "px";

   document.getElementById("pop"+i).style.left = oleft;
   document.getElementById("pop"+i).style.top = otop;
   document.getElementById("pop"+i).style.visibility = "visible";
 }
 setTimeout("nichtschliessen()",5);
}

//*********************************************
function int2hex(n) {
var result = n.toString(16);
if (result.length==1) result = "0"+result;
return result;
}

//*********************************************
function wechseln(fseite){
 alleSchliessen();
 location.href=fseite;
}

//********** menü hinzufügen ******************
function addMenu(ftext,fbreite){
 x = 0;
 for (i=1;i<=menuCount;i++) {
  if (document.all) {
    x += parseInt(eval("document.all.men"+i+".style.width"));
  } else {
    x += parseInt(eval("document.getElementById('men"+i+"').style.width"));
  }
  x += 10;
 }

 //y = menutable.style.width;
 //y=30;
//x=0;
 menuCount++;
 farbe = 255;//255-menuCount*20;
 document.write("<span class=\"menu2\" id=\"men"+menuCount+"\" name=\"men"+menuCount+"\" style=\"cursor:pointer; margin:0px; padding:1px; color:#000000; white-space:nowrap; position:relative;left:auto;top:auto;width:"+fbreite+"px; background-color:#aaaaaa;\" onmousemove=\"mousemoveint('men"+menuCount+"');\" onMouseOut=\"mouseoutint('men"+menuCount+"');\" onmousedown=\"mousedownint("+menuCount+");\">");
 document.write("<span style=\"color:#cc0000\">");
 document.write(ftext.substr(0,1));
 document.write("</span>");
 document.write(ftext.substr(1));

 //document.write("<img id=\"menimg"+menuCount+"\" src=\"menimg"+menuCount+".gif\">");
 document.write("</span>");
}


//****************************
function highlightx(obj,onoff){
  if (onoff) {
    if (document.all) {
      eval("document.all."+obj+".style.setAttribute(\"background-color\",\"#ffffff\");");
      //eval("document.all."+obj+".style.setAttribute(\"background-image\",\"url(nav2.gif)");");
    } else {
      eval("document.getElementById(\""+obj+"\").style.backgroundColor = \"#ffffff\"");
      eval("document.getElementById(\""+obj+"\").style.backgroundImage = \"url(nav2.gif)\"");
    }
  } else {
    if (document.all) {
      eval("document.all."+obj+".style.setAttribute(\"background-color\",\"#cccc00\");");
      //eval("document.all."+obj+".style.setAttribute(\"background-image\",\"url(nav.gif)\");");
    } else {
      eval("document.getElementById(\""+obj+"\").style.backgroundColor = \"#cccc00\"");
      eval("document.getElementById(\""+obj+"\").style.backgroundImage = \"url(nav.gif)\"");
    }
  }
}
//****************************
function highlight(obj,onoff){
  if (onoff) {
    if (document.all) {
      eval("document.all."+obj+".style.setAttribute(\"backgroundImage\",\"url('img/nav2.gif')\");");
    } else {
      eval("document.getElementById(\""+obj+"\").style.backgroundImage = \"url('img/nav2.gif')\"");
    }
  } else {
    if (document.all) {
      eval("document.all."+obj+".style.setAttribute(\"backgroundImage\",\"url('img/nav.gif')\");");
    } else {
      eval("document.getElementById(\""+obj+"\").style.backgroundImage = \"url('img/nav.gif')\"");
    }
  }
}

//****************************
function addPopup(fname,fcaption,furl){
 if (fcaption != "---"){
   document.write("<p style=\"text-align:left;background-image:url('img/nav.gif');cursor:pointer;margin:0px;\" id=\""+fname+"\" name=\""+fname+"\" onMouseDown='wechseln(\""+furl+"\")' onMouseOut='highlight(\""+fname+"\",false);' onMouseOver=\"highlight('"+fname+"',true);\">"+fcaption+"</p>");
 } else {
   document.write("<p style=\"background-image:url('img/nav.gif');cursor:pointer;margin:0px;\" id=\""+fname+"\" name=\""+fname+"\"><img src=\"img/trenner.gif\" style=\"margin-left:3pt;\" width=\"90%\" height=\"10\"></p>");
 }
}