/*
//written by Ralf Einhorn - info at einhorn-net.de (c) 20040120-20040714
//do not reuse without permission
*/
var sBase="../";
var nMType=0; //0=none 1=button 2=menu
var bHideMenu=false;
var nClosed=0;
var bClosed=false;


function toggleMenu() {
if(bClosed) {
document.getElementById("hl").firstChild.innerHTML="";
} else  {
document.getElementById("hl").firstChild.innerHTML="";
}
bClosed=!bClosed;
}

function showMenu() {
if(nMType!=0) updateView(2);
//keepMenu(0);
}

function hideMenu() {
if((bHideMenu)&&(nMType!=0)) updateView(1);
}

function keepMenu(nKeep) {
if(nKeep==1) {bHideMenu=false;}
if(nKeep==0) {bHideMenu=true; setTimeout('hideMenu()', 1500);}
}


function updateView(nNewState) {
if(nNewState>=0) nMType=nNewState; //-1 for update
if(nMType==0) {
document.getElementById("hl").style.visibility="hidden";
document.getElementById("hm").style.visibility="hidden";
} else if(nMType==1) {
document.getElementById("hm").style.visibility="hidden";
document.getElementById("hl").style.visibility="visible";
} else if(nMType==2) {
document.getElementById("hl").style.visibility="hidden";
document.getElementById("hm").style.visibility="visible";
}
}

function goUrl(sCnt) {
//if(document.forms.ein.base) if(document.forms.ein.base.value!="") sBase=document.forms.ein.base.value;
//alert(sBase);
if(sCnt=="") sCnt="einhome.html";
document.location.href=sBase+sCnt;
}


function posHome() {
var nTop=window.pageYOffset;
if (isNaN(nTop)) {nTop=document.body.scrollTop;}
nTop=nTop;
document.getElementById("hl").style.top=(nTop+"px");
document.getElementById("hm").style.top=(nTop+"px");
setTimeout('posHome()', 500);
}

function startHome() {
if(navigator.appName!="Netscape") posHome();
updateView(1);
}


function writeHome() {
document.writeln("<style type=\"text/css\">\na.hb,a.hb:visited{-moz-opacity:0.8; -moz-border-radius:4px; margin:1px; text-decoration:none; color:#8080e0; background-color:#101030; border:1px solid #4040c0; padding:3px; text-decoration:none; font-family:Tahoma,MS Sans Serif; font-size:8pt; font-weight:normal}\na.hb:hover{text-decoration:none; color:#ffffff; background-color:#3030b0; border:1px solid #b0b0ff; font-size:8pt; font-weight:normal}\na.hb:active{color:#ffffff}\ndiv.eat{font-family:Verdana; font-size:14pt; font-weight:normal; color:#4040c0}</style>");
var sPosTag="position:absolute; top:0px;";
if(navigator.appName=="Netscape") sPosTag="position:fixed; top:4px;";
document.writeln("<div id=\"hl\" onMouseOver=\"showMenu(); return true\" style=\"text-align:left; vertical-align:top; visibility:hidden; "+sPosTag+" left:0px; width:480px; height:24px; z-index:3; background-color:transparent\"><div class=\"eat\"></div></div>");
document.writeln("<div id=\"hm\" onMouseOver=\"keepMenu(1); return true\" onMouseOut=\"keepMenu(0); return true\"  style=\"vertical-align:middle; text-align:left; visibility:hidden; "+sPosTag+" left:0px; width:580px; height:24px; z-index:4; background-color:transparent; padding: 2px\">");
document.writeln("<a class=\"hb\" href=\"javascript:goUrl('')\" title=\"home\">&nbsp;einhorn-net.de&nbsp;</a><a class=\"hb\" href=\"javascript:goUrl('work/index.html')\"title=\"Projekte, Publikationen\">&nbsp;Projekte&nbsp;</a><a class=\"hb\" href=\"javascript:goUrl('sw/index.html')\"title=\"Software-Download\">&nbsp;Software&nbsp;</a><a class=\"hb\" href=\"javascript:goUrl('hw/index.html')\"title=\"Hardware (Bauanleitungen...)\">&nbsp;Hardware&nbsp;</a><a class=\"hb\" href=\"javascript:goUrl('service/index.html')\"title=\"Service\">&nbsp;Service&nbsp;</a><a class=\"hb\" href=\"javascript:goUrl('jstools/index.html')\"title=\"JavaScript Tools\">&nbsp;JavaScript&nbsp;</a><a class=\"hb\" href=\"javascript:goUrl('gallery/index.html')\"title=\"Bildergalerie\">&nbsp;Galerie&nbsp;</a><a class=\"hb\" href=\"javascript:goUrl('at/index.html')\"title=\"Impressum\">&nbsp;@&nbsp;</a></div>");
setTimeout('startHome()', 1000);
}

function findLocByTagName() {
var sOut="";
var nST=0;
var eScr=document.getElementsByTagName('script');
while (eScr[nST]!=null) {
//sOut=sOut+nST+' '+eScr[nST].src+'\n';
var sScr=eScr[nST].src;
if(sScr) {
var nPos=sScr.indexOf("home.js");
if(nPos>=0) sBase=sScr.substring(0, nPos);
}
nST++;
}
}

function initHome() {
//locate position
findLocByTagName();
var lSi=document.createElement("link");
lSi.rel="shortcut icon";
lSi.href=sBase+"einhome.ico";
document.getElementsByTagName("head")[0].appendChild(lSi);
//write menu
if (!parent.e_guide) writeHome();
}

initHome();
