// JavaScript Document

var xmlhttp = false;

//CREATE AN XHTML REQUEST
if (!window.XMLHttpRequest) { 
        window.XMLHttpRequest = function() { 
				var types = [ 
					'Microsoft.XMLHTTP', 
					'MSXML2.XMLHTTP.5.0', 
					'MSXML2.XMLHTTP.4.0', 
					'MSXML2.XMLHTTP.3.0', 
					'MSXML2.XMLHTTP' 
				]; 
	
				for (var i = 0; i < types.length; i++) { 
					try { 
						return new ActiveXObject(types[i]); 
					} 
					catch(e) {} 
            	} 
            	return undefined; 
        	} 
}

function DoFormSubmit(url, div, dest, inputid) { 
var xmlhttp = new XMLHttpRequest();  
var currencyExp = new RegExp(/[0-9]/);
var stringExp = new RegExp(/[^\w\s\-\.\!]/);
    if (xmlhttp) 
        { 
            // closure! 
            xmlhttp.onreadystatechange = function() 
            { 
                if (xmlhttp.readyState == 1) 
                { 
                    document.getElementById(div).innerHTML = "<img src=\"../img/loading.gif\" width=\"20\" height=\"20\" class=\"image_noborder\">";                    
                }
    if (xmlhttp.readyState == 2) 
                { 
                    document.getElementById(div).innerHTML = "<img src=\"../img/loading.gif\"  width=\"20\" height=\"20\" class=\"image_noborder\">";                    
                }
    if (xmlhttp.readyState == 4) 
                { 
                    if (xmlhttp.status == 200) 
					{  
                        //document.getElementById(div).innerHTML = xmlhttp.responseText;   
						if (xmlhttp.responseText == 'true') {
							document.getElementById(div).innerHTML = "<img src=\"../img/icon_enabled_forbidden.png\" width=\"16px\" height=\"16px\" alt=\"bestaat al vul wat anders in\" title=\"Bestaat al vul een unieke waarde in\" class=\"image_noborder\">";                    
							document.getElementById(dest).value = '0';
						}
						else {
							
							if (inputid == 'gebruikersnaam') {
								if (document.getElementById(inputid).value != "") {
									if (!stringExp.test(document.getElementById(inputid).value) && document.getElementById(inputid).value.length >= 3 && document.getElementById(inputid).value.charAt(0) != " ") {
										document.getElementById(div).innerHTML = "<img src=\"../img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"image_noborder\">";
										document.getElementById(dest).value = '1';
									}
									else {
										document.getElementById(div).innerHTML = "<img src=\"../img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
										document.getElementById(dest).value = '0';
									}
								}
								else {
									document.getElementById(div).innerHTML = "<img src=\"../img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
									document.getElementById(dest).value = '0';
								}
							}	
							
							if (inputid == 'email') {
								if (document.getElementById(inputid).value != "") {
									if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.getElementById(inputid).value)){
										document.getElementById(div).innerHTML = "<img src=\"../img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"image_noborder\">";
										document.getElementById(dest).value = '1';
									}
									else {
										document.getElementById(div).innerHTML = "<img src=\"../img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
										document.getElementById(dest).value = '0';
									}
								}
								else {
									document.getElementById(div).innerHTML = "<img src=\"../img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
										document.getElementById(dest).value = '0';
								}
							}
							
							EnableSubmit();
							
						}
                    } 
                    else 
                    { 
                        alert('Connection Failed\nStatus : ' + xmlhttp.status); 
                    } 
                }
            } 
 
            xmlhttp.open('POST', url + '?name=' + document.getElementById(inputid).value, true); 
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 
            xmlhttp.send(null); 
			
            // cancel form submit   
            return false; 
    } 
    else 
    { 
        alert('Not Ajax-capable, trying normal form-submit'); 
 } 
    return true;
}

function ComparePasswords(id1, id2) {	
	var action = document.getElementById('hidWachtwoord2').value
	
	if (document.getElementById(id1).value != document.getElementById(id2).value){
		document.getElementById('check_wachtwoord2').innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" alt=\"Het wachtwoord komt niet overeen\" title=\"Het wachtwoord komt niet overeen\" />";
		document.getElementById('hidWachtwoord2').value =  '0';
	}
	else {
		/*document.getElementById('errorMessage').style.display = 'none';*/
		document.getElementById('check_wachtwoord2').innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
		document.getElementById('hidWachtwoord2').value =  '1';
	}
}

function DoInputboxCheck(div, inputboxid, hiddenid, buttonid, type) {	
	var currencyExp = new RegExp(/[0-9]/);
	var stringExp = new RegExp(/[^\w\s\-\.\!]/);
	
	//var action = document.getElementById('hidAction').value

	if (type == 'gebruikersnaam') {
		if (document.getElementById(inputboxid).value != "") {
			if (!stringExp.test(document.getElementById(inputboxid).value) && document.getElementById(inputboxid).value.length >= 3 && document.getElementById(inputboxid).value.charAt(0) != " ") {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidGebruikersnaam').value =  '1';
			}
			else {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidGebruikersnaam').value = '0';
			}
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidGebruikersnaam').value = '0';
		}
	}	
	
		if (type == 'voornaam') {
		if (document.getElementById(inputboxid).value != "") {
			if (!stringExp.test(document.getElementById(inputboxid).value) && document.getElementById(inputboxid).value.length >= 3 && document.getElementById(inputboxid).value.charAt(0) != " ") {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidVoornaam').value =  '1';
			}
			else {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidVoornaam').value = '0';
			}
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidVoornaam').value = '0';
		}
	}	
	
	if (type == 'achternaam') {
		if (document.getElementById(inputboxid).value != "") {
			if (!stringExp.test(document.getElementById(inputboxid).value) && document.getElementById(inputboxid).value.length >= 3 && document.getElementById(inputboxid).value.charAt(0) != " ") {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidAchternaam').value =  '1';
			}
			else {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidAchternaam').value = '0';
			}
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidAchternaam').value = '0';
		}
	}	

	if (type == 'woonplaats') {
		if (document.getElementById(inputboxid).value != "") {
			if (!stringExp.test(document.getElementById(inputboxid).value) && document.getElementById(inputboxid).value.length >= 3 && document.getElementById(inputboxid).value.charAt(0) != " ") {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidWoonplaats').value =  '1';
			}
			else {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidWoonplaats').value = '0';
			}
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidWoonplaats').value = '0';
		}
	}

	if (type == 'email') {
		if (document.getElementById(inputboxid).value != "") {
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.getElementById(inputboxid).value)){
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidEmail').value = '1';
			}
			else {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidEmail').value = '0';
			}
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidEmail').value = '0';
		}
	}
	
	if (type == 'MSN') {
		if (document.getElementById(inputboxid).value != "") {
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.getElementById(inputboxid).value)){
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidMSN').value = '1';
			}
			else {
				document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
				document.getElementById('hidMSN').value = '0';
			}
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidMSN').value = '0';
		}
	}
	
	if (type == 'password1') {
		if (document.getElementById(inputboxid).value != "" && document.getElementById(inputboxid).value.length >= 5) {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidWachtwoord1').value =  '1';			
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidWachtwoord1').value = '0';
		}
	}
	
	if (type == 'password2') {
		if (document.getElementById(inputboxid).value != "" && document.getElementById(inputboxid).value.length >= 5) {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidWachtwoord2').value =  '1';			
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidWachtwoord2').value = '0';
		}
	}
	
	if (type == 'voorwaarden') {
		if (document.getElementById(inputboxid).checked != false) {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_yes.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidVoorwaarden').value =  '1';			
		}
		else {
			document.getElementById(div).innerHTML = "<img src=\"img/icon_enabled_no.png\" width=\"16px\" height=\"16px\" class=\"ImageNoBorder\" />";
			document.getElementById('hidVoorwaarden').value = '0';
		}
	}
EnableSubmit();
}

function EnableSubmit() {
if (document.getElementById('hidGebruikersnaam').value =='1' && document.getElementById('hidEmail').value =='1' && document.getElementById('hidWachtwoord1').value =='1' && document.getElementById('hidWachtwoord2').value =='1' && document.getElementById('hidVoornaam').value =='1' && document.getElementById('hidAchternaam').value =='1' && document.getElementById('hidWoonplaats').value =='1' && document.getElementById('hidVoorwaarden').value == '1') {
		document.getElementById('subFormReg').disabled = false;
		
	}
	else {
		document.getElementById('subFormReg').disabled = true;
	}
}

function go(){
	location=document.selectPage.dxCountPages.options[document.selectPage.dxCountPages.selectedIndex].value
}

function Venster(URL) {
venster = window.open(URL, 'popupvenster', 'width=400, height=500, resizable=no, menubar=no, scrollbars=yes, status=no, toolbar=no');
}

