var piclist=new Array();
var global_piclist;
var i_bigpic;

function getBody(w)
{
    return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}

function getWinSize(win)
{
    if(!win) win = window;
    var s = new Object();
    if(typeof win.innerWidth != 'undefined')
    {
        s.width = win.innerWidth;
        s.height = win.innerHeight;
    }
    else
    {
         var obj = getBody(win);
         s.width = parseInt(obj.clientWidth);
         s.height = parseInt(obj.clientHeight);
    }
    return s;
}

function bigpicNext() {
  i=i_bigpic+1;

  if (i>global_piclist.length-1) i=0;
  picshow(global_piclist,i);
}

function bigpicPrev() {
  i=i_bigpic-1;
  if (i<0) i=global_piclist.lenght-1;
  picshow(global_piclist,i);
}

function picshow(AList,x) {
   global_piclist=AList;
   i_bigpic=x;
   s="&nbsp;";
   if (x>0) s='<a href="javascript:bigpicPrev()"><img src="../pic_prev.gif" width=6 height=16 border=0></a>'+s;
   if (x<AList.length-1) s+='<a href="javascript:bigpicNext()"><img src="../pic_next.gif" width=6 height=16 border=0></a>';
   document.getElementById("picnav").innerHTML=s;
   showPic(AList[x]["pic"],AList[x]["caption"], AList[x]["width"],AList[x]["height"]);
}

function showPic(pic,caption,w,h) {
  b= new Image();
  b.src = pic;
  w=Number(w);
  h=Number(h);
  document.images['showpic'].src=b.src;
  document.images['picspacer'].width=w-40;

  ps = document.getElementById("picshow");

   s=getWinSize();

   h+=20;
   x=(s.width-w)/2;
   y=(s.height-h)/2;

   x+="px";

   if (y<20) y=20;
   y=(document.all)?("30px"):(y+"px");

   ps.style.left=x;
   ps.style.top=y;
   ps.style.width=w+4+"px";
   //document.getElementById("container").onclick=hidePic();
   if (document.all) {
      //alert(document.all.container.style.textAlign);
      document.all.container.style.textAlign="center";

      document.all.seite.className="container-blend";
   } else
      document.getElementById("container").className="container-blend";
}

function hidePic() {
  document.getElementById("picshow").style.top="-1000px";
  document.getElementById("container").className="container";
  if (document.all) document.all.seite.className="";

}

function collectPicLinks()
{
  x=0; found=0;
  for (i=0; i<document.links.length; i++) {
    s=String(document.links[i]);
    if (s.substr(0,22)=="javascript:showDetPic(") {
      s=s.substr(23);

      a=s.split(',');
      src=a[0].substr(0,a[0].length-1);
      found=0;
      if (eval(piclist)) {
        for (y=0; y<piclist.length; y++) {
           if (src==piclist[y]["pic"]) {
             found=1;
             break;
           }
        }
      }
      if (found) {
        document.links[i].href="javascript:picshow(piclist,"+y+")";
        continue;
      }
      x=piclist.length;
      piclist[x]=new Object();

      piclist[x]["pic"]=src;
      piclist[x]["caption"]=a[1];
      piclist[x]["width"]=a[2];
      piclist[x]["height"]=a[3].substr(0,a[3].length-1);
      //alert(piclist[x]["pic"]+'\n'+piclist[x]["caption"]+'\n'+piclist[x]["width"]+'\n'+piclist[x]["height"]);
      document.links[i].href="javascript:picshow(piclist,"+x+")";
    }
    if (eval(piclist[0])) piclist[0]['name']="piclist";
  }
}
window.onload=collectPicLinks;
