function YPos(e)
{
   if (!(e=document.getElementById(e))) return 0;
   var y = 0;
   while (e)
   {
      if (e.offsetTop) y += e.offsetTop;
      e = e.offsetParent;
   }
   return y;
}

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

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")
   {
      if (collapseprevious=="yes")
      {
         contractcontent(cid);
      }
      document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none";

      ep = YPos(cid);
      if ( ep < window.pageYOffset || ep > window.pageYOffset + window.innerHeight)
      {
         window.scrollTo(0,Math.max(0, ep - 100));
      }
   }
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
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 opencmd(pid){
 targeturl="index.php?src=picture&action=scmnt&pid="+pid;
 x=window.open(targeturl ,"Neuen_Kommentar","width=400,height=200,left=50,top=50");
 x.focus();
}

function delcmd(gid,pid,cid){
 x = window.open('index.php?src=picture&action=delcmd&pid='+pid+'&cid='+cid ,'Kommentar_loeschen','width=400,height=200');
 x.focus();
}


