$(document).ready(function(){
    //height correction:
    if($(document).height() > 500) {
    	
    	var nH = $(window).height();
    	
    	$("#container").css({"height":nH});
    	
    	//alert(nH + " " + $("#container").height() );
    }

    //only slide if more than 1 image
    if( $( "#headerContainer .csc-textpic-imagewrap dt img" )[1]){
       $('#headerContainer .csc-textpic-imagewrap').cycle({ 
          delay:  5000, 
          speed:  1000
       });
    };
  
    $( "#headerContainer .csc-textpic-imagewrap dt img" ).hover(function (e){
    	$( this ).css({"cursor":"pointer"});
    });
  
    //bind click to div.model
    $( "#headerContainer .csc-textpic-imagewrap dt img" ).click(function (e){

	var pagelink = $( this ).parent().parent().find("dd").html();
	pagelink = pagelink.replace("<BR>", "");
	pagelink = pagelink.replace("<br>", "");
	
	window.location.href = "http://www.kve.nl/" + pagelink;
    });
    
    
    $("li.news-list-item").click(function (e){
    	//$("li.news-list-item").removeClass("open");
	//set
	if ( $(this).hasClass("open") ){
		//reset
		$(this).removeClass("open");
		$(this).find("h3").css({
			"background-position" : "520px 2px"
		});
		$(this).find(".news-list-container ul").css({
			"display": "none"
		});
	} else {
		//reset
		$("li.news-list-item").removeClass("open");
		$("li.news-list-item h3").css({
			"background-position" : "520px 2px"
		});
		
		$("li.news-list-item").find(".news-list-container ul").css({
			"display": "none"
		});
		
		//set	
		$(this).find(".news-list-container ul").css({
			"display": "block"
		});
		$(this).addClass("open");
		$(this).find("h3").css({
			"background-position" : "520px -20px"
		});
	}
     });
});
