/* Bild-Funktionen für Artikel */

function img_change(name,url,besch) {
  document.images[name].src= "../img_archiv/medium_"+url;
  document.images[name].alt = url;
  document.images[name].title = besch;
}

function zoom(name) {
  var datei = document.images[name].src;
  var rx = /^(.*\/(large_|medium_|small_)?)(.*)$/;
  if (rx.test(datei)) datei = RegExp.$3;
  var zoom_win = window.open("../templates/zoom.php?img="+datei,"Zoom","location=0,dependent=1,resizable=0,scrollbars=0,status=0,toolbar=0,height=500,width=700");
}

/* Mouseover-Effekte */

function button_mouseout() {
  if (this.img != document.mousedownimage) this.img.src = this.img.outsrc;
}

function button_mouseover() {
  if (this.img != document.mousedownimage) this.img.src = this.img.oversrc;
}

function button_mousedown() {
  if (document.mousedownimage) document.mousedownimage.src = document.mousedownimage.outsrc;
  this.img.src = this.img.downsrc;
  document.mousedownimage = this.img;
}

function button_preload() {
  document.preloaded_images = new Array();
  var res = "";
  var rx = /^(.*\/button-[^\/.]*)(\.[a-z0-9_-]+)$/i;
  for (var i = 0; document.images[i]; i++) {
    if (!rx.test(document.images[i].src)) continue;
    var name = RegExp.$1;
    var ext = RegExp.$2;
    if (!document.preloaded_images[name+"-over"]) {
      document.preloaded_images[name+"-over"] = new Image();
      document.preloaded_images[name+"-over"].src = name+"-over"+ext;
      document.preloaded_images[name+"-down"] = new Image();
      document.preloaded_images[name+"-down"].src = name+"-down"+ext;
    }
    if (!document.images[i].name) {
      document.images[i].img = document.images[i];
      document.images[i].onmouseover = button_mouseover;
      document.images[i].onmouseout = button_mouseout;
      document.images[i].onclick = button_mousedown;
    }
    document.images[i].outsrc = name+ext;
    document.images[i].oversrc = name+"-over"+ext;
    document.images[i].downsrc = name+"-down"+ext;
  }
  var linkrx = /^link-(.*)$/;
  for (var i = 0; document.anchors[i]; i++) {
    if (!linkrx.test(document.anchors[i].name)) continue;
    var imgname = "img-"+RegExp.$1;
    if (document.images[imgname]) {
      document.anchors[i].img = document.images[imgname];
      document.anchors[i].onmouseover = button_mouseover;
      document.anchors[i].onmouseout = button_mouseout;
      document.anchors[i].onclick = button_mousedown;
    }
  }
}

