﻿var temp, temp2, cookieArray, cookieArray2, cookieCount;
var lastId=-1;
navi = new Array();
navi["Gesamtkatalog"] = new Object();
navi["Gesamtkatalog"][0] = "Gesamtkatalog/Gesamtkatalog.htm";

navi["Flammendurchschlagsicherungen"] = new Object();
navi["Flammendurchschlagsicherungen"][0] = "Flammendurchschlagsicherungen/Allgemein.htm";
navi["Flammendurchschlagsicherungen"][1] = "Flammendurchschlagsicherungen/Ent_Belueftungshauben.htm";
navi["Flammendurchschlagsicherungen"][2] = "Flammendurchschlagsicherungen/Deflagrationssicherungen.htm";
navi["Flammendurchschlagsicherungen"][3] = "Flammendurchschlagsicherungen/Detonationssicherungen.htm";

navi["PROTEGOTechnologie"] = new Object();
navi["PROTEGOTechnologie"][0] = "PROTEGO_Technologie/Allgemein.htm";
navi["PROTEGOTechnologie"][1] = "PROTEGO_Technologie/Gesamtkatalog.htm";
navi["PROTEGOTechnologie"][2] = "PROTEGO_Technologie/PROTEGO_sich_vor.htm";
navi["PROTEGOTechnologie"][3] = "PROTEGO_Technologie/Technische_Grundlagen.htm";
navi["PROTEGOTechnologie"][4] = "PROTEGO_Technologie/Sichere_Anlagen_Praxis.htm";
navi["PROTEGOTechnologie"][5] = "PROTEGO_Technologie/Liefer_Leistungsuebersicht.htm";
navi["PROTEGOTechnologie"][6] = "PROTEGO_Technologie/Anhang.htm";

navi["Ventile"] = new Object();
navi["Ventile"][0] = "Ventile/Allgemein.htm";
navi["Ventile"][1] = "Ventile/Endarmaturen.htm";
navi["Ventile"][2] = "Ventile/Rohrleitungsarmaturen.htm";
navi["Ventile"][3] = "Ventile/Flammensicherung_Endarmaturen.htm";

navi["Tankzubehoer_Sonderausruestung"] = new Object();
navi["Tankzubehoer_Sonderausruestung"][0] = "Tankzubehoer_und_Sonderausruestung/tankzubehoer_sonderausruestung.html";

navi["Werkstoffe_Begriffe"] = new Object();
navi["Werkstoffe_Begriffe"][0] = "Werkstoffe_Begriffe/Werkstoffe_Begriffe.htm";

navi["Auslegungsdatenblatt"] = new Object();
navi["Auslegungsdatenblatt"][0] = "Auslegungsdatenblatt/Auslegungsdatenblatt.htm";

function fillIframe(navPoint,id)
{
	parent.frames['contentIFrame'].location.href =  navi[navPoint][id];
}

function initiate(){

 /*cookieCount=0;

  if(document.cookie){

    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();

    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }

  }
  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();

*/

	cookieArray = new Array();
  temp=document.getElementById("containerul");

  for(var o=0;o<temp.getElementsByTagName("li").length;o++){

    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){

      temp2                                = document.createElement("span");
      temp2.className                        = "symbols";
      temp2.style.backgroundImage        = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(../../images/base/pfeil_symbol_offen.gif)":"url(../../images/base/pfeil_symbol_zu.gif)"):"url(../../images/base/pfeil_symbol_zu.gif)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        //writeCookie();
      }

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)

      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";

      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }

      cookieCount++;

    }
    else{

      temp2                                = document.createElement("span");
      temp2.className                        = "symbols";
      temp2.style.backgroundImage        = "url(../../images/base/pfeil_symbol_zuXX.gif)";

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);

    }

  }

}



function showhide(el){

  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";

  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(../../images/base/pfeil_symbol_offen.gif)":"url(../../images/base/pfeil_symbol_zu.gif)";

}



function writeCookie(){                // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.

  cookieArray=new Array()

  for(var q=0;q<temp.getElementsByTagName("li").length;q++){

    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){

        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");

      }
    }

  }

  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();

}

function liMouseOver(id)
{
	if(id != lastId)
	{
		if(document.getElementById("li" + id) != null)
			document.getElementById("li" + id).style.backgroundColor = "#e2e2e2";
	}
}

function liMouseOut(id)
{
	if(id != lastId)
	{
		if(document.getElementById("li" + id) != null)
			document.getElementById("li" + id).style.backgroundColor = "#ffffff";
	}
}

function liMouseClick(id)
{
	if(lastId != -1)
		document.getElementById("li" + lastId).style.backgroundColor = "#ffffff";
	document.getElementById("li" + id).style.backgroundColor = "#e2e2e2";
	lastId = id;
}

function kontakt()
{
	parent.frames['contentIFrame'].location.href='kontakt.html';
}
