function addCommas() {
	var Num = document.form.input.value;
	var newNum = "";
	var newNum2 = "";
	var count = 0;
	
	//check for decimal number
	if (Num.indexOf('.') != -1){
		//number ends with a decimal point
		if (Num.indexOf('.') == Num.length-1){ 
			Num += "00";
		}
	 //number ends with a single digit
		if (Num.indexOf('.') == Num.length-2) {
			Num += "0";
		}
		
		var a = Num.split(".");
		//the part we will commify
		Num = a[0];
		//the decimal place we will ignore and add back later
		var end = a[1];
	} else {
		var end = "00";
	}
	
	//this loop actually adds the commas   
	for (var k = Num.length-1; k >= 0; k--){
		var oneChar = Num.charAt(k);
		if (count == 3){
			newNum += ",";
			newNum += oneChar;
			count = 1;
			continue;
		} else {
			newNum += oneChar;
			count ++;
		}
	}
	
	//but now the string is reversed!		
	//re-reverse the string
	for (var k = newNum.length-1; k >= 0; k--){
		var oneChar = newNum.charAt(k);
		newNum2 += oneChar;
	}
	
	// add dollar sign and decimal ending from above
	newNum2 = "$" + newNum2 + "." + end;
	document.form.newValue.value = newNum2;
}
// -->