
function util_hexnib(d) { if (d<10) return d; return String.fromCharCode(65+d-10); }
function util_hexbyte(d) { return "%"+util_hexnib((d&240)>>4)+""+util_hexnib(d&15); }

function URLEncode(value) {
	value=value.toString();
	var result="";
	var hex="";
	for(var i=0;i<value.length; i++) {
		var cc=value.charCodeAt(i);
		if (cc<128) { result+=util_hexbyte(cc); }
		else if((cc>127) && (cc<2048)) result += util_hexbyte((cc>>6)|192) + util_hexbyte((cc&63)|128);
		else result+= util_hexbyte((cc>>12)|224) + util_hexbyte(((cc>>6)&63)|128) + util_hexbyte((cc&63)|128);
	}
   return result;
}

