

/////////////////////////////////////////////////////////////////////// Besten Dank an www.internet-pro.de
var ie = document.all?1:0;
var w3c = document.getElementById?1:0;
var ns4 = document.layers?1:0;

var smallWidth=372, smallHeight=363;	// Breite und Hoehe der kleinen Grafik
//var smallWidth=270, smallHeight=110;	// Breite und Hoehe der kleinen Grafik 800 530
var smallLeft= 320, smallTop = 185;	// Position der kleinen Grafik
var lensWidth = 250, lensHeight= 250;	// Breite und Hoehe der Lupe

var zoom = 1.65;   /* 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
	  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;
	smallLeft = findPos(document.getElementById('smallimg'))[0];
	smallTop = findPos(document.getElementById('smallimg'))[1];

}

//http://www.quirksmode.org/js/findpos.html
function findPos(obj) {
	
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
			
return [curleft,curtop];

		}	
}

	
	

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() { // Clipping und Verschieben der grossen Grafik
 
	 if(mouseX > 0 && mouseX < smallWidth && mouseY > 0 && mouseY < smallHeight) {
		  lens.visibility = "visible";   // Grosse Grafik sichtbar machen
		  if(ie||w3c) { // Fuer IE 5+, Mozilla, Netscape 6+ und Opera 7 // Clipping

			   lens.clip="rect(" + topClip + "px " + rightClip +"px "+ bottomClip +"px "+ leftClip +"px)";
			   // Grosse Grafik entsprechend der Mausposition verschieben
			   lens.left = smallLeft - mouseX*(zoom-1) +"px";
			   lens.top = smallTop - mouseY*(zoom-1) + "px";
		  }
		  else if(ns4) { // Fuer NS 4
			   lens.clip.left = leftClip;		// Clipping
			   lens.clip.top = topClip;
			   lens.clip.right = rightClip;
			   lens.clip.bottom = bottomClip;
			   lens.left = smallLeft - mouseX*(zoom-1);  // Grosse Grafik entsprechend
			   lens.top = smallTop - mouseY*(zoom-1);    // der Mausposition verschieben
		 	 }
	 	}
	 else {
	  lens.visibility = "hidden";    // Grosse Grafik unsichtbar machen
	 }
}


intro();
