/**
 * Subpagina
 */
var HEADER_HEIGHT = 0;
var FOOTER_HEIGHT = 0;

 
$(document).ready(function(){ 
 
 	HEADER_HEIGHT = $('#header').outerHeight();
 	$("#header form input").keydown(function(event){
      switch (event.keyCode) {
        case 13:
            $("#header form").submit();   
          break;
      }  
 	});
 	if($("#navigation").length > 0){
 		$("#navigation li:last").addClass("active");
 	}
 	vpro.utils.onBodyResize(onResize); 
 	window.onresize();
});
 
function onResize(dimensions){
	
	if($("body").is("#winkel")){
		
		remW = dimensions.innerWidth;
		if(document.documentElement.clientWidth){
			var withoutScroll = document.documentElement.clientWidth;
			if(withoutScroll < remW){
				remW = withoutScroll;
			}
		}
		
	}else{
		var contentWidth = $('#content').outerWidth();
		var remW = (dimensions.innerWidth > contentWidth)? dimensions.innerWidth : contentWidth;
		FOOTER_HEIGHT = $('#footer').outerHeight();
		
		var remH = dimensions.innerHeight - HEADER_HEIGHT - FOOTER_HEIGHT;
		var contentHeight = $('#content').outerHeight();
		if( contentHeight < remH){
			$('#content-wrapper').height(remH);
		}else{
			$('#content-wrapper').height(contentHeight);
		}	
	}
	
	if(dimensions.innerWidth > contentWidth){
		$('#footer,#header').removeAttr("style");
	}else{
		$('#footer,#header').width(remW);
	}
	
	if(!$("body").is(".node_zoeken,.node_programma-index,#winkel")){
		var blindWidth = Math.floor((dimensions.innerWidth / 6))-3;
		var tresholdSmall = 640;
		var tresholdMedium = 1080;
	}else{
		var blindWidth = Math.floor(((dimensions.innerWidth - 640) / 5))-3;
		var tresholdSmall = 1280;
		var tresholdMedium = 1520;
	}	
	
	if(remW <= tresholdSmall){
		$("body").removeClass("medium").addClass("small");
	}else if(remW <= tresholdMedium){
		$("body").removeClass("small").addClass("medium");
	}else{
		$("body").removeClass("medium").removeClass("small");
	}
	
	$("#header .blinds .blind").css("width", blindWidth);
}
