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 focusmain() {
	window.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/js/popUpWindow.php?sTitle="+title+"&sText="+text, "", "fullscreen=1");
	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 subNavOver(tdID,verwID) {
	document.all(tdID).style.backgroundColor='#eeeeee';
	document.all(tdID).style.border='1px solid #dddddd';
	document.all(verwID).style.color='#333333';
}

function subNavOut(tdID,verwID) {
	document.all(tdID).style.backgroundColor='#6580b6'; 
	document.all(tdID).style.border='1px solid #6580b6';
	document.all(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.all.minmaxbutton2.src='/abaton/images/buttons/minmax.gif';
		top.content.document.all.minmaxbutton1.src='/abaton/images/buttons/min.gif';
		top.document.all.mainFrame.rows="0,*";
		if(!bFirstRun) top.content.fixSize();
		bRestoreMax = false;
		bRestoreMin = true;
	} else {
		top.content.document.all.minmaxbutton2.src='/abaton/images/buttons/max.gif';
		top.document.all.mainFrame.rows="180,*";
		if(!bFirstRun) top.content.fixSize();
		bRestoreMax = true;
	}
	bFirstRun = false;
}

function switchMinRestore() {
	if(bRestoreMin) {
		top.content.document.all.minmaxbutton1.src='/abaton/images/buttons/minmax.gif';
		top.content.document.all.minmaxbutton2.src='/abaton/images/buttons/max.gif';
		top.document.all.mainFrame.rows = (top.document.body.offsetHeight - 35) + ",*";
		if(!bFirstRun) top.content.fixSize();
		bRestoreMin = false;
		bRestoreMax = true;
	} else {
		top.content.document.all.minmaxbutton1.src='/abaton/images/buttons/min.gif';
		top.document.all.mainFrame.rows="180,*";
		if(!bFirstRun) top.content.fixSize();
		bRestoreMin = true;
	}
	bFirstRun = false;
}
