                        <!--
                        function num_format(x) { // format numbers with two digits
                      	sgn = (x < 0);
                      	x = Math.abs(x);
                      	x = Math.floor((x * 100) + .5);
                      	i = 3;
                      	y = "";
                      	while(((i--) > 0) || (x > 0)) {
                      		y = (x % 10) + y;
                      		x = Math.floor(x / 10);
                      		if(i == 1) {
                      			y = "." + y;
                      		}
                      	}
                      	if(sgn) {
                      		y = "-" + y;
                      	}
                      	return(y);
                      }
                      function comp(x,v) { // general entry point for all cases

                      	// convert all entry fields into variables

                      	pv = parseFloat(x.pv.value);
                      	fv = parseFloat(x.fv.value);
                      	np = parseFloat(x.np.value);
                      	pmt = parseFloat(x.pmt.value);
                      	if(x.ir.value == "") {
                      		alert("You must enter an interest rate (ir).");
                      	}
                      	else {
                      		ir = eval(x.ir.value) / 1200;

                      		// test and compute all cases

                      		if (v == 'pv') {
                      			if(ir == 0) {
                      				pv = -(fv + (pmt * np));
                      			}
                      			else {
                      				q1 = Math.pow(1 + ir,-np);
                      				q2 = Math.pow(1 + ir,np);
                      				pv = -(q1 * (fv * ir - pmt + q2 * pmt))/ir;
                      			}
                      			x.pv.value = num_format(pv);
                      		}

                      		if (v == 'fv') {
                      			if(ir == 0) {
                      				fv = -(pv + (pmt * np));
                      			}
                      			else {
                      				q = Math.pow(1+ir,np);
                      				fv = -(-pmt + q * pmt + ir * q * pv)/ir;
                      			}
                      			x.fv.value = num_format(fv);
                      		}
                      		if (v == 'np') {
                      			if(ir == 0) {
                      				if(pmt != 0) {
                      					np = - (fv + pv)/pmt;
                      				}
                      				else {
                      					alert("Divide by zero error.");
                      				}
                      			}
                      			else {
                      				np = Math.log((-fv * ir + pmt)/(pmt + ir * pv))/ Math.log(1 + ir);
                      			}
                      			if(np == 0) {
                      				alert("Can't compute Number of Periods for the present values.");
                      			}
                      			else {
                      				x.np.value = num_format(np);
                      			}
                      		}

                      		if (v == 'pmt') {
                      			if(ir == 0.0) {
                      				if(np != 0) {
                      					pmt = - (fv + pv)/np;
                      				}
                      				else {
                      					alert("Divide by zero error.");
                      				}
                      			}
                      			else {
                      				//q = Math.pow(1 + (ir/12),np);
                      				//pmt = (((ir/12) * (fv + q * pv))/(-1 + q));
                      				q = Math.pow(1 + (ir),np);
                      				pmt = (((ir) * (fv + q * pv))/(-1 + q));
                      			}
                      			x.pmt.value = num_format(pmt);
                      		}
                      		if(v == 'ir') { // I am so lazy!
                      			alert("Sorry! Can't calculate interest rate.\nYou must enter this value.");
                      		}
                      	}
                      } // function comp
                      //-->
