var enablepersist="on" //Enable saving state of content structure? (on/off)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined")
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if ( document.getElementById(cid).style.display == "block" ){
ChangeImg(cid+"Button", "images/cross_div_opened.gif");
} else {
ChangeImg(cid+"Button", "images/cross_div_closed.gif");
}
}

function expandcontent2(cid,state){
if (typeof ccollect!="undefined"){
if ( document.getElementById(cid) )
document.getElementById(cid).style.display = state;
}
if ( document.getElementById(cid) ){
if ( document.getElementById(cid).style.display == "block" ){
ChangeImg(cid+"Button", "images/cross_div_opened.gif");
} else {
ChangeImg(cid+"Button", "images/cross_div_closed.gif");
}
}
}

function revivecontent(){
selectedItem=getselectedItems()
selectedComponents = selectedItem.split(",")
for ( i=0 ; i<selectedComponents.length ; i++ ){
    currentComponents = selectedComponents[i].split("|");
    expandcontent2(currentComponents[0],currentComponents[1])
}
}

function getselectedItems(){
if (get_cookie('1012divext') != ""){
sItems = get_cookie('1012divext')
return sItems
}
else
return ""
}

function saveswitchstate(){
var ck = new Array();
var inc=0
while (ccollect[inc]){
ck.push ( ccollect[inc].id+"|"+ ccollect[inc].style.display );
inc++
}
document.cookie='1012divext'+"="+ck
}

function do_onload(){
getElementbyClass("switchcontent")
if (enablepersist=="on" && getselectedItems()!="")
revivecontent()
}

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 (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

function switchdivreload (divname){
    document.forms[0].switchdivreload.value = ( document.forms[0].switchdivreload.value != divname ) ? divname : '' ;
    FormSubmit();
}

function ChangeImg(id, newSrc) {
	document.images[id].src = newSrc;
}

