	/*function validateAndAddProfitOLD(){
		var pTOTAL=0
		for(i=1;i<9;i++){
			if(!isNaN(parseFloat(document.getElementById("p"+i).value))){
				pTOTAL=pTOTAL+parseFloat(document.getElementById("p"+i).value);
			}
		}
		document.getElementById("pTOTAL").value=pTOTAL.toFixed(2);
	}*/
	function validateAndAddProfit(){
		var pTOTAL=0
		for(i=1;i<9;i++){
			if(!isNaN(parseFloat(document.getElementById("p"+i).value))){
				if(i==4 || i==7)
					//subtract from profit if rent or income field - p4 or p7
					pTOTAL=pTOTAL-parseFloat(document.getElementById("p"+i).value);
				else
					pTOTAL=pTOTAL+parseFloat(document.getElementById("p"+i).value);
			}
		}
		document.getElementById("pTOTAL").value=pTOTAL.toFixed(2);
	}
	function validateAndAddChoices(){
		var choiceTOTAL=0
		for (var i=0; i<document.Form1.teamChoice.length; i++)  { 
			if (document.Form1.teamChoice[i].checked)  {			
			choiceTOTAL=choiceTOTAL+parseFloat(document.Form1.teamChoice[i].value);			
			} 
		}
		for (var i=0; i<document.Form1.customerChoice.length; i++)  { 
			if (document.Form1.customerChoice[i].checked)  {			
			choiceTOTAL=choiceTOTAL+parseFloat(document.Form1.customerChoice[i].value);			
			} 
		}
		for (var i=0; i<document.Form1.tradeChoice.length; i++)  { 
			if (document.Form1.tradeChoice[i].checked)  {			
			choiceTOTAL=choiceTOTAL+parseFloat(document.Form1.tradeChoice[i].value);			
			} 
		}
		choiceTOTAL=choiceTOTAL / 13 * document.getElementById("typicalPE").value;
		document.getElementById("choiceTOTAL").value=parseFloat(choiceTOTAL) ;
		var subTOTAL=parseFloat(choiceTOTAL) * parseFloat(document.getElementById("pTOTAL").value);
		document.getElementById("subTOTAL").value=subTOTAL.toFixed(2);
	}
	
	function validateAndAddFinalVals(){
		var grandTOTAL=parseFloat(document.getElementById("subTOTAL").value);
		for(i=9;i<11;i++){
			if(!isNaN(parseFloat(document.getElementById("p"+i).value))){
				grandTOTAL=grandTOTAL+parseFloat(document.getElementById("p"+i).value);
			}
		}
		if(!isNaN(parseFloat(document.getElementById("p11").value))){
			grandTOTAL=grandTOTAL-parseFloat(document.getElementById("p11").value);
		}
		document.getElementById("grandTOTAL").value=grandTOTAL.toFixed(2);
	}
	function gotoPage(pageId){
		document.getElementById("page"+1).style.display="none";
		document.getElementById("page"+2).style.display="none";
		document.getElementById("page"+3).style.display="none";
		document.getElementById("page"+4).style.display="none";
		validateAndAddProfit();
		validateAndAddChoices();
		validateAndAddFinalVals();
		document.getElementById("page"+pageId).style.display="";
	}