// Configs fuer PopUps
var lastWin = 0;
document.wins = new Array();
document.wins['banking'] = new Array(800,560,0,0,'directories=0,location=0,menubar=0,scrollbars=yes,status=yes,toolbar=0,resizable=no');
document.wins['banking'].win = 0;
document.wins['print'] = new Array(620,600,0,0,'directories=0,location=0,menubar=1,scrollbars=yes,status=1,toolbar=1,resizable=yes');
document.wins['print'].win = 0;
document.wins['login'] = new Array(520,550,0,0,'directories=0,location=0,menubar=0,scrollbars=yes,status=yes,toolbar=0,resizable=no');
document.wins['login'].win = 0;
document.wins['blank'] = new Array(0,0,0,0,0,'');
document.wins['blank'].win = 0;
document.wins['tellafriend'] = new Array(520,550,0,0,'directories=0,location=0,menubar=0,scrollbars=yes,status=yes,toolbar=0,resizable=no');
document.wins['tellafriend'].win = 0;
document.wins['suche'] = new Array(620,600,0,0,'directories=0,location=0,menubar=0,scrollbars=yes,status=0,toolbar=0,resizable=yes');
document.wins['suche'].win = 0;
document.wins['rmodul'] = new Array(500,500,0,0,'directories=0,location=0,menubar=0,scrollbars=yes,status=0,toolbar=0,resizable=yes');
document.wins['rmodul'].win = 0;

//PopUp Fenster
function newWin(loc,what){
	nm = what;
	txt = ('' + document.wins[what][4] + ',height='+ document.wins[what][1]+ ',width='+ document.wins[what][0]+ '');
	if (what != 'app'){
		if (! document.wins[what].win.closed){
			if (document.wins[what].win != 0) document.wins[what].win.close();
		}
		if (what == 'blank'){
			window.open(loc,what);
		} else{
			document.wins[what].win = window.open(loc,nm,txt);
			document.wins[what].win.focus();
		}
	} else {
		fenster = window.open(loc,nm + document.wins[what].win++,txt);
		fenster.focus();
	}
} //newWin

window.onresize = function() {
	window.resized = true;
}


// initialisiert die Seite, nachdem Sie geladen wurde
window.onload = function() {
	var a = document.getElementsByTagName("a");			// Alle Link-Elemente der Seite
	// Zerlegt die URLs anhand der Slashes, Index angeben fuer die Navigation Wir über uns
	var pagehref = document.location.href.split("/")[4]; // Hier bin ich
	var pagereferer = document.referrer.split("/")[4];   // Hier komme ich her

	var i, temp;// Itterator und Temporär-Speicher

	window.subnav = new Array();

	for (i = 0; i < a.length; i++) {
		a[i].onfocus = linkBlur;						// Jeder Link erhält eine onmouseover-Methode
	}

    window.name="ergebnis";
    //newWinOnLoad();
}

// verstckt gestrichelte Outline um aktive Elemente
linkBlur = function() {
	this.blur();
}

showSubnav = function(pos, obj) {
	var myX = (document.getElementById && !document.all)? -1: 0;
	var myY = pos.offsetHeight + 1;

	hideSubnav();

	obj = document.getElementById(obj);
	pos.className = "active";

	if (!obj.linkobj || window.resized) {
		obj.linkobj = pos;

		if (pos.parentNode.className == "last") myX -= obj.offsetWidth - pos.offsetWidth - 1;

		do {
			myX += pos.offsetLeft;
			myY += pos.offsetTop;
		} while (pos = pos.offsetParent);

		obj.style.left = myX + "px";
		obj.style.top = myY + "px";
	}
	
	obj.linkobj.onmouseout = showReset;

	obj.style.visibility = "visible";
	window.subnav.push(obj);
}

showReset = function() {
	document.getElementById('resetLayer').style.display = "block";
}

hideSubnav = function() {
	var obj;

	while (obj = window.subnav.shift()) {
		obj.style.visibility = "hidden";
		obj.linkobj.className = "";
		obj.linkobj.onmouseout = function () {return false};
	}

	document.getElementById('resetLayer').style.display = "none";
}

// Switch Tool- und Produktfinder
function useTool(sel){
    var toolURL = document.toolFinder.tools.options[sel].value;
    document.location.href=toolURL;
}

function useProduct(sel){
    var productURL = document.productFinder.products.options[sel].value;
    document.location.href=productURL;
}
