
function toggleDisplay(element, show)
{
	if (typeof(element) == "string")
		element = $(element);
	if (typeof(show) == "undefined")
		show = element.style.display == "none";
	element.style.display = show ? "" : "none";
}

String.prototype.trim = function()
{
	return this.replace(/^\s+/, "").replace(/\s+$/, "");
}

function selectElement(e, className)
{
	if (!e) return;
	className = className ? className : "selected";

	var sibling = e.parentNode.firstChild;
	while (sibling != null)
	{
		if (e == sibling)
			Element.addClassName(sibling, className);
		else if (sibling.nodeType == 1)
			Element.removeClassName(sibling, className);
		sibling = sibling.nextSibling;
	}

}

initDateInput = function(input)
{
	input = $(input);
	input.style.width = (input.offsetWidth - 19) + "px";

	var button = document.createElement("img");
	button.className = "calendarbutton";
	button.style.marginLeft = "3px";
	button.src = siteroot + "local/images/global/small_calendar.gif";
	if (input.nextSibling == null)
		input.parentNode.appendChild(button);
	else
		input.parentNode.insertBefore(button, input.nextSibling);

	Calendar.setup({
		inputField : input,
		button : button,
		ifFormat : "%Y-%m-%d",
		showTime : "false"
	});
}

