d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
function sE(e){l?e.visibility='show':e.style.visibility='visible';}
function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
function sZ(e,z){l?e.zIndex=z:e.style.zIndex=z;}
function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x;}
function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y;}
function gX(e){x=l?e.pageX:op?e.style.pixelLeft:e.offsetLeft;return x;}
function gY(e){y=l?e.pageX:op?e.style.pixelTop:e.offsetTop;return y;}
function sW(e,w){l?e.clip.width=w:op?e.style.pixelWidth=w:e.style.width=w;}
function sH(e,h){l?e.clip.height=h:op?e.style.pixelHeight=h:e.style.height=h;}
function sC(e,t,r,b,x){l?(X=e.clip,X.top=t,X.right=r,X.bottom=b,X.left=x):e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}else if(e.innerHTML)e.innerHTML=h;}
function cE(i){if(l){d.layers[i]=new Layer(0);eval("document."+i+"=d.layers[i]");}else{if(typeof d.createElement!='undefined'){X="<div id='"+i+"' style=\"position:absolute\">&nbsp;</div>";Y=d.createElement("DIV");if(Y){Y.innerHTML=X;d.body.appendChild(Y);}else if(typeof d.body.insertAdjacentHTML!='undefined')d.body.insertAdjacentHTML("BeforeEnd",X);}}}


var bFirstRun = true;
function setImgTitle() {
	if(document.all) return;
	if(bFirstRun == true) {
		bFirstRun = false;
		var di = document.images;
		for(var i = 0; i < di.length; i++){
			if(di[i].alt != '' && di[i].title == ''){
				di[i].title = di[i].alt;
			}
		}
	}
}

function doChallengeResponseLogin() {
  str = document.login.passwd.value;
  document.login.md5passwd.value = MD5(str);
  document.login.passwd.value = '';
}

function doChallengeResponseUserPasswd(form, userID, passwd, repasswd, md5passwd) {
  eval('str = document.'+form+'.'+passwd+';');
  eval('restr = document.'+form+'.'+repasswd+';');
  eval('userID = document.'+form+'.'+userID+';');
  eval('md5passwd = document.'+form+'.'+md5passwd+';');
  if(userID.value != ''){ 
  	if(str.value == '' && restr.value == ''){
    	md5passwd.value = '';
		return true;
	}
	else{ 
		if(str.value != restr.value){
			alert('Passwort und Passwort erneut müssen identisch und dürfen nicht leer sein');
			return false; 
		}
		else{ 
			md5passwd.value = MD5(str.value);
			str.value = '';
			restr.value = '';
			return true;
		}
	}
  }
  else{
  	if (str.value != restr.value || str.value == ''){
		alert('Passwort und Passwort erneut müssen identisch und dürfen nicht leer sein');
		return false;
  	} 
  	else {
		md5passwd.value = MD5(str.value);
		str.value = '';
		restr.value = '';
		return true;
  	}
  }
}

function openPopup(sUrl, sName, iWidth, iHeight, scrolling, resizable, sToolbar) {
	myNicePopup = window.open(sUrl, sName, "dependent=yes,width="+iWidth+",height="+iHeight+",location=no,menubar=no,status=no,toolbar="+sToolbar+",scrollbars="+scrolling+",resizable="+resizable);
	var sw = window.screen.availWidth;
	var sh = window.screen.availHeight;
	var w = iWidth;
	var h = iHeight;
	if(myNicePopup == true) {
		myNicePopup.moveTo((sw - w) / 2, (sh - h) / 2);
		myNicePopup.focus();
	}
}

function addText( id, insText ) {
	
	if(typeof(id) == 'string'){
		input = document.getElementById(id);
	}else{
		input = id;
	}
	
	input.focus();
	
	// für ie
	if( input.createTextRange ) {
		document.selection.createRange().text += insText;
	} 
	
	 // für gecko
	else if( input.setSelectionRange ) {
		var len = input.selectionEnd;
		input.value = input.value.substr(0, len) + insText + input.value.substr(len);
		input.setSelectionRange(len+insText.length, len+insText.length);
	} 
	
	// für opera, ...
	else { input.value += insText; }
}

function focusmain() {
	if (top.opener.blur) top.opener.focus();
}

function modelessWin(url, mwidth, mheight, resizable, scrollbars, status) {
	window.showModelessDialog(url,"","status:"+status+";scroll:"+scrollbars+";center:0;edge:raise;help:0;resizable:"+resizable+";dialogWidth:"+mwidth+"px;dialogHeight:"+mheight+"px");
}

function openChromeLess(title, text, iWidth, iHeight) {
	win = window.open("/abaton/cssjs/popUpWindow.php?sTitle="+title+"&sText="+text, "", "fullscreen=0");
	var sw = window.screen.availWidth;
	var sh = window.screen.availHeight;
	win.resizeTo(iWidth, iHeight);
	win.moveTo((sw - iWidth) / 2, (sh - iHeight) / 2);
}

function openNicePopup(sUrl, sTitle, sName, iWidth, iHeight, bDontShowStandardTitle, sReturnField) {
	openPopup(sUrl, sName, iWidth, iHeight, 0, 1);
}

/*
function openCalendar(sTargetField) {
	openNicePopup("/abaton/js/calendar.php?sTargetField="+sTargetField, "Kalendar", "calendar", 350, 360, 1, sTargetField);
}
*/

function showCal(id, posX, posY) {
	
	// iFrame, in dem Kalender angezeigt wird
	myFrame = document.getElementById('calFrame');
	// Feld, in das das Datum geschrieben wird
	window.frames['calFrame'].setTarget(id);
	
	// Anzeige des Kalenders (Position von oben und links)
	calTop = posY;
	calLeft = posX;
	
	myFrame.style.top = calTop;
	myFrame.style.left = calLeft;
	myFrame.style.display='block';
	eval("window.frames['calFrame'].setCalendarDate(document.getElementById('" + id + "').value);");
	myFrame.focus;
}

function subNavOver(tdID,verwID) {
	document.getElementById(tdID).style.backgroundColor='#eeeeee';
	document.getElementById(tdID).style.border='1px solid #dddddd';
	document.getElementById(verwID).style.color='#333333';
}

function subNavOut(tdID,verwID) {
	document.getElementById(tdID).style.backgroundColor='#6580b6'; 
	document.getElementById(tdID).style.border='1px solid #6580b6';
	document.getElementById(verwID).style.color='#eeeeee';
}

// Diese Funktion ermittelt die Anzahl der eingegeben Zeichen
// und gibt sie im counterfield aus.
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);
	else
	countfield.value = field.value.length;
}

// Aufruf einer URL die als Value im Select-Feld steht (wird
// beim Wechlse einer Option aufgerufen
function loadUrlFromSelect(field){
	if (field.options[field.selectedIndex].value != "none") {
		location = field.options[field.selectedIndex].value
	}
}

bRestoreMax = true;
bRestoreMin = true;
bFirstRun = true;
function switchMaxRestore() {
	if(bRestoreMax) {
		top.content.document.getElementById('minmaxbutton2').src='/abaton/images/buttons/minmax.gif';
		top.content.document.getElementById('minmaxbutton1').src='/abaton/images/buttons/min.gif';
		top.document.getElementById('mainFrame').rows="0,*";
		//if(!bFirstRun) top.content.fixSize();
		bRestoreMax = false;
		bRestoreMin = true;
	} else {
		top.content.document.getElementById('minmaxbutton2').src='/abaton/images/buttons/max.gif';
		top.document.getElementById('mainFrame').rows="180,*";
		//if(!bFirstRun) top.content.fixSize();
		bRestoreMax = true;
	}
	bFirstRun = false;
}

function switchMinRestore(sModule) {
	if(bRestoreMin) {
		top.content.document.getElementById('minmaxbutton1').src='/abaton/images/buttons/minmax.gif';
		top.content.document.getElementById('minmaxbutton2').src='/abaton/images/buttons/max.gif';
		top.document.getElementById('mainFrame').rows = (top.document.body.offsetHeight - 35) + ",*";
		if(sModule == 'bv' || sModule == 'nl'){
			top.head.document.getElementById('serviceFrame').height = (top.document.body.offsetHeight - 35 - 27);
		}else{
			top.head.headright.document.getElementById('serviceFrame').height = (top.document.body.offsetHeight - 35 - 27);
		}
		//top.content.document.getElementById('contentFrame').rows = (top.document.body.offsetHeight - 35) + ",*";
		//if(!bFirstRun) top.content.fixSize();
		bRestoreMin = false;
		bRestoreMax = true;
	} else {
		top.content.document.getElementById('minmaxbutton1').src='/abaton/images/buttons/min.gif';
		top.document.getElementById('mainFrame').rows="180,*";
		if(sModule == 'bv'){
			top.head.document.getElementById('serviceFrame').height = (180 - 27);
		}else{
			top.head.headright.document.getElementById('serviceFrame').height = (180 - 27);
		}
		//if(!bFirstRun) top.content.fixSize();
		bRestoreMin = true;
	}
	bFirstRun = false;
}