$(document).ready(function() {
	
	$(document).pngFix();
	$('#rechter-img').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: 	'130px',
		slide_timer_on: 	'yes',
		slide_ui_parent: 	'rechter-img',
		slide_ui_text:		'null',
		pause_button_id: 	'null',
		slide_nav_id:		'null'
	});
	
	// fade de afbeeldingen rechts onder de nieuwsberichten.
	$('#img-small').innerfade({
	speed: 1000,
	timeout: 5000,
	type: 'sequence',
	containerheight: 	'370px',
	slide_timer_on: 	'yes',
	slide_ui_parent: 	'img-small',
	slide_ui_text:		'null',
	pause_button_id: 	'null',
	slide_nav_id:		'null'
	});
	
	var hoofdstuk = $('#hoofdstuk').attr('value');
	var timer = 'yes';
	if(hoofdstuk == undefined) var hoofdstuk = 0;
	if(hoofdstuk == 20){
		timer = 'no';
	}
	
	if($('#img-big').attr('id') != undefined){
		// fade de afbeeldingen op de voorpagina
		$('#img-big').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: 	'130px',
		slide_timer_on: 	timer,
		slide_ui_parent: 	'img-big',
		slide_ui_text:		'null',
		pause_button_id: 	'null',
		slide_nav_id:		'switch_nummer'
		});
		
		$.setOptionsButtonEvent();
	    
		
		$("#next_button").click(function() {
			$.next('yes');
		});
		
		$("#prev_button").click(function() {
			$.prev('yes');
		});
		
		//verstop de knop bij het laden
		$('#image-switch').hide();
		
		//laat hem zien als je eroverheen gaat
		$('#img-big').mouseover(function(){$('#image-switch').show();});
		$('#image-switch').mouseover(function(){$('#image-switch').show();});
		
		//verstop hem weer als je van het plaatje af gaat.
		$('#img-big').mouseout(function(){$('#image-switch').hide();});
		$('#image-switch').mouseout(function(){$('#image-switch').hide();});
	}
		
	
	if($('#img-front').attr('id') != undefined){
		// fade de afbeeldingen op de voorpagina
		$('#img-front').innerfade({
		speed: 2000,
		timeout: 4000,
		type: 'sequence',
		containerheight: 	'130px',
		slide_timer_on: 	'yes',
		slide_ui_parent: 	'img-front',
		slide_ui_text:		'null',
		pause_button_id: 	'null',
		slide_nav_id:		'switch_nummer'
		});
		
		$("#next_button").click(function() {
			$.next('yes');
		});
		$("#prev_button").click(function() {
			$.prev('yes');
		});
		
		//verstop de knop bij het laden
		$('#image-switch').hide();
		
		//laat hem zien als je eroverheen gaat
		$('#img-front').mouseover(function(){$('#image-switch').show();});
		$('#image-switch').mouseover(function(){$('#image-switch').show();});
		
		//verstop hem weer als je van het plaatje af gaat.
		$('#img-front').mouseout(function(){$('#image-switch').hide();});
		$('#image-switch').mouseout(function(){$('#image-switch').hide();});
		
	}
	
	$('#cnt .gridlink').hover(
		function() {
			$(this).children('span').children('img').attr('src',$(this).children('span').children('img').attr('src').replace("-off","-blauwon"));
		},
		function() {
			$(this).children('span').children('img').attr('src',$(this).children('span').children('img').attr('src').replace("-blauwon","-off"));
		}
	);
	// initialise plugins
	$('#mainmenu').superfish();
	
	$('#mainmenu a').each(function(){
		if($(this).is('.negeren')){
			var parent = $(this);
			var a = 0;
			while(a<1){
				if(parent.children(':first').attr('id') != 'wrap'){
					parent.parent().parent().siblings(':first').addClass('negeren');
				if(parent.parent().parent().siblings(':first').children('img').attr('src') != undefined){
					parent.parent().parent().siblings(':first').children('img').attr('src',parent.parent().parent().siblings(':first').children('img').attr('src').replace("-off","-on"));
					//stop hier, want met het plaatje is altijd het hoogste niveau.
					a++;
				}
				parent = parent.parent().parent();
				}else{
					a++;
				}
				
			}
			//alert($(this).attr('class'));
		}
	});
	
	$('#mainmenu li').hover(
		/*function() {
			if($(this).children('a').children('div not:(.active)').attr('innerHTML') != undefined){
				$(this).children('a').children('div').css("background-image",$(this).children('a').children('div').css("background-image").replace("-off","-on"));
			}
			if($(this).children('a not:(.active)').children('img').attr('src') != undefined){
				$(this).children('a').children('img').attr('src',$(this).children('a').children('img').attr('src').replace("-off","-on"));
				$(this).children('a').addClass('hover');
			}
		},
		function() {
			if($(this).children('a').children('div not:(.active)').attr('innerHTML') != undefined){
				$(this).children('a').children('div').css("background-image",$(this).children('a').children('div').css("background-image").replace("-on","-off"));
			}
			if($(this).children('a not:(.active)').children('img').attr('src') != undefined){
				$(this).children('a').children('img').attr('src',$(this).children('a').children('img').attr('src').replace("-on","-off"));
				$(this).children('a').removeClass('hover');
			}
		}*/
		function() {
			if($(this).children('a').children('div').attr('innerHTML') != undefined){
				if(!$(this).children('a').children('div').hasClass('negeren')){
					$(this).children('a').children('div').css("background-image",$(this).children('a').children('div').css("background-image").replace("-off","-on"));
				}
			}
			if($(this).children('a').children('img').attr('src') != undefined){
				if(!$(this).children('a').hasClass('negeren')){
					$(this).children('a').children('img').attr('src',$(this).children('a').children('img').attr('src').replace("-off","-on"));
					$(this).children('a').addClass('hover');
				}
			}
		},
		function() {
			if($(this).children('a').children('div').attr('innerHTML') != undefined){
				if(!$(this).children('a').children('div').hasClass('negeren')){
					$(this).children('a').children('div').css("background-image",$(this).children('a').children('div').css("background-image").replace("-on","-off"));
				}
			}
			if($(this).children('a').children('img').attr('src') != undefined){
				if(!$(this).children('a').hasClass('negeren')){
					$(this).children('a').children('img').attr('src',$(this).children('a').children('img').attr('src').replace("-on","-off"));
					$(this).children('a').removeClass('hover');
				}
			}
		}
	);
				
	$('#mainmenu li:.submenu').hover(
		function() { 
			var parent_id = $(this).attr('id').substring(4); 
			$(this).siblings().each(function(){
				if($(this).attr('id').substring(4) == parent_id){
					$(this).children('a').children('img').attr('src',$(this).children('a').children('img').attr('src').replace("-off","-on"));
					$(this).children('a').addClass('hover');
				}
				if($(this).attr('id').substring(4) != parent_id){
					if($(this).children('a').children('img').attr('src') != undefined){
					$(this).children('a').children('img').attr('src',$(this).children('a').children('img').attr('src').replace("-on","-off"));
					$(this).children('a').removeClass('hover');
					}
				}
			})},
		function() {  }
	);
	
});

