/**
 * Copyright (c) 2000-2004 Liferay, LLC. All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

var submitFormCount = 0;

function updateUsername() 
{
	var input = document.forms[0].name.value;
	if (input != "") 
	{
		var noUml = input.toLowerCase();
		noUml = noUml.replace(new RegExp(unescape("%F6"),"g"),'oe');
		noUml = noUml.replace(new RegExp(unescape("%E4"),"g"),'ae');
		noUml = noUml.replace(new RegExp(unescape("%FC"),"g"),'ue');				
		noUml = noUml.replace(new RegExp(unescape("%DF"),"g"),'ss');			
		document.forms[0].login.value = noUml;

	} 
	else 
	{
		document.forms[0].login.value="";
	}
	input = document.forms[0].firstName.value;
	if (input != "") 
	{
		document.forms[0].login.value = document.forms[0].login.value + input.substring(0,1).toUpperCase();
	}
}

function updateDomains() {
	var tcsuffix = "-training.academymaker.de";
	var amsuffix = ".academymaker.de";
	var input = document.forms[0].kundennummer.value;
	if (input != "") {
		document.forms[0].AMDomain.value=input+amsuffix;
		document.forms[0].TCDomain.value=input+tcsuffix;
	} else {
		document.forms[0].AMDomain.value="";
		document.forms[0].TCDomain.value="";
	}
}

function openMediaCenter() {
	MC=window.open("/academymaker/viewMedia.do" +  uuid + "&fromMenu=1", "_blank", "width=817, height=600, scrollbars=yes, resizable=no, toolbar=no");
	MC.focus();
}

function openHelp(link) {
	
	//alert("/academymaker/"+link);
	
	MC=window.open("/academymaker/"+link, "_blank", "width=1000, height=600, scrollbars=yes, resizable=yes, toolbar=no");
	MC.focus();
	
}

function openHelpChapter(link) {

	//alert("/academymaker/"+link);
	
	MC=window.open("/academymaker/"+link, "_blank", "width=1000, height=600, scrollbars=yes, resizable=yes, toolbar=no");
	MC.focus();
	
}

function openSystemInfo() {
	MC=window.open("/academymaker/viewSystemInfo.do" + uuid, "_blank", "width=1024, height=600, scrollbars=yes, resizable=no, toolbar=no");
	MC.focus();
}

function openEmailDialog() {
	var link = "/academymaker/writeMail.do" + uuid;
	MC=window.open(link, "_blank", "width=1000,height=800,left=0, top=0, scrollbars=yes");
	MC.focus();
}

function openMailObserver() {
	MC=window.open("/academymaker/mailObserver.do" + uuid, "_blank", "width=800,height=600,left=0, top=0, scrollbars=yes");
	MC.focus();
}

function openPrintPopup(whichPage) {
	var page = '/academymaker/'+whichPage;
	MC=window.open(page, "_blank", "width=1024,height=800,left=0, top=0, scrollbars=yes, menubar=yes, toolbar=yes, resizable=no");
	MC.focus();
}

function openExcelPopup(whichPage) {
	var page = '/academymaker/'+whichPage;
	MC=window.open(page, "_blank", "width=900,height=800,left=0, top=0, scrollbars=yes, menubar=yes, toolbar=yes, resizable=yes");
	MC.focus();
}

//function openAssignUsersDialog() {
//	MC=window.open("/academymaker/showAssignUsers.do" + (new com.xcell.util.XC_UUIDUtil()).getUUID(), "_blank", "width=650,height=750,left=0, top=0, scrollbars=yes");
// MC.focus();
// }


	
function addItem(box, text, value, sort) {
	box[box.length] = new Option(text, value);

	if (sort == true) {
		sortBox(box);
	}
}

function addItemCheck(feld) {
	addItem();
	return checkItemChars(feld);
}

/*
if (!Array.prototype.push) {
	function array_push() {
		for(var i = 0; i < arguments.length; i++) {
			this[this.length] = arguments[i];
		}

		return this.length;
	}

	Array.prototype.push = array_push;
}
*/

/*
 * if (!Array.prototype.pop) { function array_pop(){ lastElement =
 * this[this.length - 1]; this.length = Math.max(this.length - 1, 0);
 * 
 * return lastElement; }
 * 
 * Array.prototype.pop = array_pop; }
 */

function autoComplete(box, text) {
	var prevStartPos;
	var prevMidPos;
	var prevEndPos;

	if ((box.length > 0) && (text != "")) {

		// The character '*' is ordered differently between Java and JavaScript

		text = text.toLowerCase().replace(/\*/g, "");

		// Use binary search to find the first instance of the selection

		var startPos = 0;
		var midPos = Math.floor(box.length / 2);
		var endPos = box.length;

		for (;;) {
			var sText = trimString(box.options[midPos].text.toLowerCase().replace(/\*/g, ""));

			if (midPos > 0) {
				var prevSText = trimString(box.options[midPos - 1].text.toLowerCase().replace(/\*/g, ""));

				if ((sText.indexOf(text) == 0) &&
					(prevSText.indexOf(text) != 0)) {

					box.selectedIndex = midPos;

					break;
				}
			}
			else {
				if (sText.indexOf(text) == 0) {
					box.selectedIndex = midPos;

					break;
				}
			}

			box.selectedIndex = -1;

			if (text < sText) {
				endPos = midPos;
				midPos = (Math.floor((endPos - startPos) / 2)) + startPos;
			}
			else if (text > sText) {
				startPos = midPos;
				midPos = (Math.floor((endPos - midPos) / 2)) + midPos;
			}

			if ((prevStartPos != null) && (prevMidPos != null) && (prevEndPos != null)) {

				// Break out of the loop when all positions repeat

				if ((prevStartPos == startPos) && (prevMidPos == midPos) && (prevEndPos == endPos)) {
					break;
				}
			}

			prevStartPos = startPos;
			prevMidPos = midPos;
			prevEndPos = endPos;
		}
	}
	else {
		box.selectedIndex = -1;
	}
}

function autoFill(fromBox, toBox) {
	i = fromBox.selectedIndex;

	if (i != -1) {
		s = fromBox.options[i].value;

		if (s != "") {
			to = toBox.value;

			if (to == "") {
				toBox.value = s;
			}
			else {
				toBox.value = to + ", " + s;
			}
		}
	}
}

function blink() {
	if (document.all) {
		var blinkArray = document.all.tags("blink");

		for (var i = 0; i < blinkArray.length; i++) {
			blinkArray[i].style.visibility = blinkArray[i].style.visibility == "" ? "hidden" : "";
		}
	}
}
/*
if (document.all) {
	setInterval("blink()", 750);
}
*/

function check(form, name, checked) {
	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];

		if ((e.name == name) && (e.type == "checkbox")) {
			e.checked = checked;
		}
	}
}

function checkAll(form, name, allBox) {
	if (isArray(name)) {
		for (var i = 0; i < form.elements.length; i++) {
			var e = form.elements[i];

			if (e.type == "checkbox") {
				for (var j = 0; j < name.length; j++) {
					if (e.name == name[j]) {
						e.checked = allBox.checked;
					}
				}
			}
		}
	}
	else {
		for (var i = 0; i < form.elements.length; i++) {
			var e = form.elements[i];

			if ((e.name == name) && (e.type == "checkbox")) {
				e.checked = allBox.checked;
			}
		}
	}
}

function checkAllBox(form, name, allBox) {
	var totalBoxes = 0;
	var totalOn = 0;

	if (isArray(name)) {
		for (var i = 0; i < form.elements.length; i++) {
			var e = form.elements[i];

			if ((e.name != allBox.name) && (e.type == "checkbox")) {
				for (var j = 0; j < name.length; j++) {
					if (e.name == name[j]) {
						totalBoxes++;

						if (e.checked) {
							totalOn++;
						}
					}
				}
			}
		}
	}
	else {
		for (var i = 0; i < form.elements.length; i++) {
			var e = form.elements[i];

			if ((e.name != allBox.name) && (e.name == name) && (e.type == "checkbox")) {
				totalBoxes++;

				if (e.checked) {
					totalOn++;
				}
			}
		}
	}

	if (totalBoxes == totalOn) {
		allBox.checked = true;
	}
	else {
		allBox.checked = false;
	}
}

function checkTab(box) {
	if ((document.all) && (event.keyCode == 9)) {
		box.selection = document.selection.createRange();
		setTimeout("processTab(\"" + box.id + "\")", 0);
	}
}

function count(s, text) {
	if ((s == null) || (text == null)) {
		return 0;
	}

	var count = 0;

	var pos = s.indexOf(text);

	while (pos != -1) {
		pos = s.indexOf(text, pos + text.length);
		count++;
	}

	return count;
}

function disableEsc() {
	if ((document.all) && (event.keyCode == 27)) {
		event.returnValue = false;
	}
}

function disableFields(fields) {
	for (var i = 0; i < fields.length; i++) {
		fields[i].disabled = true;
	}
}

function enableFields(fields) {
	for (var i = 0; i < fields.length; i++) {
		fields[i].disabled = false;
	}
}

function getIndex(col, value) {
	for (var i = 0; i < col.length; i++) {
		if (col[i].value == value) {
			return i;
		}
	}

	return -1;
}

function getSelectedIndex(col) {
	for (var i = 0; i < col.length; i++) {
		if (col[i].checked == true) {
			return i;
		}
	}

	return -1;
}

function getSelectedRadioName(col) {
	var i = getSelectedIndex(col);

	if (i == -1) {
		var radioName = col.name;

		if (radioName == null) {
			radioName = "";
		}

		return radioName;
	}
	else {
		return col[i].name;
	}
}

function getSelectedRadioValue(col) {
	var i = getSelectedIndex(col);

	if (i == -1) {
		var radioValue = col.value;

		if (radioValue == null) {
			radioValue = "";
		}

		return radioValue;
	}
	else {
		return col[i].value;
	}
}

function hasItemWithText(box, text) {
	for (var i = 0; i < box.length; i ++) {
		if (box.options[i].text.toLowerCase() == text.toLowerCase()) {
			return true;
		}
	}

	return false;
}

function hasItemWithValue(box, value) {
	for (var i = 0; i < box.length; i ++) {
		if (box.options[i].value.toLowerCase() == value.toLowerCase()) {
			return true;
		}
	}

	return false;
}

function isArray(object) {
	if (!window.Array) {
		return false;
	}
	else {
		return object.constructor == window.Array;
	}
}

function isEven(x) {
	if ((x % 2) == 0) {
		return true;
	}

	return false;
}

function isOdd(x) {
	return !isEven(x);
}

function isRadioChecked(col) {
	var i = getSelectedIndex(col);

	return col[i].checked;
}

function isSelected(box) {
	if (box.selectedIndex >= 0) {
		return true;
	}
	else {
		return false;
	}
}

function listChecked(form) {
	var s = "";

	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];

		if ((e.type == "checkbox") && (e.checked == true) && (e.value > "")) {
			s += e.value + ",";
		}
	}

	return s;
}

function listCheckedExcept(form, except) {
	var s = "";

	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];

		if ((e.type == "checkbox") && (e.checked == true) && (e.value > "") && (e.name.indexOf(except) != 0)) {
			s += e.value + ",";
		}
	}

	return s;
}

function listSelect(box, delimeter) {
	var s = "";

	if (delimeter == null) {
		delimeter = ",";
	}

	if (box == null) {
		return "";
	}
	
	for (var i = 0; i < box.length; i++) {
    	if (box.options[i].value > "") {
			s += box.options[i].value + delimeter;
		}
	}

	if (s == ".none,") {
		return "";
	}
	else {
		return s;
	}
}

function listSelected(box, delimeter) {
	var s = "";

	if (delimeter == null) {
		delimeter = ",";
	}

	if (box == null) {
		return "";
	}

	for (var i = 0; i < box.length; i++) {
    	if ((box.options[i].value > "") && (box.options[i].selected)) {
			s += box.options[i].value + delimeter;
		}
	}

	if (s == ".none,") {
		return "";
	}
	else {
		return s;
	}
}

function loadPage(page) {
	if (page.indexOf("?") == -1) {
		page += "?";
	}

	page += "&r=" + random();

	// parent.hidden_iframe.document.location = page;
}

function mathRound(n, places) {
	return (Math.round(n * Math.pow(10, places))) / Math.pow(10, places);
}

function moveItem(fromBox, toBox, sort) {
	var newText = null;
	var newValue = null;
	var newOption = null;
	
	/*
	 * DJ - 3.11.2006 Hier werden die Indexe hereingeschrieben, die aus der
	 * fromBox geloescht werden muessen
	 */
	var indexArray = new Array(0);
	

	if (fromBox.selectedIndex >= 0) {
		for (var i = 0; i < fromBox.length; i++) {
			if (fromBox.options[i].selected) {
				newText = fromBox.options[i].text;
				newValue = fromBox.options[i].value;

				newOption = new Option(newText, newValue);

				toBox[toBox.length] = newOption;
				indexArray[indexArray.length] = i;
			}
		}
	
		/* Hier werden die Auswaehlten Daten aus der fromBox geloescht.  */
		for (var i = 0; i < indexArray.length; i++) {
			fromBox[indexArray[i] - i] = null;
		}
		
		/* Herausgenommen, da sehr langsam bei langen Listen n2 */
		/*
		 * for (var i = 0; i < toBox.length; i++) { for (var j = 0; j <
		 * fromBox.length; j++) { if (fromBox[j].value == toBox[i].value) {
		 * fromBox[j] = null;
		 * 
		 * break; } } }
		 */
	}
	

	if (newText != null) {
		if (sort == true) {
			sortBox(toBox);
		}
	}
}

function printCheck() {
	if (window.print) {
		return 1;
	}

	return 0;
}

function printWindow() {
	if (window.print) {
		window.print();
	}
}

function processTab(id) {
	document.all[id].selection.text = String.fromCharCode(9);
	document.all[id].focus();
}

function random() {
	return randomMinMax(0, 4294967296);
}

function randomMinMax(min, max) {
	return (Math.round(Math.random() * (max - min))) + min;
}

function redirect(form) {
	var url = form.options[form.options.selectedIndex].value;

	if (url != "null") {
		self.location = url;
	}
}

function removeItem(box, value) {
	if (value == null) {
		for (var i = box.length - 1; i >= 0; i--) {
			if (box.options[i].selected) {
				box[i] = null;
			}
		}
	}
	else {
		for (var i = box.length - 1; i >= 0; i--) {
			if (box.options[i].value == value) {
				box[i] = null;
			}
		}
	}
}

function reorder(box, down) {
	var si = box.selectedIndex;

	if (si == -1) {
		box.selectedIndex = 0;
	}
	else {
		sText = box.options[si].text;
		sValue = box.options[si].value;

		if ((box.options[si].value > "") && (si > 0) && (down == 0)) {
			box.options[si].text = box.options[si - 1].text;
			box.options[si].value = box.options[si - 1].value;
			box.options[si - 1].text = sText;
			box.options[si - 1].value = sValue;
			box.selectedIndex--;
		}
		else if ((si < box.length - 1) && (box.options[si + 1].value > "") && (down == 1)) {
			box.options[si].text = box.options[si + 1].text;
			box.options[si].value = box.options[si + 1].value;
			box.options[si + 1].text = sText;
			box.options[si + 1].value = sValue;
			box.selectedIndex++;
		}
		else if (si == 0) {
			for (var i = 0; i < (box.length - 1); i++) {
				box.options[i].text = box.options[i + 1].text;
				box.options[i].value = box.options[i + 1].value;
			}

			box.options[box.length - 1].text = sText;
			box.options[box.length - 1].value = sValue;

			box.selectedIndex = box.length - 1;
		}
		else if (si == (box.length - 1)) {
			for (var j = (box.length - 1); j > 0; j--) {
				box.options[j].text = box.options[j - 1].text;
				box.options[j].value = box.options[j - 1].value;
			}

			box.options[0].text = sText;
			box.options[0].value = sValue;

			box.selectedIndex = 0;
		}
	}
}

function setBox(oldBox, newBox) {
	for (var i = oldBox.length - 1; i > -1; i--) {
		oldBox.options[i] = null;
	}

	for (var i = 0; i < newBox.length; i++) {
		oldBox.options[i] = new Option(newBox[i].value, i);
	}

	oldBox.options[0].selected = true;
}

function setSelectedValue(col, value) {
	for (var i = 0; i < col.length; i++) {
		if (col[i].value == value) {
			col.selectedIndex = i;

			break;
		}
	}
}

function sortBox(box) {
	var newBox = new Array();

	for (var i = 0; i < box.length; i++) {
		newBox[i] = new Array(box[i].value, box[i].text);
	}

	newBox.sort(sortByAscending);

	for (var i = box.length - 1; i > -1; i--) {
		box.options[i] = null;
	}

	for (var i = 0; i < newBox.length; i++) {
		box.options[box.length] = new Option(newBox[i][1], newBox[i][0]);
	}
}

function sortByAscending(a, b) {
	if (a[1].toLowerCase() > b[1].toLowerCase()) {
		return 1;
	}
	else if(a[1].toLowerCase() < b[1].toLowerCase()) {
		return -1;
	}
	else {
		return 0;
	}
}

function sortByDescending(a, b) {
	if (a[1].toLowerCase() > b[1].toLowerCase()) {
		return -1;
	}
	else if(a[1].toLowerCase() < b[1].toLowerCase()) {
		return 1;
	}
	else {
		return 0;
	}
}

function stripCarriageReturn(s) {
	return s.replace(/\r|\n|\r\n/g, "");
}

function submitForm(form, action, singleSubmit) {
	if (submitFormCount == 0) {
		if (singleSubmit == null || singleSubmit) {
			submitFormCount++;

			for (var i = 0; i < form.length; i++){
				var e = form.elements[i];

				if (e.type.toLowerCase() == "button" || e.type.toLowerCase() == "reset" || e.type.toLowerCase() == "submit") {
					e.disabled=true;
				}
			}
		}

		if (action != null) {
			form.action = action;
		}

		form.submit();
	}
	else {
		if (this.submitFormAlert != null) {
  			submitFormAlert();
		}
	}
}

// String functions

function startsWith(str, x) {
	if (str.indexOf(x) == 0) {
		return true;
	}
	else {
		return false;
	}
}

function endsWith(str, x) {
	if (str.lastIndexOf(x) == str.length - x.length) {
		return true;
	}
	else {
		return false;
	}
}

function trimString(str) {
	str = str.replace(/^\s+/g, "").replace(/\s+$/g, "");

	var charCode = str.charCodeAt(0);

	while (charCode == 160) {
		str = str.substring(1, str.length);
		charCode = str.charCodeAt(0);
	}

	charCode = str.charCodeAt(str.length - 1);

	while (charCode == 160) {
		str = str.substring(0, str.length - 1);
		charCode = str.charCodeAt(str.length - 1);
	}

	return str;
}

//String.prototype.trim = trimString;

// --------------------------------------------------------------------
// H I D E / U N H I D E E L E M E N T
// -----------------------------------------------------------------------------
// KS: Null Ueberbpruefung hinzugefuegt
function setElementHidden(what) {
	if (document.getElementById(what)) {
		document.getElementById(what).style.display="none";
	}
}

// KS: Null Ueberpruefung hinzugefuegt
function setElementVisible(what) {
	if (document.getElementById(what)) {
		if (is_ie) {
			document.getElementById(what).style.display = "inline";
		} else {
			document.getElementById(what).style.display = 'table-row';
		}
	}
}

//-------------------------------------------------
// Zeige/Verstecke DIV zum vergroesserten Image
// ------------------------------------------------------
function showBigImage (what) {
	document.getElementById(what).style.visibility = 'visible';
}

function hideBigImage (what) {
	document.getElementById(what).style.visibility = 'hidden';
}
	
//-------------------------------------------------
// I N S E R T A T C U R S O R P O S I T I O N
// ------------------------------------------------------
function insertAtCursor(myField, myValue) 
{
	startTag = ' ';
	endTag = ' ';
	myValue = startTag + myValue + endTag;
	
	// IE support
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA-NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
			+ myValue
			+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
}

//--------------------------------------------------------------------
// B R O W S E R C H E C K
// -----------------------------------------------------------------------------
// function browserCheck() {
    // Konvertierung aller Buchstaben zu Kleinbuchstaben und den Test zu
	// vereinfachen
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Hinweis: IE5 meldet immer Version 4, deswegen is.ie5up benutzen um IE5 zu
	// erkennen.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);

    var is_ie   = ((agt.indexOf("msie") != -1) && (agt.indexOf('opera')==-1));
    var is_ie3  = (is_ie && (is_major < 4));
    var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) );
    var is_ie4up  = (is_ie  && (is_major >= 4));
    var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")!=-1) );
		var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_operaun = ((agt.indexOf("opera") != -1) && (agt.indexOf("5") == -1));
    var is_opera5 = ((agt.indexOf("opera") != -1) && (agt.indexOf("5") != -1));
    var is_operahide = ((agt.indexOf("opera") != -1) && ((agt.indexOf("msie") != -1) || (agt.indexOf('mozilla')!=-1)));

    var is_webtv = (agt.indexOf("webtv") != -1);

    // *** TEST DER JAVASCRIPT VERSION ***
    // N?tzlich um den Bug in nav3 zu umgehen, der trotz mangelnder F?higkeiten
    // versucht, <SCRIPT LANGUAGE="JavaScript1.2"> Seiten anzuzeigen.

    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0
    else if (is_nav3 || is_operaun) is_js = 1.1
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3
    else if (is_opera5) is_js = 1.3
    else if (is_nav6 || is_gecko) is_js = 1.5

    // HINWEIS: Machen sie ein Update wenn in der Zukunft neuere Versionen von
    // Javascript herausgegeben werden. Derzeit versuche ich nur einige
    // Aufw?rtskompatibilit?t zu erreichen, jedoch wird es sich erst in der
    // Zukunft herausstellen, ob weitere Versionen des NC uder IE
    // zumindestens JS 1.x kompatibel bleiben.
    // JS Versionen immer mit > oder >= testen

    else if (is_nav && (is_major > 5)) is_js = 1.4
    else if (is_ie && (is_major > 5)) is_js = 1.3

    // HINWEIS: Keine Ahnung, wie es bei anderen Browsern aussieht;
    // Deswegen nicht vergessen: JS Versionen immer mit > oder >= testen

    else is_js = 0.0;

    // *** BETRIEBSSYSTEM ***

    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );

    // HINWEIS: Bei Opera 3.0 wird im userAgent string leider "Windows 95/NT4"
	// auf
    // allen Win32 Systemen ausgegeben, so dass man leider nicht zwischen Win98
	// und NT
    // unterscheiden kann. :-( [Hat irgendjemand eine Idee?]

    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // Ist es eine mit 16 Bit compilierte Version?

    var is_win16 = ((agt.indexOf("win16")!=-1) ||
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
               (agt.indexOf("windows 16-bit")!=-1) );

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    // HINWEIS: Es kann passieren, dass Win98 nicht zuverl?ssig erkannt wird.
	// Dies kann
    // an folgenden Umst?nden liegen:
    // - Fr?he Versionen von Nav 4.x zeigen nur "Windows" im userAgent an.
    // - Der Mercury Client gibt in der 32 Bit Version "Win98" an, in der
    // 16 Bit Version allerings nur "Win95", selbst wenn er unter Win98 l?uft.
	// :-(

    var is_win2000 = ((agt.indexOf("winnt5")!=-1) || (agt.indexOf("windows nt 5")!=-1));
		var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || ((agt.indexOf("windows nt")!=-1) && (agt.indexOf("windows nt 5") ==-1)));
    var is_win32 = (is_win95 || is_winnt || is_win98 ||
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
    var is_os2   = ((agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);

		// der Mac ist unter IE5up mit JS weiter
    if (is_mac && is_ie5up) is_js = 1.4;

    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);
    var is_aix2  = (agt.indexOf("aix 2") !=-1);
    var is_aix3  = (agt.indexOf("aix 3") !=-1);
    var is_aix4  = (agt.indexOf("aix 4") !=-1);
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1);
    var is_mpras    = (agt.indexOf("ncr")!=-1);
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
                 is_sco ||is_unixware || is_mpras || is_reliant ||
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));

	// *** VERSCL?SSELUNG ***
	// Leider weiss ich noch nicht alle Codes aus den Strings um alle
	// Verschl?sselungen zu erkennen.
	
	if ((navigator.appVersion.indexOf("; U") > 0) || (navigator.appVersion.indexOf("; N") > 0)) {
	        encryption = "128-Bit";
	}
	else if (navigator.appVersion.indexOf("; I") > 0) {
	        encryption = "56-Bit";
	}
	else {
	        encryption = "unbekannt";
	}
//}
function checkTimefield(field)
{
		if ( document.getElementById(field+"Checkbox").checked  == true) {
			document.getElementsByName(field+"Day")[0].disabled=false;
			document.getElementsByName(field+"Month")[0].disabled=false;
			document.getElementsByName(field+"Year")[0].disabled=false;						
		} else {
			document.getElementsByName(field+"Day")[0].disabled=true;
			document.getElementsByName(field+"Month")[0].disabled=true;
			document.getElementsByName(field+"Year")[0].disabled=true;			
		}
}
function checkInvDate(field)
{
	if ( field == "month" ){
		document.forms[0].invitationMonth.value = document.forms[0].valid_from_month.value;
		}
	if ( field == "day" ){
		document.forms[0].invitationDay.value = document.forms[0].valid_from_day.value;
		}
	if ( field == "year" ){
		document.forms[0].invitationYear.value = document.forms[0].valid_from_year.value;
		}				
}

function unSelectAll(box) {
	if (box == null)
		return "";
	
	for (var i = 0; i < box.length; i++) {
    	if (box.options[i].selected) {
			box.options[i].selected = false;
		}
	}
}

/** Diese Funktion wird dazu genutzt den pinEditor vor dem Speichern in den
 * EDIT Mode zurückzusetzen, da dieser sonst, wenn er sich im Firefox im 
 * HTML Mode befindet, aus dem HTML Code neuen HTML Code erzeugt und dadurch
 * den Inhalt verändert. Sie MUSS beim onsubmit Eventhandler in der jeweiligen 
 * Form vor dem eigentlichen submit ausgeführt werden. 
 *
 * @author Daniel Olczyk 
 * @since 03.09.2008 - rev 1.4.2
 * @param peName ist der Präfix der ID, welche dem IFrame zugewiesen ist. In 
 * 		  den meisten Fällen ist das 'pinEditID'
 * @param counter ist die Anzahl der in dem Formular vorhandenen pinEdit Objekte.
 * 		  Wird der counter mit 0 angegeben, wird davon ausgegangen, dass der
 * 		  Präfix die ID des iFrames ist.
 *
 * @modified René Backes
 * @since 10.03.2009 - rev 1.4.3
 * @comment war zwar intern korrekt aber Anzeige nicht korrekt für den Enduser.
 */
function backToEditMode(peName, counter) {
	
	if (counter == '' || counter == 0) {
		var elmnt = document.getElementById(peName);
		var cntwnd = elmnt.contentWindow;
		cntwnd.editSetToolbarVisible('TOP', true);
		cntwnd.editSetMode('EDIT');
		cntwnd.editSetActiveMode('EDIT');
	} else {
		for(var i = 1; i <= counter; i++) {
			var elmnt = document.getElementById(peName + '' + i);								
			var cntwnd = elmnt.contentWindow;
			cntwnd.editSetToolbarVisible('TOP', true);
			cntwnd.editSetMode('EDIT');
			cntwnd.editSetActiveMode('EDIT');			
		}
	}
}



/**
 * Konvertiert text/html in text/plain
 *
 * @author René Backes
 * @since 10.03.2009
 * @param {String} text --- Der zu konvertierende String
 * @return {String} --- Der konvertierte String
 */
function convertText_HtmlToPlain(text)
{
	var temp = text;
	temp = temp.replace(/<br.*?>/gi, '\n');
	temp = temp.replace(/<.*?>/gi, ' ');
	temp = temp.replace(/  +/gi, ' ');
	
	temp = temp.replace(/&#x([0-9a-fA-F]+?);/g,
		function (match, submatch)
		{
			return String.fromCharCode(parseInt(submatch, 16));
		}
	);
	temp = temp.replace(/&#(\d+?);/g,
		function (match, submatch)
		{
			return String.fromCharCode(submatch);
		}
	);
	
	temp = temp.replace(/&nbsp;/gi, ' ');
	
	temp = temp.replace(/&quot;/g, '"');
	temp = temp.replace(/&amp;/g, '&');
	temp = temp.replace(/&lt;/g, '<');
	temp = temp.replace(/&gt;/g, '>');
	temp = temp.replace(/&iexcl;/g, '¡');
	temp = temp.replace(/&cent;/g, '¢');
	temp = temp.replace(/&pound;/g, '£');
	temp = temp.replace(/&curren;/g, '¤');
	temp = temp.replace(/&yen;/g, '¥');
	temp = temp.replace(/&brvbar;/g, '¦');
	temp = temp.replace(/&sect;/g, '§');
	temp = temp.replace(/&uml;/g, '¨');
	temp = temp.replace(/&copy;/g, '©');
	temp = temp.replace(/&ordf;/g, 'ª');
	temp = temp.replace(/&laquo;/g, '«');
	temp = temp.replace(/&not;/g, '¬');
	temp = temp.replace(/&shy;/g, '­');
	temp = temp.replace(/&reg;/g, '®');
	temp = temp.replace(/&macr;/g, '¯');
	temp = temp.replace(/&deg;/g, '°');
	temp = temp.replace(/&plusmn;/g, '±');
	temp = temp.replace(/&sup2;/g, '²');
	temp = temp.replace(/&sup3;/g, '³');
	temp = temp.replace(/&acute;/g, '´');
	temp = temp.replace(/&micro;/g, 'µ');
	temp = temp.replace(/&para;/g, '¶');
	temp = temp.replace(/&middot;/g, '·');
	temp = temp.replace(/&cedil;/g, '¸');
	temp = temp.replace(/&sup1;/g, '¹');
	temp = temp.replace(/&ordm;/g, 'º');
	temp = temp.replace(/&raquo;/g, '»');
	temp = temp.replace(/&frac14;/g, '¼');
	temp = temp.replace(/&frac12;/g, '½');
	temp = temp.replace(/&frac34;/g, '¾');
	temp = temp.replace(/&iquest;/g, '¿');
	temp = temp.replace(/&Agrave;/g, 'À');
	temp = temp.replace(/&Aacute;/g, 'Á');
	temp = temp.replace(/&Acirc;/g, 'Â');
	temp = temp.replace(/&Atilde;/g, 'Ã');
	temp = temp.replace(/&Auml;/g, 'Ä');
	temp = temp.replace(/&Aring;/g, 'Å');
	temp = temp.replace(/&AElig;/g, 'Æ');
	temp = temp.replace(/&Ccedil;/g, 'Ç');
	temp = temp.replace(/&Egrave;/g, 'È');
	temp = temp.replace(/&Eacute;/g, 'É');
	temp = temp.replace(/&Ecirc;/g, 'Ê');
	temp = temp.replace(/&Euml;/g, 'Ë');
	temp = temp.replace(/&Igrave;/g, 'Ì');
	temp = temp.replace(/&Iacute;/g, 'Í');
	temp = temp.replace(/&Icirc;/g, 'Î');
	temp = temp.replace(/&Iuml;/g, 'Ï');
	temp = temp.replace(/&ETH;/g, 'Ð');
	temp = temp.replace(/&Ntilde;/g, 'Ñ');
	temp = temp.replace(/&Ograve;/g, 'Ò');
	temp = temp.replace(/&Oacute;/g, 'Ó');
	temp = temp.replace(/&Ocirc;/g, 'Ô');
	temp = temp.replace(/&Otilde;/g, 'Õ');
	temp = temp.replace(/&Ouml;/g, 'Ö');
	temp = temp.replace(/&times;/g, '×');
	temp = temp.replace(/&Oslash;/g, 'Ø');
	temp = temp.replace(/&Ugrave;/g, 'Ù');
	temp = temp.replace(/&Uacute;/g, 'Ú');
	temp = temp.replace(/&Ucirc;/g, 'Û');
	temp = temp.replace(/&Uuml;/g, 'Ü');
	temp = temp.replace(/&Yacute;/g, 'Ý');
	temp = temp.replace(/&THORN;/g, 'Þ');
	temp = temp.replace(/&szlig;/g, 'ß');
	temp = temp.replace(/&agrave;/g, 'à');
	temp = temp.replace(/&aacute;/g, 'á');
	temp = temp.replace(/&acirc;/g, 'â');
	temp = temp.replace(/&atilde;/g, 'ã');
	temp = temp.replace(/&auml;/g, 'ä');
	temp = temp.replace(/&aring;/g, 'å');
	temp = temp.replace(/&aelig;/g, 'æ');
	temp = temp.replace(/&ccedil;/g, 'ç');
	temp = temp.replace(/&egrave;/g, 'è');
	temp = temp.replace(/&eacute;/g, 'é');
	temp = temp.replace(/&ecirc;/g, 'ê');
	temp = temp.replace(/&euml;/g, 'ë');
	temp = temp.replace(/&igrave;/g, 'ì');
	temp = temp.replace(/&iacute;/g, 'í');
	temp = temp.replace(/&icirc;/g, 'î');
	temp = temp.replace(/&iuml;/g, 'ï');
	temp = temp.replace(/&eth;/g, 'ð');
	temp = temp.replace(/&ntilde;/g, 'ñ');
	temp = temp.replace(/&ograve;/g, 'ò');
	temp = temp.replace(/&oacute;/g, 'ó');
	temp = temp.replace(/&ocirc;/g, 'ô');
	temp = temp.replace(/&otilde;/g, 'õ');
	temp = temp.replace(/&ouml;/g, 'ö');
	temp = temp.replace(/&divide;/g, '÷');
	temp = temp.replace(/&oslash;/g, 'ø');
	temp = temp.replace(/&ugrave;/g, 'ù');
	temp = temp.replace(/&uacute;/g, 'ú');
	temp = temp.replace(/&ucirc;/g, 'û');
	temp = temp.replace(/&uuml;/g, 'ü');
	temp = temp.replace(/&yacute;/g, 'ý');
	temp = temp.replace(/&thorn;/g, 'þ');
	temp = temp.replace(/&yuml;/g, 'ÿ');
	temp = temp.replace(/&Alpha;/g, String.fromCharCode(913));
	temp = temp.replace(/&alpha;/g, String.fromCharCode(945));
	temp = temp.replace(/&Beta;/g, String.fromCharCode(914));
	temp = temp.replace(/&beta;/g, String.fromCharCode(946));
	temp = temp.replace(/&Gamma;/g, String.fromCharCode(915));
	temp = temp.replace(/&gamma;/g, String.fromCharCode(947));
	temp = temp.replace(/&Delta;/g, String.fromCharCode(916));
	temp = temp.replace(/&delta;/g, String.fromCharCode(948));
	temp = temp.replace(/&Epsilon;/g, String.fromCharCode(917));
	temp = temp.replace(/&epsilon;/g, String.fromCharCode(949));
	temp = temp.replace(/&Zeta;/g, String.fromCharCode(918));
	temp = temp.replace(/&zeta;/g, String.fromCharCode(950));
	temp = temp.replace(/&Eta;/g, String.fromCharCode(919));
	temp = temp.replace(/&eta;/g, String.fromCharCode(951));
	temp = temp.replace(/&Theta;/g, String.fromCharCode(920));
	temp = temp.replace(/&theta;/g, String.fromCharCode(952));
	temp = temp.replace(/&Iota;/g, String.fromCharCode(921));
	temp = temp.replace(/&iota;/g, String.fromCharCode(953));
	temp = temp.replace(/&Kappa;/g, String.fromCharCode(922));
	temp = temp.replace(/&kappa;/g, String.fromCharCode(954));
	temp = temp.replace(/&Lambda;/g, String.fromCharCode(923));
	temp = temp.replace(/&lambda;/g, String.fromCharCode(955));
	temp = temp.replace(/&Mu;/g, String.fromCharCode(924));
	temp = temp.replace(/&mu;/g, String.fromCharCode(956));
	temp = temp.replace(/&Nu;/g, String.fromCharCode(925));
	temp = temp.replace(/&nu;/g, String.fromCharCode(957));
	temp = temp.replace(/&Xi;/g, String.fromCharCode(926));
	temp = temp.replace(/&xi;/g, String.fromCharCode(958));
	temp = temp.replace(/&Omicron;/g, String.fromCharCode(927));
	temp = temp.replace(/&omicron;/g, String.fromCharCode(959));
	temp = temp.replace(/&Pi;/g, String.fromCharCode(928));
	temp = temp.replace(/&pi;/g, String.fromCharCode(960));
	temp = temp.replace(/&Rho;/g, String.fromCharCode(929));
	temp = temp.replace(/&rho;/g, String.fromCharCode(961));
	temp = temp.replace(/&Sigma;/g, String.fromCharCode(931));
	temp = temp.replace(/&sigmaf;/g, String.fromCharCode(962));
	temp = temp.replace(/&sigma;/g, String.fromCharCode(963));
	temp = temp.replace(/&Tau;/g, String.fromCharCode(932));
	temp = temp.replace(/&tau;/g, String.fromCharCode(964));
	temp = temp.replace(/&Upsilon;/g, String.fromCharCode(933));
	temp = temp.replace(/&upsilon;/g, String.fromCharCode(965));
	temp = temp.replace(/&Phi;/g, String.fromCharCode(934));
	temp = temp.replace(/&phi;/g, String.fromCharCode(966));
	temp = temp.replace(/&Chi;/g, String.fromCharCode(935));
	temp = temp.replace(/&chi;/g, String.fromCharCode(967));
	temp = temp.replace(/&Psi;/g, String.fromCharCode(936));
	temp = temp.replace(/&psi;/g, String.fromCharCode(968));
	temp = temp.replace(/&Omega;/g, String.fromCharCode(937));
	temp = temp.replace(/&omega;/g, String.fromCharCode(969));
	temp = temp.replace(/&thetasym;/g, String.fromCharCode(977));
	temp = temp.replace(/&upsih;/g, String.fromCharCode(978));
	temp = temp.replace(/&piv;/g, String.fromCharCode(982));
	temp = temp.replace(/&forall;/g, String.fromCharCode(8704));
	temp = temp.replace(/&part;/g, String.fromCharCode(8706));
	temp = temp.replace(/&exist;/g, String.fromCharCode(8707));
	temp = temp.replace(/&empty;/g, String.fromCharCode(8709));
	temp = temp.replace(/&nabla;/g, String.fromCharCode(8711));
	temp = temp.replace(/&isin;/g, String.fromCharCode(8712));
	temp = temp.replace(/&notin;/g, String.fromCharCode(8713));
	temp = temp.replace(/&ni;/g, String.fromCharCode(8715));
	temp = temp.replace(/&prod;/g, String.fromCharCode(8719));
	temp = temp.replace(/&sum;/g, String.fromCharCode(8721));
	temp = temp.replace(/&minus;/g, String.fromCharCode(8722));
	temp = temp.replace(/&lowast;/g, String.fromCharCode(8727));
	temp = temp.replace(/&radic;/g, String.fromCharCode(8730));
	temp = temp.replace(/&prop;/g, String.fromCharCode(8733));
	temp = temp.replace(/&infin;/g, String.fromCharCode(8734));
	temp = temp.replace(/&ang;/g, String.fromCharCode(8736));
	temp = temp.replace(/&and;/g, String.fromCharCode(8743));
	temp = temp.replace(/&or;/g, String.fromCharCode(8744));
	temp = temp.replace(/&cap;/g, String.fromCharCode(8745));
	temp = temp.replace(/&cup;/g, String.fromCharCode(8746));
	temp = temp.replace(/&int;/g, String.fromCharCode(8747));
	temp = temp.replace(/&there4;/g, String.fromCharCode(8756));
	temp = temp.replace(/&sim;/g, String.fromCharCode(8764));
	temp = temp.replace(/&cong;/g, String.fromCharCode(8773));
	temp = temp.replace(/&asymp;/g, String.fromCharCode(8776));
	temp = temp.replace(/&ne;/g, String.fromCharCode(8800));
	temp = temp.replace(/&equiv;/g, String.fromCharCode(8801));
	temp = temp.replace(/&le;/g, String.fromCharCode(8804));
	temp = temp.replace(/&ge;/g, String.fromCharCode(8805));
	temp = temp.replace(/&sub;/g, String.fromCharCode(8834));
	temp = temp.replace(/&sup;/g, String.fromCharCode(8835));
	temp = temp.replace(/&nsub;/g, String.fromCharCode(8836));
	temp = temp.replace(/&sube;/g, String.fromCharCode(8838));
	temp = temp.replace(/&supe;/g, String.fromCharCode(8839));
	temp = temp.replace(/&oplus;/g, String.fromCharCode(8853));
	temp = temp.replace(/&otimes;/g, String.fromCharCode(8855));
	temp = temp.replace(/&perp;/g, String.fromCharCode(8869));
	temp = temp.replace(/&sdot;/g, String.fromCharCode(8901));
	temp = temp.replace(/&loz;/g, String.fromCharCode(9674));
	temp = temp.replace(/&lceil;/g, String.fromCharCode(8968));
	temp = temp.replace(/&rceil;/g, String.fromCharCode(8969));
	temp = temp.replace(/&lfloor;/g, String.fromCharCode(8970));
	temp = temp.replace(/&rfloor;/g, String.fromCharCode(8971));
	temp = temp.replace(/&lang;/g, String.fromCharCode(9001));
	temp = temp.replace(/&rang;/g, String.fromCharCode(9002));
	temp = temp.replace(/&larr;/g, String.fromCharCode(8592));
	temp = temp.replace(/&uarr;/g, String.fromCharCode(8593));
	temp = temp.replace(/&rarr;/g, String.fromCharCode(8594));
	temp = temp.replace(/&darr;/g, String.fromCharCode(8595));
	temp = temp.replace(/&harr;/g, String.fromCharCode(8596));
	temp = temp.replace(/&crarr;/g, String.fromCharCode(8629));
	temp = temp.replace(/&lArr;/g, String.fromCharCode(8656));
	temp = temp.replace(/&uArr;/g, String.fromCharCode(8657));
	temp = temp.replace(/&rArr;/g, String.fromCharCode(8658));
	temp = temp.replace(/&dArr;/g, String.fromCharCode(8659));
	temp = temp.replace(/&hArr;/g, String.fromCharCode(8660));
	temp = temp.replace(/&bull;/g, String.fromCharCode(8226));
	temp = temp.replace(/&prime;/g, String.fromCharCode(8242));
	temp = temp.replace(/&Prime;/g, String.fromCharCode(8243));
	temp = temp.replace(/&oline;/g, String.fromCharCode(8254));
	temp = temp.replace(/&frasl;/g, String.fromCharCode(8260));
	temp = temp.replace(/&weierp;/g, String.fromCharCode(8472));
	temp = temp.replace(/&image;/g, String.fromCharCode(8465));
	temp = temp.replace(/&real;/g, String.fromCharCode(8476));
	temp = temp.replace(/&trade;/g, String.fromCharCode(8482));
	temp = temp.replace(/&euro;/g, String.fromCharCode(8364));
	temp = temp.replace(/&alefsym;/g, String.fromCharCode(8501));
	temp = temp.replace(/&spades;/g, String.fromCharCode(9824));
	temp = temp.replace(/&clubs;/g, String.fromCharCode(9827));
	temp = temp.replace(/&hearts;/g, String.fromCharCode(9829));
	temp = temp.replace(/&diams;/g, String.fromCharCode(9830));
	temp = temp.replace(/&OElig;/g, String.fromCharCode(338));
	temp = temp.replace(/&oelig;/g, String.fromCharCode(339));
	temp = temp.replace(/&Scaron;/g, String.fromCharCode(352));
	temp = temp.replace(/&scaron;/g, String.fromCharCode(353));
	temp = temp.replace(/&Yuml;/g, String.fromCharCode(376));
	temp = temp.replace(/&fnof;/g, String.fromCharCode(402));
	temp = temp.replace(/&ensp;/g, String.fromCharCode(8194));
	temp = temp.replace(/&emsp;/g, String.fromCharCode(8195));
	temp = temp.replace(/&thinsp;/g, String.fromCharCode(8201));
	temp = temp.replace(/&zwnj;/g, String.fromCharCode(8204));
	temp = temp.replace(/&zwj;/g, String.fromCharCode(8205));
	temp = temp.replace(/&lrm;/g, String.fromCharCode(8206));
	temp = temp.replace(/&rlm;/g, String.fromCharCode(8207));
	temp = temp.replace(/&ndash;/g, String.fromCharCode(8211));
	temp = temp.replace(/&mdash;/g, String.fromCharCode(8212));
	temp = temp.replace(/&lsquo;/g, String.fromCharCode(8216));
	temp = temp.replace(/&rsquo;/g, String.fromCharCode(8217));
	temp = temp.replace(/&sbquo;/g, String.fromCharCode(8218));
	temp = temp.replace(/&ldquo;/g, String.fromCharCode(8220));
	temp = temp.replace(/&rdquo;/g, String.fromCharCode(8221));
	temp = temp.replace(/&bdquo;/g, String.fromCharCode(8222));
	temp = temp.replace(/&dagger;/g, String.fromCharCode(8224));
	temp = temp.replace(/&Dagger;/g, String.fromCharCode(8225));
	temp = temp.replace(/&hellip;/g, String.fromCharCode(8230));
	temp = temp.replace(/&permil;/g, String.fromCharCode(8240));
	temp = temp.replace(/&lsaquo;/g, String.fromCharCode(8249));
	temp = temp.replace(/&rsaquo;/g, String.fromCharCode(8250));
	temp = temp.replace(/&circ;/g, String.fromCharCode(710));
	temp = temp.replace(/&tilde;/g, String.fromCharCode(732));
	
	return temp;
}

/**
 * Konvertiert text/plain in text/html
 *
 * @author René Backes
 * @since 10.03.2009
 * @param {String} text --- Der zu konvertierende String
 * @return {String} --- Der konvertierte String
 */
function convertText_PlainToHtml(text)
{
	var output = '';
	
	for(var i=0; i<text.length; i++)
	{
		if(text.charAt(i) == '\n')
		{
			output = output + '<br>';
		}
		else if(text.charAt(i) == ' ')
		{
			output = output + '&nbsp;';
		}
		else
		{
			output = output +'&#'+ text.charCodeAt(i) +';';
		}
	}
	
	return output;
}
function changeColor(tableCell) {
		
			
	tableCell.className = "answer_box_hover";
	

}

function changeColorBack(tableCell) {

	tableCell.className = "answer_box";

}


function raiseEvent (elementID)  {  
 
 	var o = document.getElementById(elementID);   
    
    if (o.checked) {
    	o.checked = false;
    } else {
    	o.checked = true;
	}
 	//o.onchange();

}  

/* Öffnet die Vorschau der Antwort-Erläuterung mit Hilfe von AJAX */
function openAnswerIllustrationPreview(url, questionId) {

	
	new Ajax.Request(url, {
		onLoading: function() { showLoadingIcon() },
 			method: 'get',
 			parameters: 'view=true&questionId='+ questionId,
 			onComplete: function(transport){ 
 				
 				if (200 == transport.status) {
     
 					fillAnswerIllustrationPreviewContainer(transport) 
 					
 				} else {
 					
 					document.getElementById("loading_icon").style.display = 'none';
 					alert('ERROR:' + transport.status);
 				
 				}
 			}
 				
	});
}


/* Füllt den Vorschau-Container mit Inhalt und zeigt diesen an. */
function fillAnswerIllustrationPreviewContainer(transport) {
	
	document.getElementById("loading_icon").style.display = 'none';
	
	var container = document.getElementById("answer_illustration_container");
	var containerContent = document.getElementById("answer_illustration_container_content");

    //Container resetten um Höhe zu berechnen
	containerContent.innerHTML = "";
	container.style.height = "";
	containerContent.style.height = "";

	containerContent.innerHTML = transport.responseText;
	
	
	
	
	
	
	var containerHeight = Element.getHeight(container) + 12;	
	if (containerHeight > 600) {
	     containerHeight = 600;
	}
	
	container.style.height = containerHeight + "px";
	containerContent.style.height = (containerHeight - 27) + "px";
	
	setElementToAbsoluteMiddle("answer_illustration_container");
	
	container.style.display = 'block';
	
}

/* Schließt die Vorschau der Antwort-Erläuterung */
function closeAnswerIllustrationPreview() {

	document.getElementById("answer_illustration_container").style.display = 'none';

}

/* Zeigt das Lade-Icon an */
function showLoadingIcon () {
	setElementToAbsoluteMiddle("loading_icon");
	document.getElementById("loading_icon").style.display = 'inline';
} 


