﻿// JScript-Datei

var displayContainer = new Array();

function initMenu() 
{
	var rowCount=document.getElementById("treeMenu").rows.length;
    myPath=document.getElementById("ctl00_hlPath1");
	myPath.style.display="none";
	myPath=document.getElementById("ctl00_hlPath2");
	myPath.style.display="none";
	myPath=document.getElementById("ctl00_hlPath3");
	myPath.style.display="none";
	
	for (i=0;i<rowCount;i++) {
		myRow=document.getElementById("treeMenu").rows[i];
		if (myRow.id.indexOf("|")==-1)
			myRow.style.display="";
		else
			myRow.style.display="none";
	}	
}


function menuClick(myID)
{
	hideLanguage();
	//initMenu();
	expand(myID); 
} 


function expand(myID) 
{
	var rowCount=document.getElementById("treeMenu").rows.length;
	currPre=myID;
	var i;
	var tmp = myID.split("|");
	menuLevel=tmp.length;
    myAnchorID="";
    for (i=0;i<tmp.length-1;i++){
        if (tmp[i].indexOf("L")==0)
            tmp[i]=tmp[i].substring(1,tmp[i].length);
        myAnchorID+=tmp[i];
    }
    
	for (i=0;i<rowCount;i++) {
		myRow=document.getElementById("treeMenu").rows[i];
		if (myRow.id.indexOf(currPre)==0)
		{
			rest=myRow.id.substr(currPre.length+1,myRow.id.length-currPre.length)
			if (rest.indexOf("|")==-1 || rest.length==0){
	            displayContainer.push(myRow);
				//myRow.style.display="";	
				
			}
			if (myRow.id==currPre && menuLevel>1) 
			{
			    myCell=myRow.cells[0];
			    myA=firstNonTextChildNode(myCell);
			    if (myA!=null) {
			        myA.style.color="#000000"; 
			        tmpClass=myCell.className;
			        tmpClass=tmpClass+"B";
			        myCell.className=tmpClass;
			    }
			}
		}  
	}
	tmp=myAnchorID;
	myPath=null;
	myRightPath=null;

    if (tmp.indexOf("L")==0)
        tmp=tmp.substring(1,tmp.length);
    if (tmp.length==6) {   
        myPath=document.getElementById("ctl00_hlPath3");        
    }    
    if (tmp.length==4) {     
        myPath=document.getElementById("ctl00_hlPath2");
        myRightPath=document.getElementById("ctl00_hlPath3");
    }
    if (tmp.length==2)  {  
        myPath=document.getElementById("ctl00_hlPath1");
        myRightPath=document.getElementById("ctl00_hlPath2");
    }
    if (myPath!=null) {  
        myAnchorID="ctl00_hl"+myAnchorID;  
        myAnchor=document.getElementById(myAnchorID);	
        myPath.href=myAnchor.href;
        myPath.firstChild.nodeValue=myAnchor.firstChild.nodeValue;
        if (myRightPath!=null){
            if (contains(displayContainer,myRightPath)){
                myPath.firstChild.nodeValue=myPath.firstChild.nodeValue+" >";
            }
        }
        displayContainer.push(myPath)
    }
	if (myID.indexOf("|")>=0){ 
		expand(myID.substr(0,myID.lastIndexOf("|")));      
	}
}

function findCurrentMenuPage() 
{
    var el;
    myFilename="";
    if (document.getElementById("referencePage")!=null){
        myFilename=document.getElementById("referencePage").value;    
    }
    if (myFilename.length==0) {
        tmp=location.href;
        myFilename=tmp.substr(tmp.lastIndexOf("/")+1,tmp.length-tmp.lastIndexOf("/")+1);
    }
    
    if (myFilename.indexOf("?")>-1)
        myFilename=myFilename.substr(0,myFilename.indexOf("?"));
    var rowCount=document.getElementById("treeMenu").rows.length;
    
	expandID="";
	for (i=0;i<rowCount;i++) {
		myRow=document.getElementById("treeMenu").rows[i];
		myCell = myRow.cells[0];
		if (myCell.hasChildNodes()) {
		    var childCount=myCell.childNodes.length;
		    for (j=0;j<childCount;j++) {
		        el=myCell.childNodes[j];
		        if (el.nodeType==1 && el.href!=null) {
		            if (el.href.indexOf(myFilename)>=0){
		                expandID=myRow.id;
		            }
		        }
		    } 
		}
	}
	if (displayContainer.length>0)
	    displayContainer.splice(0,displayContainer.length);
	if (expandID.length==0)
	    initMenu();	
	else
	    menuClick(expandID); 
	
	while (displayContainer.length>0){
	    el=displayContainer.pop();
	    if (el.id.length>3 && el.id.indexOf("Path")==-1) {
	        myID="ctl00_hl"+el.id.substr(1, el.id.length-1);
	        while (myID.indexOf("|")>-1)
	            myID=myID.replace("|","");
	        //alert(myID);
            testEL=document.getElementById(myID);
	        if (testEL!=null)
	            el.style.display="";
	    }
	    else
	        el.style.display="";
	        
	}
}

function showLanguage()
{
    myDiv=document.getElementById("divLanguage");
    if (myDiv.style.display=="")
        myDiv.style.display="none";
    else 
    {    	
       var yPos=0;
       var xPos=0;

        elem=document.getElementById("tdLanguage");
        xPos=elem.offsetWidth-55;
        yPos=elem.offsetHeight-27;
        while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
        {
            yPos+=elem.offsetTop;     /* Offset des jeweiligen Elements addieren */     
            xPos+=elem.offsetLeft;       
            tagname=elem.tagName.toUpperCase(); /* tag-Name ermitteln, Grossbuchstaben */
            if (tagname=="BODY")
                elem=0;
            if (typeof(elem)=="object")
                if (typeof(elem.offsetParent)=="object")
                    elem=elem.offsetParent;
        }
        tmp=xPos+"px";
        myDiv.style.left=tmp;
        tmp=yPos+"px";
        myDiv.style.top=tmp;
        myDiv.style.display="";	
    }
}


function getYoffset(elem_id)
{
    var yPos=0;
    elem=document.getElementById("tdLanguage");
    while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
    {
        yPos+=elem.offsetTop;     /* Offset des jeweiligen Elements addieren */          
        tagname=elem.tagName.toUpperCase(); /* tag-Name ermitteln, Grossbuchstaben */
        if (tagname=="BODY")
            elem=0;
        if (typeof(elem)=="object")
            if (typeof(elem.offsetParent)=="object")
                elem=elem.offsetParent;
    }
    return yPos;
}


function hideLanguage()
{
    myDiv=document.getElementById("divLanguage");
    myDiv.style.display="none";
}

function windowResized()
{
    hideLanguage();
}


function firstNonTextChildNode(myNode)
{
    var i;
    myResultNode=null;
    if (myNode.hasChildNodes())
        for (i=0;i<myNode.childNodes.length;i++){
            myChildNode=myNode.childNodes[i];
            if (myChildNode.nodeName!="#text" && myChildNode.nodeName!="#comment"){
                myResultNode=myChildNode;
                break;
            }
        }    

    return myResultNode;
}




function showMenuEffekt(myID) 
{
    var myEl=myID;
    var myID="hl"+myID+"Effekt";
    var tmp=location.href;
    tmp=tmp.substr(tmp.lastIndexOf("/")+1,tmp.length-tmp.lastIndexOf("/")+1);
    if (tmp.toUpperCase().indexOf(myEl.toUpperCase())==-1){    
        document.getElementById(myID).style.visibility="visible";
        document.getElementById(myID).src="../images/olAni.gif";
    }
}

function hideMenuEffekt(myID) 
{
    var myEl=myID;
    var myID="hl"+myID+"Effekt";
    var tmp=location.href;
    tmp=tmp.substr(tmp.lastIndexOf("/")+1,tmp.length-tmp.lastIndexOf("/")+1);
    if (tmp.toUpperCase().indexOf(myEl.toUpperCase())==-1){    
        document.getElementById(myID).style.visibility="hidden";
        document.getElementById(myID).src="../images/ol0.gif";
    }
}

function showMenuLink(lNr) 
{
    
    var myEl,myImg;
    if (lNr==1) // Home 
    {
        myEl=document.getElementById("ctl00_hlHome");
        myImg=document.getElementById("hlHomeEffekt");   
        //myEl.style.fontWeight="bold";
        myEl.style.color="#000000";
        myImg.src="../images/ol8.gif";
        myImg.style.visibility="visible";          
    }
    if (lNr==2) // Contact
    {
        myEl=document.getElementById("ctl00_hlKontakt");
        myImg=document.getElementById("hlKontaktEffekt");   
        //myEl.style.fontWeight="bold";
        myEl.style.color="#000000";
        myImg.src="../images/ol8.gif";
        myImg.style.visibility="visible";          
    }
    if (lNr==3) // Download
    {
        myEl=document.getElementById("ctl00_hlDownloads");
        myImg=document.getElementById("hlDownloadsEffekt");   
        //myEl.style.fontWeight="bold";
        myEl.style.color="#000000";
        myImg.src="../images/ol8.gif";
        myImg.style.visibility="visible";          
    }
    if (lNr==4) // Impressum
    {
        myEl=document.getElementById("ctl00_hlImpressum");
        myImg=document.getElementById("hlImpressumEffekt");   
        //myEl.style.fontWeight="bold";
        myEl.style.color="#000000";
        myImg.src="../images/ol8.gif";
        myImg.style.visibility="visible";          
    }

}

function contains(myArray,myValue)
{
    var i;
    var myResult=false;
    
    for (i=0;i<myArray.length;i++)
        if (myArray[i]==myValue) {
            myResult=true;
            break;    
        }
    return myResult;
}

function isMSIE()
{
   var s = navigator.userAgent;
   return ((s.lastIndexOf("MSIE") > -1 ) && s.lastIndexOf("Opera") == -1);
}

