// This code wil attach a <span> element to the end of the last <li> in a notice <ul> enabeling the user to dismiss a notice
Event.observe(window, 'load', function()
{
	function addCloseButton(element)
	{
		var closeButton;
		var lastli = element.lastChild;
		while (true) {
			if (lastli.tagName && lastli.tagName.toLowerCase() == 'li') {
				if (lastli.lastChild.tagName.toLowerCase() == 'span' && lastli.lastChild.className.match(/(^|\s)closebutton_placeholder(\s|$)/)) {
					closeButton = lastli.lastChild;
				break;
				}
			}
			if (lastli.previousSibling) {
				lastli = lastli.previousSibling;
			} else {
				return false;
			}
		}
		if (!closeButton) return false;

		Event.observe(closeButton, 'click', function()
		{
			element.parentNode.removeChild(element);
			document.fire("splitpane:windowresize");
		});
		closeButton.className = closeButton.className.replace(/closebutton_placeholder/, 'closebutton');
	}

	// Get all ul elements
	var uls = document.getElementsByTagName('ul');
	for (var i = 0; i < uls.length; i++) {
		if (uls[i].className.match(/(^|\s)notice(\s|$)/i)) {
			addCloseButton(uls[i]);
		}
	}
});

function removeAllNotices()
{
	// Get all ul elements
	var uls = document.getElementsByTagName('ul');
	for (var i = 0; i < uls.length; i++) {
		if (uls[i].className.match(/(^|\s)notice(\s|$)/i)) {
			uls[i].parentNode.removeChild(uls[i])
		}
	}
}