function oppVal (bool) {
	if (bool == "unset") return "";
	if (bool == 1) return 0;
	else return 1;
}

function _gel (id) {
	return document.getElementById ? document.getElementById(id) : null
}

//AKA, the Dollar ($) function
function getElements () {
	var elements = new Array();
	if (arguments.length == 1) return (typeof arguments[0] == 'string') ? _gel(arguments[0]) : arguments[0];
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = _gel(element);
		elements.push(element);
	}
	return elements;
}

function loadScript (url) {
	var el = document.createElement("script");
	el.src = url;
	el.type="text/javascript";
	//document.getElementsByTagName("head")[0].appendChild(el);
	document.body.appendChild(el);
}

function toggle (obj) {
	var el = (typeof obj == 'string') ? _gel(obj) : obj;
	if (arguments[1] == null) {
		el.style.display = (el.style.display == 'none') ? '' : 'none';
	} else {
		switch (arguments[1]) {
			case 'vis':
				el.style.visibility = (el.style.visibility == 'hidden') ? '' : 'hidden';
				break;
		}
	}
}

//Thanks Simon Willison
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

//Thanks Dustin Diaz (modified by me)
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	node = (node == null) ? document : _gel(node);
	//if (node == null) node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

//From mootools
window.xpath = !!(document.evaluate);
if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.webkit = window[window.xpath ? 'webkit420' : 'webkit419'] = true;
else if (document.getBoxObjectFor != null) window.gecko = true;
if (window.ie6) try {document.execCommand("BackgroundImageCache", false, true);} catch(e){};

//String trim prototypes written by me for "Custom Inputs" functions
String.prototype.ltrim = function () { return this.replace(/^([\s]+)/, ''); };
String.prototype.rtrim = function () { return this.replace(/([\s]+)$/, ''); };
String.prototype.trim = function () { return this.ltrim().rtrim(); };