// cbddm.js
// V 1.4f
// 01/Jun/2003
// (c) Andrew Holt
// http://www.webdevtips.co.uk
// http://www.dropmenu.co.uk
// http://www.webdesignhelp.co.uk
// http://www.andys-onestop.co.uk
//14/08 konqueror workaround
//works in chimera
//You are free to use this script providing you leave all the comments intact
//Scripts can end up all over the net and by removing comments you are 
//  stopping people from getting proper updates from the author. 
//End of preaching :)
//http://www.dropmenu.co.uk


var wnamex=(window.location.pathname);				// "/D:/_test/s51.htm"
var wname3=(wnamex.substr((wnamex.search(".h")-2),1));		// .h (.htm bzw. .html) suchen

var path_to_stylesheet = "style/style" + wname3 + ".css";		// style/style5.css (5 = aus s51!)

var buttonwidth=10;						// Breite der Menüs
var buttonheight=10;						// Höhe der Menüs
var mrahmen=0;
var menudir ="hor";						// "hor" = Horizontal oder "ver" = vertikal
var cellpad=0;
var effectopen=-1;						// Effekt beim Öffnen;    -1 = kein Effekt
var effectclose=-1;						// Effekt beim Schließen; -1 = kein Effekt
var toggleswitch=0;
var stopshow=0;
var noway=0;

    var Mac=(navigator.userAgent.indexOf("mac")!=-1)  || (navigator.userAgent.indexOf("Mac")!=-1);
    var msie=(navigator.userAgent.indexOf('MSIE')!=-1);		// MS IE 6.x / 8.x
    var ns6=(navigator.userAgent.indexOf('Netscape6/6')!=-1);	// Netscape 6.x
    var ns7=(navigator.userAgent.indexOf('Netscape/7')!=-1);	// Netscape 7.x
    var ffox=(navigator.userAgent.indexOf('Firefox')!=-1);		// FireFox 2.x  /  3.x
    var op=(navigator.userAgent.indexOf('Opera')!=-1);		// Opera 9.x  /  10.x
  // alert((navigator.userAgent));

    if (ns6) {ns7=true;}	// NS anpassen
    if (msie) {msie=1;}	// MSIE anpassen

    if(msie || ns7 || ffox || op) {var dom=1;}

    var timerID=null
    var timerID2=null
    var stopclose=1;
    var whatsopen="none";
    var newsonoff=0;
    var operaload=0;
    var isform="no";
    var menutop=0;
    var menuleft=0;
    var nsmenutop=0;
    var nsmenuleft=0;
    var docwidth;


function move(e) {
  // alert("toggle - move");
    nsmenuleft=e.pageX;
    nsmenutop=e.pageY;
    nsmenuleft1-=0;
    nsmenutop-=0;
    }

    if(noway==0) {document.write("<link rel=\"stylesheet\" href=\""+path_to_stylesheet+"\">");}


function startup() {
  // alert("startup - Anfang");

    if(noway) {return;}
    if (msie && !Mac) {
        for(var i = 0 ; i <= howmanymenus ; i++) {toggle2(menunames[i]);}
    }
    else {return false;}
}


function toggle(whatmenu,isMain) {
  // alert("toggle: "+whatmenu+"   "+isMain);

    if(noway) {return;}
    getpositions();
    if(newsonoff==1) {return false;}
    if (isMain==1) {
        if(timerID) {clearTimeout(timerID);}
        if (whatsopen == "none") {
            toggle2(whatmenu);
            isMain=0;
        }
        if(whatsopen == whatmenu) {isMain=0;}
        if(whatsopen != whatmenu && whatsopen != "none") {
            toggle2(whatsopen);
            toggle2(whatmenu);
            isMain=0;
        }
        if(timerID2) {clearTimeout(timerID2)}
        timerID2=setTimeout("toggle2('"+whatmenu+"');",2000);
        return;
    }
    if(isMain==0) {
        if(whatsopen != "none" && isMain!=1) {toggle2(whatmenu);}
    }
}


function toggle2(whatmenu) {
  // alert("toggle2 - Anfang");
 
    if(noway) {return;}
    if (msie) {
        if (effectopen != -1 && effectclose != -1) {eval(whatmenu+".filters(0).Apply();");}
        if (eval(whatmenu+".style.visibility") == 'hidden') {
            if (isform=="yes") {document.getElementById('formhide').style.visibility='hidden';}
            eval(whatmenu+".style.visibility='visible';");                        
            eval(whatmenu+".filters[0].transition=effectopen");                        
            whatsopen=whatmenu; }
        else {
            if (isform=="yes") {document.getElementById('formhide').style.visibility='visible';}
            eval(whatmenu+".style.visibility = 'hidden';");
            eval(whatmenu+".filters[0].transition=effectclose");
            whatsopen="none";
            }       
            if (effectopen != -1 && effectclose != -1) {eval(whatmenu+".filters(0).Play();");}
        }

    if (ns7 || ffox || op) {
        if(toggleswitch == 0) {
            if(isform=="yes") {document.getElementById('formhide').style.visibility='hidden';}
            eval("document.getElementById('"+whatmenu+"').style.visibility = 'visible';");
            toggleswitch=1;
            whatsopen=whatmenu;
            ;return;
        }
        if(toggleswitch == 1) {
            if(isform=="yes") {document.getElementById('formhide').style.visibility='visible';}
            eval("document.getElementById('"+whatmenu+"').style.visibility = 'hidden';");toggleswitch=0;whatsopen="none";return;
        }
    }
}


function goSub(where,what,tgt) {
    stopshow=-1;
    clearTimeout(timerID);
    clearTimeout(timerID2);
    if (tgt=='') {var wintgt="self";}
    else {var wintgt=tgt;}    
    if (effectopen!=-1 || effectclose!=-1) {toggle2(what);}        
    if (tgt == '') {whereto= "location.href='"+where+"'";}    
    if (tgt == 'new') {whereto= "window.open('"+where+"','"+tgt+"');";}       
    if (tgt != 'new' && tgt != '') {whereto= "parent."+tgt+".location.href='"+where+"'";}
    setTimeout("eval(whereto)",550);
}


function getpositions() {
    if(noway) {return;}
    docwidth = document.body.clientWidth;
    docwidth-=0;
    if (dom) {
        var menutop=document.getElementById('navbar').offsetTop;
        var menuleft=document.getElementById('navbar').offsetLeft;
        var menuheight=document.getElementById('navbar').offsetHeight;
        menutop += menuheight+2;
        for(var i = 0 ; i <= howmanymenus ; i++) {
            menuleft+=cellpad;
            eval("document.getElementById('"+menunames[i]+"').style.left="+menuleft);
            eval("document.getElementById('"+menunames[i]+"').style.top="+menutop);  
            tot=menuleft+navwidth[i]+buttonwidth;
            if( tot >= docwidth ) {
	        menuleft += navwidth[i]+navwidth[i+1];
	        menuleft -= buttonwidth;
                }
            else {                        
	        menuleft += navwidth[i]+cellpad;
	        if(ns7) {menuleft += cellpad;
                }
            }
        }
    }
}


function donewsitem(onoff){
    if(noway){return;}
    newsonoff=onoff;
    if (window.innerWidth) {
        docwidth = window.innerWidth;
        docheight = window.innerHeight;
        }
    else {
        docwidth = document.body.clientWidth;
        docheight = document.body.clientHeight;
        }
    newsleft = docwidth-newswide;
    newsleft=newsleft/2;
    newstop = docheight-newshigh;
    newstop=newstop/2;
    timer=newstimer*1000;
    effectopenbak=effectopen;
    effectclosebak=effectclose;
    if(newsonoff != 1){return false;}
    toggleswitch = 1;

    if(dom) {
        effectopen=newseffect;
        effectclose=newseffect;
        document.getElementById("newsitem").style.left=newsleft;
        document.getElementById("newsitem").style.top=newstop;
        toggle2('newsitem');
    }

    toggle2('newsitem');
    setTimeout("toggle2('newsitem');newsonoff=0;effectopen=effectopenbak;effectclose=effectclosebak",timer);
}

function killMenu(whatwait){
    if(noway) {return;}
    if(stopshow==-1) {return;}
    if(timerID) {clearTimeout(timerID)}
    if(timerID2 ){clearTimeout(timerID2)}
    timerID=setTimeout("toggle2('"+whatwait+"');",500);
}

function checkMenu(){
    if(noway){return;}
    if(stopshow==-1){return;}
    if(timerID){clearTimeout(timerID)}
    if(timerID2){clearTimeout(timerID2)}
}
