jQuery(document).ready(function() {
	
	jQuery("div[id^='module-news-news_']").click(function()
	{
		var clickedTitleId = jQuery(this).attr('id');
		jQuery("div[id^='module-news-news_']").attr('class', 'module-news-newstitle');
		jQuery(this).attr('class','module-news-newstitle-on');
		
		jQuery("#module-news").stop().animate(
					{backgroundPosition:"(-160px 0px)"},
					"swing", function() {
						jQuery(this).css('background-image', 'url(' + jQuery('#' + clickedTitleId).attr('rel') + ')');
						jQuery(this).animate( {backgroundPosition:"(160px 0px)"}, "swing");
					});
		
		jQuery("#module-news-text").clearQueue();
		jQuery("#module-news-text").delay(350)
							  .animate({bottom : '-' + (jQuery(this).height() + 50) + 'px'}, 250, 'swing', function() { jQuery("#module-news-text div").html( jQuery("#" + clickedTitleId + "-content").html() ); })
							  .delay(50)
							  .animate({bottom : '0'}, 250, 'swing');
							  
							  //.animate({bottom : '-=' + jQuery(this).height() + ''}, 250, 'swing', function() { jQuery("#module-news-text div").html( jQuery("#" + clickedTitleId + "-content").html() ); })
							  //.animate({bottom : '+=' + jQuery(this).height() + ''}, 250, 'swing');
		
	});
	
	jQuery("#module-news-news_1").trigger('click');
	
});

jQuery(window).bind('load', function()
{
	jQuery("div[id^='module-news-news_']").each(function() {
		jQuery(document).append('<img src="' + jQuery(this).attr('rel') + '" style="visibility : collapsed;" />');
	});
});
