// JavaScript Document
// $Date: 2007-11-16 12:44:36 +0100 (Fr, 16 Nov 2007) $ $Revision: 8227 $


/* handle illegal access to foreign url */
function handleFrameSetError() {
	msg = "Frameset-Fehler.\n\nDie Seiten der Postbank dürfen aus Gründen der Sicherheit nur unter "+location.hostname+" erscheinen. Sie werden nun auf "+location.hostname+" umgeleitet.";
	alert (msg);
	top.location = self.location;
}

/* Check if Contents belong to parent host */
function checkFrames() {
	if (window != parent) {
		try {
			var parentHostname = parent.location.hostname;
		} catch (e) {
			var parentHostname = '';
		}
		if (parentHostname == '' || parentHostname.search(/\.postbank\.de$/) == -1) {
			handleFrameSetError();
		}
	}
}

function closeLink()
{
	if (document.getElementById("closeLink"))
	{

		closeLinkId = document.getElementById("closeLink");
		cssjs("remove", closeLinkId, "jsHide");
		cssjs("add", closeLinkId, "close");

		closeLinkId.onclick = function()
		{
			window.close();
			return false;
		}
	}
}
function openPopup() {

	// #########################################################################
	// # Default-Werte setzen
	// #########################################################################

	var url = "#";
	var width = 560;
	var height = 580;
	var center = false;
	var x = 0;
	var y = 0;
	var addparams = "";
	var windowname = "popup";


	// #########################################################################
	// # Argumente verarbeiten
	// #########################################################################

	var arglen = openPopup.arguments.length;

	if (arglen > 0)	url = openPopup.arguments[0];
	if (arglen > 1) width = openPopup.arguments[1];
	if (arglen > 2) height = openPopup.arguments[2];
	if (arglen > 3) center = openPopup.arguments[3];
	if (arglen > 4) x = openPopup.arguments[4];
	if (arglen > 5) y = openPopup.arguments[5];
	if (arglen > 6) addparams = openPopup.arguments[6];
	if (arglen > 7) windowname = openPopup.arguments[7];

	var eigenschaft, sbreite, shoehe, fenster, satURL, satPrint, satTopframe;

	// Welcher Browser?
	var ns6 = (!document.all && document.getElementById);
	var ie4 = (document.all);
	var ns4 = (document.layers);


	// #########################################################################
	// # Fensterposition / Groesse
	// #########################################################################

	// Wenn zentriert werden soll
	if (center) {
		// stellt die Bildschirmabmessungen fest
		if (ns6 || ns4 || ie4) {
			swidth = screen.width;
			sheight = screen.height;
		}
		else {
			swidth = 1024;
			sheight = 768;
		}

		x = Math.floor((swidth - width) / 2);
		y = Math.floor((sheight - height) / 2);

	}

	// falls x und y 0 sind oder ein "unsinniger" Wert rauskam (<0 oder >1024 bzw. >768), dann default setzen
	if ((x <= 0) || (x > 1024)) {
		x = 50;
	}
	if ((y <= 0) || (y > 768)) {
		y = 30;
	}


	// #########################################################################
	// # Fenstereigenschaften definieren
	// #########################################################################

	windowparams = "left=" + x + ",top=" + y + ",screenX=" + x + ",screenY=" + y + ",width=" + width + ",height=" + height;
	if (addparams != "") windowparams = windowparams + "," + addparams;



	// #########################################################################
	// # Fenster oeffnen
	// #########################################################################

	if (satWin = window.open(url, windowname, windowparams)) satWin.focus();

	return false;
}
function openSalesPop() {
var i;
var allea=document.getElementById("contentWrap").getElementsByTagName("a");
for(i=0;i<allea.length;i++)
	{
		if (cssjs("check", allea[i], "pop"))
		{
			allea[i].onclick = function ()
			{
				theURL=this.href;
				window.open(theURL,"pop","width=565 ,height=560, left=150, top=100, dependent, scrollbars=yes, resizable=yes")
				return false;
			}
		}
		if (cssjs("check", allea[i], "pop02"))
		{
			allea[i].onclick = function ()
			{
				theURL=this.href;
				window.open(theURL,"pop02","width=780 ,height=560,left=150,top=100,dependent,scrollbars=yes, resizable=yes")
				return false;
			}
		}
	}
}

function showprint() {

	isprint = document.getElementById("jsPrint");
	if (!isprint) {
		return;
	}
	cssjs('remove', isprint.parentNode, "jsHide");
	isprint.onclick = function ()
	{
		Druck();
		return false;
	}

	isprint02 = document.getElementById("jsPrint02");
	if (!isprint02) {
		return;
	}
	cssjs('remove', isprint02.parentNode, "jsHide");
	isprint02.onclick = function ()
	{
		Druck();
		return false;
	}

	isprint03 = document.getElementById("jsPrint03");
	if (!isprint03) {
		return;
	}
	cssjs('remove', isprint02.parentNode, "jsHide");
	isprint03.onclick = function ()
	{
		Druck();
		return false;
	}
	function Druck()
	{
		window.print();
		return false;
	}
}
function recommend() {
	isrecommend = document.getElementById("jsRecommend");
	if (!isrecommend) {
		return;
	}
	document.getElementById("jsRecommend").onclick = function Empfehlen()
	{
		titel = escape(document.title.replace('•','-'));
		seite = ''+self.location;

		seite = seite.replace(/;jsessionid=[A-F0-9]+/g, '');
		enm = seite.match(/\b-enm-\b/g);

		//filter the -snm- -enm-
		ws_start = 'Hallo, \n\nich habe folgende interessante Seite entdeckt:\n\n';
		var seite_parts1 = seite.split('-snm-');
		if (enm) {
			var seite_parts2 = seite.split('-enm-');
			link = 'mailto:?subject=' + titel + '&body=' + escape(ws_start) + titel + ' ' + escape('\n' + seite_parts1[0] + seite_parts2[1]);
		}
		else {
			link = 'mailto:?subject=' + titel + '&body=' + escape(ws_start) + titel + ' ' + escape('\n' + seite_parts1[0]);
		}
		this.href = link;
		return true;
	}
}
function bookmark() {
	isbookmark = document.getElementById("jsBookmark");
	if (!isbookmark) {
		return;
	}
	document.getElementById("jsBookmark").onclick = function Bookmarken()
	{
		var opera = window.opera;
		var ie = (!opera && navigator.userAgent.indexOf('MSIE') > -1);
		var safari = (navigator.userAgent.indexOf('AppleWebKit') > -1);
		var gecko = (!safari && navigator.userAgent.indexOf('Gecko') > -1);
		var ver = parseInt(navigator.appVersion);
		var mac = navigator.appVersion.indexOf('Mac') > -1;
		var win = navigator.appVersion.indexOf('Win') > -1;
		apfeltaste = ((mac) ? 'Apfel' : 'Strg');
		lz_tastatur = 'Bitte ' + apfeltaste + '-D druecken, um ein Lesezeichen fuer diese Seite anzulegen.';
		lz_drag = 'Bitte ziehen Sie diesen Link auf Ihre Lesezeichenleiste.';

		seite = location.href;
		seite = seite.replace(/;jsessionid=[A-F0-9]+/g, '');

		if (ie && ver >= 4 && !mac) {
			window.external.AddFavorite(seite, document.title);
			return false;
			// Favoritenfenster oeffnen
		}
		else if (opera || gecko) {
			this.href = seite;
			this.title = document.title;
			alert(lz_drag);
		}
		else { // Browser mit falschem Titel bei Drag&Drop
			this.href = seite;
			alert(lz_tastatur);
		}
		return false;
	}
}

 /*
 * Transforms a list into a selectbox.
 *
 * list: List as object
 */
function listConverter(obj)
{
    if (!obj || typeof obj != 'object') return false;

    // get object id
    var id = obj.id;

    // get links
    var links = obj.getElementsByTagName('a');

    // create form
    var form = document.createElement('form');
    form.setAttribute('action', 'javascript:void(0);');

    // create label
    var label = document.createElement('label');
    label.setAttribute('for', 'pbLink_' + id);
	//create eventually labelText for Content
	var headline = obj.getElementsByTagName('h6');
	for (n = 0; n < headline.length; n++) {
		var headlineText = document.createTextNode(headline[0].innerHTML);
		label.appendChild(headlineText);
	}
    // create select
    var select = document.createElement('select');
    select.setAttribute('name', 'sel_' + id);
    select.setAttribute('id', 'pbLink_' + id);

    // create + append options
    for (i = 0; i < links.length; i++) {
        var option = document.createElement('option');
        var link = links[i].getAttribute('href');
        option.setAttribute('value', 'self.location=\'' + link + '\'');
        if (links[i].target == '_blank') {
            option.setAttribute('value', 'window.open(\'' + link + '\', \'\', \'\');');
        }
        if (links[i].onclick) {
            if (navigator.appName == 'Microsoft Internet Explorer') {
                option.setAttribute('value', links[i].getAttribute('onclick'));
            } else {
                option.setAttribute('value', links[i].getAttribute('onclick').replace(/return false;/, ''));
            }
        }
		var ContentList = links[i].parentNode.parentNode.parentNode.parentNode.id;
		if(ContentList=="jsConvertList"){
			option.setAttribute('value', link);
		}
        var text = document.createTextNode(links[i].firstChild.data);
        option.appendChild(text);
        select.appendChild(option);
    }

    // create label for button
    var btnlabel = document.createElement('label');
    btnlabel.setAttribute('for', 'send_' + id);
    btnlabel.className = 'send';

    // create submitbutton
    var btn = document.createElement('input');
    btn.setAttribute('type', 'image');
    btn.setAttribute('name', 'sel_' + id);
    btn.setAttribute('value', 'Anzeigen');
    btn.setAttribute('src', '/pbmedia/bt_arrow.gif');
    btn.setAttribute('id', 'send_' + id);

if ('pbLink_' + id != "pbLink_jsContentList") {

    btn.onclick = function () {
        var el = document.getElementById('pbLink_' + id);
		if (el[el.selectedIndex].value != '') {
			eval(el[el.selectedIndex].value);
			if (typeof anonymous == 'function') {
				anonymous();
			}
		}
	    return false;
    }
} else {
	btn.onclick = function () {

		showTheContent()
	    return false;
    }
}

    // remove all children
    while (obj.firstChild) {
        obj.removeChild(obj.firstChild);
    }

    // append dropdown
    label.appendChild(select);
    form.appendChild(label);

    // append submitbutton
    btnlabel.appendChild(btn);
    form.appendChild(btnlabel);

    // append form
    obj.appendChild(form);
}
function HideTheContent (){
	Inhalt = document.getElementById("theContent");
	if (!Inhalt) {
		return;
	}
	ContentDivs = Inhalt.getElementsByTagName("div");
	for (b = 0; b < ContentDivs.length; b++) {
		if(ContentDivs[b].id){
			cssjs('add', ContentDivs[b], "jsHide");
			cssjs('remove', ContentDivs[0], "jsHide");
		}
	}
}
function showTheContent(){
	Inhalt = document.getElementById("theContent");
	if (!Inhalt) {
		return;
	}
	ContentDivs = Inhalt.getElementsByTagName("div");
	for (b = 0; b < ContentDivs.length; b++) {
		if(ContentDivs[b].id){
			cssjs('add', ContentDivs[b], "jsHide");
		}
	}
	theSelect = document.getElementById("pbLink_jsContentList");
	theOptions = theSelect.getElementsByTagName ("option");
	for (i = 0; i < theOptions.length; i++) {

		allValues = theOptions[i].text;
		thisItem = theSelect.selectedIndex;

		thisValue = theOptions[thisItem].value;
		thisValue01 = thisValue.replace(/.*#/g, '');
		theDiv = document.getElementById(thisValue01);

		if (!theDiv) {
			return;
		}
		cssjs('remove', theDiv, "jsHide")
	}
}
 /*
 * Transforms lists into selectboxes.
 *
 * cssclass:    Class of the list to be transformed
 */
function menuConverter(cssclass)
{
    if (!document.getElementById) return;

    // standard class of the surrounding element
    if (!cssclass) {
        cssclass = 'mhelper';
    }

    // limit to nav
    var nav = document.getElementById('naviMainWrap');
	if (!nav) return;
    var els = nav.getElementsByTagName('div');
    for (var i = 0; i < els.length; i++) {
        if (cssjs('check', els[i], cssclass)) {
            listConverter(els[i]);
        }
    }
	// limit in Content
	var wrapElement = document.getElementById('jsConvertList');
	if (!wrapElement) return;
	var contentEls = wrapElement.getElementsByTagName('div');
    for (var i = 0; i < contentEls.length; i++) {
        if (cssjs('check', contentEls[i], cssclass)) {
            listConverter(contentEls[i]);
        }
    }
}

// Funktionalitaet zu entfernen und erneutem Setzen eines Default-Values
// fuer input-Felder

function removeValue() {
	if (document.getElementById("term")) {
		theInput = document.getElementById("term");
		theInput.onfocus = function() {
			if (this.value == this.defaultValue) this.value='';
		}
		theInput.onblur = function() {
			if (this.value == '') this.value=this.defaultValue;
		}
	}
	if (document.getElementById("rateSearch")) {
		theInput = document.getElementById("rateSearch");
		theInput.onfocus = function() {
			if (this.value == this.defaultValue) this.value='';
		}
		theInput.onblur = function() {
			if (this.value == '') this.value=this.defaultValue;
		}
	}
}

function sendNondefault() {
	if (document.getElementById("sendrateSearch")) {
		theInput = document.getElementById("sendrateSearch");
		theInput.onclick = function() {
			theInputValue = document.getElementById("rateSearch");
			if (theInputValue.value == theInputValue.defaultValue) theInputValue.value='';
		}
	}
	if (document.getElementById("sendTerm")) {
		theInput = document.getElementById("sendTerm");
		theInput.onclick = function() {
			theInputValue = document.getElementById("term");
			if (theInputValue.value == theInputValue.defaultValue) theInputValue.value='';
		}
	}
}
function hideShow() {
	theElement = document.getElementById("jsHideShow");
	if (!theElement) {
		return;
	}

	theListContainer = document.getElementById("jsListContainer");
	allHeadlines = theElement.getElementsByTagName("h4");
	allFieldsets = theElement.getElementsByTagName("fieldset");
	allDivs = theElement.getElementsByTagName("div");
	// Set initial
	for (i = 0; i < allFieldsets.length; i++) {
		allFieldsets[i].className = "jsHide";
		cssjs("add", allFieldsets[i], "jsHide");
			cssjs("remove", allFieldsets[i], "jsShow");
			cssjs("remove", allFieldsets[0], "jsHide");
			cssjs("add", allFieldsets[0], "jsShow");
	}

	// Set initial
	for (i = 0; i < allDivs.length; i++) {
		if(cssjs("check", allDivs[i], "jsShow")){
			cssjs("add", allDivs[i], "jsHide");
			cssjs("remove", allDivs[i], "jsShow");
			cssjs("remove", allDivs[1], "jsHide");
			cssjs("add", allDivs[1], "jsShow");

		}
	}

	// Erzeuge Liste mit Tabnavi
	var theList = document.createElement("ul");
	with (theList) {
		className = 'tabList';
	}
	theListContainer.appendChild(theList);
	for (i = 0; i < allHeadlines.length; i++) {
		// Erzeuge Listitems mit dem Headlinetext
		allHeadlines[i].className = "jsHide";
		theHeadlineId = allHeadlines[i].id;

		var theListItems = document.createElement("li");
		var theListLinks = document.createElement("a");
		var theText = document.createTextNode(allHeadlines[i].childNodes[0].data);
		theListLinks.appendChild(theText);
		theListItems.appendChild(theListLinks);
		with (theListLinks) {
			href = "#";
		}
		with (theListItems) {
			id = "Li_" + theHeadlineId;
		}

		theList.appendChild(theListItems);
		firstId = "Li_" + allHeadlines[0].id;
		firstListItem = document.getElementById(firstId);
		cssjs("add", firstListItem, "on");


		theListItems.onclick = function() {
			show(this);
			return false
		}
		theListItems.onfocus = function() {
			show(this);
			return false
		}

	}
	function show(o) {
		for (i = 0; i < allFieldsets.length; i++) {
			if (cssjs("check", allFieldsets[i], "jsShow")) {
				cssjs("remove", allFieldsets[i], "jsShow");
				cssjs("add", allFieldsets[i], "jsHide");
			}
		}
		for (i = 0; i < allDivs.length; i++) {
			if (cssjs("check", allDivs[i], "jsShow")) {
				cssjs("remove", allDivs[i], "jsShow");
				cssjs("add", allDivs[i], "jsHide");
			}
		}
		allLis = theElement.getElementsByTagName("li")
		for (i = 0; i < allLis.length; i++) {
			cssjs("remove", allLis[i], "on");
		}
		cssjs("add", o, "on");

		matchId = "js" + o.id;
		theFieldset = document.getElementById(matchId);
		cssjs("add", theFieldset, "jsShow");
	}
}

function sortTable() {
	sortTable = document.getElementById("jsSortTable");
	if (!sortTable) {
		return;
	}

	// find all Checkboxes
	allCheckboxes = sortTable.getElementsByTagName("input");
	for (i = 0; i < allCheckboxes.length; i++) {
		isChecked = allCheckboxes[i].checked;
		if (isChecked == true) {
			checkedCheckbox = allCheckboxes[i];
			setBg(checkedCheckbox);
		}
        // keep old onclick-events
        allCheckboxes[i].onclick = (function (old) {
            return function () {
                if (typeof old == 'function') old();
                setBg(this);
            };
        })(allCheckboxes[i].onclick);
	}
	function setBg(o) {
		allTds = sortTable.getElementsByTagName("td");
		theThead = sortTable.getElementsByTagName("thead");
		allThs = theThead[0].getElementsByTagName("th");
		thePos = o.parentNode.cellIndex;

		for (n = 0; n < allTds.length; n++) {
			theCellPos = allTds[n].cellIndex;
			cssjs("remove", allTds[n], "aktiv");
			if (theCellPos == o.parentNode.cellIndex) {
				cssjs("add", allTds[n], "aktiv");
			}
		}

		for (n = 0; n < allThs.length; n++) {
			theCellPos = allThs[n].cellIndex;
			cssjs("remove", allThs[n], "aktiv");
			if (theCellPos == o.parentNode.cellIndex) {
				cssjs("add", allThs[n], "aktiv");
			}
		}
	}
}
function toggleTable() {
	theTable = document.getElementById("toggleTable");
	if (!theTable) {
		return;
	}
	var theBody = theTable.getElementsByTagName("tbody");
	var allTrs = theBody[0].getElementsByTagName("tr");
	for(i=0; i<allTrs.length; i++){
		// The first Level
		if(cssjs("check", allTrs[i], "secLevel") || cssjs("check", allTrs[i], "firstLevel")){
			// set all first Levels on "inactiv" (remove class="on")
			cssjs("addremove", allTrs[i], "on");

			// set the first "first Level" on "active" (add class="on")
			cssjs("add", allTrs[0], "on");
		}

		// The next Levels
		if(cssjs("check", allTrs[i], "secLevel") || cssjs("check", allTrs[i], "thirdLevel")){
			// Hide all second and third levels
			cssjs("add", allTrs[i], "trHide");

			// Make the first second and third levels visible
			var NextEls = allTrs[0].nextSibling;
				while (NextEls != null) {
					if(NextEls.nodeType==1){


						if(cssjs("check", NextEls, "secLevel")){
							 cssjs("remove", NextEls, "trHide");
							 cssjs("add", NextEls, "on");
						}
						 if(cssjs("check", NextEls, "thirdLevel")){
							 cssjs("remove", NextEls, "trHide")
						}
						 if(cssjs("check", NextEls, "firstLevel")){

							 break
						}
					}
					NextEls = NextEls.nextSibling;
				}
		}
		if(cssjs("check", allTrs[i], "firstLevel")){
			allTrs[i].onclick = function(){
				cssjs("addremove", this, "on");
				var NextEls = this.nextSibling;
				while (NextEls != null) {
					if(NextEls.nodeType==1){


						if(cssjs("check", NextEls, "secLevel")){
							 cssjs("addremove", NextEls, "trHide")	;
							 cssjs("remove", NextEls, "on");
							 /*for(n=0; n<NextEls.length; n++){console.log(NextEls[0].innerHTML);}*/

						}
						 if(cssjs("check", NextEls, "thirdLevel")){
							 cssjs("add", NextEls, "trHide")
						}
						 if(cssjs("check", NextEls, "firstLevel")){

							 break
						}
					}
					NextEls = NextEls.nextSibling;
				}
				return false
			}

		}
		if(cssjs("check", allTrs[i], "secLevel")){
			allTrs[i].onclick = function(){
				cssjs("addremove", this, "on");
				var NextEls = this.nextSibling;

				while (NextEls != null) {
					if(NextEls.nodeType==1){

						 if(cssjs("check", NextEls, "thirdLevel")){
							 cssjs("addremove", NextEls, "trHide")
						}
						if(cssjs("check", NextEls, "secLevel")){
							break
						}
					}
					NextEls = NextEls.nextSibling;

				}
				return false
			}
		}
	}
}

function checkedElements() {
	allContainer = document.getElementsByTagName("*");
	for (n = 0; n < allContainer.length; n++) {
		if (cssjs("check", allContainer[n], "jsCheck") || cssjs("check", allContainer[n], "jsRadio")) {
			cssjs("add", allContainer[n], "inActive");
			allInputs = allContainer[n].getElementsByTagName("input");
			allSelects = allContainer[n].getElementsByTagName("select");
			allTextareas = allContainer[n].getElementsByTagName("textarea");
			for (i = 0; i < allInputs.length; i++) {
				if (!cssjs("check", allInputs[i], "jsNoSwitch")) {
					allInputs[i].setAttribute("disabled", "disabled", 0);
				}
			}
			for (i = 0; i < allSelects.length; i++) {
				allSelects[i].setAttribute("disabled", "disabled", 0);
			}
			for (i = 0; i < allTextareas.length; i++) {
				allTextareas[i].setAttribute("disabled", "disabled", 0);
			}
			for (i = 0; i < allInputs.length; i++) {
				isChecked = allInputs[i].checked;
				if (cssjs("check", allContainer[n], "jsCheck")) {
					if (cssjs("check", allInputs[i], "jsNoSwitch")) {
						allInputs[i].onclick = function() {
							thisContainer = this.offsetParent;
							theseInputs = thisContainer.getElementsByTagName("input");
							theseSelects = thisContainer.getElementsByTagName("select");
							theseTextareas = thisContainer.getElementsByTagName("textarea");
							cssjs('addremove', thisContainer, "inActive")
							for (m = 0; m < theseInputs.length; m++) {
								if (cssjs("check", thisContainer, "inActive")) {
									theseInputs[m].setAttribute("disabled", "disabled", 0);
								}
								else if (!cssjs("check", thisContainer, "inActive")) {
									theseInputs[m].removeAttribute("disabled", "disabled", 0);
								}
								this.removeAttribute("disabled", "disabled", 0)
							}
							for (m = 0; m < theseSelects.length; m++) {
								if (cssjs("check", thisContainer, "inActive")) {
									theseSelects[m].setAttribute("disabled", "disabled", 0);
								}
								else if (!cssjs("check", thisContainer, "inActive")) {
									theseSelects[m].removeAttribute("disabled", "disabled", 0);
								}
							}
							for (m = 0; m < theseTextareas.length; m++) {
								if (cssjs("check", thisContainer, "inActive")) {
									theseTextareas[m].setAttribute("disabled", "disabled", 0);
								}
								else if (!cssjs("check", thisContainer, "inActive")) {
									theseTextareas[m].removeAttribute("disabled", "disabled", 0);
								}
							}

						}
					}
				}
				if (cssjs("check", allContainer[n], "jsRadio")) {
					if (cssjs("check", allInputs[i], "jsNoSwitch")) {
						allInputs[i].onclick = function() {

							thisContainer = this.offsetParent;
							theseInputs = thisContainer.getElementsByTagName("input");
							theseSelects = thisContainer.getElementsByTagName("select");
							theseTextareas = thisContainer.getElementsByTagName("textarea");

							allInputs = document.getElementsByTagName("input");
							allSelects = document.getElementsByTagName("select");
							allTextareas = document.getElementsByTagName("textarea");

							for (n = 0; n < allInputs.length; n++) {
								hiddenType=allInputs[n].getAttribute("type")=="hidden";
								if (!hiddenType && cssjs("check", allInputs[n].offsetParent, "jsRadio")  ) {

									cssjs("add", allInputs[n].offsetParent, "inActive");
									/*IE braucht das, er bekommt den Bezug nicht hin, wenn die Eingabefelder in Elementen liegen,
									die sie noch zusätzlich positionieren */
									allTheseInputs = allInputs[n].offsetParent.getElementsByTagName("input");
									for (b = 0; b < allTheseInputs.length; b++) {
										if (cssjs("check", allInputs[n], "jsNoSwitch")) {
											allTheseInputs[b].setAttribute("disabled", "disabled", 0);
										}
									}
								}
								if (cssjs("check", allInputs[n], "jsNoSwitch")) {
									allInputs[n].removeAttribute("disabled", "disabled", 0);
								}
							}
							for (n = 0; n < allSelects.length; n++) {
								if (cssjs("check", allSelects[n].offsetParent, "jsRadio")) {
									allSelects[n].setAttribute("disabled", "disabled", 0);
									cssjs("add", allSelects[n].offsetParent, "inActive");
								}
							}
							for (n = 0; n < allTextareas.length; n++) {
								if (cssjs("check", allTextareas[n].offsetParent, "jsRadio")) {
									allTextareas[n].setAttribute("disabled", "disabled", 0);
									cssjs("add", allTextareas[n].offsetParent, "inActive");
								}
							}

							cssjs("remove", thisContainer, "inActive");
							for (m = 0; m < theseInputs.length; m++) {
								theseInputs[m].removeAttribute("disabled", "disabled", 0);
							}
							for (m = 0; m < theseSelects.length; m++) {
								theseSelects[m].removeAttribute("disabled", "disabled", 0)
							}
							for (m = 0; m < theseTextareas.length; m++) {
								theseTextareas[m].removeAttribute("disabled", "disabled", 0)
							}

						}
					}
				}
				if (isChecked) {
					thisContainer = allInputs[i].offsetParent;
					cssjs("remove", thisContainer, "inActive");
					theseEls = thisContainer.getElementsByTagName("*");
					for (m = 0; m < theseEls.length; m++) {
						theseEls[m].removeAttribute("disabled", "disabled", 0);
					}
				}
			}
		}
	}
}
function checkToggle() {
	var allContainer = document.getElementsByTagName("div");
	for (n = 0; n < allContainer.length; n++) {
		if (cssjs("check", allContainer[n], "jsCheck02")) {
			cssjs("add", allContainer[n], "jsContactHide");
			allInputs = allContainer[n].getElementsByTagName("input");
			for (i = 0; i < allInputs.length; i++) {
			isChecked = allInputs[i].checked;
					if (isChecked == true) {
						thisContainer = allInputs[i].parentNode;
						cssjs("remove", thisContainer, "jsContactHide");
					}
				if (cssjs("check", allInputs[i], "jsNoSwitch")) {

					allInputs[i].onclick = function() {
						thisContainer = this.parentNode;
						cssjs("addremove", thisContainer, "jsContactHide");
					}
				}
			}
		}
		if (cssjs("check", allContainer[n], "jsRadio02")) {
			cssjs("add", allContainer[n], "jsContactHide");
			allInputs = allContainer[n].getElementsByTagName("input");
			for (i = 0; i < allInputs.length; i++) {
			isChecked = allInputs[i].checked;
					if (isChecked == true) {
						thisContainer = allInputs[i].parentNode;
						cssjs("remove", thisContainer, "jsContactHide");
					}
				if (cssjs("check", allInputs[i], "jsNoSwitch")) {

					allInputs[i].onclick = function() {
						var allContainer = document.getElementsByTagName("div");
						for (n = 0; n < allContainer.length; n++) {
							if (cssjs("check", allContainer[n], "jsRadio02")) {
								cssjs("add", allContainer[n], "jsContactHide");
							}
						}
						thisContainer = this.parentNode;
						cssjs("remove", thisContainer, "jsContactHide");
					}
				}
			}
		}
	}
	theArea = document.getElementsByTagName("*");
	for (i = 0; i < theArea.length; i++) {
		if (cssjs("check", theArea[i], "toggleNextElement")) {
			allInputs = theArea[i].getElementsByTagName("input");
			allEl = theArea[i].getElementsByTagName("*");

			for (n = 0; n < allEl.length; n++) {
				if (cssjs("check", allEl[n], "nextEl")) {
					cssjs("add", allEl[n], "jsContactHide");
				}
			}
			for (n = 0; n < allInputs.length; n++) {
				if (cssjs("check", allInputs[n], "jsSwitchOff")) {
					allInputs[n].onclick = function() {
						for (n = 0; n < allEl.length; n++) {
								if (cssjs("check", allEl[n], "nextEl")) {
									cssjs("add", allEl[n], "jsContactHide");
								}
							}
					}
				}
				if (cssjs("check", allInputs[n], "jsSwitchOn")) {
					allInputs[n].onclick = function() {
						theDiv = nextSibling(this.parentNode);
						cssjs("remove", theDiv, "jsContactHide");
					}
					isChecked = allInputs[n].checked;

					if (isChecked == true) {
						thisContainer = nextSibling(allInputs[n].parentNode);
						cssjs("remove", thisContainer, "jsContactHide");
					}
				}
			}
		}
	}
}

function openClose() {

	var allContainer = document.getElementById("contentInnerWrap").getElementsByTagName("*");
	var allHeadlines = document.getElementById("contentInnerWrap").getElementsByTagName("h3");
	var allDivHeadlines = document.getElementById("contentInnerWrap").getElementsByTagName("div");
	for (n = 0; n < allHeadlines.length; n++) {
        // leave the loop if id of parent element is "tool"
        if (allHeadlines[n].parentNode.parentNode.id == 'tool') return false;

		if (cssjs("check", allHeadlines[n], "questions")) {
			allH3Container = nextSibling(allHeadlines[n]);
			cssjs("add", allH3Container, "jsHide");

			allHeadlines[n].onclick = function(){
				theContainer = nextSibling(this);

				cssjs('addremove', theContainer, "jsHide");
				cssjs('addremove', this, "on");
				return false
			}
		}
	}
	for (n = 0; n < allHeadlines.length; n++) {
        // leave the loop if id of parent element is "tool"
        if (allHeadlines[n].parentNode.parentNode.id == 'tool') return false;

		if (cssjs("check", allHeadlines[n], "questions")) {
			thisContainer = nextSibling(allHeadlines[n]);

			if (cssjs("check", thisContainer, "jsToggleFirst")) {
				cssjs('remove', thisContainer, "jsHide");
				cssjs('add', allHeadlines[n], "on");
				break;
			}
		}
	}
	for (n = 0; n < allDivHeadlines.length; n++) {
        // leave the loop if id of parent element is "tool"
        if (allDivHeadlines[n].parentNode.parentNode.id == 'tool') return false;

		if (cssjs("check", allDivHeadlines[n], "questions")) {

			allH3Container = nextSibling(allDivHeadlines[n]);
			cssjs("add", allH3Container, "jsHide");
			if (cssjs("check", allH3Container, "jsToggleFirst")) {
				firstH3Container = nextSibling(allDivHeadlines[0]);
				cssjs("remove", firstH3Container, "jsHide");
				cssjs('add', allDivHeadlines[0], "on");
			}

			allDivHeadlines[n].onclick = function(){
				theContainer = nextSibling(this);

				cssjs('addremove', theContainer, "jsHide");
				cssjs('addremove', this, "on");
				return false
			}
		}
	}
	for (n = 0; n < allContainer.length; n++) {
        // leave the loop if id of parent element is "tool"
        if (allContainer[n].parentNode.parentNode.id == 'tool') return false;

		if (cssjs("check", allContainer[n], "jsToggle") ||cssjs("check", allContainer[n], "jsToggleFirst")) {
			var divId = allContainer[n].id;

			var allDls = document.getElementById(divId).getElementsByTagName("dl");
			for (c = 0; c < allDls.length; c++) {
				if (cssjs("check", allDls[c], "toggleDl")) {
					allDls[c].id="dl_"+divId;
					var allDts = document.getElementById(allDls[c].id).getElementsByTagName("dt");
					var allDds = document.getElementById(allDls[c].id).getElementsByTagName("dd");

					for (b = 0; b < allDds.length; b++) {
						cssjs("add", allDds[b], "jsHide");

					}
					for (i = 0; i < allDts.length; i++) {
						cssjs("add", allDts[i], "off");
						allDts[i].onclick = function(){
							theDd = nextSibling(this);
							cssjs('addremove', theDd, "jsHide");
							cssjs('addremove', this, "off");
						}

					}
				}
			}

		}
	}


	var thisURL = window.location.href;
	var thisURL01 = thisURL.replace(/.*#/g, '');
		var theDt = document.getElementById(thisURL01);
		if (!theDt) {
			return;
		}
		if(theDt.tagName!="DT"){
			return;
		}
		thisDd = nextSibling(theDt);
		cssjs('remove', theDt, "off");
		cssjs('remove', thisDd, "jsHide");
		var theWrapper = theDt.parentNode.parentNode;
		var theHeadline = preSibling(theWrapper);
		if (cssjs("check", theWrapper, "jsHide")) {
			cssjs("remove", theWrapper, "jsHide")
		}
		if (cssjs("check", theHeadline, "questions")) {
			cssjs("add", theHeadline, "on")
		}
}

function openPrintView() {
	isprintView = document.getElementById("printView");
	if (!isprintView) {
		return;
	}
	isprintView.onclick = function() {
		theURL = this.href
		window.open(theURL, "", "width=705,height=585,left=150,top=100,dependent,scrollbars=yes, resizable=yes");
		return false;
	}
}
function closePrintView()
{
	isLink = document.getElementById("jsClose");
	if (!isLink) {
		return;
	}
	cssjs('remove', isLink.parentNode, "jsHide");
	isLink.onclick = function()
	{
		window.close();
		return false;
	}
	isLink02 = document.getElementById("jsClose02");
	if (!isLink02) {
		return;
	}
	cssjs('remove', isLink02.parentNode, "jsHide");
	isLink02.onclick = function()
	{
		window.close();
		return false;
	}
}
function setBgCell (){
	isSetBgCell=document.getElementById("setBgCell");
	if(!isSetBgCell){
		return;
	}
	allCheckboxes = isSetBgCell.getElementsByTagName("input");
	for(i=0;i<allCheckboxes.length;i++){

		if(cssjs("check",allCheckboxes[i],"jsSetBg")){
			isChecked = allCheckboxes[i].checked;
			if(isChecked == true){
					checkedCheckbox=allCheckboxes[i];
					cssjs("add",checkedCheckbox.parentNode,"aktiv")
				}

			allCheckboxes[i].onclick=function(){

				for(i=0;i<allCheckboxes.length;i++){
					if(allCheckboxes[i].name == this.name){
						cssjs("remove",allCheckboxes[i].parentNode,"aktiv");
						cssjs("add",this.parentNode,"aktiv");
					}
				}
			}
		}
	}
}
function nextSibling(startBrother){
    if (!startBrother.nextSibling) return false;
	var tempObj = startBrother.nextSibling;
	while(tempObj.nodeType!=1 && tempObj.nextSibling!=null){
		tempObj = tempObj.nextSibling;
	}
	return (tempObj.nodeType==1)?tempObj:false;
}
function preSibling(nextBrother){
	var tempObj = nextBrother.previousSibling;
	while(tempObj.nodeType!=1 && tempObj.previousSibling!=null){
		tempObj = tempObj.previousSibling;
	}
	return (tempObj.nodeType==1)?tempObj:false;
}
function helpTxt() {
	theElement = document.getElementById("contentInnerWrap");
	if (!theElement) {
		return;
	}

	var allParagraphs = theElement.getElementsByTagName("p");
	for (i = 0; i < allParagraphs.length; i++) {
		if (allParagraphs[i].className == "help") {
			allParagraphs[i].className = "jsHelpTxtHide"

			// Create the Link with Image
			var theHelpLink = document.createElement("a");
			var theHelpImg = document.createElement("img");
			var theSpan = document.createElement("img");
			with (theHelpLink) {
				className = 'helpLink';
				setAttribute('href', 'javascript:void(0);');
				setAttribute('id', 'helpLink');
				setAttribute('title', 'Zeigt Hilfetext');
			}

			// Attribute Hilfeimage!!! Das muss noch angepasst werden!!! Pfad und Image
			with (theHelpImg) {
				src = '/pbmedia/ic_help_small01_h.gif';
				setAttribute('alt', 'Hilfeicon');
			}
			theHelpLink.appendChild(theHelpImg);
			var Ausgabe = allParagraphs[i];
			Ausgabe.appendChild(theHelpLink);

			Ausgabe.onmouseover = function() {
				show(this);
			}

			Ausgabe.onmouseout = function() {
				hide(this);
			}
			theHelpLink.onfocus = function() {
				show(this.parentNode);
			}
			theHelpLink.onblur = function() {
				hide(this.parentNode);
			}

			// Hide/Show the paragraph
			function show(o) {
				
				cssjs("add", o, "jsHelpTxtShow");
				var thisImg = o.lastChild.childNodes[0];
				thisImg.src = '/pbmedia/ic_help_small02_h.gif';
				
				if (o.id == "helpTracking") {
					sendHelpPixel(oNetMindPixel, oNetMindSession);
				}
			}
			function hide(o) {
				cssjs("remove", o, "jsHelpTxtShow");
				var thisImg = o.lastChild.childNodes[0];
				thisImg.src = '/pbmedia/ic_help_small01_h.gif';
			}
		}
	}

}

// Diese schicke Funktion stammt von Christian Heilmann und hier gibt's das Original mitsamt Tutorial: http://ichwill.net/cssjsseparation.html
function cssjs(a, o, firstClass, secondClass)
{
	switch (a) {
		case "check":
			return new RegExp("\\b" + firstClass + "\\b").test(o.className)
			break;
		case "addremove":
			var rep = o.className.match(" " + firstClass) ? " " + firstClass : firstClass;
			o.className = cssjs("check", o, firstClass) ? o.className = o.className.replace(rep, "") : o.className += o.className ? " " + firstClass : firstClass;
			break;
		case 'swap':
				o.className=!cssjs('check',o,firstClass)?o.className.replace(secondClass,firstClass):o.className.replace(firstClass,secondClass);
		break;
		case "add":
			if (!cssjs("check", o, firstClass)) {
				o.className += o.className ? " " + firstClass : firstClass;
			}
			break;
		case "remove":
			var rep = o.className.match(" " + firstClass) ? " " + firstClass : firstClass;
			o.className = o.className.replace(rep, "");
			break;

	}
}

function decode_utf8(utftext)
{
    var plaintext = "";
    var i=0;
    var c=c1=c2=0;

    // while-Schleife, weil einige Zeichen uebersprungen werden
    while (i < utftext.length) {
        c = utftext.charCodeAt(i);
        if (c < 128) {
            plaintext += String.fromCharCode(c);
            i++;
        } else if ((c > 191) && (c < 224)) {
            c2 = utftext.charCodeAt(i + 1);
            plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
            i += 2;
        } else {
            c2 = utftext.charCodeAt(i + 1);
            c3 = utftext.charCodeAt(i + 2);
            plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
            i += 3;
        }
    }
    return plaintext;
}

/* highlight (highlights search result) ##### start ##### */
function init()
{
    //var pattern = /_suche\.html/i;
    //if (pattern.exec(document.referrer) != null && pattern.exec(document.location) == null) {
        //var url_parts = document.referrer.split('?');
        var url_parts = window.location.href.split('?');
        if (url_parts[1]) {
            var url_args = url_parts[1].split('&');
            for (var i = 0; i < url_args.length; i++) {
                var keyval = url_args[i].split('=');
                if (keyval[0] == 'hl') {
                    getKeywords(decodeUrl(keyval[1]));
                    return;
                }
            }
        }
    //}
}

function decodeUrl(url)
{
    url = unescape(url);
    url = decode_utf8(url);
    return url.replace(/\+/g,' ');
}

function getKeywords(string)
{
    string = string.replace(/&|\"/g,'');
    string = string.replace(/\s+/g,' ');
    string = string.replace(/^\s*/g,'');
    string = string.replace(/\s*$/g,'');
    var terms = string.split(' ');
    for (var i = 0; i < terms.length; i++) {
        highlight(terms[i], document.getElementById('contentWrap'));
    }
}

function highlight(term, container)
{
    var term_low = term.toLowerCase();

    // exclude navigation elements from highlight
    if (container.className == 'path') return;
    if (container.className == 'contentFooter') return;
    if (container.id == 'naviMainWrap') return;
    if (container.id == 'footerWrap') return;

    for (var i = 0; i < container.childNodes.length; i++) {
        var node = container.childNodes[i];
        if (node.nodeType == 3) {
            var data = node.data;
            var data_low = data.toLowerCase();
            if (data_low.indexOf(term_low) != -1) {
                // term found!
                var pnode = node.parentNode;
                var nnode = node.nextSibling;
                pnode.removeChild(node);
                var result;
                while ((result = data_low.indexOf(term_low)) != -1 &&
                    data.length > term.length) {
                    // text before term
                    pnode.insertBefore(document.createTextNode(data.substr(0,result)), nnode);
                    // term
                    pnode.insertBefore(createColorNode(document.createTextNode(data.substr(result, term.length))), nnode);
                    // text after term
                    data = data.substr(result + term.length);
                    data_low = data_low.substr(result + term.length);
                }
                pnode.insertBefore(document.createTextNode(data), nnode);
            }
        } else {
            // recurse
            highlight(term, node);
        }
    }
}

function createColorNode(child)
{
    var node = document.createElement('span');
    node.className = 'highlight';
    node.appendChild(child);
    return node;
}

function attachToggleNextBox()
{
    var allInputs = document.getElementsByTagName('input');
    for (var i = 0; i < allInputs.length; i++) {
        if (cssjs('check', allInputs[i], 'jsToggleBox')) {
            var input = allInputs[i];
            input.onclick = function()
            {
                toggleNextBox(this);
            }
            // hide if other radio is checked
            if (input.getAttribute('type') == 'radio') {
                var inputs = input.parentNode.parentNode.getElementsByTagName('input');
                for (var n = 0; n < inputs.length; n++) {
                    if (!cssjs('check', inputs[n], 'jsToggleBox')) {
                        inputs[n].onclick = function()
                        {
                            toggleNextBox(this, 'hide');
                        }
                    }
                }
            }
        }
    }
}

function toggleNextBox(el, state)
{
    // get parent fieldset
    var parentfs = el;
    while (parentfs.parentNode && parentfs.nodeName != 'FIELDSET') {
        parentfs = parentfs.parentNode;
    }
    // get following h4
    var h4 = parentfs;
    while (h4.parentNode && h4.nodeName != 'H4') {
        h4 = nextSibling(h4);
    }
    // get following fieldset
    var fs = h4;
    while (fs.parentNode && fs.nodeName != 'FIELDSET') {
        fs = nextSibling(fs);
    }
    // show/hide h4/fieldset
    switch (state) {
        case 'hide':
            cssjs('remove', h4, 'jsShow');
            cssjs('add', h4, 'jsHide');
            cssjs('remove', fs, 'jsShow');
            cssjs('add', fs, 'jsHide');
            break;
        case 'show':
            cssjs('remove', h4, 'jsHide');
            cssjs('add', h4, 'jsShow');
            cssjs('remove', fs, 'jsHide');
            cssjs('add', fs, 'jsShow');
            break;
        default:
            if (el.checked == true && cssjs('check', h4, 'jsHide') && cssjs('check', fs, 'jsHide')) {
                cssjs('remove', h4, 'jsHide');
                cssjs('add', h4, 'jsShow');
                cssjs('remove', fs, 'jsHide');
                cssjs('add', fs, 'jsShow');
            } else if (el.checked == false && cssjs('check', h4, 'jsShow') && cssjs('check', fs, 'jsShow')) {
                cssjs('remove', h4, 'jsShow');
                cssjs('add', h4, 'jsHide');
                cssjs('remove', fs, 'jsShow');
                cssjs('add', fs, 'jsHide');
            }
    }
}

// Blendet UL mit der ID "mid" aus und schreibt deren Links
// an aufrufender Stelle als Select-Box heraus.
// Der Konverter muss *nach* der entsprechenden UL aufgerufen werden.
//
// mid - id der Liste
// bPreSelect - wenn "true" wird der passende Wert vorausgewaehlt
function menuekonverter(mid, bPreSelect) {

}

// Commit to subdomains:
document.domain = location.hostname.replace(/^(.+)?\.([^\.]+\.[^\.]+)$/, '$2');


// Catch error handler for old browsers:
saveErrorHandler = window.onerror;
window.onerror = handleFrameSetError;
checkFrames();
// Reset error handler:
window.onerror = saveErrorHandler;




// Diese Funktion lässt den Cursor von Feld zu Feld springen (geburtsdatum eingabe)
function jumpToNextInputField(el) {

	var f = document.forms[formName];
	var elm = f.elements;
	var nextIndex = -1;
	var maxlen = el.maxLength;

	for(i=0;i<elm.length;i++) {
		if (elm[i].name == el.name) {
			nextIndex = (i+1);
		}
	}

	if (el.value.length > (maxlen-1)) {
		elm[nextIndex].focus();
		elm[nextIndex].select();
	}

}

function addEvent(obj, evType, fn) {
	if(obj==null) return false;

	if (obj.addEventListener){
		obj.addEventListener(evType, fn, true);
		return true;
  	} else if (obj.attachEvent){
  		var r = obj.attachEvent("on"+evType, fn);
   		return r;
  	} else {
  		return false;
	}
}

window.onload = function() {
	showprint();
	recommend();
	bookmark();
	helpTxt();
	openClose();
	closeLink();
	removeValue();
	sendNondefault();
	hideShow();
	toggleTable ();
	sortTable ();
	openPrintView ();
	closePrintView ();
	setBgCell ();
	openSalesPop ();
    init();
    attachToggleNextBox();
    menuConverter();
	HideTheContent();
}
