function obj2str( obj, sep ){
	sep = typeof sep == "undefined" ? ", " : sep;
	var out = "{";
	var first = true;
	for( m in obj ){
		if( first == true ){
			first = false;
		}else{
			out += sep;
		}
		out += m+" : "+ ( typeof obj[m] == "object" ? obj2str( obj[m] ) : obj[m] );
	}
	return out+"}";
}

function errorMsg( msg ){
	alert( "ERROR : \n"+msg );
}
function notifyMsg( msg ){
	alert( "NOTE : \n"+msg );
}

function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}

var ie = document.all?1:0;
var w3c = document.getElementById?1:0;
var ns4 = document.layers?1:0;

var smallWidth=390, smallHeight=260;	// Breite und Hoehe der kleinen Grafik
var smallLeft= 220, smallTop = 100;	// Position der kleinen Grafik
var lensWidth = 136, lensHeight= 136;	// Breite und Hoehe der Lupe

var zoom = 2;   /* 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;
var Top1 = {};
var oTop = 0;
var oLeft = 0;


function intro() {
	var Haupttabelle_Spalte2 = document.getElementById('Haupttabelle_Spalte2');
	var Haupttabelle = document.getElementById('Haupttabelle');
	var small = document.getElementById('small');
	
	oTop = small.offsetTop+Haupttabelle.offsetTop+Haupttabelle_Spalte2.offsetTop;
	oLeft = small.offsetLeft+Haupttabelle.offsetLeft+Haupttabelle_Spalte2.offsetLeft;
	
	Top1 = document.getElementById('Top1');
	
	
	// 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()", 50);
	document.onmousemove = pos;
}

function pos(e) { // Mausposition und Clipping-Werte berechnen
	var sp = getScrollXY();

	smallLeft = oLeft+Top1.offsetLeft;
	smallTop = oTop+Top1.offsetTop;
	
	if(!e) e = window.event; // Event-Definition fuer IE
	mouseX = ( ( (ns4) ? e.pageX : e.clientX ) + sp[0] ) - smallLeft; // Mausposition innerhalb der
	mouseY = ( ( (ns4) ? e.pageY : e.clientY ) + sp[1] ) - 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) +"px";
			lens.top = (smallTop - mouseY) + "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;  // Grosse Grafik entsprechend
			lens.top = smallTop - mouseY;    // der Mausposition verschieben
		}
	}else{
		lens.visibility = "hidden";    // Grosse Grafik unsichtbar machen
	}
}
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.w = win.innerWidth;
        s.h = win.innerHeight;
    }
    else
    {
         var obj = getBody(win);
         s.w = parseInt(obj.clientWidth);
         s.h = parseInt(obj.clientHeight);
    }
    return s;
}
