$(document).ready(function()
{	
	/* 
	* Register the nn-zebra widget which will keep row colouring intact when sorting.
	* Rows with the class 'no-zebra' will not be affected
	*/
	$.tablesorter.addWidget({
		id: "nn-zebra",
		format: function(table) {
			$("tr:visible:not(.no-zebra)",table.tBodies[0]).filter(':even-row').removeClass('even-row');
			$("tr:visible:not(.no-zebra)",table.tBodies[0]).filter(':odd-row').removeClass('odd-row');
			$("tr:visible:odd:not(.no-zebra)",table.tBodies[0]).addClass('odd-row');
			$("tr:visible:even:not(.no-zebra)",table.tBodies[0]).addClass('even-row');
		}
	});
	
	$("table.sortable").tablesorter({widgets: ['nn-zebra']});
		
	$("img.bb-icon-bold").click(function(){surroundText('[B]', '[/B]', document.forum_post.body);});
	$("img.bb-icon-italic").click(function(){surroundText('[I]', '[/I]', document.forum_post.body);});
	$("img.bb-icon-underline").click(function(){surroundText('[U]', '[/U]', document.forum_post.body);});
	$("img.bb-icon-happy").click(function(){replaceText(':)', document.forum_post.body);});
	$("img.bb-icon-very-happy").click(function(){replaceText(':D', document.forum_post.body);});
	$("img.bb-icon-tongue").click(function(){replaceText(':P', document.forum_post.body);});
	$("img.bb-icon-sad").click(function(){replaceText(':(', document.forum_post.body);});
	$("img.bb-icon-indecisive").click(function(){replaceText(':/', document.forum_post.body);});
});
