$(document).ready(function(){
	/////INIT/////
	checkForImageLink();
	//////EVENTS/////
	if($.browser.msie && $.browser.version < 8){
		$(".entry img").load(
			function(){
				checkImages($(this));
			}
		)
	
	}
	/////FUNCTIONS/////
	function getPadding(side){
		padding = $(".entry:first").css("padding"+side);
		return padding==undefined ? 0 : padding;
	}
	
	function getWidth(){
		width = $(".entry:first").width();
		width -=  parseInt(getPadding("Left")) + parseInt(getPadding("Right"));
		return width;
	}
	function checkImages(item){
		item.hide()
		max_width = getWidth();
		if(item.width() > max_width)item.width(max_width);
		item.show();
		$('.leaderboard').hide().show();
	}
	function checkForImageLink(){
		$('.entry a').each(
			function(){
				imageexists = ($(this).find("img").length != 0);
				links_to_img = ($(this).attr("href").search(/(jpg)|(gif)/i) > 0)
				if(imageexists && links_to_img)$(this).lightbox();
			}
		);
	}
});

