$(document).ready(function(){

	// submit form on change selectbox
	$('form #kunstenaar, form #item').change(function () {
		$(this).parents('form').submit();
	});
		
	// uitgelicht
	var idBlockInt=1;
	var maxBlocks=Number( $("#uitgelicht_container .navigatie a:last").text() ) ;
	//alert(maxBlocks);
	var timeoutID;
	$("#uitgelicht_container .navigatie a").click(function(event){
		idBlockInt=Number($(this).text());	
		clearTimeout(timeoutID);
		showHomeItem();
		event.preventDefault();
		this.blur();
	});
	function showHomeItem(){
		var idBlock="uitL"+idBlockInt.toString();
		// zet de boxen uit en de nieuwe aan
		$(".uitgelichtbox").fadeOut("slow");
		$("#"+idBlock).fadeIn("slow");
		// set de juiste navigatie bolletje aan
		$("#uitgelicht_container .navigatie a").removeClass("active");
		//$("#uitgelicht .navigatie a:contains('"+idBlockInt+"')").addClass("active");
		$("#uitgelicht_container .navigatie a:contains('"+idBlockInt+"')").each(function (i){
        if ( $(this).text() == idBlockInt ){
          $(this).addClass("active");
        }
      });
      
		// 
		timeout();
	}
	function timeout(){
		timeoutID=setTimeout(function() { 
			idBlockInt++;
			if(idBlockInt > maxBlocks) idBlockInt=1;
			showHomeItem();
			//timeout();
			 }, 8000); 
	}
	if(maxBlocks > 1)	timeout();
	
	
	
	
	
	
	
	
	
	
	function setPageHeight(){
		if(!document.getElementById) return false;
		var elrm=	document.getElementById("main");
		var rmhgt=document.documentElement.clientHeight-(420);
		// hier moet nog iets met Math.max() main en dus wat main zou moeten worden.
		elrm.style.height=Math.max(rmhgt,(elrm.clientHeight-50))+"px";
		//elrm.style.height=(rmhgt)+"px";
		// alert(rmhgt);
	}
	//setPageHeight();
	/*
	setTimeout(function() {
        $('div.request').fadeOut();
    }, 5000); 
    */

});