// 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;
document.wins['stoererlinks'] = new Array(740,320,0,0,'directories=0,location=0,menubar=0,scrollbars=no,status=0,toolbar=0,resizable=no');
document.wins['stoererlinks'].win = 0;
document.wins['stoererrechts'] = new Array(600,400,0,0,'directories=0,location=0,menubar=0,scrollbars=no,status=0,toolbar=0,resizable=no');
document.wins['stoererrechts'].win = 0;
document.wins['rechnergerling'] = new Array(600,670,0,0,'directories=0,location=0,menubar=0,scrollbars=yes,status=0,toolbar=0,resizable=no');
document.wins['rechnergerling'].win = 0;
document.wins['rechnerrheinland'] = new Array(675,600,0,0,'directories=0,location=0,menubar=0,scrollbars=yes,status=0,toolbar=0,resizable=no');
document.wins['rechnerrheinland'].win = 0;

window.subnav = new Array();

//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() {
	fontsize_init();
	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



	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;

		// Spezialbehandlung letzte Subnavigation: rechts angeschlagen
		if (pos.parentNode.className == "last")
		{
			// Manche Browser koennen die Breite eines Elementes erst dann
			// ermitteln, wenn es 'sichtbar' ist
			obj.style.left = '-1000px';
			obj.style.top = '-1000px';
			obj.style.visibility='visible';

			// Den Pixelwert des linken Rands des Navigationsdivs ermitteln
			var mainNavCont = document.getElementById('horizontalNav');

			do {
				myX += mainNavCont.offsetLeft;
			} while (mainNavCont = mainNavCont.offsetParent);

			// Die Breite des Navigationsdivs hinzuaddieren
			myX += document.getElementById('horizontalNav').offsetWidth;

			// Davon die Breite der einzublendenen Subnavi abziehen
			myX -= obj.offsetWidth;

			// Die Breite der Left-Borders der aeusseren Element wieder draufgeben
			myX += 1;

			do {
				myY += pos.offsetTop;
			} while (pos = pos.offsetParent);

			// Subnavi positinieren
			obj.style.left = myX + "px";
			obj.style.top = myY + "px";
		}

		// Alle anderen Navigationspunkte
		else
		{
			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[window.subnav.length] = obj;

	window.resized = 1;
}

showReset = function() {
	document.getElementById('resetLayer').style.display = "block";
}

hideSubnav = function() {
	var obj;

	for (i=0; i<window.subnav.length; i++)
	{
		obj = window.subnav[i];
		obj.style.visibility = "hidden";
		obj.linkobj.onmouseout = function () {return false};
	}

	window.subnav = new Array();

	document.getElementById('resetLayer').style.display = "none";
}

// Switch Produktfinder
function useProduct(sel){

	var productURL = document.productForm.products.options[sel].value;

	if (navigator.appName.indexOf("Internet Explorer") != -1)
	{
		document.productForm.action = productURL;
	}
	else
	{
		document.location.href=productURL;
	}
}

// Switch Layer Search und Productfinder | 2006-05-22
function pfsearchSwitch(which){

	var pfId = 'productfinder';
	var searchId = 'search';

	switch(which){
		case('pf'):
			document.getElementById(pfId).style.display = 'block';
			document.getElementById(searchId).style.display = 'none';
		break;

		default:
			document.getElementById(pfId).style.display = 'none';
			document.getElementById(searchId).style.display = 'block';
		break;
	}
}

function checkRE(field, re, message) {
	var v = field.value;
	if ( v.replace( / /, "" ) == "" ) {
		return true;
	}
	var ret = re.test(v);
	if ( !ret) {
		alert(message);
		field.focus();
		field.select();
	}
	return ret;
}

function checkAmount( field, message ) {
	return checkRE( field, /^[0-9][0-9\.]*$/, message );
}
