function calcPaint(formElement, strField){
	var formElementName = formElement;
	if(!isNumeric(strField))
		{
	var formElementName = formElement;
//	alert (document.formCalc.elements[formElementName].value)
			alert("Please enter numeric values only");
				document.formCalc.elements[formElementName].value="";
			return false;
	}
}

function checkNumber(formElement, strField){
var the_calcForm = document.formCalc
	if(!isNumeric(strField))
		{
	var formElementName = formElement;
//	alert (document.formCalc.elements[formElementName].value)
			alert("Please enter numeric values only");
				document.formCalc.elements[formElementName].value="";
			return false;
		}else{
		calculateAll();
		}
		
}
function changeCM(cmvalue){
	if (cmvalue.length=1){
		cmvalue = 0
		//alert (cmvalue)
	}
}

function calculateAll(){
var the_calcForm = document.formCalc
	
var areaWall1
var areaWall2
var areaWall3
var areaWall4
var areawindow1
var areawindow2
var areadoor1
var areadoor2


if (the_calcForm.w_wall1 && the_calcForm.h_wall1)  {
	if (isNumeric(the_calcForm.w_wall1.value) && isNumeric(the_calcForm.h_wall1.value)) {
		areaWall1 = (the_calcForm.w_wall1.value*the_calcForm.h_wall1.value)
		//areaWall1 = areaWall1.toFixed(2)
		}else{
		areaWall1 = 0
		}
	}else{
	areaWall1 = 0
	}
	
if (the_calcForm.w_wall2 && the_calcForm.h_wall2)  {
	if (isNumeric(the_calcForm.w_wall2.value) && isNumeric(the_calcForm.h_wall2.value)) {
		areaWall2 = (the_calcForm.w_wall2.value*the_calcForm.h_wall2.value)
		}else{
		areaWall2 = 0
		}
	}else{
	areaWall2 = 0
	}
	
if (the_calcForm.w_wall3 && the_calcForm.h_wall3)  {
	if (isNumeric(the_calcForm.w_wall3.value) && isNumeric(the_calcForm.h_wall3.value)) {
		areaWall3 = parseFloat(the_calcForm.w_wall3.value*the_calcForm.h_wall3.value)
		//areaWall3 = areaWall3.toFixed(2)
		}else{
		areaWall3 = 0
		}
	}else{
	areaWall3 = 0
	}
	
if (the_calcForm.w_wall4 && the_calcForm.h_wall4)  {
	if (isNumeric(the_calcForm.w_wall4.value) && isNumeric(the_calcForm.h_wall4.value)) {
		areaWall4 = (the_calcForm.w_wall4.value*the_calcForm.h_wall4.value)
	//	areawall4 = areawall4.toFixed(2)
		}else{
		areaWall4 = 0
		}
	}else{
	areaWall4 = 0
	}
	
if (the_calcForm.w_door1 && the_calcForm.h_door1)  {
	if (isNumeric(the_calcForm.w_door1.value) && isNumeric(the_calcForm.h_door1.value)) {
		areadoor1 = (the_calcForm.w_door1.value*the_calcForm.h_door1.value)
		//areadoor1 = areadoor1.toFixed(2)
		}else{
		areadoor1 = 0
		}
	}else{
	areadoor1 = 0
	}
	
if (the_calcForm.w_door2 && the_calcForm.h_door2)  {
	if (isNumeric(the_calcForm.w_door2.value) && isNumeric(the_calcForm.h_door2.value)) {
		areadoor2 = (the_calcForm.w_door2.value*the_calcForm.h_door2.value)
		//areadoor2 = areadoor2.toFixed(2)
		}else{
		areadoor2 = 0
		}
	}else{
	areadoor2 = 0
	}
	
if (the_calcForm.w_window1 && the_calcForm.h_window1)  {
	if (isNumeric(the_calcForm.w_window1.value) && isNumeric(the_calcForm.h_window1.value)) {
		areawindow1 = (the_calcForm.w_window1.value*the_calcForm.h_window1.value)
		//areawindow1 = areawindow1.toFixed(2)
		}else{
		areawindow1 = 0
		}
	}else{
	areawindow1 = 0
	}
	
if (the_calcForm.w_window2 && the_calcForm.h_window2)  {
	if (isNumeric(the_calcForm.w_window2.value) && isNumeric(the_calcForm.h_window2.value)) {
		areawindow2 = (the_calcForm.w_window2.value*the_calcForm.h_window2.value)
		//areawindow2 = areawindow2.toFixed(2)
		}else{
		areawindow2 = 0
		}
	}else{
	areawindow2 = 0
	}
	
	
	
	var totalWall = parseFloat(areaWall1 + areaWall2 + areaWall3 + areaWall4);
//	totalWall = totalWall.toFixed(2);
//	alert ('totalWall1: '+areaWall1)
//	alert ('totalWall2: '+areaWall2)
//	alert ('totalWall3: '+areaWall3)
//	alert ('totalWall4: '+areaWall4)
//	alert ('totalWall: '+totalWall)
	//Remove doors and windows
	var totalDoor = parseFloat(areadoor1 + areadoor2);
//	totalDoor = totalDoor.toFixed(2);
//	alert ('totalDoor: '+totalDoor)
	var totalWindow = parseFloat(areawindow1 + areawindow2);
//	totalWindow = totalWindow.toFixed(2);
//	alert ('totalWindow'+totalWindow)

	var totalAll=parseFloat(totalWall-totalDoor-totalWindow);
	the_calcForm.totalM2.value = totalAll.toFixed(2);
}

// isNumeric(value)
//   Returns true if value contains a positive float value
//-------------------------------------------------------------------
function isNumeric(val){
	return(parseFloat(val,10)==(val*1));
	}

	function isFloat(xvar)
		{		
		for (k=0;k<xvar.length;k++)
			{
				if(isNaN(xvar.charAt(k)) && xvar.charAt(k) != '.') 
					{
						return false;
					}
			}

		return true;		
		}	

function checkNull(nValue){
	if (!nValue){
		return 0;
	} else {
		return nValue;
	}
}
function checkBlank(bValue){
	if (!bValue){
		return null;
	} else {
		return bValue;
	}
}


