function swap(name, objekt) {
	window.document.images[name].src = objekt.src;
}

var newWindow = null;

function closeWin() {
	if (newWindow != null) {
		if (!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight) {

	closeWin();

	if (type == "fullScreen") {
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}

	var tools = "";
	if (type == "standard" || type == "fullScreen")
		tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="
				+ strWidth + ",height=" + strHeight + ",top=0,left=0";
	if (type == "console1")
		tools = "resizable,toolbar=no,location=no,scrollbars=no,width="
				+ strWidth + ",height=" + strHeight + ",left=0,top=0";
	if (type == "console2")
		tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="
				+ strWidth + ",height=" + strHeight + ",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

// Grusstext-Zaehler Zeichen

function getObject(obj) {
	var theObj;
	if (document.all) {
		if (typeof obj == "string") {
			return document.all(obj);
		} else {
			return obj.style;
		}
	}
	if (document.getElementById) {
		if (typeof obj == "string") {
			return document.getElementById(obj);
		} else {
			return obj.style;
		}
	}
	return null;
}

function Contar(entrada, salida, texto, caracteres) {
	var entradaObj = getObject(entrada);
	var salidaObj = getObject(salida);
	var longitud = caracteres - entradaObj.value.length;
	if (longitud <= 0) {
		longitud = 0;
		texto = '<span class="grudisable">' + texto + '</span>';
		entradaObj.value = entradaObj.value.substr(0, caracteres);
	}
	salidaObj.innerHTML = texto.replace("{CHAR}", longitud);
}

function CountMax() {

	var greetingObject = document.getElementById("eBann");

	var words = greetingObject.value.split("\n");
	var lines = 0;
	var maxlines = 11;
	var textlength = 0;
	/*
	 * if (document.Grusskarte.greetingCardMessage.value.length > 500) {
	 * alert("Bitte geben Sie nicht mehr als 500 Zeichen ein.");
	 * document.Grusskarte.greetingCardMessage.value =
	 * document.Grusskarte.greetingCardMessage.value.substr(0,500); } else {
	 */
	if (words) {
		for (k = 0; (k < words.length); k++) {
			if (k != 0)
				textlength += 1;
			inLines = Math.ceil(words[k].length / 50);
			lines += inLines;
			if (lines > maxlines) {
				greetingObject.value = greetingObject.value.substr(0,
						textlength + ((inLines - 1) * 50));
				if (greetingObject.value
						.charCodeAt(greetingObject.value.length - 1) == 10) {
					greetingObject.value = greetingObject.value.substr(0,
							greetingObject.value.length - 2);
				}
				lines = maxlines;
				break;
			} else {
				textlength += words[k].length;
			}
		}
	}
}



