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"
	});
};

uploaderDefaults = function()
{
	return {
		debug: false,
		flash_url: siteroot + "local/flash/swfupload.swf",
		file_types: "*.pdf;*.swf;*.udf;*.mov;*.wmv",
		file_types_description: "PAAB documents",
		file_size_limit: "20 MB",
		file_queue_limit: 1,
		button_image_url: siteroot + "local/images/browse_en.png",
		button_text: "<span class='button'>" + (location.href.indexOf("english") < 0 ? "Parcourir" : "Browse") + "</span>",
		button_text_style: ".button {font-family: sans-serif; text-align: center; font-weight: bold;}",
		button_text_left_padding : 0, 
		button_text_top_padding : 1, 
		button_width: 73,
		button_height: 20,
		button_cursor: SWFUpload.CURSOR.HAND,
		button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE,
		//debug_handler: printfire,
		file_queued_handler: function()
		{
			this.startUpload();
		},
		upload_start_handler: function()
		{
			document.body.style.cursor = "wait";
		},
		upload_complete_handler: function()
		{
			document.body.style.cursor = "default";
		}
	};
};
