String.extend({
	startsWith: function(str) {
		return this.indexOf(str) == 0;
	},
	endsWith: function(str) {
		return this.indexOf(str) == this.length - str.length;
	},
	substringBetween: function(a,b) {
		var ai = this.indexOf(a);
		var bi = this.indexOf(b);
		return this.substring(ai+a.length,bi);
	},
	removeXml: function() {
		return this.replace(/<(.|\n)*?>/g,"");
	},
	isNumeric: function() {
		return this.match(/^[0-9]*(\.)?[0-9]+$/);
	},
	isBoolean: function() {
		return this.match(/^(true|false)$/);
	}
});

$c = function(node,contents) {
	return $(node).clone(contents);
};

Element.extend({
	uFormats: function() {
		var uFormats = {};
		this.className.split(" ").each(function(uFormat){
			uFormat = uFormat.split(":");
			uKey = uFormat[0];
			uValue = uFormat[1];
			if (uValue) {
				if (uValue.startsWith("(s)")) uValue = uValue.replace("(s)","");
				else if (uValue.isNumeric())  uValue = +uValue;
				else if (uValue.isBoolean())  uValue = uValue == "true";
				uFormats[uKey] = uValue;
			}
		});
		return uFormats;
	},
	toggleDisplay: function() {
		var display = this.getStyle('display');
		if (display != 'none') this.originalDisplay = display;
		this.setStyle('display', display == 'none' ? this.originalDisplay || 'block' : 'none');
		return this;
	},
	getActualSize: function() {
		if (this.offsetHeight) return this.getSize().size;
		var clone = this.clone(true).setStyles(this.getStyles('font-family','font-size','line-height','padding','border')).setStyles({
			'position': 'absolute',
			'top': '-1000px'
		}).injectInside(document.body);
		var size = clone.getSize().size;
		clone.remove();
		return size;
	},
	getHeight: function() {
		return this.getActualSize().y;
	},
	getWidth: function() {
		return this.getActualSize().x;
	},
	getText: function() {
		return window.ie ? this.innerText : this.textContent;
	}
});
