// JavaScript Document
$(document).ready(function() {
    setBackgroundImageBottom();
	alignNewsItems();
});


function setBackgroundImageBottom() {
	var windowHeight = $(window).height();	
	var containerHeight = $('.container').height();		
	//alert("WH: " + windowHeight + " DH: " + containerHeight);	
	if (windowHeight > containerHeight) {		
		$('.container').height(windowHeight);		
	}
}

function alignNewsItems() {
	
	var nMaxImageHeight = 0;
	
	// Calculate max position
	$(".features .content .cell img" ).each(function(){
											
		var pImagePosition = $(this).position();										
		nMaxImageHeight = Math.max(nMaxImageHeight, pImagePosition.top);						   
	});
	
	$(".features .content .cell img" ).each(function(){
											
		var pImagePosition = $(this).position();	
		var nDifference = nMaxImageHeight - pImagePosition.top;
		if (nDifference > 0) {
			$(this).css({"marginTop":nDifference});	
		}					   
	});
	
}
