$(document).ready(function(){
	$("#winkelmenu a").click(function(){
		var rel = $(this).attr("rel");
		$("#winkelmenu a span").removeClass('red');
		$(this).find("span").addClass('red');
		$("#winkeltekst div:visible").slideUp(function(){
			$("#" + rel).slideDown();
		});
	});
	$("#collectiesmenu ul li ul li").click(function(){
		var rel = $(this).attr("rel");
		$("#collectiesmenu ul li ul li").removeClass('current');
		$(this).addClass('current');
		$("#collectiestekst div:visible").slideUp('',function(){
			$("#" + rel).slideDown('');
		});
	});
	$("#collectiesmenu ul li span").not(".sub").click(function(){
		$("#collectiesmenu li span.red").removeClass("red");
		if($(this).next().is(':hidden')){
			$("#collectiesmenu li ul").slideUp();
			$(this).addClass("red").parent().find("ul").slideDown();
		}
		else{
			$("#collectiesmenu li ul").slideUp();
		}
	});	
	
	$('#winkel_background_relative img:first').fadeIn('normal',function(){
		setTimeout('fadeImagesW()',3000);
	});
	
	$('#collecties_background_relative img:first').fadeIn('normal',function(){
		setTimeout('fadeImagesC()',3000);
	});
	
	$('#openingstijden_background_relative img:first').fadeIn('normal',function(){
		setTimeout('fadeImagesO()',3000);
	});
});

function fadeImagesW(){
	if ($('#winkel_background_relative img:last').is(':visible')) {
		$('#winkel_background_relative img:visible').fadeOut('slow', function(){
			$('#winkel_background_relative img:first').fadeIn();
			setTimeout('fadeImagesW()',5000);
		});
	}
	else {
		$('#winkel_background_relative img:visible').fadeOut('slow', function(){
			$(this).next().fadeIn();
			setTimeout('fadeImagesW()',5000);
		});
	}
}

function fadeImagesC(){
	if ($('#collecties_background_relative img:last').is(':visible')) {
		$('#collecties_background_relative img:visible').fadeOut('slow', function(){
			$('#collecties_background_relative img:first').fadeIn();
			setTimeout('fadeImagesC()',5000);
		});
	}
	else {
		$('#collecties_background_relative img:visible').fadeOut('slow', function(){
			$(this).next().fadeIn();
			setTimeout('fadeImagesC()',5000);
		});
	}
}

function fadeImagesO(){
	if ($('#openingstijden_background_relative img:last').is(':visible')) {
		$('#openingstijden_background_relative img:visible').fadeOut('slow', function(){
			$('#openingstijden_background_relative img:first').fadeIn();
			setTimeout('fadeImagesO()',5000);
		});
	}
	else {
		$('#openingstijden_background_relative img:visible').fadeOut('slow', function(){
			$(this).next().fadeIn();
			setTimeout('fadeImagesO()',5000);
		});
	}
}

function loadHomepage(val){
	if(val==null){
		$("#content.loadscreen").fadeIn("slow");
		setTimeout("loadHomepage('fade')",3000);
	}
	else if(val=='fade'){
		$("#content.loadscreen").fadeOut(function(){
			$(this).remove();
			$(".content_background").hide();
			$("#content_co_").css({"display":"none"}).fadeIn("slow",function(){
				$(".content_background").show();
			});
			$("#sidebar ul li a img:first").attr("src","img/menu_1_hover.png");
		})
		$("#winkeltekst div:first").slideDown();
	}
	else if(val=='sudden'){
		$("#content.loadscreen").remove();
		$("#content_co_").show();
		$("#sidebar ul li a img:first").attr("src","img/menu_1_hover.png");
		$("#winkeltekst div:first").slideDown();
	}
}

