$(document).ready(function(){
	select_first();
	function select_first(){
		if($('#headerknoppen .active').length == 0){
			$('.headerknop').first().addClass('active');
			$(".tekstvlak").first().addClass("active");
			
		}
		
	}
function hide_all(){
	$("#headerimg img").fadeOut('fast');
	$("#headerinfo div").removeClass("active");
	$("#headerknoppen div").removeClass("active");
}

var header_count = 1;
				var showFirst = function(){
			         toShow = "header_1";
                     $("#maps #light").fadeOut('slow');
                     $("#licht_background_overlay").fadeOut('slow');
                    $("#maps").find("#"+toShow).stop(true, true).fadeIn('slow');
                    $("#map_info").find("#"+toShow).stop(true, true).fadeIn('normal');
					$('#map_modes').find("#"+toShow).addClass("active");
				}
				var cycleHeaders = function(){
					var element = $("#headerinfo div:first");
					for(var i=0; i < header_count; i++){
						element = element.next();
					}
					var toShow  = element.attr('id');
					if(header_count == 3){
						header_count=0;
					}else{
						header_count++;
					}
				 	changeHeader(toShow);
				};
				
				var changeHeader = function(toShow){
					
					if($("#headerimg").find("#"+toShow).css('display')=='none'){
						
						hide_all();
						$("#headerimg").find("#"+toShow).stop(true, true).fadeIn('fast');
					}
					
                   // $("#headeringo").find("#"+toShow).stop(true, true).fadeIn('normal');
					$('.headerknop').removeClass('active');
					$('.tekstvlak').removeClass('active');
					$('#headerknoppen').find("#"+toShow).addClass("active");
					$("#headerinfo").find("#"+toShow).addClass("active");
				}
				
				//Bij mouseOver veranderen van header.
				$("#headerknoppen div").mouseover(function(){
					var toShow = $(this).attr('id');
					changeHeader(toShow);
				});
				
				//Automatisch veranderen
              //  $("#map_modes").oneTime(2000, showFirst );
				$("#headerknoppen").everyTime(7000, cycleHeaders );
				
				//Stoppen bij MouseOver
				$("#headerknoppen").mouseover(function(){
				 	$(this).stopTime();
				});
				//Weer starten bij MouseOut
				$("#headerknoppen").mouseout(function() {
					$(this).everyTime(7000, cycleHeaders );
				});
				
	});

