$(window).load(function() {
	
	var cHeightOrg = $(".container").height();
	var jScrollPaneContainerOrg = $(".jScrollPaneContainer").height();
	var jScrollPaneTrackOrg = $(".jScrollPaneTrack").height();
	var jScrollPaneDragOrg = $(".jScrollPaneDrag").height();
	var scrollpaneOrg = $(".scroll-pane").height();
	var actionOrg = parseInt($(".actions ul").css("padding-top").replace("px",""));
	
	function doResize() {
		
		//jHeight = wHeight - 225;
		//$(".container").height(wHeight - 25);
		//
		//$('#pane').jScrollPaneRemove();
		//$("#pane").css("height", jHeight + "px");
		//$('#pane').jScrollPane({scrollbarWidth:5});
		
		var wHeight = $(window).height();
		var cHeight = $(".container").height();
		if(wHeight < 590) {
			if(wHeight > 315) {
				$(".container").height(wHeight - 25);
				$(".jScrollPaneContainer").height(wHeight - 240);
				$(".jScrollPaneTrack").height(wHeight - 240);
				jpd = wHeight - 350;
				if(jpd < 25) jpd = 25; // minimal scroller height
				$(".jScrollPaneDrag").height(jpd);
				$(".scroll-pane").height(wHeight - 225);
				$(".actions ul").css("padding-top", (wHeight - actionOrg) - 280);
				$('#pane').jScrollPane();
			}
		} else {
			$(".container").height(cHeightOrg);
			$(".jScrollPaneContainer").height(jScrollPaneContainerOrg);
			$(".jScrollPaneTrack").height(jScrollPaneTrackOrg);
			$(".jScrollPaneDrag").height(jScrollPaneDragOrg);
			$(".scroll-pane").height(scrollpaneOrg);
			$(".actions ul").css("padding-top", actionOrg);
			$('#pane').jScrollPane();
		}
	}
	
	$(window).resize(function() {
		doResize();
	});
	
	doResize();
	
});

