String.prototype.removeTags = function(){
	return this.replace(/<.*?>/gim, "");
}
function tableSort(o, call){
	var comp = function(v1, v2, d){
		!isNaN(v1) && (v1 = parseFloat(v1));
		!isNaN(v2) && (v2 = parseFloat(v2));
		return d ? v1 < v2 : v1 > v2;
	}
	var sortRow = function(o, x, d){
		var o = o.tBodies[0], t, l = (t = o.rows).length - 1, i = -1, j;
		while((j = ++i) < l)
			while(++j <= l)
				comp(t[i].cells[x].innerHTML.removeTags(), t[j].cells[x].innerHTML.removeTags(), d & 1) &&
					(o.insertBefore(t[i], t[j]), o.insertBefore(t[j], t[i]));
	}
	for(var t, j = (t = o.tHead.rows[0].cells).length; j--;)
		new function(i){
			for(var a, v = 0, l = (a = t[j].getElementsByTagName("a")).length; l--;)
				a[l].onclick = function(){return false;}
			t[j].onclick = function(){
				var a, l = (a = this.parentNode.parentNode.rows[0].cells).length;
				while(l--) call && call.call(a[l], a[l] == this, (v + 1) & 1);
				sortRow(o, i, v++);
			}
		}(j);
}
