
window.onload = rollup;

function rollout(objMenuitem, objEvent)
{
    var iKeyCode;

    // Check if from a keyboard - non IE, but
    // irrelevant as tab doesn't trigger the 
    // keypress event in IE
    if (objEvent && objEvent.type == 'keypress')
    {
        if (objEvent.keyCode)
            iKeyCode = objEvent.keyCode;
        else if (objEvent.which)
            iKeyCode = objEvent.which;

        // If it's not the enter key or space key, 
        // pass control back to the browser
        if (iKeyCode != 13 && iKeyCode != 32)
            return true;
    }

    // Work out what we need to do
    if (objMenuitem.nextSibling.style.display == 'block')
        var strDisplay = 'none'
    else
        var strDisplay = 'block';

    // Close any nested lists that are open
    var objMenu = document.getElementById('navigation');
    var objNested = objMenu.getElementsByTagName('ul');

    for (var i=0; i<objNested.length; i++)
        if (objNested[i].style.display == 'block')
            objNested[i].style.display = 'none';

    objMenuitem.nextSibling.style.display = strDisplay;
    
    // Keep any parent menus for this item open
    while (objMenuitem.parentNode.parentNode.id != 'navigation')
    {
        objMenuitem = objMenuitem.parentNode.parentNode;
        objMenuitem.style.display = 'block';
    }

    // Stop the browser requesting the link
    return false;
}

function rollup()
{
    var bRollup, objLinks, objNode, objAnchor;

    // Check we're working with a DOM compliant browser
    if (document.getElementById && document.createElement)
    {
        var strLocation = window.location;

        var objMenu = document.getElementById('navigation');

        var objNested = objMenu.getElementsByTagName('ul');

        // Hide each of the nested unordered list
        for (var i=0; i<objNested.length; i++)
        {
            // Only hide, if the current location is not found in the list
            bRollup = true;
            objLinks = objNested[i].getElementsByTagName('a');

            for (var j=0; j<objLinks.length; j++)
            {
                if (objLinks[j].href == strLocation)
                {
                    bRollup = false;

                    // Added by John Hunter
                    // remove link for current page
                    objNode = objLinks[j];
                    strContent = objNode.firstChild.data;
                    var objCurrentPage = document.createElement('strong');
                    objCurrentPage.appendChild(document.createTextNode(strContent));
                    //objNode.parentNode.replaceChild(objCurrentPage, objNode);

                    // Add an id so we can keep the parents open
                    objCurrentPage.id = 'jsKeepOpen';
                }

            }

            if (bRollup == true)
                objNested[i].style.display = 'none';
            else
                objNested[i].style.display = 'block';

            // Place the top-level text in an anchor tag
            objNode = objNested[i].parentNode;

            strContent = objNode.firstChild.data;

            objAnchor = document.createElement('a');
            objAnchor.href = '#';
            objAnchor.onclick = function(event){return rollout(this, event);}
            objAnchor.onkeypress = function(event){return rollout(this, event);}
            objAnchor.appendChild(document.createTextNode(strContent));

            objNode.replaceChild(objAnchor, objNode.firstChild);
        }

        // Keep any parent menus for the current item
        if (document.getElementById('jsKeepOpen'))
        {
            var objKeepOpen = document.getElementById('jsKeepOpen');
            while (objKeepOpen.parentNode.id != 'navigation')
            {
                objKeepOpen = objKeepOpen.parentNode;
                objKeepOpen.style.display = 'block';
            }
        }
    }
	 // Initialisierung für Ladebalken
	 if(document.getElementById("load")){count();}
	
	 // Externe Links
	 //handleLinks();
	 
	 // Initialisierung für STR
	 if(!STRDetect())
    	return;
		 SwishReplace("h2.str","/flash/h2.swf","300","25","#ffffff","#444444","#C85A02");
		//SwishReplace("address","pixel.swf","350","14","#FFFFFF","#900");
		//SwishReplace("h3","h3.swf","350","30","#FFFFFF","#C85A02","#3D993C");
}


var y=0;
function count(){
	if(y<80){
		pelement = document.getElementById("load").firstChild;	
		document.getElementById("load").firstChild.firstChild.nodeValue = (y+1) + "%";
		pelement.style.width = y + "%";
		y++;
		setTimeout("count();", 20);
	}
}


//SwishMax Text Replacement by Alessandro Fulciniti
//related article here:

//released in Creative Commons - Commons Deeds
// http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en

function STRDetect(){
if(!detectFlash(6) || !document.getElementsByTagName || !document.getElementById || !document.createElement)
    return(false);
if(Array.prototype.push == null){Array.prototype.push = function(){
      this[this.length] = arguments[0]; return(this.length);}}
isIE=window.ActiveXObject && navigator.userAgent.indexOf('Mac')==-1;
return(true);
}

function SwishReplace(selector,flashsource,w,h,bk,col,hcol){
var hx=getElementsBySelector(selector);
var k1,k2,opt="",el,v,mylink;
k1=TColor(col);
k2=TColor(hcol);
if(k1) opt="&k1="+k1;
if(k2) opt+="&k2="+k2;
for(var i=0;i<hx.length;i++){
    mylink="";
    el=hx[i];
    v=el.firstChild;
    if(v.nodeType==1 && v.tagName=="A")
        el=el.firstChild;
    if(el.tagName=="A"){
        v.style.display="block";
        mylink="&mylink="+el.href;
        }
    text=el.firstChild.nodeValue;
    var basetext=document.createElement("span");
    basetext.appendChild(document.createTextNode(text));
    basetext.style.height=h+"px";
    basetext.style.width=w+"px";
    basetext.className="strText";
    var fr=document.createElement("b");
    fr.className="strFlash";
    var htmlcode="";
    if(isIE){ //Internet Explorer PC
        htmlcode='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + w + '" height="'+ h + '" title="'+text+'">';
        htmlcode+='<param name="bgcolor" value="' + bk + '">';
        htmlcode+='<param name="src" value="' + flashsource + '">';
        htmlcode+='<param name="menu" value="false">';
        htmlcode+='<param name="flashVars" value="txt=' + text+opt+mylink;
        htmlcode+='"></object>';
        }
    else{
        htmlcode='<embed type="application/x-shockwave-flash" src="' +  flashsource  + '"' + ' width="' + w + '" height="' + h + '" title="'+text + '" bgcolor="' + bk + ' menu="false"' + '" flashVars="txt=' + text;
        htmlcode+=opt+mylink;
        htmlcode+='"></embed>';
        }
    fr.innerHTML=htmlcode;
    basetext.appendChild(fr);
    el.removeChild(el.childNodes[0]);
    el.appendChild(basetext);
    }
}

function detectFlash(ver){
var flashversion=0;
if(navigator.plugins && navigator.plugins.length){
    var x=navigator.plugins["Shockwave Flash"];
    if(x && x.description) {
        var y=x.description;
        flashversion=y.charAt(y.indexOf('.')-1);
        }
    }
else{
    for(var i=15; i>=3 && flashversion==0;i--){
        execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
        flashversion=i;
        }
    }
return(flashversion>=ver);
}

function getElementsBySelector(selector){
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];

if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    f=document.getElementById(fs[1]);
    if(f) return(f.getElementsByTagName(s[1]));
    return(objlist);
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    f=document.getElementById(selid);
    if(f) objlist.push(f);
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className.indexOf(selclass)>=0){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function TColor(col)
{
var tcol="";
if(col){
    if(col.indexOf("#")>=0)
        col=col.substring(1,col.length);
    if(col.length==3)
        for(var j=0;j<3;j++)
            tcol=tcol+col.substr(j,1)+col.substr(j,1);
    else tcol=col;
    tcol="0x"+tcol;
    if(tcol=="0x000000") tcol="0x000001";
    }
return(tcol);
}

