/* Tools-Bibliothek */
	function jstrim(trim_value){
			if(trim_value.length < 1){
				return "";
			}
			trim_value=jsrtrim(trim_value);
			trim_value=jsltrim(trim_value);
			if(trim_value == ""){
				return "";
			}
			else{
				return trim_value;
			}
		}
	
	function jsrtrim(value){
			var w_space=String.fromCharCode(32);
			var v_length=value.length;
			var strTemp="";
	
			if(v_length < 0){
				return "";
			}
			var iTemp=v_length-1;
			
			while(iTemp > -1){
				if (value.charAt(iTemp) == w_space){
				}
				else{
					strTemp=value.substring(0,iTemp + 1);
					break;
				}
				iTemp = iTemp - 1;
			}
			return strTemp;
		}
		
	function jsltrim(value){
			var w_space=String.fromCharCode(32);
			var v_length=value.length;
			var strTemp="";
	
			if(v_length < 1){
				return "";
			}
			var iTemp=0;
			
			while(iTemp < v_length){
				if (value.charAt(iTemp) == w_space){
				}
				else{
					strTemp=value.substring(iTemp,v_length);
					break;
				}
				iTemp = iTemp + 1;
			}
			return strTemp;
		}
		
	function mailCheck(s){
			var a = false;
			var res = false;
			if (typeof(RegExp)=='function'){
				var b=new RegExp('abc');
				if (b.test('abc') == true){a=true;}
			}
			
			if (a == true){
				reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.\\_]+)'+'(\\.)([a-zA-Z]{2,4})$');
				res = (reg.test(s));
			}
			else{
				res = (s.search('@') >= 1 && s.lastIndexOf('.') > s.search('@') && s.lastIndexOf('.') >= s.length-5)
			}
			return res;
		}
		
	function openCustomPopup(pfad,frmName,frameOptions){
		mywin=window.open(pfad, frmName, frameOptions);
		mywin.focus();
	}

	function clearbox(fo,fi,ct){
		var tfo = document.forms[fo];
		var tfi = tfo[fi].value;
		if (tfi == ct){
			tfo[fi].value = '';
		}
	}
	
	function checkMailForm(formname){
		var result=true;
		var missing=""
		if (jstrim(document.forms[formname].MailFromName.value) == ""){
			missing = missing + "Absender-Name ";
			result=false;
		}
		if (jstrim(document.forms[formname].MailFrom.value) == "" || !(mailCheck(document.forms[formname].MailFrom.value))){
			missing = missing + "Absender-Email ";
			result=false;
		}
		if (jstrim(document.forms[formname].MailTo.value) == "" || !(mailCheck(document.forms[formname].MailTo.value))){
			missing = missing + "Empfaenger-Email ";
			result=false;
		}
		if (!result){
			alert("Bitte fuellen Sie die folgenden Felder aus:" + missing);
		}
		return result;
	}
	
	function getWindowHeight() {
		var windowHeight = 0;
		if (typeof(window.innerHeight) == 'number') {
			windowHeight = window.innerHeight;
		}
		else {
			if (document.documentElement && document.documentElement.clientHeight) {
				windowHeight = document.documentElement.clientHeight;
			}
			else {
				if (document.body && document.body.clientHeight) {
					windowHeight = document.body.clientHeight;
				}
			}
		}
		return windowHeight;
	}
	
	function getPageYOffset() {
		var result = 0;
		if (typeof(window.pageYOffset) == 'number') {
		  result = window.pageYOffset;
		}
		else {
			if (document.documentElement && document.documentElement.scrollTop) {
				result = document.documentElement.scrollTop;
			}
			else {
				if (document.body && document.body.scrollTop) {
					result = document.body.scrollTop;
				}
			}
		}
		return result;
	}
	
	function fullSize(content) {
		if (document.getElementById) {
			var windowHeight = getWindowHeight();
			if (windowHeight > 0) {
				var contentElement = document.getElementById(content);
				var contentHeight  = contentElement.offsetHeight;
				contentElement.style.height = (windowHeight - 140) + 'px';
			}
		}
	}
	
	function setFooter(footer,content,toplink) {
		if (document.getElementById) {
			var windowHeight = getWindowHeight();
			if (windowHeight > 0) {
				var contentHeight = document.getElementById(content).offsetHeight;
				var footerElement = document.getElementById(footer);
				var footerHeight  = footerElement.offsetHeight;
				if (windowHeight - (contentHeight + footerHeight) >= 0) {
					footerElement.style.position = 'absolute';
					footerElement.style.top = (windowHeight - footerHeight) + 'px';
					footerElement.style.visibility = 'visible';
					if (toplink) {
						var topElement = document.getElementById(toplink);
						topElement.style.visibility = 'hidden';
					}
				}
				else {
					footerElement.style.position = 'static';
					footerElement.style.visibility = 'visible';
					if (toplink) {
						var topElement = document.getElementById(toplink);
						topElement.style.visibility = 'visible';
					}
				}
			}
		}
	}
	
	function goHrefFromPulldown(url){
		// Schauen, ob in der url noch ein target versteckt ist.
		stlen = url.length;
		if (stlen > 0) {
			pos=url.lastIndexOf("|");
			if (pos == -1){
				document.location.href=url;
			} else {
				gourl = url.substring(0,pos);
				gotarget = url.substring(pos+1,stlen);
				if (gotarget.substring(1,5) == 'self'){
					document.location.href=gourl;
				} else {
					popup = window.open(gourl,gotarget,'');
					popup.focus();
				}
			}
		}
	}

	function openSingle(dlid) {
		openCustomPopup('doc/doc_precheck.cfm?dlid='+dlid,'dlpopup','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,titlebar=no,width=600,height=560,screenX=15,screenY=13');
	}
	
	function openMulti(form) {
		openCustomPopup('doc/doc_precheck.cfm','dlpopup','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,titlebar=no,width=600,height=560,screenX=15,screenY=13');
		document.forms[form].submit();
	}
