$(document).ready(function(){
	// Set max height for news_summary_text
	max_height = 65;  // This should be the same as height in css for news_summary_text
	
	// Hide 'Read Me' link for any news items that are only 1 line
	$('.news_summary').each(function() {
		news_summary_text = $(this).children('.news_summary_text');
		read_more = $(this).children('.read_more');
		nst_span = $(this).children('.news_summary_text').children('span');
		nst_height = $(nst_span).height();
		if (!$(news_summary_text).hasClass('has_download')) {
			if (nst_height<=max_height) {
				$(read_more).hide();
				$(news_summary_text).css('height',max_height+'px');
			}
		} else {
			$(news_summary_text).css('height','18px');
		}
	});
	
	// News story toggle
	$('.read_more').click(function() {
		news_summary = $(this).parent();
		news_summary_text = $(news_summary).children('.news_summary_text');
		read_more = $(news_summary).children('.read_more');
		nst_span = $(news_summary).children('.news_summary_text').children('span');
		nst_height = $(nst_span).height();
		nst_height = nst_height+4;
		
		$('.read_more').html('READ MORE');
		
		if (!$(news_summary_text).hasClass('open')) {
			$('.news_summary_text').each(function() {
				if ($(this).hasClass('open')) {
					$(this).css('height',max_height+'px');
				}
			});	
			$('.news_summary_text').removeClass('open');
			$(news_summary_text).addClass('open');
			$(news_summary_text).animate({height:nst_height+'px'});
			
			$(read_more).addClass('open');
			$(read_more).html('CLOSE');	
		} else {		
			$('.news_summary_text').removeClass('open');
			$(read_more).removeClass('open');		
			$(news_summary_text).animate({height:max_height+'px'});
		}		
	});
	
});
