function sendForm(form, controller, action, params) {
	if ('undefined' == typeof zendpath) {
		alert('Framework Basispfad ist nicht definiert.');
		return false;
	}

	f = document.forms[form];

	if (typeof f == 'undefined') {
		alert('das Formular ' + form + ' existiert nicht!');
		return false;
	}

	// Password hashen, leider kann der hash nicht aus der Konfiguration
	// ausgelesen werden.
	hash = 'Kehine alteglische seichketa fur verchluesseluhnk';
	if (typeof f.password != 'undefined') {

		// Wenn das Passwort aus 32 Zeichen besteht darf es nicht geaendert
		// werden
		if (f.pass.value.length == 32 || f.pass.value.length == 0) {
			f.password.value = f.pass.value;
		} else {
			str = hex_md5(f.pass.value + hash);
			f.password.value = str;
		}
	}

	if ('undefined' == typeof params) {
		params = '';
	} else {
		params = '/' + params;
	}

	if (zendpath == '/')
	{
		f.action = '/' + controller + '/' + action + params;
	} else {
		f.action = zendpath + '/' + controller + '/' + action + params;
	}

	f.submit();

	return true;
}

function sendUrl(controller, action, params, frame) {
	if ('undefined' == typeof zendpath) {
		alert('Framework Basispfad ist nicht definiert.');
		return false;
	}

	if ('undefined' == typeof action) {
		action = '';
	}

	if ('undefined' == typeof params) {
		params = '';
	} else {
		params = '/' + params;
	}

	if ('undefined' == typeof frame) {
		document.location.href = zendpath + '/' + controller + '/' + action
				+ params;
	} else if (frame == 'parent') {
		parent.location.href = zendpath + '/' + controller + '/' + action
				+ params;
	} else {
		f = document.getElementById(frame);
		f.src = zendpath + '/' + controller + '/' + action + params;
	}

	return true;
}

function openWindow(address) {
	win = window
			.open(address, "",
					"width=600,height=700,toolbar=no,status=no,menubar=no,resizable=yes");
	win.focus();
}

function setWindowSize() {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	} else {
		winW = window.innerWidth;
		winH = window.innerHeight;
	}
	var obj = document.getElementById("FrameMiddleLeft");

	var tabletoph = document.getElementById("MainTableTop").clientHeight;

	h = winH - tabletoph - 35;
	obj.style.height = h + "px";

	var maintableh = document.getElementById("MainTable").clientHeight;

	if (maintableh > obj.clientHeight) {
		obj.style.height = maintableh + "px";
	}
}

function findPosTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		do {
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	} else if (obj.y) {
		curtop += obj.y
	}

	return curtop;
}

function findPosLeft(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	} else if (obj.x) {
		curleft += obj.x
	}

	return curleft;
}

function checkPassword(pw1, pw2) {
	if (document.getElementById(pw1).value != document.getElementById(pw2).value) {
		document.getElementById(pw1).value = ""
		document.getElementById(pw2).value = "";
		alert("Das Passwort wurde unterschiedlich eingegeben.");
		return false;
	} else {
		return true;
	}
}

function scroll() {
	c = document.cookie + ";";
	b = c.search('ypos=') + 5;
	pos = c.substring(b, c.indexOf(';', b));

	b = c.search('URL=') + 4;
	url = c.substring(b, c.indexOf(';', b));
	if (url.indexOf('?') == -1) {
		curl = url;
	} else {
		curl = url.substring(0, url.indexOf('?'));
	}

	url = document.URL;
	if (url.indexOf('?') == -1) {
		durl = url;
	} else {
		durl = url.substring(0, url.indexOf('?'));
	}

	if (curl == durl) {
		document.getElementById("FrameMiddleLeft").scrollTop = parseInt(pos);
	}
}
