function adminRemove(comment){
	new Ajax.Request( 
		'http://limerickrugby.ie/removepost.php', {
			method:'post', 
			parameters:{id:comment},
			onSuccess: function(t) {
				var reply = t.responseText.evalJSON();
				if(reply.outcome==1){
					location.reload(true);
				}else if(reply.outcome==3){
					alert("An error has occurred while trying to update the database. Please try again later");
				}else{
					alert("An error has occurred while trying to update the database. Please make sure you are logged in as a site administrator");
				}
			}
		}
	);
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}


function adminRestore(comment){
	new Ajax.Request( 
		'http://limerickrugby.ie/restorepost.php', {
			method:'post', 
			parameters:{id:comment},
			onSuccess: function(t) {
				var reply = t.responseText.evalJSON();
				if(reply.outcome==1){
					location.reload(true);
				}else if(reply.outcome==3){
					alert("An error has occurred while trying to update the database. Please try again later");
				}else{
					alert("An error has occurred while trying to update the database. Please make sure you are logged in as a site administrator");
				}
			}
		}
	);
}
function adminEdit(id){
	var msgbody = $('comment_'+id).innerHTML;
	msgbody=msgbody.trim();	
	$('comment_'+id).innerHTML= "<div><textarea name = 'commentbody' id = 'commentbody"+id+"' cols='50' rows='7'></textarea></div>";
	$('commentbody'+id).value = msgbody.replace(/<br>/gi, '\n');
	$('admincontrol_'+id).innerHTML="<a href = 'javascript:adminSave(\""+id+"\")'>Save</a>";
}
function adminSave(id){
	var comment = $F('commentbody'+id);
	new Ajax.Request( 
		'http://limerickrugby.ie/admineditpost.php', {
			method:'post', 
			parameters:{comment:comment,id:id},
			onSuccess: function(t) {
				var reply = t.responseText.evalJSON();
				if(reply.outcome==1){
					location.reload(true);
				}else if(reply.outcome==3){
					alert("An error has occurred while trying to update the database. Please try again later");
				}else{
					alert("An error has occurred while trying to update the database. Please make sure you are logged in as a site administrator");
				}
			}
		}
	);
}
