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("div[id^='module-news-news_4']").attr('class', 'module-news-newstitle-4');
		if(jQuery(this).attr('id') == 'module-news-news_4') {
			jQuery(this).attr('class','module-news-newstitle-4-on');
			jQuery("div[id^='module-news-bottom']").attr('class','module-news-bottom-on');
		} else {
			jQuery(this).attr('class','module-news-newstitle-on');
			jQuery("div[id^='module-news-bottom']").attr('class','module-news-bottom');
		}
		
		jQuery("#module-news").stop().animate(
					{backgroundPosition:"(-200px 0px)"},
					"swing", function() {
						jQuery(this).css('background-image', 'url(' + jQuery('#' + clickedTitleId).attr('rel') + ')');
						jQuery(this).animate( {backgroundPosition:"(130px 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;" />');
	});
});
