Element.prototype.addClass = function(value) {
	if (this.className) {
		this.className = this.className + ' ' + value;
	} else {
		this.className = value;
	}
}

Element.prototype.insertAfter = function(targetElement) {
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement) {
		parent.appendChild(this);
	} else {
		parent.insertBefore(this,targetElement.nextSibling);
	}
}

Element.prototype.removeClass = function(value) {
	var classes = this.className.split(' ');
	this.className = '';
	for (var c = 0; c < classes.length; c++) {
		var class_name = classes[c];
		if (value != class_name) {
			if (c != 0) {
				this.className += ' ';
			}
			this.className += class_name;
		}
	}
}

String.prototype.replaceAll = function(s1, s2) {return this.replace(new RegExp(s1, 'g'), s2);}

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