
function login(a){
	if (a==0){
		if (document.DlgLogin.fUser.value==''){
			alert('Vul uw gebruikersnaam in.');
			document.DlgLogin.fUser.select();
			document.DlgLogin.fUser.focus();
			return;
			}
		if (document.DlgLogin.fPassw.value==''){
			alert('Vul uw wachtwoord in.');
			document.DlgLogin.fPassw.select();
			document.DlgLogin.fPassw.focus();
			return;
			}
		var pwd = hex_md5(document.DlgLogin.fPassw.value + document.DlgLogin.fPassw.value.length);
		var hsh = hex_md5(document.DlgLogin.fUser.value + document.DlgLogin.dlgAuth1.value);
		wacht=true;
		document.rmForm.rmAction.value='login';
		document.rmForm.rmReturn.value='parent.' + window.name + '.login';
		document.rmForm.rmParams.value=document.DlgLogin.fUser.value + '|' + pwd + '|' + hsh;
		document.rmForm.submit();
		}
	if (a>0){
		wacht=false;
		rmResult=readRemote(parent.frames[document.rmForm.target].document.getElementById("content").value);
		var arrLogin=rmResult.split("|");
		if (arrLogin[0] == "OK"){
			top.location='../default.asp';
			}
		else {
			if (parseInt(arrLogin[1])==0){
				alert("Toegang geweigerd.\nUw login wordt om veiligheidsredenen voor de duur van 10 minuten geblokkeerd.\nProbeer het daarna opnieuw.");
				location="../main/lockout.asp";
				return;
				}
			if (parseInt(arrLogin[1])>1){
				alert('Toegang geweigerd.\nU heeft nog '+arrLogin[1]+' pogingen.');
				}
			else {
				alert('Toegang geweigerd.\nU heeft nog '+arrLogin[1]+' poging.');
				}
			//document.getElementById('fUser').value="";
			//document.getElementById('fPassw').value="";
			document.getElementById('fUser').focus();
			return;
			}
		}
		//top.fTop.document.body.innerHTML='';
	}

function chgPassword(a){
	if (a==0){
		if (wacht){
			setTimeout("chgPassword("+a+")",500);
			}
		else {
//			if (document.DlgPassw.dlgOldPw.value==''){
//				alert('Vul uw oude wachtwoord in.');
//				document.DlgPassw.dlgOldPw.focus();
//				return;
//				}
			if (document.DlgPassw.dlgNewPw1.value!=document.DlgPassw.dlgNewPw2.value){
				alert('Het nieuwe wachtwoord en de bevestiging zijn niet gelijk.\Vul uw nieuwe wachtwoord nogmaals in.');
				document.DlgPassw.dlgNewPw1.value="";
				document.DlgPassw.dlgNewPw2.value="";
				document.DlgPassw.dlgNewPw1.focus();
				return;
				}
			if (document.DlgPassw.dlgNewPw1.value==""){
				alert('Vul uw nieuwe wachtwoord in.');
				document.DlgPassw.dlgNewPw1.value="";
				document.DlgPassw.dlgNewPw2.value="";
				document.DlgPassw.dlgNewPw1.focus();
				return;
				}
//			if (document.DlgPassw.dlgOldPw.value==document.DlgPassw.dlgNewPw1.value){
//				alert('Uw nieuwe wachtwoord mag niet hetzelfde zijn als uw oude.');
//				document.DlgPassw.dlgNewPw1.value="";
//				document.DlgPassw.dlgNewPw2.value="";
//				document.DlgPassw.dlgNewPw1.focus();
//				return;
//				}
			wacht=true;
			document.rmForm.rmAction.value="chgPassword";
			document.rmForm.rmReturn.value="parent."+window.name+".chgPassword";
			document.rmForm.rmParams.value=document.DlgPassw.dlgAuth1.value + "|" + document.DlgPassw.dlgNewPw1.value;
			document.rmForm.submit();
			}
		}
	if (a>0){
		wacht=false;
		rmResult=readRemote(parent.frames[document.rmForm.target].document.getElementById("content").value);
		document.getElementById("dialog").innerHTML=rmResult;
		}
	}

function forgotPassword(a){
	if (a==0){
		if (wacht){
			setTimeout("forgotPassword("+a+")",500);
			}
		else {
			if (document.Dlg.dlgUser.value==""){
				alert('Vul eerst uw loginnaam in.');
				document.Dlg.dlgUser.focus();
				return;
				}
			if (document.Dlg.dlgMail.value==""){
				alert('Vul eerst uw mailadres in.');
				document.Dlg.dlgMail.focus();
				return;
				}
			if (!isEmail(document.Dlg.dlgMail.value)){
				alert('Dit is geen geldig mailadres.');
				document.Dlg.dlgMail.select();
				document.Dlg.dlgMail.focus();
				return;
				}
			document.rmForm.rmAction.value="forgotPassword";
			document.rmForm.rmReturn.value="parent."+window.name+".forgotPassword";
			document.rmForm.rmParams.value=document.Dlg.dlgAuth1.value + "|" + document.Dlg.dlgUser.value + "|" + document.Dlg.dlgMail.value;
			document.rmForm.submit();
			}
		}
	if (a>0){
		wacht=false;
		rmResult=readRemote(parent.frames[document.rmForm.target].document.getElementById("content").value);
		document.getElementById("dialog").innerHTML=rmResult;
		}
	}

function logout(a){
	if (a==0){
		wacht=true;
		document.rmForm.rmAction.value='logout';
		document.rmForm.rmReturn.value='parent.' + window.name + '.logout';
		document.rmForm.rmParams.value='';
		document.rmForm.submit();
		}
	if (a>0){
		wacht=false;
		rmResult=readRemote(parent.frames[document.rmForm.target].document.getElementById("content").value);
		if (rmResult == "OK"){
			top.location='../default.asp';
			}
		}
	}
