// JavaScript Document

function closeLink()
{
	if (document.getElementById("closeLink"))
	{
		closeLinkId = document.getElementById("closeLink");
		closeLinkId.className = "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 showprint() {

	isprint = document.getElementById("jsPrint");
	if (!isprint) {
		return;
	}
	cssjs('remove', isprint.parentNode, "jsHide");
	isprint.onclick = function ()
	{
		Druck();
	}

	isprint02 = document.getElementById("jsPrint02");
	if (!isprint02) {
		return;
	}
	cssjs('remove', isprint02.parentNode, "jsHide");
	isprint02.onclick = function ()
	{
		Druck();
	}
}

function Druck()
{
	window.print();
	return false;
}

function recommend() {
	isrecommend = document.getElementById("jsRecommend");
	if (!isrecommend) {
		return;
	}
	document.getElementById("jsRecommend").onclick = function Empfehlen()
	{
		/*this.href=link;*/
		ws_start = 'Hallo, \r\rich habe folgende interessante Seite entdeckt:\r\r';
		ws_ende = '\r\rViel Spass!';
		/* link = 'mailto:?subject=BHW Immobilien GmbH&body=' + escape(ws_start + document.title + '\r' + self.location + ws_ende); */
		link = 'mailto:?subject=BHW Immobilien GmbH&body=' + escape(ws_start) + replaceUmlaute(document.title) + escape('\r' + self.location + ws_ende);
		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.';

		if (ie && ver >= 4 && !mac) {
			window.external.AddFavorite(location.href, document.title);
			return false;
			// Favoritenfenster oeffnen
		}
		else if (opera || gecko) {
			this.href = location.href;
			this.title = document.title;
			alert(lz_drag);
		}
		else { // Browser mit falschem Titel bei Drag&Drop

			alert(lz_tastatur);
		}
		return false;
	}
}
// Blendet UL mit der ID "mid" aus und schreibt deren Links
// an aufÃ¼rufender 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) {
	if (document.getElementById) {
		if (bPreSelect == null) bPreSelect = false;
		document.getElementById(mid).style.display = 'none';
		document.write('<form action="JavaScript:void(0)" method=""><div id="div_' + mid + '"><label for="pbLink_' + mid + '" ><select name="sel_' + mid + '" id="pbLink_' + mid + '">');
		allLinks = document.getElementById(mid).getElementsByTagName('a');
		firstLink = document.getElementById(mid).getElementsByTagName('a')[0];
		for (i = 0; i < allLinks.length; i++) {
			attribs = '';
			text = allLinks[i].innerHTML;
			if (allLinks[i] == firstLink) {
				attribs += 'selected="selected"';
			}
			if (allLinks[i].getAttribute('onclick')) {
				aktion = allLinks[i].getAttribute('onclick');
			} else {
				aktion = 'self.location=\'' + allLinks[i].getAttribute('href') + '\'';
			}
			document.write('<option value="' + aktion + '"' + attribs + '>' + text + '<' + '/option>');
		}
		document.write('<' + '/select></label><label class="send" for="send_' + mid + '"><input type="image" src="pbmedia/bt_arrow.gif" value="Anzeigen" id="send_' + mid + '"  name="sel_' + mid + '" onclick="if (pbLink_' + mid + '[pbLink_' + mid + '.selectedIndex].value!=\'\') { eval(pbLink_' + mid + '[pbLink_' + mid + '.selectedIndex].value); if (typeof anonymous == \'function\') { anonymous(); } } return false;" /></label></div></form>');
	}
}
function helpTxt() {
	theElement = document.getElementById("contentInnerWrap");
	if (!theElement) {
		return;
	}
	// Hide all <p> with class="help"
	var allParagraphs = document.getElementById("contentInnerWrap").getElementsByTagName("p");
	for (i = 0; i < allParagraphs.length; i++) {
		if (allParagraphs[i].className == "help") {
			allParagraphs[i].className = "jsHelpTxtHide"
		}
	}
	// Hide all <div> with class="jsHelp .."
	helpDivs = document.getElementById("contentInnerWrap").getElementsByTagName("div");
	for (i = 0; i < helpDivs.length; i++) {
		if (cssjs("check", helpDivs[i], "jsHelp")) {
			// Create the Link with Image
			var theHelpLink = document.createElement("a");
			var theHelpImg = document.createElement("img");
			with (theHelpLink) {
				className = 'helpLink';
				setAttribute('href', '#');
				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 = helpDivs[i];
			Ausgabe.appendChild(theHelpLink);

			// Hide/Show the paragraph
			function show(o) {
				thisImg = o.childNodes[0];
				thisImg.src = 'pbmedia/ic_help_small02_h.gif'
				o.className = "helpLink jsOverlay";
				o.removeAttribute('title', 0);
				thisDiv = o.parentNode;
				thisParagraph = thisDiv.getElementsByTagName("p");
				for (m = 0; m < thisParagraph.length; m++) {

					if (thisParagraph[m].className == "jsHelpTxtHide") {
						thisParagraph[m].className = "jsHelpTxtShow"
					}
				}
			}
			function hide(o) {
				o.className = "helpLink";
				thisImg = o.childNodes[0];
				thisImg.src = 'pbmedia/ic_help_small01_h.gif'
				thisDiv = o.parentNode;
				thisParagraph = thisDiv.getElementsByTagName("p");
				for (m = 0; m < thisParagraph.length; m++) {
					if (thisParagraph[m].className == "jsHelpTxtShow") {
						thisParagraph[m].className = "jsHelpTxtHide"
					}
				}
				o.className = "helpLink";
				with (theHelpLink) {
					setAttribute('title', 'Zeigt Hilfetext');
				}
			}
			theHelpLink.onmouseover = function() {
				show(this);
			}
			theHelpLink.onfocus = function() {
				show(this);
			}
			theHelpLink.onmouseout = function() {
				hide(this);
			}
			theHelpLink.onblur = function() {
				hide(this);
			}
		}
	}
}

function removeValue() {
	if (document.getElementById("term")) {
		theInput = document.getElementById("term");
		theInput.value = ("Bitte hier Objekt-ID eingeben");
		theInput.onclick = function() {
			theInput.value = ("");
		}
		theInput.onfocus = function() {
			theInput.value = ("");
		}
	}
}
function hideShow() {
	theElement = document.getElementById("jsHideShow");
	if (!theElement) {
		return;
	}

	theListContainer = document.getElementById("jsListContainer");
	allHeadlines = theElement.getElementsByTagName("h4");
	allFieldsets = theElement.getElementsByTagName("fieldset");
	// Set initial
	for (i = 0; i < allFieldsets.length; i++) {
		allFieldsets[i].className = "jsHide"
		allFieldsets[0].className = "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);
		}
		theListItems.onfocus = function() {
			show(this);
		}

	}
	function show(o) {
		for (i = 0; i < allFieldsets.length; i++) {
			//cssjs('swap',allFieldsets[i],"jsShow","jsHide");
			if (cssjs("check", allFieldsets[i], "jsShow")) {
				cssjs("remove", allFieldsets[i], "jsShow");
				cssjs("add", allFieldsets[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);
		}
		allCheckboxes[i].onclick = function() {
			setBg(this);
		}
	}
	function setBg(o) {
		allTds = sortTable.getElementsByTagName("td");
		allThs = sortTable.getElementsByTagName("th");
		thePos = o.parentNode.cellIndex;

		for (n = 0; n < allTds.length; n++) {
			theCellPos = allTds[n].cellIndex;
			var activated = "aktiv";
			cssjs("remove", allTds[n], activated);
			if (theCellPos == o.parentNode.cellIndex) {
				cssjs("add", allTds[n], activated);
			}
		}
		for (n = 0; n < allThs.length; n++) {
			theCellPos = allTds[n].cellIndex;
			var activated = "aktiv";
			cssjs("remove", allThs[n], activated);
			if (theCellPos == o.parentNode.cellIndex) {
				cssjs("add", allThs[n], activated);
			}
		}
	}
}
function toggleTable() {
	theTable = document.getElementById("toggleTable");
	if (!theTable) {
		return;
	}
	allTBodies = theTable.getElementsByTagName("tbody");

	// mehrere tbodies als einzelne Sektionen
	for (i = 0; i < allTBodies.length; i++) {

		allTrs = allTBodies[i].getElementsByTagName("tr");
		firstGroup = allTBodies[0].getElementsByTagName("tr");
		var hide = "trHide"
		var linkOn = "on"
		// alle trs in einem tbody
		for (j = 0; j < allTrs.length; j++) {
			firstLevel = allTrs[0];
			cssjs("add", allTrs[j], hide);
			cssjs("remove", firstLevel, hide);
			cssjs("remove", allTrs[j], linkOn);
			firstLevel.onclick = function() {
				cssjs('addremove', this, linkOn);
				openSecondLevel(this);
			}
		}
		// erste Elemente in erstem tbody sind initial geï¿½ffnet
		for (j = 0; j < firstGroup.length; j++) {
			firstHead = firstGroup[0];
			firstItem = firstGroup[1];
			firstId = firstGroup[1].id;
			// Zweite Ebene mit Klasse secLevel
			if (cssjs("check", firstGroup[j], "secLevel")) {
				cssjs("add", firstHead, linkOn);
				cssjs("add", firstGroup[1], linkOn);
				cssjs("remove", firstGroup[j], hide);
				firstGroup[j].onclick = function() {
					openThirdLevel(this);
				};
			}
			if (cssjs("check", firstGroup[j], firstId)) {
				cssjs("remove", firstGroup[j], hide);
			}
		}
	}

	function openSecondLevel(o) {
		thisTBody = o.parentNode;
		thisNextLevel = thisTBody.getElementsByTagName("tr");
		for (j = 0; j < thisNextLevel.length; j++) {
			if (!cssjs("check", thisNextLevel[j], "secLevel")) {
				cssjs("add", thisNextLevel[j], hide);
				cssjs("remove", o, hide);
			}
			// Zweite Ebene mit Klasse secLevel
			if (cssjs("check", thisNextLevel[j], "secLevel")) {
				cssjs('addremove', thisNextLevel[j], hide);
				cssjs("remove", thisNextLevel[j], linkOn);
				thisNextLevel[j].onclick = function() {
					openThirdLevel(this);
				};
			}
		}
	}
	function openThirdLevel(o) {
		thisTBody = o.parentNode;
		// die dritte Eben wird ueber eine Klasse angesprochen, die der ID der zweiten Ebene entspricht, diese Variable wird hier gesetzt
		thisId = o.id;
		allTrs = thisTBody.getElementsByTagName("tr");
		cssjs('addremove', o, linkOn);
		for (j = 0; j < allTrs.length; j++) {
			if (cssjs("check", allTrs[j], thisId)) {
				cssjs('addremove', allTrs[j], hide);
			}
		}
	}
}

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++) {
								if (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 openClose() {

	var allContainer = document.getElementById("contentInnerWrap").getElementsByTagName("div");
	var allTables = document.getElementById("contentInnerWrap").getElementsByTagName("table");
	var allLinks = document.getElementById("contentInnerWrap").getElementsByTagName("a");
	var firstElement = true;

	for (n = 0; n < allContainer.length; n++) {
		if (cssjs("check", allContainer[n], "jsToggleFirst")) {
			if (firstElement) firstElement = false;
			else {
				cssjs("add", allContainer[n], "jsHide");
				var divId = allContainer[n].id;
				var link = document.getElementById(divId.substr(3));
				cssjs("remove", link, "on");
			}
		}
		if (cssjs("check", allContainer[n], "jsToggle")) {
			cssjs("add", allContainer[n], "jsHide");
			for (var i = 0; i < allLinks.length; i++) {
				cssjs("remove", allLinks[i], "on");
			}
		}
	}

	for (n = 0; n < allTables.length; n++) {
		if (cssjs("check", allTables[n], "jsToggleFirst")) {
			if (firstElement) firstElement = false;
			else {
				cssjs("add", allTables[n], "jsHide");
				var divId = allTables[n].id;
				var link = document.getElementById(divId.substr(3));
				cssjs("remove", link, "on");
			}
		}
		if (cssjs("check", allTables[n], "jsToggle")) {
			cssjs("add", allTables[n], "jsHide");
			for (var i = 0; i < allLinks.length; i++) {
				cssjs("remove", allLinks[i], "on");
			}
		}
	}
	for (i = 0; i < allLinks.length; i++) {
		if (cssjs("check", allLinks[i].parentNode, "questions") || cssjs("check", allLinks[i].parentNode, "jsToggleLink")) {
			allLinks[i].onclick = function() {
				nextElement = document.getElementById("js_" + this.id);
				cssjs('addremove', nextElement, "jsHide");
				cssjs('addremove', this, "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 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 "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 loadMandantCss() {
	if(document.createStyleSheet) {
		document.createStyleSheet('http://www.bhw-immobilien.de/cscss/mandant.neu.css');
	}
	else {
		var styles = "@import url('http://www.bhw-immobilien.de/cscss/mandant.neu.css');";
		var newSS=document.createElement('link');
		newSS.rel='stylesheet';
		newSS.href='data:text/css,'+escape(styles);
		document.getElementsByTagName("head")[0].appendChild(newSS);
	}
}

window.onload = function() {
	showprint();
	recommend();
	bookmark();
	helpTxt();
	openClose();
	closeLink();
	removeValue();
	hideShow();
	toggleTable ();
	sortTable ();
	openPrintView ();
	closePrintView ();
	setBgCell ();
	loadMandantCss();
}


// #########################################################################
// # Schriftskalierung
// #########################################################################

function  fontScale(iVal) 
{
	myfontsize = 	Number(getCookie("fontsize")) == 0 ? 12 : Number(getCookie("fontsize"));
	newfontsize = myfontsize + iVal;
	document.body.style.fontSize = newfontsize + "px";
	setCookie("fontsize", newfontsize, null, null, "/", null);
}

function setFontSize()
{
	myfontsize = Number(getCookie("fontsize")) == 0 ? 12 : Number(getCookie("fontsize"));
	document.body.style.fontSize = myfontsize + "px";
}

function setCookie (name, value, domain, expires, path, secure) {
	var today = new Date();
	today.setTime(today.getTime());
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + expires);
	var cookie = name + "=" + encodeURIComponent(value);
	if (expires)
		 cookie += "; expires=" + expires_date.toGMTString();
	if (path)
		cookie += "; path=" + path;
	if (domain)
		cookie += "; domain=" + domain;
	if (secure)
		cookie += ";secure";
	document.cookie = cookie;
}

function getCookie (name) {
	var name_index = document.cookie.indexOf(name + "=");
	if (name_index == -1)
		return null;
	var value_index = name_index + name.length + 1;
	var end = document.cookie.indexOf(";", value_index);
	if (end == -1)
		end = document.cookie.length;
	var value = decodeURIComponent(document.cookie.substring(value_index, end));
	return value;
}

function deleteCookie (name, domain, path) {
	if (getCookie(name)) {
		var cookie = name + "=";
		if (path)
			cookie += "; path=" + path;
		if (domain)
			cookie += "; domain=" + domain;
		cookie += "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
		document.cookie = cookie;
	}
}


function replaceUmlaute(curText) {
 if (typeof curText != "number" && typeof curText != "string" ) {
  alert("Sie versuchen Text auszugeben, der kein Text ist sondern: "+typeof curText);
  return "err";
 }
 if (curText == "") return "";
 if (typeof curText == "number") curText = String(curText);
 var result = curText;
 result=result.replace(/\u00fc/g, "ue");
 result=result.replace(/\u00f6/g, "oe");
 result=result.replace(/\u00e4/g, "ae");
 result=result.replace(/\u00dc/g, "Ue");
 result=result.replace(/\u00d6/g, "Oe");
 result=result.replace(/\u00c4/g, "Ae");
 result=result.replace(/\u00df/g, "ss");
 result=result.replace(/\u002d/g, " ");
 result=result.replace(/\s\S\s/g, " ");
 return result;
}