// Thanks to Bernhard Wagner for submitting this function

function replace8a8(str) {
	str = str.toUpperCase();
	var splitstr = "____";
	var ar = str.replace(
		/(([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?)(.*)/,
	 "$1"+splitstr+"$4").split(splitstr);
	var num = Number(ar[0]).valueOf();
	var ml = ar[1].replace(/\s*([KMGB])\s*/, "$1");

	if (ml == "kB")
		num *= 1024;
	else if(ml == "MB")
		num *= 1024 * 1024;
	else if (ml == "GB")
		num *= 1024 * 1024 * 1024;
	else if (ml == "TB")
		num *= 1024 * 1024 * 1024 * 1024;
	// B and no prefix

	return num;
}

function yrPercentage(s) {
	var i = s.indexOf( "%" );
	if ( i != -1 )
	{
      var val = s.substr( 0, i );
		return Number(val);
	}
	return 0;
}


SortableTable.prototype.addSortType( "NumberK", replace8a8 );
SortableTable.prototype.addSortType( "Percentage", yrPercentage );
