/**
 * FILENAME: budget.js
 * AUTHOR: Ashley Barrett (ashley.barret@rgroup.co.uk)
 * CREATED: 21/12/2009
 * COMMENTS: A javascript file reduce the size of the right hand planel, depending on the height of the left handpanel
 * */

$(function(){
	
	if($("#news")){
	
		var leftHeight = $("#left").height();
		var rightHeight = $("#right").height();
		var tablesHeight = 0;
		var hideCompletely = 1;
		
		$("#news table").each(function(){
			tablesHeight +=  $(this).height();
		})
		
		var rightHeightWithout = rightHeight - tablesHeight;
	
		$("#news table").each(function(){
			if((rightHeightWithout + $(this).height()) <= leftHeight){
				rightHeightWithout += $(this).height();
				hideCompletely = 0;
			}else{
				$(this).css("display", "none");
			}
		});
		
		//if there are no news hide the entire news bit so there is no heading with 0 news items.
		if (hideCompletely == 1){
			$("#news").css("display", "none");
		}
		
	}
});
