function calculateValues(form){

	calcIncome(form);

	calcExpenditures(form);

	calcPrincipal(form);

	calcTotal(form);
	
	checkMin(form);

	return false;

}

function toCurrency(num) {

     var newNum;

	newNum = Math.round(num * 100) / 100;

if(parseFloat(newNum)!=parseInt(newNum)){

			if(parseFloat(newNum*10)==parseInt(newNum*10))
				newNum+="0";
			}

		else{

    		newNum+=".00";

		}

	return '$' + newNum;

}


function calcIncome(form){

	var value1;

	var Income;
	Income = form.txtIncome.value.replace(/[,\$]/g,"");

    value1 = Income * .03;

//	if (Income<100001){
//		value1 = RealProperty * .04;
//
//	}
//	else if (RealProperty<400001){
//		value1 = ((RealProperty - 100000) * .03) + 4000;
//	}
//
//	else {
//		value1 = ((RealProperty - 400000) * .02) + 13000;
//	}


	form.txtIncomeFee.value = toCurrency(value1);

	return false;

}


function calcExpenditures(form){

	var Expenditures;
	var value2;
	Expenditures = form.txtExpenditures.value.replace(/[,\$]/g,"");
	
		if (Expenditures<200000){
		value2 = Expenditures * .03;
	}

	else {
		value2 = ((Expenditures - 199999.99) * .02) + 6000;
	}

	form.txtExpendituresFee.value = toCurrency(value2);

}

function calcPrincipal(form){

	var Principal;
	Principal = form.txtPrincipal.value.replace(/[,\$]/g,"");

	form.txtPrincipalFee.value = toCurrency(Principal * .002);
    
}

function calcTotal(form){

    var ttlValue;
	
	form.txtTotalFee.value = toCurrency(eval(form.txtIncomeFee.value.slice(1)) + eval(form.txtExpendituresFee.value.slice(1)) + eval(form.txtPrincipalFee.value.slice(1)));
 
  }
  
function checkMin(form){
    
    var ttlValue4;
    
    var minValue4;
    
    minValue4=500;
    
    ttlValue4=form.txtTotalFee.value.slice(1);
    
    if (ttlValue4<minValue4) {
    
       if (ttlValue4>0) {
    
       form.txtTotalFee.value = toCurrency(500.00);
              }
        }
         
    }

