// Make sure the console is open before trying to print to it.
if(!window.console) {
	var console = {};
	console.log = function() {};
}

jQuery(document).ready(function($) {
	
	var max_height = 175;
	var read_more_button, show_less_button;
	$('.news_item_important, .news_item').each(function() {

		// If the content is bigger than the box, add a "read more"" button
		if($(this).attr('scrollHeight') > max_height) {
			$(this).prepend("<p class='read-more'>Read More &raquo;</p>");
		}
	});
	
	// Read more/Show less functionality 
	$('.read-more').live('click', function() {
		$('#shadow-box').fadeIn('medium');
		$(this).parent().addClass('shadow-boxed')
						.animate({ height: $(this).parent().attr('scrollHeight') + 'px' })
						.prepend("<p class='show-less'>Close [X]</p>");
		$(this).remove();
		console.log('Done expanding');
	});
	
	$('.show-less').live('click', function() {
		
		$(this).parent().removeClass('shadow-boxed')
						.animate({ height: $(this).parent().css('min-height') })
						.prepend("<p class='read-more'>Read More &raquo;</p>");
		$('#shadow-box').fadeOut('medium');
		$(this).remove();
	});

});
