/***********************************************
* Switch Content script II- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var erlaube="on" //Enable saving state of content structure using session cookies? (on/off)
var merke="7" //persistence in # of days

var einimg='img/basics/objects/map_down_1.gif' //Path to image to represent contract state.
var ausimg='img/basics/objects/map_down_0.gif' //Path to image to represent expand state.

/////No need to edit beyond here //////////////////////////

function getElementbyKlasse(rootobj, classname){
var temparray=new Array()
var nr=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[nr++]=rootobj[i]
}
return temparray
}

function aendern(ab){
var nr=0
while (sammeln[nr]){
sammeln[nr].style.display=(ab=="contract")? "none" : ""
nr++
}
holestatus()
}


function raus(curobj, cid){
if (sammeln.length>0){
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
curobj.src=(document.getElementById(cid).style.display=="none")? ausimg : einimg
}
}

function holecontent(){
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="none"
}

function holestatus(){
var nr=0
while (status[nr]){
if (sammeln[nr].style.display=="none")
status[nr].src=ausimg
else
status[nr].src=einimg
nr++
}
}

function hole_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getAuswahl(){
if (hole_cookie(window.location.pathname) != ""){
Auswahl=hole_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function speichern(){
var nr=0, Auswahl=""
while (sammeln[nr]){
if (sammeln[nr].style.display=="none")
Auswahl+=sammeln[nr].id+"|"
nr++
}
if (hole_cookie(window.location.pathname)!=Auswahl){ //only update cookie if current states differ from cookie's
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+parseInt(erlaube))
document.cookie = window.location.pathname+"="+Auswahl+";path=/;expires=" + expireDate.toGMTString()
}
}

function do_onload(){
uniqueidn=window.location.pathname+"erstemal"
var alltags=document.all? document.all : document.getElementsByTagName("*")
sammeln=getElementbyKlasse(alltags, "tauscheinhalt")
statecollect=getElementbyKlasse(alltags, "status")
if (erlaube=="on" && hole_cookie(window.location.pathname)!="" && sammeln.length>0)
holecontent()
if (sammeln.length>0 && status.length>0)
holestatus()
}
if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (erlaube=="on" && document.getElementById)
window.onunload=speichern