$(document).ready(function() {
	var newsMarginTop = 0;
		
	$(".news-item .description > span").click(function() {
		var id = $(this).parents('.news-item').data('id');
		var description = $(this).parent();
		
		if ( id > 0 ) {
			$.ajax({  
				type: "post",
				url: 'getnewsitem,' + id,
				cache: false,
				async: false,
				dataType: 'json',
				success: function(oJsonObject) {
					if ( oJsonObject.status || oJsonObject.status == 'true' ) {
						description.html(oJsonObject.content);
						$(this).remove();
						
						$.rebuildNews();
					}
				}
			});
		}
	});
	
	jQuery.rebuildNews = function() {
		newsMarginTop = 0;
		
		if ( !$('.news-content').hasClass('history') ) {
			$(".content-box .center .news-content .news-item").each(function() {
				$(this).css('margin-top', newsMarginTop);
				newsMarginTop = $(this).outerHeight();
			});
		}	
	};
	
	$.rebuildNews();
});