function char_ms(write){ 
var explo; 
var explo = write.value.length; 
var str = ""; 
for (var k = (explo); k >= 0 ; k--) { 
	if(write.value.substring(k-1,k) != ","){ 
		str = write.value.substring(k-1,k) + str; 
	} 
} 
explo = str.length; 
var msg = ""; 
var no =1; 
for (var k = (explo); k >= 0 ; k--) { 
	if(no == 3 && k != 0){ 
		msg = str.substring(k-1,k) + "," + msg; 
		no = 0; 
	} 
	else { 
		msg = str.substring(k-1,k) + msg ; 
	} 
	no++; 
} 
write.value = msg; 
write.focus(); 
return (false); 
} 
function commaSplit(srcNumber) {
	var txtNumber = '' + srcNumber;
	var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
	var arrNumber = txtNumber.split('.');
	arrNumber[0] += '.';
	do {
		arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
	} while (rxSplit.test(arrNumber[0]));
	if (arrNumber.length > 1) {
		return arrNumber.join('');
	}
	else {
		return arrNumber[0].split('.')[0];
    }
}
function filterNum(str) {
	re = /^\$|,/g;
	return str.replace(re, "");
}
function calculate() {
	var f = document.form1;
	var expect = f.expect.value;
	expect = filterNum(expect);
	if(expect < 50000000) {
		document.form1.charge.value = commaSplit(150000);
	}
	if((expect >= 50000000) && (expect < 500000000)) {
		document.form1.charge.value = commaSplit((expect / 10000 * 11) + 95000);
	}
	if((expect >= 500000000) && (expect < 1000000000)) {
		document.form1.charge.value = commaSplit((expect / 10000 * 9) + 195000);
	}
	if((expect >= 1000000000) && (expect < 5000000000)) {
		document.form1.charge.value = commaSplit((expect / 10000 * 8) + 295000);
	}
	if((expect >= 5000000000) && (expect < 10000000000)) {
		document.form1.charge.value = commaSplit((expect / 10000 * 7) + 795000);
	}
	if((expect >= 10000000000) && (expect < 50000000000)) {
		document.form1.charge.value = commaSplit((expect / 10000 * 6) + 1795000);
	}
	if((expect >= 50000000000) && (expect < 100000000000)) {
		document.form1.charge.value = commaSplit((expect / 10000 * 5) + 6975000);
	}
	if((expect >= 100000000000)) {
		document.form1.charge.value = commaSplit((expect / 10000 * 4) + 16795000);
	}
//	reformat(document.form1.charge);
}
function reformat(field) {
	var padding = field.maxLength - field.value.length;
    for (i = 0; i < padding; i++) {
		field.value = " " + field.value;
    }
    return(true);
}

