var ie = document.all?1:0;
var w3c = document.getElementById?1:0;
var ns4 = document.layers?1:0;

var smallWidth=257, smallHeight=153;	// Breite und Hoehe der kleinen Grafik
var smallLeft = 290, smallTop = 14;	// Position der kleinen Grafik
var lensWidth = 248, lensHeight= 171;	// Breite und Hoehe der Lupe
var detailLeft = 3, detailTop = 3;	// Position des Rahmen-Layers 

var zoom = 4;   /* Position großes Bild zu kleinem Bild. Jeder Faktor ist moeglich, wenn Breite und Hoehe der grossen
                und kleinen Grafik im gleichen Verhaeltnis referenziert werden */

var lens, mouseX = 0, mouseY = 0, X, Y;
var leftClip, topClip, rightClip, bottomClip;


function intro() {

 // Opera ab Version 7 ermitteln - unabhaengig von der eingestellten Identifizierung
 if((window.opera) && !(navigator.userAgent.indexOf("7")!=-1)) {

  alert("Die Lupe funktioniert leider erst mit Opera 7.");
  return;
 }

 lens = (ie)?document.all.magnify.style:(w3c)?document.getElementById("magnify").style:document["magnify"];

  if(ns4) {
   document.captureEvents(Event.MOUSEMOVE);
  }
  setInterval("cut()", 30);
  document.onmousemove = pos;
}


function pos(e) { // Mausposition und Clipping-Werte berechnen

 if(!e) e = window.event; // Event-Definition fuer IE
 mouseX = ((ns4)?e.pageX:e.clientX) - smallLeft; // Mausposition innerhalb der
 mouseY = ((ns4)?e.pageY:e.clientY) - smallTop;  // kleinen Grafik ermitteln

 X = Math.round(mouseX * zoom); // Umrechnen der Mausposition
 Y = Math.round(mouseY * zoom); // auf grosse Grafik

 leftClip = X - lensWidth /2; // Clipping-Werte
 topClip = Y - lensHeight /2; // fuer die grosse Grafik
 rightClip = X + lensWidth /2;
 bottomClip = Y + lensHeight /2;
}


function cut() {

 if(mouseX > 0 && mouseX < smallWidth && mouseY > 0 && mouseY < smallHeight) {

  lens.visibility = "visible";

  if(ie||w3c) { // Fuer IE 5+, Mozilla, Netscape 6+ und Opera 7

   lens.clip="rect(" + topClip + "px " + rightClip +"px "+ bottomClip +"px "+ leftClip +"px)";
   lens.left = (detailLeft - leftClip + 4) + "px";
   lens.top = (detailTop - topClip + 4) + "px";
  }
  else if(ns4) { // Fuer NS 4

   lens.clip.left = leftClip;
   lens.clip.top = topClip;
   lens.clip.right = rightClip;
   lens.clip.bottom = bottomClip;
   lens.left = (detailLeft - leftClip + 4);
   lens.top = (detailTop - topClip + 4);
  }
 }
 else {
  lens.visibility = "hidden";
 }
}
