    function calculate(document) {
       var formObj = document.calculator;
       var theAmount = 0;
       for (var i = 1; i <= 2; i++) {
           var parsecheck = "" + parseFloat(formObj.elements[i].value);
           if (parseFloat(formObj.elements[i].value) < 0 ||
               parseFloat(formObj.elements[i].value) == 0 || 
               parsecheck == "NaN"	||
               ((formObj.elements[i].value)/(formObj.elements[i].value)!=1)&&(formObj.elements[i].value !=0)) 
           {
               alert("Length, width and depth must be numeric\nand greater than zero, please correct.");
               return false;
           }
       }
       theAmount = (formObj.hight.value * formObj.width.value * (formObj.depth.value / GetSelectedButton(formObj.depthMeasure)) / 27.0);  
       formObj.areaAnswer.value = formatAnswer(theAmount,4);
       formObj.qty.value = formatAnswer(theAmount,4);
       //document.getElementById('areaAnswer').innerHTML = formatAnswer(theAmount,4);
       // use jQuery to update the area 
       $("#areaAnswer").text(formatAnswer(theAmount,4));
       //	if the volumn or unit unit of measure is different than the volumn unit of measure
       //	of the calculation factor then display the calculation factor
       if (formObj.useCalcFactor.value=="1") {
           var theAnswer = theAmount * formObj.theCalcFactor.value;
           formObj.Answer.value = formatAnswer(theAnswer,4);
           //document.getElementById('Answer').innerHTML = formatAnswer(theAnswer,4);
           // user jQuery to update the answer
           $("#Answer").text(formatAnswer(theAnswer,4));
       }
       //return true;	
    }

    function  GetSelectedButton(RadioObj) {
	   for (var i=0; i<RadioObj.length; i++) {
		  if (RadioObj[i].checked)
			 return RadioObj[i].value;
	   }
    }

    function formatAnswer(input, rsize) {
       var invalid = "**************************";
       var highVal = "999999999999999999999999";
       var inString = "" + input;
       var floatIn = parseFloat(inString);
       if (inString.indexOf("e") != -1 || floatIn > parseFloat(highVal.substring(0,rsize)+".4"))
           return invalid.substring(0, rsize);

       if (inString.length <= rsize) 
           return inString;
        
       // round the number to 2 decimal points.    
       return roundNumber(input,2);
       
       // return rounded = (floatIn + (floatIn - parseFloat(inString.substring(0, rsize))));
       //var rounded = "" + (floatIn + (floatIn - parseFloat(inString.substring(0, rsize))));
       //return rounded.substring(0, rsize);
    }
    
    // from http://www.mediacollege.com/internet/javascript/number/round.html
    // 02-07-2009
    function roundNumber(number,decimals) {
    	var newString;// The new rounded number
    	decimals = Number(decimals);
    	if (decimals < 1) {
    		newString = (Math.round(number)).toString();
    	} else {
    		var numString = number.toString();
    		if (numString.lastIndexOf(".") == -1) {// If there is no decimal point
    			numString += ".";// give it one at the end
    		}
    		var cutoff = numString.lastIndexOf(".") + decimals;// The point at which to truncate the number
    		var d1 = Number(numString.substring(cutoff,cutoff+1));// The value of the last decimal place that we'll end up with
    		var d2 = Number(numString.substring(cutoff+1,cutoff+2));// The next decimal, after the last one we want
    		if (d2 >= 5) {// Do we need to round up at all? If not, the string will just be truncated
    			if (d1 == 9 && cutoff > 0) {// If the last digit is 9, find a new cutoff point
    				while (cutoff > 0 && (d1 == 9 || isNaN(d1))) {
    					if (d1 != ".") {
    						cutoff -= 1;
    						d1 = Number(numString.substring(cutoff,cutoff+1));
    					} else {
    						cutoff -= 1;
    					}
    				}
    			}
    			d1 += 1;
    		} 
    		newString = numString.substring(0,cutoff) + d1.toString();
    	}
    	if (newString.lastIndexOf(".") == -1) {// Do this again, to the new string
    		newString += ".";
    	}
    	var decs = (newString.substring(newString.lastIndexOf(".")+1)).length;
    	for(var i=0;i<decimals-decs;i++) newString += "0";
    	var newNumber = Number(newString);// make it a number if you like
    	return newNumber; // return 
    }
    
    
