function SendNewsComment(obj, id) {
	DeasactiveForm('#news_form');
	$('#news_form').submit();
}

function GoPage(id, page) {
	if (!$('#last_comments').length) {
		Show(id);
	}
	$('#last_comments').block({ message: null, overlayCSS: { backgroundColor: '#FFF' }  });
	$.ajax({
		url: '/',
		data: 'news/'+id+'/page/'+page+'/xhr',
		success: function(msg){
			$('last_comments').unblock();
			$('#last_comments').html(msg);
			UpdateInterface();
		}
	});
}

function UpdatePostedForm(formType, msg, key) {
	if (formType == 'comment') {
		ActiveForm('#news_form');
		if (msg.indexOf('error:') > -1) {
			DisplayError($('#news_form_error'), msg);
		} else {
			$('#body').val('Write something...');
			GoPage(msg+'-'+key, -1);
		}
	} else {
		alert(msg);
	}
}

function Show(context) {
	$('#content').block({ message: null, overlayCSS: { backgroundColor: '#FFF' }  });
	if (context == '') { context = 'all';	}
	$.ajax({
		url: '/',
		data: 'news/'+context+'/xhr',
		success: function(msg){
			$('#content').unblock();
			$('#content').html(msg);
			UpdateInterface();
			if (is_webid(context)) {
				document.title = winTitle +' > ' + $('#crumbs li:last').text();
			} else if ($("a[rel='address:"+context+"']").length > 0) {
				document.title = winTitle +' > ' + $("a[rel='address:"+context+"']").text().substr(0, $("a[rel='address:"+context+"']").text().length - 3);
			} else {
				document.title = winTitle +' > ' + ucfirst(context);
			}
		}
	});
}

function customHistory(hash) {
	var tableau=hash.split('/');
	if (tableau.length == 1) {
		Show(tableau[0]);
	} else if (tableau.length == 3) {
		GoPage(tableau[0], tableau[2]);
	}
}

function DeleteMessage(id, msg_id) {
	$.ajax({
		url: '/',
		data: 'news/'+id+'/delete/'+msg_id+'/xhr',
		success: function(msg){
			GoPage(id, 1);
		}
	});
}
