$(document).ready(function(){
	
	fadeImage = 3;

	if($('#languageDiv .actief').html()=='english'){
		language='en';
	}else{
		language='nl';
	}

	$('.searchButton').click(function(){
		if(language=='en'){
			document.location = '/english/search?q='+$(this).parent().children('.searchTerm').val();
		}else{
			document.location = '/zoeken?q='+$(this).parent().children('.searchTerm').val();
		}
		
		return false;
	});
	
	$('.searchTerm').keypress(function(e){
		if(e.which == 13){
			if(language=='en'){
				document.location = '/english/search?q='+$(this).val();
			}else{
				document.location = '/zoeken?q='+$(this).val();
			}
		}
    });
	
	$('.nieuwsitem').hover(function(){
		$(this).children('.newsDate').css('color','#bababa');
	},function(){
		$(this).children('.newsDate').css('color','#e5e5e5');
	});
	
	setInterval("fader()",10000);
	
	//Inputform nieuwsbrief op focus stijl geven
	$('.emailN').focus(function(){
		$(this).val('');
		$(this).removeClass('notFocussed');
	});
	
	
	//Open-sollicitatie
	$('.example').live("focus", function(event) {
		$(this).val('');
		$(this).removeClass('example');
	});
	
	//Open-sollicitatie ingevuld
	$('#sollicitatieForm form').submit(function(){
		var fout = false;
		$('.verplicht').each(function(){
			if($(this).hasClass('example') || $(this).val().length<1){
				$(this).css('color','red');
				$(this).css('border-color','red');
				$(this).addClass('fout');
				fout = true;
			}
		});
		//Er zijn fouten geconstateerd in het formulier
		if(fout){
			return false;
		}
	});
	
	//Open-sollicitatie foute velden goedkeuren
	$('.fout').live("focus", function(event) {
		$(this).css('color','black')
		$(this).css('border-color','');
		$(this).removeClass('fout');
	});
	
});

function fader(){
	if(fadeImage==3){
		$('#image3').fadeOut(1000);
		fadeImage=2;
		return 0;
	}
	if(fadeImage==2){
		$('#image2').fadeOut(1000);
		fadeImage=1;
		return 0;
	}
	if(fadeImage==1){
		$('#image3').fadeIn(1000,function(){
			$('#image2').show();
		});
		fadeImage=3;
		return 0;
	}
}
