xmlhttp5 = new Array();
var usedxmlhttpindex = 0;
var q_questionnr;
var q_questionstotal;
var q_goback = false;



function moveOnMax(field,nextFieldID){
  if(field.value.length >= field.maxLength){
    document.getElementById(nextFieldID).focus();
  }
}

function mouseOver(obj) {
	objactive = obj.src.indexOf("_active");
	if (objactive == -1) {
		obj.src = obj.src.replace(".jpg", "_hover.jpg");
	}
}

function mouseOut(obj) {
	objactive = obj.src.indexOf("_active");
	if (objactive == -1) {
		obj.src = obj.src.replace("_hover.jpg", ".jpg");
	}
}

function rand ( n, m )
{
    if (typeof m == 'undefined')
    {
        m = parseInt(n);
        n = 0;
    }

    var genNo = 0;

    while (genNo < n || genNo > m)
    {
        genNo = Math.floor ( Math.random ( ) * m + 100 );
    }
    
    return genNo ;
}

function microtime(get_as_float)
{
    var now = new Date().getTime() / 1000;
    var s = parseInt(now, 10); 
    return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;

}

function getXMLHTTP() {
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp = false;
	}
	}
	return xmlhttp;
}


function articleview(articleId) {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=updateview&articleid=" + articleId  );
	xmlhttp.send(null);
}

function postCodeCheck(obj) {
	mval = obj.value.toUpperCase();
	rExp = /^[1-8]{1}[0-9]{3}[A-Z]{2}$/;
	OK = rExp.exec(mval);
	if (!OK)
	{
		document.getElementById('zipcodecheckerror').innerHTML = "Vul de postcode in met notatie 1234AB";
		return false;
	}
	return true;
}


function bookmark_us(url, title){              
                                               
if (window.sidebar) // firefox                 
    window.sidebar.addPanel(title, url, "");   
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');    
    elem.setAttribute('href',url);             
    elem.setAttribute('title',title);          
    elem.setAttribute('rel','sidebar');        
    elem.click();                              
}                                              
else if(document.all)// ie                     
    window.external.AddFavorite(url, title);   
}       


function addComment(obj) {
	
	af = document.getElementById('commentsLoggedId');
	
	if (af.getAttribute('loggedin') != 'true') {

	document.getElementById('commentnameerror').innerHTML = '';
	document.getElementById('emailerror').innerHTML = '';
	document.getElementById('commenterror').innerHTML = '';


		if (document.getElementById('frm_commmentname').value == '') {
			document.getElementById('commentnameerror').innerHTML = 'Naam is niet ingevuld';
			return false;
		}
		if (document.getElementById('frm_email').value == '') {
			document.getElementById('emailerror').innerHTML = 'Email is niet ingevuld';	
			return false;
		}
		if (!checkEmail(document.getElementById('frm_email').value)) {
			document.getElementById('emailerror').innerHTML = 'Email is niet juist ingevuld';	
			return false;
		}
	}
	if (document.getElementById('frm_comment').value == '') {
		document.getElementById('commenterror').innerHTML = 'Kommentaar is niet ingevuld';	
		return false;
	}	

	obj = showNormalLightbox(obj,'Lb','400','400');
	getCommentsCaptchaCheck();

	
	
}

function login() {
	

}


function contactSend() {
	document.getElementById('contact_name_error').innerHTML = '';
	document.getElementById('contact_email_error').innerHTML = '';
	document.getElementById('contact_email_error').innerHTML = '';
	document.getElementById('contact_body_error').innerHTML = '';
	
	
	if (document.getElementById('contact_name').value == '') {
		document.getElementById('contact_name_error').innerHTML = 'Naam is niet ingevuld';
		return false;
	}
	
	if (document.getElementById('contact_email').value == '') {
		document.getElementById('contact_email_error').innerHTML = 'E-mail is niet ingevuld';
		return false;
	}
	if (!checkEmail(document.getElementById('contact_email').value)) {
		document.getElementById('contact_email_error').innerHTML = 'E-mail adres is niet juist ingevuld';
		return false;
	}	
	if (document.getElementById('contact_subject').value == '') {
		document.getElementById('contact_subject_error').innerHTML = 'Subject is niet ingevuld';
		return false;
	}	
	
	if (document.getElementById('contact_body').value == '') {
		document.getElementById('contact_body_error').innerHTML = 'Body is niet ingevuld';
		return false;
	}
	xmlhttp = new getXMLHTTP();
	showNormalLightbox(document.body,'Lb','300','300');
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
			lightBoxaddContent(resp);
    	}
    }
 	xmlhttp.open( "POST", "/ajax/" );
 	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send("action=contact&name=" + document.getElementById('contact_name').value + "&email=" + document.getElementById('contact_email').value + "&subject=" + document.getElementById('contact_subject').value + "&body=" + document.getElementById('contact_body').value);		
}


function verifyLogin(login_user,login_password) {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		if (resp == 'true') {
    			location.replace('/overzicht');
    		} else {
    			document.getElementById('loginError').innerHTML = resp;
    		}
    	}
    }
 	xmlhttp.open( "POST", "/ajax/" );
 	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send("action=login&b=" + login_user + "&a=X9f3f" + login_password);	
}


function getlogin(obj) {
	showNormalLightbox(obj,'Lb','300','300');
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		if (resp == 'true') {
    			
    		} else {
    			lightBoxaddContent(resp);
    			document.getElementById('login_email').focus();
    		}
    	}
    }
 	xmlhttp.open( "GET", "/ajax/?action=getlogin");
	xmlhttp.send(null);
	
}

function forgotPass() {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		if (resp == 'true') {
    			
    		} else {
    			lightBoxaddContent(resp);
    		}
    	}
    }
 	xmlhttp.open( "GET", "/ajax/?action=forgotpassword");
	xmlhttp.send(null);
	
}


function resetPass(email) {
	if (!checkEmail(email)) {
		document.getElementById('errorspan').innerHTML = 'E-mail adres is niet juist ingevuld';	
		return false;
	}	
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
   			lightBoxaddContent(resp);

    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=resetpass&email=" + email);
	xmlhttp.send(null);
}


function stem() {
	
	pollvote = false;
	for (i=0;i<document.voteForm.pl.length;i++) {
		if (document.voteForm.pl[i].checked) {
			pollvote = document.voteForm.pl[i].value;
		}
	}
	if (!pollvote) {
		return false;	
	}

	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
   			document.getElementById('pollbox').innerHTML = resp;
    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=vote&pollvote=" + pollvote);
	xmlhttp.send(null);
}


function getCommentsCaptchaCheck() {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		if (resp == 'true') {
    			document.getElementById('articleResponeForm').submit();
    		} else {
    			lightBoxaddContent(resp);
    		}
    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=addcomment");
	xmlhttp.send(null);
}

function verifyCommentsCaptcha(captcha) {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		if (resp == 'true') {
    			document.getElementById('articleResponeForm').submit();
    		} else {
    			document.getElementById('captchaError').innerHTML = "De tekens zijn onjuist!";
    		}
    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=verifycaptcha&code=" + captcha);
	xmlhttp.send(null);
}


function checkEmail(email) {
	var filter = RegExp("([a-z0-9_.-]+)@(([a-z0-9-\.]+)\.)*([a-z0-9\-]+)\.([a-z0-9]{2,4})$");

    return filter.test(email);

	if (!filter.test(email)) {
		return false;
	} else {
		return true;
	}
}


function showqrequired() {
	for(i=1;i<10;i++) {
		if (document.getElementById('mainQuestion' + i)) {
			obj = document.getElementById('mainQuestion' + i);
			if (obj.getAttribute("required") == 'false') {
				obj.style.display = 'block';	
			}
		}
	}
}

function hideqrequired() {
	for(i=1;i<10;i++) {
		if (document.getElementById('mainQuestion' + i)) {
			obj = document.getElementById('mainQuestion' + i);
			if (obj.getAttribute("required") == 'false') {
				obj.style.display = 'none';	
			}
		}
	}
}




function verifyQuestion(goback) {
	//qform =document.getElementById('questionForm');
	totalquestions = 0;
	for(i=0;i<10;i++) {
		if (document.getElementById('mainQuestion' + i)) {
			totalquestions++;
		}
	}
	
	gobackval = goback;

	for(y=0;y<totalquestions;y++) {
		qform = document.getElementById('mainQuestion' + y);
		qinputs = qform.getElementsByTagName("input");
		fdata = "";
		chk_radio = false;
		chk_radio_check = true;
		chk_radio_checked = false;
		for(icnt=0;icnt<qinputs.length;icnt++) {
	
			if (qinputs[icnt].getAttribute("validate") != '') {
	
				switch(qinputs[icnt].getAttribute("validate")) {
					
					case "int":
						if (qinputs[icnt].getAttribute("required") == 'true') {
							chk_radio_check = false;
							if (qinputs[icnt].value == '' && gobackval == 'false') {
								questionError('Er is niets ingevuld');
								qinputs[icnt].style.borderColor = 'red';
								return false;	
							}
							
							if (!IsNumeric(qinputs[icnt].value)) {
								questionError('Alleen cijfers zijn toegestaan');
								qinputs[icnt].style.borderColor = 'red';
								return false;	
							}
						}
						fdata += "&" + qinputs[icnt].name + "=" + qinputs[icnt].value;
					break;
					
					case "date":
						if (qinputs[icnt].getAttribute("required") == 'true') {
							chk_radio_check = false;
							if (qinputs[icnt].value == '' && gobackval == 'false') {
								questionError('Er is niets ingevuld');
								qinputs[icnt].style.borderColor = 'red';
								return false;	
							}
							
							if (gobackval == 'false' && !ValidateDate(qinputs[icnt].value,document.getElementById('questionError'))) {
								qinputs[icnt].style.borderColor = 'red';
								return false;	
							}
						}
						fdata += "&" + qinputs[icnt].name + "=" + qinputs[icnt].value;
					break;					
					
					
					
					case "string":
						if (qinputs[icnt].getAttribute("required") == 'true') {
							chk_radio_check = false;
							if (qinputs[icnt].value == '') {
								qinputs[icnt].style.borderColor = 'red';
								questionError('Er is niets ingevuld');
								return false;	
							}
						}
						fdata += "&" + qinputs[icnt].name + "=" + qinputs[icnt].value;
					break;
					
					case "radio":
						if (qinputs[icnt].getAttribute("required") == 'true') {
							chk_radio = true;
						}
							if (qinputs[icnt].checked) {
								fdata += "&" + qinputs[icnt].name + "=" + qinputs[icnt].value;
								if (qinputs[icnt].getAttribute("required") == 'true') {
									chk_radio_checked = true;
								}
							}
						
					break;
					
					default:
						fdata += "&" + qinputs[icnt].name + "=" + qinputs[icnt].value;
					break;
					
				}
			}
		}
		if (chk_radio_check && gobackval == 'false') {
				if (chk_radio && (!chk_radio_checked) ) {
					questionError('Er is niets geselecteerd');
					return false;	
				}
		}
		
		
		xmlhttp5[y] = new getXMLHTTP();
		if (y == (totalquestions - 1)) {
			usedxmlhttpindex = y;
		 	xmlhttp5[y].onreadystatechange = questionOnReady;
	    }
	    
		q_questionnr = document.getElementById('q_questionnr').value;
		q_questionstotal = document.getElementById('q_totalquestions').value;
		q_goback = goback;
	 	//alert("/ajax/?action=sendquestion" + fdata + "&multiquestion=" + y + "&total=" + totalquestions + "&goback=" + goback);
	 	xmlhttp5[y].open( "GET", "/ajax/?action=sendquestion" + fdata + "&multiquestion=" + y + "&total=" + totalquestions + "&goback=" + goback );
		
		xmlhttp5[y].send(null);	
	}
	//alert(fdata);	
}


			
			
function questionOnReady(){
y = usedxmlhttpindex;
	if ( xmlhttp5[y].readyState == 4 ) {
		resp = xmlhttp5[y].responseText;
		if (resp.substring(0,7) == 'nothing') {
			surl = String(top.location);
			//if (surl.indexOf("_invullen") == -1 && q_goback == 'false') {
			//	showNormalLightbox(document.body,'lightbox','300','300');
			//} else {
				if (q_questionnr == q_questionstotal && q_goback == 'false') {
					showNormalLightbox(document.body,'lightbox','300','300');
				}	
			//}
			
			document.getElementById('item_' + resp.substring(9)).className = 'itemGreenBar tips';
			document.getElementById('questionDiv').innerHTML = '';
			updateProfileBlock();
	
			
			
			
			
			question_next();
			surl = String(top.location);
			
			//if (surl.indexOf("_invullen") == -1 && q_goback == 'false') {
				//alert('test');
			//	location.replace('/overzicht/');
				//top.location.replace(surl.replace("_invullen",""));
			//} else {
				if (q_questionnr == q_questionstotal && q_goback == 'false') {
					location.replace('/overzicht/');
				}
				
			//}

		} else {
    		if (resp == 'false') {
    			questionError('Er is een onbekende fout opgetreden');
    		} else {
    			document.getElementById('questionDiv').innerHTML = resp;	
    			updateProfileBlock();
    		}
    	}
	}
}

function questionError(err) {
	document.getElementById('questionError').innerHTML = err
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
       {
         IsNumber = false;
       }
    }
   return IsNumber;
}




function updateProfileBlock() {
	xmlhttp9 = new getXMLHTTP();
 	xmlhttp9.onreadystatechange = function( ){
    	if ( xmlhttp9.readyState == 4 ) {
    		resp = xmlhttp9.responseText;
    		document.getElementById('profileGauge').innerHTML = resp;
    	}
    }
    
 	xmlhttp9.open( "GET", "/ajax/?action=getProfileBlock");
	xmlhttp9.send(null);
}


function userLogout() {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		top.location.replace('/');
    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=loggout");
	xmlhttp.send(null);
}


function checkAndSubmit()
{

    TForm = findForm($('emailadres'));

    formCheckNotEmpty($('emailadres'), 'name', 'Email niet ingevoerd');
    TForm['emailadres'].style.border = '1px white solid';

    if (TForm['kenteken_value'].value == '')
    {
        $('kenteken').style.border = '1px red solid';
        validForm.licensePlate = false;
    }
    else
    {
        $('kenteken').style.border = 'none';
        validForm.licensePlate = true;
    }

    formCheckEmail($('emailadres'));

    if (TForm['agreeCheck'].checked !== true)
    {
        $('checklabel').style.color = 'red';
        validForm.termsAgree = false;
    }
    else
    {
        $('checklabel').style.color = 'white';
        validForm.termsAgree = true;
    }

    if (validForm.emailaddress && validForm.termsAgree && validForm.licensePlate)
    {
        TForm.submit();
    }

}


function checkAndSubmitPublic()
{

    TForm = findForm($('emailadres'));

    formCheckNotEmpty($('emailadres'), 'name', 'Email niet ingevoerd');
    TForm['emailadres'].style.border = '1px white solid';

    //if (TForm['kenteken_value1'].value == '' || TForm['kenteken_value2'].value == '' || TForm['kenteken_value3'].value == '')
    if (TForm['kenteken_value'].value == '')
    {
        $('kenteken').style.border = '1px red solid';
        validForm.licensePlate = false;
    }
    else
    {
        $('kenteken').style.border = 'none';
        validForm.licensePlate = true;
    }

    formCheckEmail($('emailadres'));

    if (TForm['agreeCheck'].checked !== true)
    {
        $('checklabel').style.color = 'red';
        validForm.termsAgree = false;
    }
    else
    {
        $('checklabel').style.color = '#484848';
        validForm.termsAgree = true;
    }

    if (validForm.emailaddress && validForm.termsAgree && validForm.licensePlate)
    {
        TForm.submit();
    }

}
function formCheckEmail(obj)
{
    formErrors.getForm(findForm(obj));

    if (typeof obj == 'undefined')
    {
        obj = this;
    }

    
    if (obj.value.length < 1)
    {
        formErrors.setErrorState(obj.id, 'Email adres niet ingevuld');
        validForm.emailaddress = false;
    }
    else
    {
        if (!checkEmail(obj.value))
        {
            formErrors.setErrorState(obj.id, 'Email adres niet juist');
            validForm.emailaddress = false;
        }
        else
        {
            formErrors.clearErrorState(obj.id);
            validForm.emailaddress = true;
        }
    }
}

/**
 * Get element - first try getElementByName, then by name
 *
 * @var string name
 */
function $(name)
{
    var object = false;

    

    if (document.getElementById(name))
    {
        
        object = document.getElementById(name);
    }
    else
    {
        var objects = document.getElementsByName(name);
        if (objects.length > 0)
        {
            object = objects[0];
        }
    }
    return object;
}

function formCheckNotEmpty(obj, formpart, msg)
{

    formErrors.getForm(findForm(obj).id);
    
    var name = obj.id;

    if (obj.value.length < 1 || checkEmail(obj.value))
    {
        formErrors.setErrorState(name, msg);
        validForm[formpart] = false;
    }
    else
    {
        formErrors.clearErrorState(name);
        validForm[formpart] = true;
    }
}

function findForm(obj)
{
    while (obj !== null && typeof obj != 'undefined' && obj.tagName.toLowerCase() != 'form')
    {
        obj = obj.parentNode;
    }

    return obj;
}

function formAccountCheck()
{

    var TForm = formErrors.getForm('accountform');

//    formCheckNotEmpty($('membername'), 'name', 'Naam niet ingevoerd');
//    formCheckNotEmpty(this, 'address', 'Adres niet ingevoerd');
//    formCheckNotEmpty(this, 'addressNo', 'Huisnummer niet ingevoerd');
//    formCheckNotEmpty($('memberpostalcode'), 'postalCode', 'Postcode niet ingevoerd');
//    formCheckNotEmpty(this, 'city', 'Plaats niet ingevoerd');
//    formCheckNotEmpty($('membercity'), 'city', 'Plaats niet ingevoerd');
    formCheckEmail($('memberemail'));

    var result =(true
        && validForm.emailaddress
//        && validForm.name
//      && validForm.address
//      && validForm.addressno
//        && validForm.postalCode
//      &&  validForm.city
    );

    return result;
}

var validForm = {
    emailaddress: false,
    termsAgree: false,
    licensePlate: false,
    name: false,
    address: false,
    addressNo: false,
    postalCode: false,
    city: false,
    province: false,
    phoneNo: false
}

var registrationForm = {
    codeIsValid: false,
    userExists: true,
    passwordMatch: false
}



function checkRegistrationForm()
{
	if (document.getElementById('regkm').value == '') {
		document.getElementById('kmcheckerror').innerHTML = 'Niet ingevuld';
		return false;
	}
	


 	if (document.getElementById('regkmyear').value == '') {
		document.getElementById('kmyearcheckerror').innerHTML = 'Niet ingevuld';
		return false;
	}

 	if (document.getElementById('regzipcode').value == '') {
		document.getElementById('zipcodecheckerror').innerHTML = 'Niet ingevuld';
		return false;
	}
		 
	if (!postCodeCheck(document.getElementById('regzipcode'))) {
		document.getElementById('zipcodecheckerror').innerHTML = 'Niet juist ingevuld';
		return false;
	}
	
    if (!registrationForm.userExists && registrationForm.passwordMatch) {
    	//captchaCheck(true);	
    	registrationForm.codeIsValid = true;
    	document.getElementById('registreerform').submit();
    }
}

function checkPasswordForm()
{
    matchPassword();

    return (registrationForm.passwordMatch);
}

function captchaCheck(submitform)
{
    var TForm = formErrors.getForm(findForm($('passworderror')));

    if (TForm['captchacode'].value.length == 0)
    {
        registrationForm.codeIsValid = false;
        formErrors.setErrorState('captchacode', 'Code niet ingevuld');
        return;
    }

    xmlhttp = new getXMLHTTP();
    xmlhttp.onreadystatechange = function( ){
        if ( xmlhttp.readyState == 4 ) {
            var TForm = document.getElementById('registreerform');
            resp = xmlhttp.responseText;
            if (resp == 'false')
            {
               registrationForm.codeIsValid = false;
               formErrors.setErrorState('captchacode', 'Controleer code');
            }
            else
            {
                registrationForm.codeIsValid = true;
                formErrors.clearErrorState('captchacode');
            	if (submitform) {
            		document.getElementById('registreerform').submit();
            	}

            }
        }
    }
    xmlhttp.open( "GET", "/ajax/?action=verifycaptcha&code=" + TForm['captchacode'].value + '&r=' + microtime());
    xmlhttp.send(null);
}

function userExistsCheck()
{

    var TForm = formErrors.getForm(findForm($('passworderror')));

    if (TForm['username'].value.length == 0)
    {
        formErrors.setErrorState('username', 'Gebruikersnaam niet ingevuld');
        registrationForm.userExists = true;
        return;
    }

    xmlhttp = new getXMLHTTP();
    xmlhttp.onreadystatechange = function( ){
        if ( xmlhttp.readyState == 4 ) {
            resp = xmlhttp.responseText;
            if (resp == 'exists')
            {
               registrationForm.userExists = true;
               formErrors.setErrorState('username', 'Gebruikersnaam bestaat al');
            }
            else
            {
                registrationForm.userExists = false;
                formErrors.clearErrorState('username');
            }
        }
    }
    xmlhttp.open( "GET", "/ajax/?action=checkusername&username=" + TForm['username'].value + '&r=' + microtime());
    xmlhttp.send(null);
}


function showHideQuestion() {
	obj = document.getElementById('questions_div');
	if (obj.style.display == 'none') {
		obj.style.display = 'block';
		document.getElementById('showhidequestionlink').innerHTML = 'Verberg je antwoorden';
		showHideQuestionAjax('show');
	} else {
		obj.style.display = 'none';
		document.getElementById('showhidequestionlink').innerHTML = 'Toon je antwoorden';
		showHideQuestionAjax('hide');
	}
}

function showHideQuestionAjax(act) {
	xmlhttp6 = new getXMLHTTP();
 	xmlhttp6.open( "GET", "/ajax/?action=showhidequestion&subaction=" + act);
	xmlhttp6.send(null);		
}


function question_prev() {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		if (resp.substring(0,7) == 'nothing') {
				document.getElementById('questionDiv').innerHTML = resp;	
    		} else {
	    		if (resp == 'false') {
	    			questionError('Er is een onbekende fout opgetreden');
	    		} else {
	    			document.getElementById('questionDiv').innerHTML = resp;	
	    		}
	    	}
    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=prevquestion");
	xmlhttp.send(null);		
}

function question_next() {
	xmlhttp = new getXMLHTTP();
 	xmlhttp.onreadystatechange = function( ){
    	if ( xmlhttp.readyState == 4 ) {
    		resp = xmlhttp.responseText;
    		if (resp.substring(0,7) == 'nothing') {
				document.getElementById('questionDiv').innerHTML = resp;	
    		} else {
	    		if (resp == 'false') {
	    			questionError('Er is een onbekende fout opgetreden');
	    		} else {
	    			document.getElementById('questionDiv').innerHTML = resp;	
	    		}
	    	}
    	}
    }
    
 	xmlhttp.open( "GET", "/ajax/?action=nextquestion");
	xmlhttp.send(null);		
}

function matchPassword()
{
    var TForm =  formErrors.getForm(findForm($('passworderror')));

if (TForm['password'].value == '' || TForm['passwordcheck'].value == '') {
	return false;	
}

//    document.getElementById('passwordcheckerror').innerHTML = '';
    
    if (TForm['password'].value.length == 0)
    {
        formErrors.setErrorState('password', 'Wachtwoord niet ingevuld');
        registrationForm.passwordMatch = false;
        return;
    }
    else
    {
        if (TForm['password'].value != TForm['passwordcheck'].value)
        {
            formErrors.clearErrorState('password');
            formErrors.setErrorState('passwordcheck', 'Wachtwoorden komen niet overeen');
            registrationForm.passwordMatch = false;
        }
        else
        {
            formErrors.clearErrorState('password');
            formErrors.clearErrorState('passwordcheck');

            registrationForm.passwordMatch = true;
        }
    }
}

var formErrors = {
    TForm: null,
    element: {},
    setErrorState: function(name, msg)
    {
        this.getForm();

        if (typeof this.element[name] == 'undefined')
        {
            this.element[name] = {
                border: this.TForm[name].style.border,
                padding: this.TForm[name].style.padding,
                margin: this.TForm[name].style.margin
            }
        }

        
        if (document.getElementById(name + 'error'))
        {
            document.getElementById(name + 'error').innerHTML = msg;
        }

        this.TForm[name].style.borderColor = 'red';
        this.TForm[name].style.borderStyle = 'solid';
    },

    clearErrorState: function(name)
    {
        this.getForm();

        if (typeof this.element[name] != 'undefined')
        {
            this.TForm[name].style.border = this.element[name].border;
            this.TForm[name].style.padding = this.element[name].padding;
            this.TForm[name].style.margin = this.element[name].margin;
        }

        if (document.getElementById(name + 'error'))
        {
            document.getElementById(name + 'error').innerHTML = '';
        }
    },

    getForm: function(formId)
    {
        if (typeof formId == 'object')
        {
            this.TForm = formId;
            return this.TForm;
        }

        if (this.TForm == null)
        {
            this.TForm = document.getElementById(formId);
            return this.TForm;
        }
    }

}


function KeyEnter(event) {
if ((event.which && event.which == 13) ||  (event.keyCode && event.keyCode == 13))
    {
    	return true;
    } else {
    	return false;
    }
}


function ribank() {
	showNormalLightbox(document.body,'Lb','750','420');
	xmlhttp = new getXMLHTTP();
    xmlhttp.onreadystatechange = function( ){
        if ( xmlhttp.readyState == 4 ) {
        	lightBoxaddContent(xmlhttp.responseText);
        }
    }
    xmlhttp.open( "GET", "/ajax/?action=ribank");
	xmlhttp.send(null);		
}

function newsletterSubmit() {

	nemail = document.getElementById('newletteremail').value;
	showNormalLightbox(document.body,'Lb','300','300');
 	xmlhttp = new getXMLHTTP();
    xmlhttp.onreadystatechange = function( ){
        if ( xmlhttp.readyState == 4 ) {
        	lightBoxaddContent(xmlhttp.responseText);
        }
    }
    xmlhttp.open( "GET", "/ajax/?action=newsletter&email=" + nemail);
	xmlhttp.send(null);		
}

var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr,errorObj){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		errorObj.innerHTML = "Het formaat moet dd-mm-jjjj zijn";
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		errorObj.innerHTML = "De maand is niet juist ingevuld";
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		errorObj.innerHTML = "Dag is niet juist ingevuld";
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		errorObj.innerHTML = "Gebruik een jaartal met 4 getallen van "+minYear+" tot "+maxYear;
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		errorObj.innerHTML = "Datum is niet juist ingevuld";
		return false
	}
return true
}

newsletterclick = false;
function newsletterClick(obj) {
	if (!newsletterclick) {
		obj.style.fontStyle = 'normal';
		obj.style.color = '#333333';
		obj.value = '';
	}
	newsletterclick = true;
}

function ValidateDate(val,errorobj){
	
	if (isDate(val,errorobj)==false){
		return false;
	}
    return true;
}


