var UNDEF = 'undefined';

function $(id) {
	return document.getElementById(id);
}
	
function trim(str) {
	return str.replace(/^[\s\xA0]+/, '').replace(/[\s\xA0]+$/, '');
}

function normalizeSpace(str) {
	return trim(str.replace(/[\s\xA0]{2,}/g, ' '));
}

function escapeRegexp(text) {
	return text.replace(/([\|\!\[\]\^\$\(\)\{\}\+\=\?\.\*\\])/g, "\\$1");
}

if (typeof Array.prototype.splice == 'undefined') {
	Array.prototype.splice = function(offset, length) {
		var temp = [];
		for (var i = this.length - 1; i >= 0; i--) {
			if (i < offset || i > (offset + length - 1)) {
				temp[temp.length] = this[i];
			}
			this.length--;
		}
		for (i = temp.length - 1; i >= 0; i--) {
			this[this.length] = temp[i];
		}
	}
}
