var immo = {
		
	// Wrapper für GA-Funktion
	flash_ad_second_tracker: function(kategorie, aktion, label) {
		var retval = secondTracker._trackEvent(kategorie,aktion,label);
	},
		
	fensterprint: function(x) {
		var winprint;
		winprint = window.open(x, 'print', 'width=460,height=450,scrollbars=no,left=100,top=50');
	},

	fensterhelp: function(x) {
		var winhelp;
		winhelp = window.open(x,'help','width=350,height=630,scrollbars=yes,left=230,top=50');
	},

	windowhelp: function(x) {
		var winhelp;
		winhelp = window.open(x, 'help', 'width=375,he ight=355,scrollbars=yes,left=200,top=50');
	},

	fensterschmal: function(x) {
		var winschmal;
		winhelp = window.open(x, 'help', 'width=280,height=500,scrollbars=yes,left=230,top=50');
	},

	fenstermedium: function(x) {
		var winmedium;
		winhelp = window.open(x, 'help', 'width=400,height=600,scrollbars=yes,left=230,top=50');
	},

	fensterhigh: function(x) {
		var winhigh;
		winhelp = window.open(x, 'help', 'width=400,height=750,scrollbars=yes,left=230,top=50');
	},

	fensterimprint: function(x) {
		var winimprint;
		winimprint = window.open(x, 'imprint', 'width=580,height=520,scrollbars=yes,left=230,top=50');
	},

	fensterfloor: function(x) {
		var winfloor;
		winfloor = window.open(x, 'floor', 'width=800,height=620,scrollbars=yes,left=230,top=50');
	},

	fensterpoke: function(x) {
		var winpoke;
		winpoke = window.open(x, 'help', 'width=490,height=650,scrollbars=no,left=50,top=50');
	},

	fensterpokeschmal: function(x) {
		var winpoke;
		winpoke = window.open(x, 'help', 'width=330,height=615,scrollbars=no,left=50,top=50');
	},

	popupAreamap: function(url) {
		immo.newscrollwinflex(url, 'Kartenansicht', 790, 690);
	},

	popupAreamapPrint: function(url) {
		immo.newscrollwinflex(url, 'Karten Druckansicht', 790, 690)
	},

	popupsmall: function(x) {
		var winfloor;
		winfloor = window.open(x, 'popup', 'width=580,height=565,scrollbars=yes,left=230,top=50');
	},
	
	// Positioniert ein Popup in der Bildschirmmitte#
	
	popupCenter: function(url,title,w,h) {
		var left = (screen.width/2)-(w/2);
		var top = (screen.height/2)-(h/2);
		var targetWin = window.open (url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
	}, 

	popuplarge: function(x) {
		var sh = screen.height;
		var sw = screen.width;
		if (sh <= 900) {
			var sh = (sh - 100);
		}
		if (sh > 900) {
			var sh = 840;
		}
		var winfloor;
		winfloor = window.open(x+'&h='+sh,'popup','width=850,height='+sh+',scrollbars=yes,left=0,top=0');
	},

	popupreview: function(url) {
		var wwidth = 670;
		var browserName=navigator.appName;
		var browserVer=parseInt(navigator.appVersion);
		if(browserName=="Netscape") {
			if(browserVer>4) {
				// Kann entfallen wenn in Funktion newscrollwinflex die Breite um 10 reduziert wird!
				wwidth=wwidth-25;
			}
		}
		immo.newscrollwinflex(url,'Bewertung',790,wwidth, true);
	},

	newscrollwinflex: function(url, wname, wheight, wwidth, showScrollbars) {
		if ((screen.height - wheight) < 100) {
			wheight = screen.height - 100;
		}
		var browserName=navigator.appName;
		var browserVer=parseInt(navigator.appVersion);
		if (browserName == "Netscape") {
			if (browserVer > 4) {
				wwidth = wwidth + 15;
				wheight = wheight + 5;
			}
		}
		// Der IE braucht ein bisschen mehr platz als der Firefox. 
		if (navigator.appName == "Microsoft Internet Explorer") {
			wheight += 15;
			wwidth += 15;
		}
		var windowtop = ((screen.height - wheight) /2) -20;
		if (windowtop < 0) {
			windowtop = 0;
		}
		var windowleft = (screen.width - wwidth) /2;
		// Wenn scrollbars nicht übergeben wird, dann ist default "yes"
		if (typeof showScrollbars == 'undefined' || (showScrollbars == null) || showScrollbars) {
			showScrollbars = "yes";
		}
		else {
			showScrollbars = "no";
		}
		var whdl = window.open(url, wname, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + showScrollbars + ",resizable=yes,copyhistory=no" + ",width=" + wwidth +",height=" + wheight + ",left=" + windowleft + ",top=" + windowtop);
		whdl.focus();
	},

	newscrollwin: function(url, wname, wheight, wwidth) {
		var windowtop = ((screen.height - wheight) /2) -20;
		var windowleft = (screen.width - wwidth) /2;
		var browserName=navigator.appName;
		var browserVer=parseInt(navigator.appVersion);
		if (browserName == "Netscape") {
			if (browserVer > 4) {
				wwidth=wwidth+15;
				wheight=wheight+5;
			}
		}
		wname = window.open(url, wname, "toolbar=0,width=" + wwidth  + ",height=" + wheight + ",location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,left=" + windowleft + ",top=" + windowtop);
		wname.focus();
	},

	SubmitForm: function(form, selectTag, selected) {
		SelectOption(document.forms[form].elements[selectTag], selected);
		document.forms[form].submit();
	},
	
	load_popup: function(param) {
		popup = window.open(param, "immonet", 'scrollbars=no,left=85,top=20,width=650,height=470');
		if(typeof(popup) == 'object') { popup.blur(); }
		window.focus();
	},

	load_impopup: function(param) {
		sapop = window.open(param, "sapop", 'scrollbars=no,left=85,top=20,width=650,height=470');
		if(typeof(sapop) == 'object') { sapop.blur(); }
		window.focus();
	},

	load_back: function(param) {
		if (window.opener && !window.opener.closed) {
			opener.location.href = "/searchagent.do?" + param;
			self.close();
		}
		else {
			win3 = window.open("/searchagent.do?" + param, 'zurueck', 'scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,status=yes,location=yes,left=85,top=20,height=768,width=1024');
			win3.focus();
			self.close();
		}
	},

	load_webde: function(param) {
		if (window.opener && !window.opener.closed) {
			window.open(location.href = "http://web.immonet.de/searchagent.do?" + param);
			self.close()
		}
		else {
			win3 =window.open("/searchagent.do?" + param, 'zurueck', 'scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,status=yes,location=yes,left=85,top=20,height=768,width=1024');
			win3.focus();
			self.close()
		}
	},

	load_focus: function(param) {
		if (window.opener && !window.opener.closed) {
			opener.location.href="/searchagent.do?navi=false&"+param;
			self.close()
		}
		else {
			win3 = window.open("/searchagent.do?navi=false&" + param, 'zurueck', 'scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,status=yes,location=yes,left=85,top=20,height=768,width=1024');
			win3.focus();
			self.close()
		}
	},


	changeLink: function(x) {
		for (i = 0; i < document.links.length; i++) {
			var y = document.links[i].href.toString();
			if (y.indexOf(x,0) >= 0 ) {
				var lnk = document.links[i].href.toString();
				var value = document.form1.objectType.options[document.form1.objecttype.selectedIndex].value;
				document.links[i].href =lnk + "&objecttype=" + value;
			}
		}
	},

	changeObjectType: function() {
		var value = document.form1.objectTypeList.options[document.form1.objectTypeList.selectedIndex].value;
		var x = 1;
		var y = 1;

		if (value == "112" || value == "11" || value == 12) {
			x = 1;
		}
		else if (value == 21) {
			x = 2;
		}
		else if (value == 31 || value == 323 || value == 30) {
			x = 3;
		}

		if (value == 12 || value == 323) {
			y = 2;
		}
		else if (value == 11 || value == 21 || value == 31) {
			y = 1;
		}
		else if (value == 112 || value == 30) {
			y = 0;
		}

		if (document.form1 != null && document.form1.objecttype != null) {
			document.form1.objecttype.value = x;
			document.form1.marketingtype.value = y;
		}
		if (document.form2 != null && document.form2.objecttype != null) {
			document.form2.objecttype.value = x;
			document.form2.marketingtype.value = y;
		}
		if (document.form3 != null && document.form3.objecttype != null) {
			document.form3.objecttype.value = x;
			document.form3.marketingtype.value = y;
		}
		if (document.form4 != null && document.form4.objecttype != null) {
			document.form4.objecttype.value = x;
			document.form4.marketingtype.value = y
		}
		if (document.NewSearch != null && document.NewSearch.objecttype != null) {
			document.NewSearch.objecttype.value = x;
			document.NewSearch.marketingtype.value =y
		}
	},

	changeNewSearchObjectType: function() {
		var value = document.NewSearch.objectTypeList.options[document.NewSearch.objectTypeList.selectedIndex].value;
		var x = 1;
		var y = 1;

		if (value == "112" || value == "11" || value == 12) {
			x = 1;
		}
		else if (value == 21) {
			x = 2;
		}
		else if (value == 31 || value == 323 || value == 30) {
			x = 3;
		}

		if (value == 12 || value == 323) {
			y = 2;
		}
		else if (value == 11 || value == 21 || value == 31) {
			y = 1;
		}
		else if (value == 112 || value == 30) {
			y = 0;
		}

		if (document.NewSearch != null && document.NewSearch.objecttype != null) {
			document.NewSearch.objecttype.value = x;
			document.NewSearch.marketingtype.value = y;
		}
	},

	showKeywords: function(pagename,id) {
		f = window.open("about:blank", "Fenster1", "width=400,height=400,left=50,top=50,status=yes");
		var y = pagename.split('/');
		f.document.open();
		f.document.writeln('<html><body>');
		f.document.writeln('<table align=\"center\"><tr><td align=\"center\" colspan=\"2\"><b>Immonet Keywords</b></td></tr><tr><td colspan=\"2\"><form name=\"addtag\">');
		f.document.writeln('<textarea rows=\"15\" cols=\"35\" name=\"tags\" onBlur=\"self.close()\">');
		for (i = 1; i < y.length; i++){
			f.document.writeln(y[i].replace('%20', ' ').replace('%20', ' ').replace('%20', ' ').replace('%20', ' '));
		}
		f.document.writeln('</textarea></form></td></tr>');
		if(y.length > 2) {
			f.document.writeln('<tr><td><b>Webseite:</td><td>' + y[1] + '</b></td></tr>');
			f.document.writeln('<tr><td><b>Werbeplatz:</td><td>' + y[2] + '</b></td></tr>');
			f.document.writeln('<tr><td><b>WerbeplatzId:</td><td>' + id + '</b></td></tr>');
		}
		f.document.writeln('</table></body></html>');
		f.document.close();
		f.addtag.tags.focus();
	},

	submitBrokerForm: function(form, method, target) {
		document.userManagerForm.method.value = method;
		document.userManagerForm.target.value = target;
		document.userManagerForm.submit();
	},

	SelectOption: function(selectTag, selected) {
		for(i = 0; i < selectTag.length;++i) {
			if (selectTag.options[i].value == selected) {
				selectTag.options[i].selected = true;
			}
			else {
			   selectTag.options[i].selected = false;
			}
		}
	},

	SubmitForm: function(form, selectTag, selected) {
		immo.SelectOption(document.forms[form].elements[selectTag], selected);
		document.forms[form].submit();
	},

	pressEnter: function(index, ev) {
		var keycode;
		if (window.event) {
			keycode = window.event.keyCode;
		}
		else if (e) {
			keycode = e.which;
		}
		else {
			return true;
		}
		if (keycode == 13) {
			document.forms[index].submit();
			return false;
		}
		else {
			return true;
		}
	},


/* ---- Ab hier neu, aufgeräumt und dokumentiert! ---- */
/* ---- Wiki: http://wiki.immonet.asv.local/display/DEV/immo.js ---- */

	/** Der Pfad zur Anmeldung */
	loginUrl: "/login/user",


	/**
	 * Gibt ein XmlHttpRequest Objekt zurück, das für Asynchrone Abfragen genutzt werden kann.
	 * Funktioniert mit Mozilla, Opera, Safari sowie Internet Explorer.
	 *
	 * @return Ein XmlHttpRequest Objekt
	 */
	getXmlHttpRequest: function() {
		var xhr = null;
		// Mozilla, Opera, Safari sowie Internet Explorer 7
		if (typeof XMLHttpRequest != 'undefined') {
			xhr = new XMLHttpRequest();
		}
		if (!xhr) {
			// Internet Explorer 6 und älter
			try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e) {
				try {
					xhr  = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e) {
					xhr  = null;
				}
			}
		}
		return xhr;
	},


	/**
	 * Sendet eine asynchrone Anfrage zu der spezifizierten URL, und Ruft bei Erfolg onSuccess, andernfalls onFailer auf.
	 *
	 * @param url Die URL, an welche die Anfrge geschickt wird
	 * @param onSuccess Eine Function welche Aufgerufen wird, wenn die Anfrage mit Rückgabe erfolgreich war. Kann einen Parameter für den responseText besitzen.
	 * @param onFailure Eine Function welche Aufgerufen wird, wenn die Anfrage mit Rückgabe nicht erfolgreich war. Kann einen Parameter für den responseText besitzen.
	 */
	sendXmlHttpRequest: function(url, onSuccess, onFailure) {
		var xhr = immo.getXmlHttpRequest();
		if (!immo.isEmpty(xhr)) {
			xhr.open("GET", url, true);
			xhr.onreadystatechange = function () {
				if (xhr.readyState == 4) {
					if (xhr.status == 200) {
						if (!immo.isEmpty(onSuccess)) {
							onSuccess(xhr.responseText);
						}
					}
					else {
						if (!immo.isEmpty(onFailure)) {
							onFailure(xhr.responseText);
						}
					}
				}
			};
			xhr.send(null);
		}
	},


	/**
	 * Sendet eine asynchrone Anfrage an die spezifizierte Url, und schreibt die Serverantwort in das
	 * angegebene Element.
	 *
	 * @param url Die URL, an welche die Anfrge geschickt wird
	 * @param elementId Die Id des Elementes, in welches die Antwort vom Server geschrieben wird
	 */
	updateXmlHttpRequest: function(url, elementId) {
		function onSuccess(responseText) {
			element = document.getElementById(elementId);
			element.innerHTML = responseText;
		}
		immo.sendXmlHttpRequest(url, onSuccess);
	},


	/**
	 * Eine textarea mit einem Zähler für die übrigbleibenden Zeichen versehen
	 *
	 * @param textAreaId Id des textarea-Form Elementes
	 * @param counterId Id des zu aktuallisierenden Zählers
	 * @param count Anzahl der erlaubten Zeichen
	 * @param helpText Ein optionaler Hilfetext, welcher erscheinen soll
	 * @param isCounterFormField Definiert ob der Zähler ein Formularfeld oder ein <span> Element ist. Default ist false (ein <span> Feld).
	 */
	counterTextArea: function(textAreaId, counterId, count, helpText, isCounterFormField) {
		isCounterFormField = immo.isEmpty(isCounterFormField) ? false : true;
		var counter = document.getElementById(counterId);
		setCountText(count);
		var textarea = document.getElementById(textAreaId);
		immo.addEvent(textarea, "keyup", countAfterContentChange);
		immo.addEvent(textarea, "blur", countAfterContentChange);
		immo.addEvent(textarea, "reset", countAfterContentChange);
		/*
		textarea.onkeyup = countAfterContentChange;
		textarea.onblur = countAfterContentChange;
		textarea.onreset = countAfterContentChange;
		*/

		if (textarea.value) {
			// Damit gezählt wird, falls bereits Text vorgegeben ist
			countAfterContentChange();
		}
		else {
			// Falls kein Text vorgegeben ist, Hilfetext ausgeben
			immo.setFormElementHelpText(textAreaId, helpText);
		}

		function countAfterContentChange() {
			var charsEntered = textarea.value.length;
			if (charsEntered > count) {
				textarea.value = textarea.value.substring(0, count);
				textarea.selectionStart = count;
				textarea.selectionEnd = count;
			}
			var charsLeft = count - charsEntered;
			if (charsLeft < 0) {
				charsLeft = 0;
			}
			setCountText(charsLeft);
		}

		function setCountText(currentCounter) {
			if (!isCounterFormField) {
				var text = currentCounter;
				if (navigator.appName == "Microsoft Internet Explorer") {
					// Der IE reduziert ansonsten das Leerzeichen weg
					text += "&nbsp;";
				}
				counter.innerHTML = text;
			}
			else {
				counter.value = currentCounter;
			}
		}
	},


	/**
	 * Ein Eingabefeld mit einem dezenten Hilfetext versehen, welcher verschwindet, sobald man reinklickt.
	 *
	 * @param formElementId Id des Form Elementes
	 * @param helpText Der Hilfetext, welcher erscheinen soll
	 */
	setFormElementHelpText: function(formElementId, helpText) {
		var formElement = document.getElementById(formElementId);
		var originalColor = formElement.style.color;
		if (!immo.isEmpty(helpText)) {
			formElement.value = helpText;
			formElement.style.color = "#aaa";
		}
		formElement.onfocus = formElementOnFocus;

		function formElementOnFocus() {
			if (formElement.value == helpText) {
				formElement.value = "";
				formElement.style.color = originalColor;
			}
		}
	},


	/**
	 * Hält die Session des Benutzers am leben, in dem alle 5 Minuten eine
	 * asynchrone Abfrage mittels XmlHttpRequest gesendet wird.
	 */
	keepAlive: function() {
		// 1200000 = 20 Minuten / 300000 = 5 Minuten
		// gaender auf 50 Sekunden damit Philip nie nie nie aus der Session geworfen wird MS 2009-10-05
		function keepAliveDelegate() {
			function onKeepAliveSuccess(resultText) {
				immo.keepAlive();
			}
			function onKeepAliveFailure(resultText) {
				location.href = immo.loginUrl;
			}
			immo.sendXmlHttpRequest("/keepalive.do?" + immo.generateRandomParameter(), onKeepAliveSuccess, onKeepAliveFailure);
		}
		window.setTimeout(keepAliveDelegate, 50000);
	},


	/**
	 * Fügt den Event Browserübergreifend an ein Objekt.
	 *
	 * @param obj Das Objekt, an welches der event gehängt wird
	 * @param type Der Name des Events (ohne "on", also bei onclick ist dies "click")
	 * @param func Die Funktion, welche bei dem Event aufgerufen werden soll
	 */
	addEvent: function(obj, type, func) {
		if (window.attachEvent) {
			obj.attachEvent("on" + type, func);
			/* alternativer code
			obj["e" + type + func] = func;
			obj[type + func] = function() {
				obj["e" + type + func](window.event);
			}
			obj.attachEvent(type, obj["on" + type + func]);
			*/
		}
		else {
			obj.addEventListener(type, func, false);
		}
	},


	/**
	 * Entfernt den Event Browserübergreifend von einem Objekt.
	 *
	 * @param obj Das Objekt, von welchem der Event entfernt werden soll
	 * @param type Der Name des Events (ohne "on", also bei onclick ist dies "click")
	 * @param func Die Funktion, welche bei dem Event nicht mehr aufgerufen werden soll
	 */
	removeEvent: function(obj, type, func) {
		if (obj.detachEvent) {
			obj.detachEvent("on" + type, func);
			/* Alternativer code
			obj.detachEvent("on" + type, obj[type + func]);
			obj[type + func] = null;
			*/
		}
		else {
			obj.removeEventListener(type, func, false);
		}
	},


	/**
	 * Support Funktion, für Stellen, an denen der body-Tag nicht zur verfügung steht, aber in der onload ein etwas geschehen soll.
	 *
	 * @param func Die Funktion, welche in onload aufgerufen werden soll
	 */
	onloadAfterBody: function(func) {
		// addEvent kann hier nicht genutzt werden, wenn jemand weiss warum, bitte melden
		// SHL: muss der Aufruf evtl. mit immo.addEvent erfolgen?
		if (window.attachEvent) {
			window.attachEvent("onload", func);
		}
		else {
			window.addEventListener("load", func, false);
		}
	},


	/**
	 * Bequemlichkeitsmethode um ein Formular abzusenden
	 *
	 * @param formName Name des Formulars
	 */
	submitForm: function(formName) {
		document.forms[formName].submit();
	},


	/**
	 * Die Umlaute in einer Zeichenkette ersetzen
	 * 
	 * @param s Die Zeichenkette, in der die Umlaute ersetzt werden sollen
	 * @return Die Zeichenkette ohne Umlaute
	 */
	decodeUmlaut: function(s) {
		s = s.replace(/ß/g, "ss");
		s = s.replace(/ä/g, "ae");
		s = s.replace(/Ä/g, "Ae");
		s = s.replace(/ö/g, "oe");
		s = s.replace(/Ö/g, "Oe");
		s = s.replace(/ü/g, "ue");
		s = s.replace(/Ü/g, "Ue");
		s = s.replace(/à/g, "a");
		s = s.replace(/À/g, "A");
		s = s.replace(/á/g, "a");
		s = s.replace(/Á/g, "A");
		s = s.replace(/â/g, "a");
		s = s.replace(/Â/g, "A");
		s = s.replace(/ã/g, "a");
		s = s.replace(/Ã/g, "A");
		s = s.replace(/å/g, "a");
		s = s.replace(/Å/g, "A");
		s = s.replace(/è/g, "e");
		s = s.replace(/È/g, "E");
		s = s.replace(/é/g, "e");
		s = s.replace(/É/g, "E");
		s = s.replace(/ê/g, "e");
		s = s.replace(/Ê/g, "E");
		s = s.replace(/ë/g, "e");
		s = s.replace(/Ë/g, "E");
		s = s.replace(/ì/g, "i");
		s = s.replace(/Ì/g, "I");
		s = s.replace(/í/g, "i");
		s = s.replace(/Í/g, "I");
		s = s.replace(/î/g, "i");
		s = s.replace(/Î/g, "I");
		s = s.replace(/ï/g, "i");
		s = s.replace(/Ï/g, "I");
		s = s.replace(/ñ/g, "n");
		s = s.replace(/Ñ/g, "N");
		s = s.replace(/ò/g, "o");
		s = s.replace(/Ò/g, "O");
		s = s.replace(/ó/g, "o");
		s = s.replace(/Ó/g, "O");
		s = s.replace(/ô/g, "o");
		s = s.replace(/Ô/g, "O");
		s = s.replace(/õ/g, "o");
		s = s.replace(/Õ/g, "O");
		s = s.replace(/ù/g, "u");
		s = s.replace(/Ù/g, "U");
		s = s.replace(/ú/g, "u");
		s = s.replace(/Ú/g, "U");
		s = s.replace(/û/g, "u");
		s = s.replace(/Û/g, "U");
		s = s.replace(/ý/g, "y");
		s = s.replace(/Ý/g, "Y");
		s = s.replace(/ç/g, "c");
		s = s.replace(/Ç/g, "C");
		return(s);
	},

	/**
	 * Entfernt die Leerzeichen am Anfang und am Ende der Zeichenkette.
	 *
	 * @param value Die Zeichenkette, bei der die Leerzeichen entfernt werden sollen.
	 * @return Eine Zeichenkette ohne Leerzeichen am Anfang und Ende
	 */
	trim: function(value) {
		return value.replace(/(^ +| +$)/, "");
		/* alternativ ohne RegEx:
		while (value.substring(0,1) == " ") {
			value = value.substring(1, value.length);
		}
		while (value.substring(value.length - 1, value.length) == " ") {
			value = value.substring(0, value.length - 1);
		}
		return value;
		*/
	},

	/**
	 * Entfernt die Leerzeichen am Anfang und am Ende der Zeichenkette.
	 * 
	 * @param value Die Zeichenkette, bei der die Leerzeichen entfernt werden sollen.
	 * @return Eine Zeichenkette ohne Leerzeichen am Anfang und Ende
	 */
	ltrim: function(value){
		return value.replace (/^\s+/, "");
	},


	/**
	 * Bestimmt ob das übergebene Objekt null oder undefined ist
	 *
	 * @param value Objekt welches überprüft werden soll
	 * @return true wenn das übergebene Objekt null oder undefined ist
	 */
	isEmpty: function(value) {
		return (typeof value == "undefined") || (value == null);
	},



	/**
	 * Bestimmt ob der übergebene String null,undefined oder Leer ist
	 *
	 * @param value String welches überprüft werden soll
	 * @return true wenn der übergebene String null, undefined oder Leer ist
	 */
	isStringEmpty: function(value) {
		return immo.isEmpty(value) || (value.length == 0);
	},
	
	/**
	 * Returns browser typ. Diese Funktion darf gerne verfeinert werden!
	 * @return:  
	 * IE6 = MS Internet Explorer 6.0
	 * IE7 = MS Internet Explorer 7.0
	 * IE8 = MS Internet Explorer 8.0
	 * FF = Firefox
	 */
	getUserAgent: function(){
		var agent = false;
		if(navigator.userAgent.toLowerCase().indexOf('msie 6.0') > -1){
			agent = 'IE6';
		}
		else if(navigator.userAgent.toLowerCase().indexOf('msie 7.0') > -1){
			agent = 'IE7';
		}
		else if(navigator.userAgent.toLowerCase().indexOf('msie 8.0') > -1){
			agent = 'IE8';
		}
		else if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
			agent = 'FF';
		}
		return agent;
	},
	
	/**
	 * Returns true, if browser type is IE.
	 * @return boolean - true (if browser typ IE), false (if browser type isn't IE)
	 */
	isIExplorer: function(){
		var returner = false;
		if(this.getUserAgent() == 'IE6' || this.getUserAgent() == 'IE7') returner = true;
		return returner;
	},
	
	/**
	 * Überprüft die Unterstützung von Cookies im Browser.
	 */
	isCookieSupportEnabled: function() {
		if(navigator.userAgent.toLowerCase().indexOf('msie') > -1){
			document.cookie = "CookieTest=OK";
			if (immo.isEmpty(immo.getCookie("CookieTest"))) {
				return false;
			}
			else {
				immo.removeCookie("CookieTest");
				return true;
			}
		}
		else {
			return navigator.cookieEnabled;
		}
	},


	/**
	 * Liest einen Cookie. Sollte in der Regel nicht verwendet werden.
	 * 
	 * @param name Der name des Cookie
	 * @return Der Cookie-String
	 */
	getCookie: function(name) {
		var i = 0;  // Suchposition im Cookie
		var suche = name + "=";
		while (i < document.cookie.length) {
			if (document.cookie.substring(i, i + suche.length) == suche) {
				var ende = document.cookie.indexOf(";", i + suche.length);
				ende = (ende >- 1) ? ende : document.cookie.length;
				var cook = document.cookie.substring(i + suche.length, ende);
				return unescape(cook);
			}
			i++;
		}
		return null;
	},


	/**
	 * Löscht einen Cookie. Sollte in der Regel nicht verwendet werden.
	 * 
	 * @param name Der Name des Cookies
	 * @param domain Die Domain, für die dieser Cookie gültig ist
	 * @param path Der Pfad, für den dieser Cookie gültig ist
	 */
	removeCookie: function(name, domain, path) {
		var cook = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
		cook += (domain) ? ";domain=" + domain : "";
		cook += (path) ? ";path=" + path : "";
		document.cookie = cook;
	},

	/**
	 * Speichert einen Session-Cookie. Sollte in der Regel nicht verwendet werden.
	 * 
	 * @param name Der Name des Cookies
	 * @param value Der Wert, der im Cookie gespeichert werden soll
	 * @param domain Die Domain, für die dieser Cookie gültig ist
	 * @param path Der Pfad, für den dieser Cookie gültig ist
	 */
	setSessionCookie: function(name, value,domain, path) {
		var cook = name + "=" + escape( value );
		cook += (domain) ? ";domain=" + domain : "";
		cook += (path) ? ";path=" + path : "";
		document.cookie = cook;
	},


	/**
	 * Zeigt einen Lade-Overlay über dem Element mit der angegebenen ID
	 * 
	 * @param elementId Das Element, über welches der Lade-Overlay gelegt wird
	 * @param backgroundPositionStyle Wenn erforderlich, kann die Ladegrafik verschoben werden
	 */
	showSpinnerOverlay: function(elementId, backgroundPositionStyle) {
		var element = document.getElementById(elementId);
		new Insertion.Before(element.firstChild, "<div id=\"spinnerOverlay\" class=\"spinnerOverlay\"></div>");
		var width = element.offsetWidth;
		var height = element.offsetHeight;
		var spinnerOverlay = document.getElementById("spinnerOverlay");
		spinnerOverlay.style.width = width + "px";	
		spinnerOverlay.style.height = height + "px";	
		spinnerOverlay.style.display = "inline";
		if (!immo.isEmpty(backgroundPositionStyle)) {
			spinnerOverlay.style.backgroundPosition = backgroundPositionStyle;
		}
	},


	/**
	 * Erzeugt einen Zufallsparameter (Timestamp) für Ajax Abfragen.
	 * Der IE ist der DÜMMSTE Browser den es gibt, ändert sich nicht die URL eines XHR,
	 * dann cached er die Antwort [sic!]
	 *
	 * @param parameterName Optinaler Name des Parameters. Default ist "p".
	 */
	generateRandomParameter: function(parameterName) {
		var parameter = "q" + new Date().getTime();
		//var p = "q" + Math.floor(Math.random() * 999999999);
		if (immo.isStringEmpty(parameterName)) {
			parameterName = "p";
		}
		return parameterName + "=" + parameter;
	},


	/**
	 * Klappt Inhalt eines Panels ein/aus.
	 *
	 * @param elementName Name des ein-/auszuklappenden Containers.
	 * @param objControlImg object HTMLImageElement, welches das Steuer-Image (+-) enthaelt
	 * @param imgName Fragment des Dateinamens des Steuer-Images
	 * @param displayStyle optional, 'block', 'none' etc.
	 */
	togglePanel: function (elementName, objControlImg, imgName, displayStyle) {
		var myElement = document.getElementById(elementName);
		var imgSuff = "";
		if(myElement) {
			//find out displaystatus of elementName
			var myStatus = myElement.style.display;
			myElement.style.display = (myStatus == '' || myStatus == 'block' || myStatus == 'inline') ? 'none' : displayStyle ;
			imgSuff = (myElement.style.display == 'none') ? '0.gif' : '1.gif';
			/* alternativer Code
			if(myStatus == '' || myStatus == 'block' || myStatus == 'inline') {
				myElement.style.display = 'none';
				imgSuff = "0.gif";
			}
			else if (myStatus == 'none') {
				myElement.style.display = displayStyle;
				imgSuff = "1.gif";
			}
			*/
			
			if(imgName != '')
				objControlImg.src = "/img/icons/"+imgName+imgSuff;
		}
	},
	
	reloadJavascript: function(src){
		var scrElement = document.createElement("script");
		scrElement.type = "text/javascript";
		scrElement.src = src;
		document.getElementsByTagName("head")[0].appendChild(scrElement);
		return true;
	},
	
	reloadCss: function(src){
		var scrElement = document.createElement("link");
		scrElement.type = "text/css";
		scrElement.setAttribute('href', src);
		scrElement.setAttribute('rel', 'stylesheet');
		document.getElementsByTagName("head")[0].appendChild(scrElement);
		return true;
	},	
	
	toggleCheckbox: function(id) {
		var e = document.getElementById(id);
 		e.checked = (e.checked) ? false : true;
 		return false;
 	},
 	
 	toggleDiv: function(element, checkbox){
 		var elementId = document.getElementById(element);
 		if (!checkbox.checked) {
// 		if(elementId.className == 'inline')
 			elementId.className = 'hiddentype';
 		}
 		else {
 			elementId.className = 'inline';}
 	},



 	
 /**
  * checken/unchecken von einer Liste von Checkboxen z.B. verwendet in Meine Objekte->Objekt->Anfragen löschen
  * und Objekteingabe->Hausbauobjekte->Bundeslandauswahl
  * @param checkboxAll: die id der Checkbox, die alle anderen checked oder unchecked
  * @param checkBoxContainer: der Container, der die checkboxen enthält
  * **/
 	//check/uncheck oder all?
	performCheck: function(checkboxAll, checkBoxContainer){
 		if(!checkBoxList){
			var checkBoxList = document.getElementById(checkBoxContainer).getElementsByTagName('input');
		}
		if(document.getElementById(checkboxAll).checked){
			immo.checkAll(checkBoxList);
		}
		if(!document.getElementById(checkboxAll).checked){
			immo.unCheckAll(checkBoxList);
		}
	},
	//check all
	checkAll: function(checkBoxList){
			for(i=0; i<checkBoxList.length; i++){
				checkBoxList[i].checked = true;
			}
	},
	//uncheck all
	unCheckAll: function(checkBoxList){
		for(i=0; i<checkBoxList.length; i++){
			checkBoxList[i].checked = false;
		}
	},
	//die check-all checkbox unchecken, wenn im zustand all-checked irgendwo drin einer unchecked wird
	uncheckListener: function(checkboxAll){
		if(document.getElementById(checkboxAll).checked){
			document.getElementById(checkboxAll).checked = false;
		}
	},
	//checked die allbox, wenn alle anderen gechecked wurden
	checkAllListener: function (checkBoxContainer, checkboxAll) {
		if(!checkBoxList){
			var checkBoxList = document.getElementById(checkBoxContainer).getElementsByTagName('input');
		}
		if(checkBoxList.length > 0){
			checkedCount = 0;
			for(i=0; i < checkBoxList.length; i++){
				if(checkBoxList[i].checked){
					checkedCount++;
				}
			}
			if(checkedCount == checkBoxList.length){
				document.getElementById(checkboxAll).checked = true;
			}
		}
	},
	
	//prueft ob mindestens eine Checkbox gechecked ist und checked sonst die "alle" box
	genOneChecked: function(checkBoxContainer, checkboxAll){
		if(!checkBoxList){
			var checkBoxList = document.getElementById(checkBoxContainer).getElementsByTagName('input');
		}
		if(checkBoxList.length > 0){
			var checkedCount = 0;
			for(i=0; i < checkBoxList.length; i++){
				if(checkBoxList[i].checked){
					checkedCount++;
				}
			}
			if(checkedCount == 0){
				document.getElementById(checkboxAll).checked = true;
			}
		}
	},
	//Alle Objekte in einem Container unchecken ausser "except"
	unCheckSelected: function (checkBoxContainer, except){
		if(!checkBoxList){
			var checkBoxList = document.getElementById(checkBoxContainer).getElementsByTagName('input');
		}
		if(checkBoxList.length > 0){
			for(i=0; i<checkBoxList.length; i++){
				if(checkBoxList[i].id != except){
					checkBoxList[i].checked = false;
				}
			}
		}
	},
	/** blendet Element 1 ein und Element 2 aus, Parameter inline ist optional default ist "block" **/
	showAndHideById: function(elemId1, elemId2, inline){
		mode = "block";
		if(inline == true){
			mode = "inline";
		}
		
		document.getElementById(elemId1).style.display = mode;
		document.getElementById(elemId2).style.display = "none";
	},
	/************* erstellt einen Slider mit 2 Reglern um z.b. einen Preisbereich zu waehlen **********/
	/**
	 * Der Slider muss aus 3 divs bestehen - einem Track und 2 Reglern. Der Track beeinhaltet die Regler.
	 * Weiterhin braucht es 2 Inputs fuer die gewaehlten Werte
	 * Parameter: 
	 * firstHandleId: Regler 1 (string), secondHandleId: Regler 2(string), trackId: Container Div(string), actualValueFrom: beim Start voreingesteller Startwert (int),
	 * actualValueTo: beim Start voreingestellter Endwert (int), rangeFrom: der Anfang des abzubildenden Wertbereiches (int),
	 * rangeTo: das Ende des abzubildenden Wertbereiches (int), stepFactor: aus dem Schrittfaktor und dem Maximalwert berechnen sich die Schrittgrößen (z.b. 1000000 max / faktor 20 = 50000er schritte) (int),
	 * isRestricted: gibt an, ob sich die Regler "ueberholen" duerfen (bool), 
	 * outputElemFromId: Id des Input-Elements, in dem der aktuelle Stand "von" ausgegeben wird (string),
	 * outputElemToId: Id des Input-Elements, in dem der aktuelle Stand "bis" ausgegeben wird (string)
	 * 
	 * Der Slider benoetigt prototype und scriptaculous
	 * **/
	createSlider: function(firstHandleId, secondHandleId, trackId, actualValueFrom, actualValueTo, rangeFrom, rangeTo, stepFactor, isRestricted, outputElemFromId, outputElemToId){
		vals = new Array();
		if(!isNaN(rangeFrom) && !isNaN(rangeTo) && !isNaN(stepFactor) && !isNaN(actualValueFrom) && !isNaN(actualValueTo)){
			maxVal = rangeTo;
			minVal = rangeFrom;
			fac = stepFactor;
			addVal = maxVal/fac;
			for(i=minVal;i<=maxVal; i = i + addVal ){
				vals.push(i);
			}
		}
		else {
			//alert("fehler");
			return false;
		}
		new Control.Slider(
		[firstHandleId, secondHandleId],trackId,{
			sliderValue:[actualValueFrom,actualValueTo], 
			range:$R(rangeFrom,rangeTo),
			values:vals,
			restricted:isRestricted,
			//spans:['slideTrackSelected'],
			//update des Slidervalues beim ziehen
			onSlide: function(v){
				spanData = v.toString().split(",");
				from = spanData[0];
				to = spanData[1];
				if(document.getElementById(outputElemFromId)){
					if(document.getElementById(outputElemFromId).type == "text"){
						document.getElementById(outputElemFromId).value = from;
					}
					else {
						document.getElementById(outputElemFromId).innerHTML = from;
					}
					
				}
				if(document.getElementById(outputElemToId)){
					if(document.getElementById(outputElemToId).type == "text"){
						document.getElementById(outputElemToId).value = to;
					}
					else {
						document.getElementById(outputElemToId).innerHTML = to;
					}
				}
			},
			//update des Slidervalues beim Klick auf den TRack
			onChange: function(v){
				spanData = v.toString().split(",");
				from = spanData[0];
				to = spanData[1];
				if(document.getElementById(outputElemFromId)){
					if(document.getElementById(outputElemFromId).type == "text"){
						document.getElementById(outputElemFromId).value = from;
					}
					else {
						document.getElementById(outputElemFromId).innerHTML = from;
					}
					
				}
				if(document.getElementById(outputElemToId)){
					if(document.getElementById(outputElemToId).type == "text"){
						document.getElementById(outputElemToId).value = to;
					}
					else {
						document.getElementById(outputElemToId).innerHTML = to;
					}
				}
			}
		
		});
	},
	
	/** OF: Element highlighting ****************************************/
	
	/** Variables for element highlighting */
	HIGHLIGHTELEMENTS: new Array(),
	HIGHLIGHTINTERVAL: new Array(),
	HIGHLIGHTCOLORS: new Array(),
	COLORCOUNTER: new Array(),
	
	/**
	 * @Description
	 * Function initialize class vars for highlighting and starts highlighting for element/s.
	 * 
	 * To use this function, you have to define the lists:
	 * 	 - immo.HIGHLIGHTELEMENTS (elements, which shall highlight)
	 * 	 - immo.HIGHLIGHTCOLORS (color(s) for highlighting)
	 * before you call this function. You will find an example in /frontend/webapp/content/fipa/fipaRate.js.
	 * If this function will find no defined elements, then returns without actions.
	 * If this function will find no defined colors, then default coloration (blue => transarent) will used.
	*/
	highlightElements: function(){
		// if there are no elements defined, then do nothing
		if(immo.HIGHLIGHTELEMENTS.length == 0) return;
		
		// if there are no colors defined, then set default color
		if(immo.HIGHLIGHTCOLORS.length == 0) immo.HIGHLIGHTCOLORS.push("#D2E3F3","#E7F0F7","#EAF1F7","#F0F5FB","#F4F7FC","transparent");
		
		// start highlighting for elements
		for (var i = 0; i < immo.HIGHLIGHTELEMENTS.length; i++){
			immo.COLORCOUNTER[immo.HIGHLIGHTELEMENTS[i]] = 0;
			immo.HIGHLIGHTINTERVAL[immo.HIGHLIGHTELEMENTS[i]] = window.setInterval("immo.highlightElement('"+immo.HIGHLIGHTELEMENTS[i]+"',"+i+")", 250);
		}
	},

	/**
	 * @Description Function will call throught window.setIntervall and hightlight all defined elements with defined colorlist. 
	 */
	highlightElement: function (elementid, i){
		var element = document.getElementById(elementid);
		element.style.backgroundColor = immo.HIGHLIGHTCOLORS[immo.COLORCOUNTER[elementid]];
		immo.COLORCOUNTER[elementid]++;
		
		if(immo.COLORCOUNTER[elementid] > immo.HIGHLIGHTCOLORS.length){
			window.clearInterval(immo.HIGHLIGHTINTERVAL[elementid]);
			immo.COLORCOUNTER[elementid] = 0;
		}
	}
	/** EOF: Element highlighting ****************************************/
}


/**
 * Objekte in den Merkzettel speichern.
 * Dies soll überall auf der Webseite verfügbar sein, von daher hier eingebunden
 */
var memoRemote = {

	/** Pfad zur Merkzettel Action */
	action: "/merkzettel.do",


	addObjectRemote: function(objectId, source, mandant) {
		if (immo.isCookieSupportEnabled()) {
			document.getElementById("memoAddLink" + objectId).style.display = "none";
			document.getElementById("memoLoader" + objectId).style.display = "inline";
			function onAddRemoteSuccess(response) {
				var result = eval("(" + response + ")");
				if (result.status == "ok") {
					document.getElementById("memoLoader" + objectId).style.display = "none";
					document.getElementById("memoRemoveLink" + objectId).style.display = "inline";
					var prominentObjectElement = document.getElementById("prominentObjects");
					if(!immo.isEmpty(prominentObjectElement)) {
						immo.updateXmlHttpRequest("/prominentObjects.do?" + immo.generateRandomParameter(), "prominentObjects");
					}
					memoRemote.incrementEtracker("merken/" + source, mandant);
				}
				else {
					document.getElementById("memoLoader" + objectId).style.display = "none";
					document.getElementById("memoAddLink" + objectId).style.display = "inline";
				}
			}
			var url = memoRemote.action + "?action=addObjectRemote&objectId=" + objectId + "&" + immo.generateRandomParameter();
			immo.sendXmlHttpRequest(url, onAddRemoteSuccess);
		}
	},


	removeObjectRemote: function(objectId, source, mandant) {
		document.getElementById("memoRemoveLink" + objectId).style.display = "none";
		document.getElementById("memoLoader" + objectId).style.display = "inline";
		function onRemoveRemoteSuccess(response) {
			document.getElementById("memoLoader" + objectId).style.display = "none";
			document.getElementById("memoAddLink" + objectId).style.display = "inline";
			var prominentObjectElement = document.getElementById("prominentObjects");
			if(!immo.isEmpty(prominentObjectElement)) {
				immo.updateXmlHttpRequest("/prominentObjects.do?" + immo.generateRandomParameter(), "prominentObjects");
			}
			memoRemote.incrementEtracker("merken/" + source, mandant);
		}
		var url = memoRemote.action + "?action=removeObjectRemote&objectId=" + objectId + "&" + immo.generateRandomParameter();
		immo.sendXmlHttpRequest(url, onRemoveRemoteSuccess);
	},


	incrementEtracker: function(subsystem, mandant) {
		var path = "/mein_immonet/merkzettel";
		var mandantIntern = mandant;
		if (!immo.isStringEmpty(subsystem)) {
			path += "/" + subsystem;
		}
		if (immo.isStringEmpty(mandantIntern)) {
			mandantIntern = "immonet";
		}
		etracker.incrementEtrackerSimple(mandantIntern, path);
	}

}

/**
 * Workoaround für alte Seiten
 * 
 */

var immonet = {
		
	/**
	 * Clears input field by click into field
	 * @param e - element (this); v - string (default value)
	 */ 
	clearField: function(e,v) {
		var value = e.value;
		if(typeof (value)== 'string' && value.length>0 && value == v) {
			e.value = '';
			e.style.color = this.colorClearInput;
		}
	},

	/**
	 * Set default value, if element value is empty
	 * @param e - element (this); v - string (default value)
	 */ 
	setField: function(e,v) {
		var value = e.value;
		if(value.length <= 0) {
			e.value = v;
			e.style.color = this.colorSetInput;
		}
	},
	
	/**
	 * Toggles layer and elements like arrow etc.
	 * @param	id - container element to toggle, idOn - arrow element to toggle, idOff - arrow element to toggle
	 */
	toggle: function(id) {
		if(typeof($j) == "undefined") {
		var e = document.getElementById(id);
		e.style.display = (e.style.display == 'none') ? 'block' :'none'; 
		}		
	},
	
	reloadJavascript: function(src){
		return immo.reloadJavascript(src);
	},
	
	isEmpty: function(value) {
		return immo.isEmpty(value);
	}, 
	
	
	/**
	 * Setzt entsprechenden Tarif auf der Vertragsübersicht auf Aktiv
	 */
	fairplusToggleActive: function(row) {
		var e = $j(".inactive");
		for(var i = 0; i < e.length; i++) {
			e[i].style.backgroundColor='#f7f7f7';
			e[i].style.fontWeight='normal';
		}
			
		var e = $j(".inactiveContract");
		for(var i = 0; i < e.length; i++) {
			e[i].style.backgroundColor='#fff';
			e[i].style.fontWeight='normal';
		}
		document.getElementById('row'+row).style.backgroundColor='#E2EEF3';
		document.getElementById('row'+row).style.fontWeight='bold';
		document.getElementById('ID'+row).checked='true';
		
		if(document.getElementById('downgrade_info')!=null){
			document.getElementById('downgrade_info').style.display = 'none';
		}
	},
	
	
	/**
	 * Cache checked Radiobutton from Fairplus
	 */
	fairplusToggleSubmit: function() {
		var radiobuttonArray = document.getElementsByName('selectedFairplusTariffId');
		if (radiobuttonArray[0]) {
			for (var i=0; i < radiobuttonArray.length; i++) {
				if (radiobuttonArray[i].checked) {
					immonet.fairplusSelectedRadiobutton = radiobuttonArray[i].value;
					window.setTimeout('immonet.fairplusToggleActive(immonet.fairplusSelectedRadiobutton)',300);
					return i;
				}
			}
		} else {
			if (radiobuttonArray.checked) {
				return 0;
			}
		}
	},
	
	
	/**
	 * Überprüft AGB und übermittelt Werte per Form Submit Oder Ajax Request
	 */
	fairplusFormSubmit: function(sourceLayer) {
		if(sourceLayer) {
			immoAjax.submitFormAndUpdateContent('contractForm', 'tinycontent', '/user/contract.do','save', false, '' , '' ,true,function(){});
		} else {
			if($j("input:radio[@name=selectedFairplusTariffId]").filter(':checked').val()==immonet.fairplusDowngradeId && $j('#ppo').attr('checked')) {
				// Hinweis wenn ein Vertragsdowngrade vorliegt und Zustimmung PPO
				if(document.getElementById('downgrade_info').style.display=='block') {
					// Hinweis wird schon angezeigt also absenden
					document.getElementById('contractForm').submit();
				} else {
					document.getElementById('downgrade_info').style.display = 'block';
				}
			} else {
				document.getElementById('contractForm').submit();
			}
		}
	},
	
	
	/**
	 * Setzt eine neue Funktion zur Berechnung der Tiny-Box Top
	 */
	initTinyBoxTop: function() {
		TINY.box.pos = function(){
			p = document.getElementById('tinybox'); 
			var t =(TINY.page.height()/2)-250; 
			t=t<10?10:t;
			p.style.top=(t+TINY.page.top())+'px';
			p.style.left=(TINY.page.width()/2)-(p.offsetWidth/2)+'px';
			
		};
	},
	
	/**
	 * Überprüft beim Aktivieren eines Objekts ob Vertragsbedingungen nach Aktivierung noch erfüllt wären 
	 */
	checkFairplusContract: function(objectId,activationType){
		if(immonet.isAllowedToChangeObjectRights(activationType)) {
			document.insertionForm.submit();
		} else {
			new Ajax.Request('/user/contract.do', {
				method: "GET",
				parameters: "action=ajax&activationType="+activationType+"&object_id="+objectId,
				onSuccess: function(data){
					var result = data.responseText.evalJSON();
					
					if(result.status=='ok') {
						// Objekt aktivieren
						if(activationType=='InactiveToActive') {
							document.location.href = '/objectinactive.do?action=inactiveToactive&object_id=' + objectId;
						}
						if(activationType=='ArchiveToActive') {	
							document.location.href = '/objectarchive.do?action=archiveToactive&object_id=' + objectId;
						}
						if(activationType=='AllInactiveToActive') {
							document.location.href = '/broker/brokerObjects.do?action=deactiveToActive&status=inactive';
						}
						if(activationType=='AllArchiveToActive') {
							document.location.href = '/broker/brokerObjects.do?action=archiveToActive&amp;status=archive';
						}
						if(activationType=='DuplicateActiveObject') {
							document.location.href = '/management.do?action=objectcopy&object_id=' + objectId;
						}
						if((activationType=='NewToActive') || (activationType=='ObjectRightChange')) {
							document.insertionForm.submit();
						}
					} else if (result.status=='error'){
						document.location.href = '/immonet/site/content/error/400/index.jsp';
					} else {
						if (result.status=='H' || result.status=='K') {
							document.location.href = '/broker/myObjects.do?status=inactive&listsize=10&action=activateNotAllowed';
						} else {
							immonet.initTinyBoxTop();
							TINY.box.show('/user/contract.do?object_id='+objectId+'&activationType='+activationType,1,455,0,0,null,20,1,null,1);
						}
					}
				}
			});
		}
	},
	
	/**
	 * Überprüft ob das Recht "Immonet" aktiviert wurde
	 */
	isAllowedToChangeObjectRights: function(activationType) {
		var res = true;
		if(activationType=='ObjectRightChange') { 
			if(!immonet.objectRightImmonet) {
				// Recht war beim Laden nicht vorhanden
				if($j('#immonetDe').is(":checked")) {
					// ist jetzt gesetzt
					res = false;
				}
			}
		} else {
			// kein ObjectRightChange wird überprüft
			res = false;
		}
		return res;
	},
	
	
	/**
	 * ID des Radiobutton, welcher ein Downgrade des Vertrags darstellt.
	 */
	fairplusDowngradeId: '',
	
	fairplusShowAGB: false,
	
	/**
	 * wird beim Laden zur Änderung der Objektrechte gesetzt (Hintergrund: wenn das Recht Immonet gesetzt wird, muss eine Aktivierungsprüfung durchgeführt werden)
	 */
	objectRightImmonet: false,
	
	/**
	 * Cache checked Radiobutton from Fairplus
	 */
	fairplusSelectedRadiobutton: '',
	
	/**
	 * Verändert die Größe der Tinybox, welche von Fairplus Layern verwendert wird
	 */
	fairplusTinyBoxResize: function() {
		var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
		$j("#tinybox").height(tHeight);
	},
	
	/**
	 * Checkbox error border style.
	 * Implement this method in 'Checkbox should be checked'-error messages. 
	 */
	addCheckboxErrorStyle: function(e){
		$j(e).css({margin:"0"}).wrap('<span></span>').parent().addClass('checkboxError');
	},
	
	/**
	 * Remove Checkbox error border style.
	 * Implement this method in 'Checkbox should be checked'-error messages. 
	 */
	removeCheckboxErrorStyle: function(){
		$j('.checkboxError').removeClass('checkboxError');
	},
	
	
	/**
	 * entfernt Hinweis, dass AGBs akzeptiert werden müssen
	 */
	hideAGBErrorNote: function() {
		$j('#agbErrorNote').hide();
		immonet.removeCheckboxErrorStyle();		
	}
}
