function checkForZero(field) {
        if (field.value == 0 || field.value.length == 0) {
            alert ("You must enter a property value.");
            field.focus(); }
        else
	    calculatePayment(field.form);
    }

    function cmdCalc_Click(form) {
        if (form.sellprice.value == 0 || form.sellprice.value.length == 0) {
            alert ("Please enter the price of the home you are selling.");
            form.price.focus(); }
        else if (form.ir.value == 0 || form.ir.value.length == 0) {
            alert ("Please enter a real estate commission rate.");
            form.ir.focus(); }
        else
            calculatePayment(form);
    }

    function calculatePayment(form) {
        princ = form.sellprice.value;
        princ = princ.replace(",","");
        princ = princ.replace("$","");
        intRate = form.ir.value;
        intRate = intRate.replace("%","")
        intRate = 6.00 - intRate;
        munthly = Math.floor(princ*intRate)/100;
        munthly = munthly.toString();
        munthly = "$" + munthly
        form.rbt.value = munthly
    }
	
	function cmdCalc_Buy(form) {
        if (form.buyprice.value == 0 || form.buyprice.value.length == 0) {
            alert ("Please enter the price of the home you are selling.");
            form.price.focus(); }
        else if (form.rp.value == 0 || form.rp.value.length == 0) {
            alert ("Please enter the percentage of the buyer's agent real estate commission you expected to be rebated.");
            form.ir.focus(); }
        else
            calculateBuy(form);
    }
	
	function calculateBuy(form) {
        princ = form.buyprice.value;
        princ = princ.replace(",","");
        princ = princ.replace("$","");
        intRate = form.rp.value;
        intRate = intRate.replace("%","")
        munthly = Math.floor(princ*0.03)*intRate/100;
        //munthly = Math.floor((princ*0.03)/(1-Math.pow(1+intRate,(-1*months)))*100)/100;
        munthly = munthly.toString();
        munthly = "$" + munthly
        form.pmt.value = munthly
    }

