/**
 * Show or hide an element with specified id.
 */
function toggle(id) {
	var el = (typeof(id) == 'string') ? document.getElementById(id) : id;
	if (el && el.style) {
		el.style.display = (el.style.display == 'none') ? '' : 'none';
	}
}

/**
 * Surely a staple to event attachment.
 */
function addEvent(el, evType, fn, useCapture) {
	if (el.addEventListener) {
		el.addEventListener(evType, fn, useCapture);
	} else if (el.attachEvent) {
		return el.attachEvent('on' + evType, fn);
	} else {
		el['on' + evType] = fn;
	}
	return true;
}

/**
 * Add an event to trigger after the page has loaded.
 */
function addLoadEvent(fn) {
	var fo = window.onload;
	if (typeof(window.onload) != 'function') {
		window.onload = fn;
	} else {
		window.onload = function() { fo(); fn(); }
	}
}

/**
 * Change opacity (transparency) of images in all browsers.
 */
function setOpacity(el, op) {
	if (el && el.style) {
		try { el.style.MsFilter = 'alpha(opacity=' + (op * 100) + ')'; } catch (ex) { }
		try { el.style.filter = 'alpha(opacity=' + (op * 100) + ')'; } catch (ex) { }
		try { el.style.KhtmlOpacity = op; } catch (ex) { }
		try { el.style.MozOpacity = op; } catch (ex) { }
		try { el.style.opacity = op; } catch (ex) { }
	}
}
