function loadTinyMCE(selector, baseUrl)
{
	if (selector == null)
	{
		tinyMCE.init({
			mode : "none",
			theme : "advanced",
			plugins: "contextmenu,paste,table",
			theme_advanced_blockformats : "p,h3,h4",
			theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,bullist,numlist,separator,undo,redo,image,link,unlink",
			theme_advanced_buttons2 : "pasteword,cleanup,removeformat,separator,charmap,code,formatselect",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
			relative_urls : false
		});
	}
	else
	{
		 tinyMCE.init({
			mode : "textareas",
			editor_selector : selector,
			theme : "advanced",
			plugins: "contextmenu,paste,table",
			theme_advanced_blockformats : "p,h3,h4",
			theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,bullist,numlist,separator,undo,redo,image,link,unlink",
			theme_advanced_buttons2 : "pasteword,cleanup,removeformat,separator,charmap,code,formatselect",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
			relative_urls : false
		});
	}
}

function addTableRollovers()
{
	$('table tr').each(function()
	{
		var firstAnchor = $('a:first', this);
		
		if ($(firstAnchor).length == 1)
		{
			$(this)
				.addClass('hoverable')
				.hover(
					function() { $(this).addClass('hover'); },
					function() { $(this).removeClass('hover'); }
				)
				.bind('click', function()
				{
					window.location = firstAnchor.attr('href');
				});
		}
	});
}

function addTableTabs()
{
	$('ul.tabs li a:first').addClass('active');
	$('table.tabs:first').show();
	
	$('ul.tabs li a').bind('click', function()
	{
		var selTab = $(this).attr('href');
		
		$(this).addClass('active').parent().siblings().children().removeClass('active');
		
		$('table.tabs').hide().filter(selTab).show();
	});
}

function animateFlash()
{
	setTimeout(function() { $('#flash').fadeOut(1500); }, 3000);
}

function initializeSearchDropdown()
{
	$('#search-icon').bind('click', function()
	{
		var search = $('#search');
		var searchKeywords = $('#search-keywords');
		var searchGo = $('#search-go');
		
		if (search.is(':animated'))
		{
			search.stop();
		}
		
		if (search.offset().top < 0)
		{
			searchKeywords.show();
			searchGo.show();
			
			$('#search').animate({ top: "0px" }, 500, function()
			{
				searchKeywords.focus();
			});
		}
		else
		{
			$('#search').animate({ top: "-26px" }, 500, function()
			{
				searchKeywords.hide();
				searchGo.hide();
			});					
		}
		
		return false; // to make the link not work for JS users
	});
}