function showlanguages()	{
	var morelanguages = document.getElementById('morelanguages');
	morelanguages.style.display = 'block';
}

function hidelanguages()	{
	var morelanguages = document.getElementById('morelanguages');
	morelanguages.style.display = 'none';
}

function check_inpage_login(form)    {
    allInput=document.getElementById('inpage_login').getElementsByTagName('INPUT');
    result = true;
    for (i=0; i < allInput.length; i++) {
        
        box = allInput[i];
        if ( box.className.search(/required/) > -1 ) {
            if (!box.value)    {
                box.style.backgroundColor='#FFAAAC';
                result = false;
								
            }
        }
    }
    if (result == false)    {
        return false;
    }
}

function check_fields(form)    {
	allInput=form.getElementsByTagName('INPUT');
	result = true;
	firstbox = 0;
	
	/* check the select boxes */
	allSelect=form.getElementsByTagName('SELECT');
	for (i=0; i < allSelect.length; i++) {
		select = allSelect[i];
		if ( select.className.search(/required/) > -1 ) {
			if (select.value == "")	{
				select.style.backgroundColor='#FFAAAC';	
				result = false;
			}
		}
	}
	
	for (i=0; i < allInput.length; i++) {

		
		box = allInput[i];
		if ( box.className.search(/required/) > -1 ) {
			
			if (box.type == 'radio')	{
				radios = document.getElementsByName(box.name);
				radioresult = false;
				for (j=0; j < radios.length; j++) {
					if (radios[j].checked)	{
						// geen lege radio gevonden
						radioresult = true;
					}
				}
				if (radioresult == false)	{
					result = false;
					box.parentNode.style.backgroundColor='#FFAAAC';
				}
				
			} else if (!box.value)    {
				box.style.backgroundColor='#FFAAAC';
				result = false;
				firstbox += 1;
				if (firstbox == 1)	box.focus();
			}
		}
		
		//minimum of 6 characters
		if ( box.className.search(/min6/) > -1 ) {
			if (box.value.length < 6)	{
				box.style.backgroundColor='#FFAAAC';						
				result = false;
				firstbox += 1;
				if (firstbox == 1)	box.focus();
			}
		}
		
		// check email
		if ( box.className.search(/email/) > -1 ) {
			if (checkemail(box) == false)	{
				box.style.backgroundColor='#FFAAAC';
				result = false;
				firstbox += 1;
				if (firstbox == 1)	box.focus();
			}
		}
		
		
		if (box.type == 'submit')	{
			submitbox = box;
		}
	}
	
	if (result == false)    {
			return false;
	} else {
		submitbox.disabled = true;

	}
}

function wordWit(dit)	{
	dit.style.backgroundColor='#EEFFFF';
}

function wordWitRadio(dit)	{
	dit.parentNode.style.backgroundColor='transparent';
}

function checkemail(box){
	var str=box.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))	{
	} else {
		return false;
	}
	return true;
}

$(function() {

    
    $("input[name='login']")
    .keyup(function(){
        
        
        
        $('#usernameResultfree').hide();
        $('#usernameResulttaken').hide();
        
        setTimeout(function(){
        
            if ( ( $('#login').val().length ) > 5 )   {
                
                //$("input[name='login']")
                
                
                
                    $('#usernameLoading').show();
                    $.post("/check.php", {
                        username: $('#login').val()
                    }, function(response){
                        if (response == true)   {
                            $('#usernameResulttaken').hide();
                            $('#usernameLoading').hide();
                            $('#usernameResultfree').show();
                            
                            
                            
                        } else {
                            $('#usernameResultfree').hide();
                            $('#usernameLoading').hide();
                            $('#usernameResulttaken').show();
                            $('#usernameResultfree').hide();
                        }
                        /*$('#usernameResult').fadeOut();*/
                        //setTimeout("finishAjax('usernameResultfree', '"+escape(response)+"')", 400);
                    });
                    return false;
                    
                
              
              
              
            } else {
                //te kort
                $('#usernameResult').fadeOut();
            }
        }, 2000);
    });
});

function finishAjax(id, response) {
  $('#usernameLoading').hide();
  //$('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
} //finishAjax

/*
function displayOverlayMessage()	{
				$('#blackOverlay').fadeTo(1, 0.7);
				$('#blackBox').fadeTo(1, 1);
				
}
$(function() {
$(".hideoverlaymessage").click(function()	{
	if ($.post("/check.php", {"hideOverlayMessage": 'hidenow'}))	{
		$('#blackOverlay').hide();
		$('#blackBox').hide();
	}

});
});
*/
