function sndReqArgRegistration()
	{
	registrationForm.style.display="block";
	
	var passData = '';

	http.open('post', 'personal/registration/register.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponseRegistration;
	http.send(passData);
  	}
function RegisterNewUser()
	{
	var passData = 	'operation=add_user&userFirstname=' + document.getElementById("userFirstname").value + '&userLastname=' + document.getElementById("userLastname").value + '&userUsername=' + document.getElementById("userUsername").value + '&password1=' + document.getElementById("password1").value + '&password2=' + document.getElementById("password2").value + '&userPersonalEmail=' + document.getElementById("userPersonalEmail").value + '&mailforward=on';

	http.open('post', 'personal/registration/register.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponseRegistration;
	http.send(passData);
	}
function handleResponseRegistration() 
	{
	if(http.readyState == 4) 
		{
		document.getElementById("registrationForm").innerHTML = http.responseText;
		}
	}

	
function checkFirstname(firstname)
	{
	if (firstname.length > 0)
		{
		document.getElementById("idfirstname").src = 'interface/figuren/ok.gif';
		}
	else
		{
		document.getElementById("idfirstname").src = 'interface/figuren/not-ok.gif';
		}
	EnableSubmitButton();
	}
	
	
function checkLastname(lastname)
	{
	if (lastname.length > 0)
		{
		document.getElementById("idlastname").src = 'interface/figuren/ok.gif';
		}
	else
		{
		document.getElementById("idlastname").src = 'interface/figuren/not-ok.gif';
		}
	EnableSubmitButton();
	}

	
function createUsername(username)
	{
	if (username)
		{
		var passData = 'username=' + username;
		}
	else
		{
		value1 = formulier.userFirstname.value.toLowerCase();
		value2 = formulier.userLastname.value.toLowerCase();
		var passData = 'username=' + escape(value1) + '.' + escape(value2);
		}
		
	http.open('post', 'personal/registration/checkUsername.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponseCheckUsername;
	http.send(passData);
	EnableSubmitButton();
	}
function handleResponseCheckUsername() 
	{
	if(http.readyState == 4) 
		{
		if (http.responseText.substring(0,1) == '1')
			{
			document.getElementById("usernameCheck").innerHTML = '';
			document.getElementById("userUsername").value = http.responseText.substring(1);
			document.getElementById("idusername").src = 'interface/figuren/ok.gif';
			}
		if (http.responseText.substring(0,1) == '2') 
			{
			document.getElementById("usernameCheck").innerHTML = '<nobr><font color=red><b>' + http.responseText.substring(1) + '</b> is al in gebruik </font><nobr>';
			document.getElementById("userUsername").value = '';
			document.getElementById("idusername").src = 'interface/figuren/not-ok.gif';
			}
		}
	EnableSubmitButton();
	}
	
	
function checkPassword(password)
	{
	var passData = 'password=' + password;
	
	http.open('post', 'personal/registration/checkPassword.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponseCheckPassword;
	http.send(passData);
	EnableSubmitButton();
	if (document.getElementById("password2").value.length > 0)
		{
		checkRepeatPassword();
		}
	}
function handleResponseCheckPassword() 
	{
	if(http.readyState == 4) 
		{
		if (http.responseText.substring(0,1) == '1')
			{
			document.getElementById("idpassword1").src = 'interface/figuren/ok.gif';
			}
		if (http.responseText.substring(0,1) == '0') 
			{
			document.getElementById("idpassword1").src = 'interface/figuren/not-ok.gif';
			}
		document.getElementById("passwordCheck").innerHTML = http.responseText.substring(1);
		}
	}
	

function checkRepeatPassword()
	{
	var passData = 'password1=' + document.getElementById("password1").value + '&password2=' + document.getElementById("password2").value;
	
	http.open('post', 'personal/registration/checkRepeatPassword.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponseCheckRepeatPassword;
	http.send(passData);
	EnableSubmitButton();
	}
function handleResponseCheckRepeatPassword() 
	{
	'<font color=red> De wachtwoorden zijn niet identiek.</font>'
	
	if(http.readyState == 4) 
		{
		if (http.responseText.substring(0,1) == '1')
			{
			document.getElementById("idpassword2").src = 'interface/figuren/ok.gif';
			document.getElementById("passwordRepeatCheck").innerHTML = '';
			}
		if (http.responseText.substring(0,1) == '0') 
			{
			document.getElementById("idpassword2").src = 'interface/figuren/not-ok.gif';
			document.getElementById("passwordRepeatCheck").innerHTML = '<font color=red> De paswoorden zijn niet identiek. </font>';
			}
		
		}
	}	

	
function checkEmail(email)
	{
	var passData = 'email=' + email;
	
	http.open('post', 'personal/registration/checkEmail.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponseCheckEmail;
	http.send(passData);
	EnableSubmitButton();
	}
function handleResponseCheckEmail() 
	{
	if(http.readyState == 4) 
		{
		if (http.responseText.substring(0,1) == '0')
			{
			document.getElementById("idmail").src = 'interface/figuren/not-ok.gif';
			document.getElementById("emailCheck").innerHTML = '<font color=red> Dit is geen geldig e-mailadres. </font>';
			}
		else if (http.responseText.substring(0,1) == '1')
			{
			document.getElementById("idmail").src = 'interface/figuren/not-ok.gif';
			document.getElementById("emailCheck").innerHTML = '<font color=red> E-mailadressen die aan een T2T-platform gekoppeld zijn, worden niet aanvaard. </font>';
			}
		else if (http.responseText.substring(0,1) == '2')
			{
			document.getElementById("idmail").src = 'interface/figuren/ok.gif';
			document.getElementById("emailCheck").innerHTML = '';
			}
		else if (http.responseText.substring(0,1) == '3')
			{
			document.getElementById("idmail").src = 'interface/figuren/not-ok.gif';
			document.getElementById("emailCheck").innerHTML = '<font color=red> Dit adres lijkt niet te bestaan. </font>';
			}
		else if (http.responseText.substring(0,1) == '4')
			{
			document.getElementById("idmail").src = 'interface/figuren/not-ok.gif';
			document.getElementById("emailCheck").innerHTML = '<font color=red> E-mailadressen van dit domein worden niet aanvaard. </font>';
			}
		}
	EnableSubmitButton();
	}

	

function EnableSubmitButton()
	{
	var length = document.getElementById("idmail").src.indexOf("figuren/");
	var startstring = length + 8;
	
	
	if ((document.getElementById("idfirstname").src.substring(startstring) == 'ok.gif') && (document.getElementById("idlastname").src.substring(startstring) == 'ok.gif') && (document.getElementById("idusername").src.substring(startstring) == 'ok.gif') && (document.getElementById("idpassword1").src.substring(startstring) == 'ok.gif') && (document.getElementById("idpassword2").src.substring(startstring) == 'ok.gif') && (document.getElementById("idmail").src.substring(startstring) == 'ok.gif') && (document.getElementById("acceptance").checked==true ) )
		{
		document.getElementById("idregisterbutton").disabled = false;
		}	
	else
		{
		document.getElementById("idregisterbutton").disabled = true;
		}	
	}
	

	
	
	
	
	
	
	

function sndReqArgPwdrecovery(ingaveoptie,login,email)
	{
	var passData = '';
	if(ingaveoptie != '')
        {
        passData = 'ingaveoptie=' + escape(ingaveoptie) + '&login=' + escape(login) + '&email=' + escape(email);
        }
	http.open('post', 'tools/administration/pwdrecovery/changepwd.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePwdrecovery;
	http.send(passData);
  	}
	
function handleResponsePwdrecovery() 
	{
	if(http.readyState == 4) 
		{
		document.getElementById("pwdrecovery").innerHTML = http.responseText;
		}
	}

function openClosePwdrecovery()
	{
	if (pwdrecovery.style.display == 'none')
		{
		pwdrecovery.style.display="block";
		sndReqArgPwdrecovery('','','');
		}
	else
		{
		pwdrecovery.style.display="none"
		}
	}
