counter = 0;
start = 0;
Objects = Array();
Array.prototype.in_array = function(needle) {
  needle = "javascript:getData('" + needle + "','false','contentgalerie')";
  for (var i=0; i<this.length; i++) {
    if (needle == this[i]) {
      return i;
    }
  }
  return 0;
}
function init() {
  if (document.getElementById) {
    initXML();
    Obj = document.getElementById("bilder");
    if (counter == 0) {
      for (var i=0;i<Obj.childNodes.length;i++) {
        if (Obj.childNodes[i].nodeType == 1 && Obj.childNodes[i].nodeName == "A") {
          for (var a=0;a<Obj.childNodes[i].childNodes.length;a++) {
            if (Obj.childNodes[i].childNodes[a].nodeType == 1 && Obj.childNodes[i].childNodes[a].nodeName == "IMG") {
              Objects[counter] = Obj.childNodes[i];
              Objects[counter][counter] = Obj.childNodes[i].childNodes[a];
            }
          }
          counter++;
        }
      }
    }
    Obj.innerHTML = "";
    for (var i=0;i<6&&i<Objects.length;i++) {
      ATAG = Objects[i];
      if (i==0) {
        startcontent = ATAG.href.replace(/javascript:/,"");
      }
      ATAG.appendChild(Objects[i][i]);
      Obj.appendChild(ATAG);
    }
    if (Objects.length <= 6) {
      Obj = document.getElementById("btn1");
      Obj.style.visibility = "hidden";
      Obj = document.getElementById("btn2");
      Obj.style.visibility = "hidden";
    }
    if (Objects.length > 0) {
      eval(startcontent);
    }
  }
}
function viewNext() {
  if (document.getElementById) {
    Obj = document.getElementById("bilder");
    Obj.innerHTML = "";
    start++;
    nextStart++;
    if (start >= Objects.length) {
      start -= Objects.length;
      nextStart -= Objects.length;
    }
    if (nextStart == Objects.length) {
      nextStart -= Objects.length;
    }
    for (var i=start;i<=(start+5);i++) {
      count = i;
      if (i >= Objects.length) {
        count -= Objects.length;
      }
      ATAG = Objects[count];
      ATAG.appendChild(Objects[count][count]);
      Obj.appendChild(ATAG);
    }
    ATAG = Objects[nextStart];
    startcontent = ATAG.href.replace(/javascript:/,"");
    eval(startcontent);
  }
}
function viewPrev() {
  if (document.getElementById) {
    Obj = document.getElementById("bilder");
    Obj.innerHTML = "";
    start--;
    nextStart--;
    if (start < 0) {
      start += Objects.length;
      nextStart += Objects.length;
    }
    if (nextStart == -1) {
      nextStart += Objects.length;
    }
    for (var i=start;i<=(start+5);i++) {
      count = i;
      if (i >= Objects.length) {
        count -= Objects.length;
      }
      ATAG = Objects[count];
      ATAG.appendChild(Objects[count][count]);
      Obj.appendChild(ATAG);
    }
    ATAG = Objects[nextStart];
    startcontent = ATAG.href.replace(/javascript:/,"");
    eval(startcontent);
  }
}
