overhead=0;
overmenu=0;
oversub=0;
showmenu=0;
menu_ok=0;
var cache1 = new Image();
cache1.src = '/pics/x.gif';
delay = 50;

var URL=self.document.location.href; var winx=self.innerWidth; var winy=self.innerHeight;

function initMenu(nr) {
  if (navigator.appName=='Netscape' && parseInt(navigator.appVersion)<=4 && (winx!=self.innerWidth || winy!=self.innerHeight)) {
    winx=self.innerWidth; winy=self.innerHeight; l=document.location; l.href=URL;
  } else {
    menu_ok=0;
    var width=getWindowWidth();
    img=getImage('windowwidth');
    if (img) width=getImageLeft(img)+1;

    for (i=1; i<=menus; i++) {
      img=getImage('menu'+i+'-position');
      div=getDiv('menu'+i);
      if (img && div) {
        var x=getImageLeft(img);
        if (i==menus) {
          var divx=parseInt(getDivAttribute(div,'width'),10);
          if (x+divx>width) x=width-divx;
        }              
        moveDiv(div,x,menu_top);
        div.onmouseover=overMenu;
        div.onmouseout=outMenu;
      }
    }

    div=getDiv('pfeil');
    if (div) {
      div.onmouseover=onSubDiv;
      div.onmouseout=offSubDiv;
    }
    menu_ok=1;
  }
}

function init() {
  _div_init();
  initMenu();
  menu_ok=1;
}

function overMenu() {
  if (!menu_ok || oversub) return;
  overhead=0;
  overmenu=1;
  div=getDiv('menu'+showmenu);
  showDiv(div);
}
function outMenu() {
  if (overhead || oversub) return;
  overmenu=0;
  setTimeout("_hideMenu()", delay);
}

function showMenu(nr) {
  if (!menu_ok) return;
  overmenu=1;
  overhead=1;
  showmenu=nr;
  hideDiv('pfeil');
  for (i=1; i<=menus; i++) if (i!=nr) hideDiv('menu'+i);
  div=getDiv('menu'+nr);
  showDiv(div);
  redrawDivs();
}
function hideMenu(nr) {
  overmenu=0;
  setTimeout("_hideMenu()", delay);
}

function _hideMenu() {
  if (overmenu || oversub) return;
  hideDiv('pfeil');
  for (i=1; i<=menus; i++) hideDiv('menu'+i);
  redrawDivs();
}


function onSubDiv() { oversub=1; }
function offSubDiv() { oversub=0; }

function onSub(m,s) {
  var img = getImage('sub.'+m+'.'+s);
  var div = getDiv('pfeil');
  if (div && img) {
    var x=getImageLeft(img);
    var y=getImageTop(img);
    moveDivTo(div,x-8,y-12);
    showDiv(div);
  }
}

function hex(d) {		
  var z=new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  var x='';
  var i=1, v=d, r=0;
  while (v>15) { v=Math.floor(v/16); i++; }
  v=d;
  for (j=i; j>=1; j--) {
    x+=z[Math.floor(v/Math.pow(16,j-1))];
    v-=Math.floor(v/Math.pow(16,j-1))*Math.pow(16,j-1);
  } 
  return x;
}	

function dec(x) {		
  var e=new Array();
  var z=new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  var d=0;
  for (i=0; i<x.length; i++) for (j=0; j<=16; j++) if (x.charAt(i)==z[j]) e[i]=j;
  for (i=0; i<x.length; i++) d+=e[i]*Math.pow(16,x.length-i-1)
  return d;
}		

function loadPage(u,s) {
  var x=0; for (i=0;i<s.length;i++) x+=s.charCodeAt(i);
  var p=x+'~'+s; var r=Math.floor(Math.random()*213)+31; var w=hex(r);
  for (i=0;i<p.length;i++) { c=hex(p.charCodeAt(i)^r); if (c.length<2) c='0'+c; w+=c; }
  var l=document.location; l.href=u+'?page='+escape(w);
}

function openWindow(id,width,height,attribs,url) {
  var left=parseInt((screen.width-width)/2);
  var top=parseInt((screen.height-height)/2);
  var win=0;
  if (!url) url='about:blank';
  if (navigator.appName=='Microsoft Internet Explorer') {
    win = window.open(url,id,'left='+left+',top='+top+',width='+width+',height='+height+','+attribs);
  } else {
    win = window.open(url,id,'screenX='+left+',screenY='+top+',width='+width+',height='+height+','+attribs);
  }
  win.focus();
  return win;
}