//this is how to set status self.status = aValue;
// JavaScript Document
// JavaScript Document
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
// these three functions handles the global for the home of individual family
	function MoveIndividualFamilyImages(){
		var myGlobal = document.getElementById("Global");
		if (myGlobal != null){
			var myX = 0;
			var myY = 0;
			var obj = myGlobal
			myX = obj.offsetLeft;
			mtY = obj.offsetTop;
			while(obj.offsetParent){
				myX = myX + obj.offsetParent.offsetLeft;
				myY = myY + obj.offsetParent.offsetTop + 2;
				obj=obj.offsetParent;
			}
			var movingObj;
			movingObj = document.getElementById("housediv");
			movingObj.style.top = myY+54+"px";
			movingObj.style.left = myX+369+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("cardiv");
			movingObj.style.top = myY+220+"px";
			movingObj.style.left = myX+444+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("plaindiv");
			movingObj.style.top = myY+391+"px";
			movingObj.style.left = myX+363+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("questionmarkdiv");
			movingObj.style.top = myY+293+"px";
			movingObj.style.left = myX+10+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("globaltextdiv");
			movingObj.style.top = myY+133+"px";
			movingObj.style.left = myX+100+"px";
			movingObj.style.visibility = "visible";
		}
	} 
	function MoveHomePageImages(){
		var myGlobal = document.getElementById("Global");
		if (myGlobal != null){
			var myX = 0;
			var myY = 0;
			var obj = myGlobal
			myX = obj.offsetLeft;
			mtY = obj.offsetTop;
			while(obj.offsetParent){
				myX = myX + obj.offsetParent.offsetLeft;
				myY = myY + obj.offsetParent.offsetTop + 2;
				obj=obj.offsetParent;
			}
			var movingObj;
			movingObj = document.getElementById("familydiv");
			movingObj.style.top = myY+40+"px";
			movingObj.style.left = myX+276+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("bizdiv");
			movingObj.style.top = myY+262+"px";
			movingObj.style.left = myX+26+"px";
			movingObj.style.visibility = "visible";
		}
	} 
	function MoveBusinessImages(){
		var myGlobal = document.getElementById("BizGlobal");
		if (myGlobal != null){
			var myX = 0;
			var myY = 0;
			var obj = myGlobal
			myX = obj.offsetLeft;
			mtY = obj.offsetTop;
			while(obj.offsetParent){
				myX = myX + obj.offsetParent.offsetLeft;
				myY = myY + obj.offsetParent.offsetTop + 2;
				obj=obj.offsetParent;
			}
			var movingObj;
			movingObj = document.getElementById("bizsitediv");
			movingObj.style.top = myY+10+"px";
			movingObj.style.left = myX+121+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("bizcardiv");
			movingObj.style.top = myY+13+"px";
			movingObj.style.left = myX+319+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("bizplaindiv");
			movingObj.style.top = myY+176+"px";
			movingObj.style.left = myX+438+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("bizfreightdiv");
			movingObj.style.top = myY+339+"px";
			movingObj.style.left = myX+407+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("bizequipmentdiv");
			movingObj.style.top = myY+437+"px";
			movingObj.style.left = myX+236+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("bizquestionmarkdiv");
			movingObj.style.top = myY+293+"px";
			movingObj.style.left = myX+10+"px";
			movingObj.style.visibility = "visible";
			movingObj = document.getElementById("bizglobaltextdiv");
			movingObj.style.top = myY+113+"px";
			movingObj.style.left = myX+100+"px";
			movingObj.style.visibility = "visible";
		}
	} 
	function MouseInOut(aDiv,aFlag){
		var aName = aDiv.getAttribute('name');
		//remove div at the end
		var iconName = aName.substring(0,aName.length-3);
		var anImage;
		var aSpan;
		anImage = document.getElementById(iconName+"circle");
		aSpan = document.getElementById(iconName+"text");
		if (aFlag == '0'){
			//mouse out
			anImage.src="images/circledarkblue.gif";
			aSpan.style.color="002d88";
		}else{
			//mouse over
			anImage.src="images/circleblue.gif";
			aSpan.style.color="1A8CFF";
		}
		anImage = document.getElementById(iconName+"icon");
		anImage.src = "images/"+iconName+"_icon"+aFlag+".gif";
	}
// end of the global


document.onkeyup = flightDestinationKeyUp;
var mytime;
function InitializeCookies(Force){
	var cookieContent;
	//******* house section (include air mile section)
	if (! ExistCookie("houseinput") || Force==true){
		cookieContent = ":";
		cookieContent += "member:0:";
		cookieContent += "heatmethod:1:";	//default to natural gas. 1: natural gas; 2:electric heat; 3: oil; 4: coal; 5:steam; 6:propane; 7:wood
		cookieContent += "heatsourcepercent:0:";
		cookieContent += "secheatmethod:0:";
		cookieContent += "secheatsourcepercent:0:";
		cookieContent += "electricbill:0:";
		cookieContent += "gasbill:0:";
		cookieContent += "fueloilbill:0:";
		cookieContent += "electricity:0:";
		cookieContent += "natgas:0:";
		cookieContent += "fueloil:0:";
		cookieContent += "coal:0:";
		cookieContent += "steam:0:";
		cookieContent += "propane:0:";
		cookieContent += "wood:0:";
		cookieContent += "newspaper:false:";
		cookieContent += "magazine:false:";
		cookieContent += "glass:false:";
		cookieContent += "plastic:false:";
		cookieContent += "aluminum:false:";
		SetCookie("houseinput",cookieContent); 
	}
	//******* end of house section (include air mile section)
	
	//******* house reduce section
	if (! ExistCookie("housereduce") || Force==true){
		cookieContent = ":";
		cookieContent += "heatingthermo:0:";
		cookieContent += "bulbs:0:";
		cookieContent += "refri:false:";
		cookieContent += "furnace:false:";
		cookieContent += "acthermo:0:";
		cookieContent += "window:false:";
		cookieContent += "material:false:";
		cookieContent += "plant:false:";
		SetCookie("housereduce",cookieContent);
	}
	//******* end of house reduce section
	
	//******* for vehicles
	if (! ExistCookie("carinfo") || Force==true){
		cookieContent = ":";
		cookieContent += "carno:1:";
		cookieContent += "car1:0|0|1|0|0|0|0:";	//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, no of vehicles to be replaced by efficient vehicles, improvement of gas mileage/gallon, few miles to drive
		cookieContent += "carlessmile:0:";
		SetCookie("carinfo",cookieContent);
	}
	//******* end of vehicles
	
	//******* for biz vehicles
	if (! ExistCookie("bizcarinfo") || Force==true){
		cookieContent = ":";
		cookieContent += "bizcarno:1:";
		cookieContent += "bizcar1:0|0|1|0|0:";	//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, fuel type
		//cookieContent += "bizcarlessmile:0:";
		SetCookie("bizcarinfo",cookieContent);
	}
	//******* end of biz vehicles
	
	//**** air
	if (! ExistCookie("airinfo") || Force==true){
		//cookieContent = ":";
		//cookieContent += "airmile:0:";
		//SetCookie("airinfo",cookieContent);
		cookieContent = ":";
		cookieContent += "airno:1:";
		cookieContent += "air1:|0|1:";	//destination name, mile, trip times
		SetCookie("airinfo",cookieContent);
	}
	//**** end of air
	
	//**** biz air
	if (! ExistCookie("bizairinfo") || Force==true){
		cookieContent = ":";
		cookieContent += "bizairno:1:";
		cookieContent += "bizair1:|0|1:";	//destination name, mile,times
		SetCookie("bizairinfo",cookieContent);
	}
	//**** end of biz air
	
	//**** biz equip
	/*
	if (! ExistCookie("bizequipinfo") || Force==true){
		cookieContent = ":";
		cookieContent += "bizequipno:1:";
		cookieContent += "bizequip1:|1|0|0|0:";	//equip name, equip number,fuel type index, gallons, time period index
		SetCookie("bizequipinfo",cookieContent);
	}
	*/
	//after 1-20-2009, use this cookie
	if (! ExistCookie("bizequipinfo2") || Force==true){
		cookieContent = ":gasoline:0|0:diesel:0|0:propane:0|0:jetfuel:0|0:aviationgasoline:0|0:biodiesel:0|0:"; //0|0 means gallon, time period index,
		SetCookie("bizequipinfo2",cookieContent);
	}
	//end of after 1-20-2009
	//**** end of biz equip
	
	//**** biz freight
	if (! ExistCookie("bizfreightinfo") || Force==true){
		cookieContent = ":";
		cookieContent += "truck:|0|0:";	//tons,miles,time period index
		cookieContent += "train:|0|0:";	//tons,miles,time period index
		cookieContent += "van:|0|0:";	//tons,miles,time period index
		cookieContent += "airgoods:|0|0:";	//tons,miles,time period index
		cookieContent += "ship:|0|0:";	//tons,miles,time period index
		cookieContent += "messenger:|0|0:";	//no of trips,distance (miles) per trip,time period index
		SetCookie("bizfreightinfo",cookieContent);
	}
	//**** end of biz freight
	
	//**** biz site
	if (! ExistCookie("bizsiteinfo") || Force==true){
		cookieContent = ":";
		cookieContent += "bizsiteno:1:";
		//cookieContent += "bizsite1:1|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|20:";	//business type index,heating method index,no of employee,building type index,squre footage,electricity,electricity time period index,natural gas, natural gas time period index,fuel oil, fuel oil time period index,coal,coal time period index,propane, propane time period index,wood, wood time period index, waste paper generated, waste paper recycled, waste paper time period index,waste food generated, waste food recycled, waste food time period index, waste glass generated, waste glass recycled, waste glass time period index, waste plastic generated, waste plastic recycled, waste plastic time period index, waste alluminum generated, waste alluminum recycled, waste alluminum time period index, Commuters subsidied, avg miles saving per person per year, avg gas mileag per vehicle
		//after 1-20-2009 use this
		cookieContent += "bizsite1:1|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|20:";	//business type index,heating method index,no of employee,building type index,squre footage,electricity,electricity time period index,natural gas, natural gas time period index,fuel oil, fuel oil time period index,coal,coal time period index,propane, propane time period index,wood, wood time period index,steam,steam time period index, waste paper generated, waste paper recycled, waste paper time period index,waste glass generated, waste glass recycled, waste glass time period index, waste plastic generated, waste plastic recycled, waste plastic time period index, waste alluminum generated, waste alluminum recycled, waste alluminum time period index, waste steel generated, waste steel recycled, waste steel time period index, Commuters subsidied, avg miles saving per person per year, avg gas mileag per vehicle
		//end of after 1-20-2009
		SetCookie("bizsiteinfo",cookieContent);
	}
	//**** end of biz site
}

function removeZeroInTextBox(){
	var textBoxes = document.getElementsByTagName("input");
	var i;
	var aBox;
	for(i=0;i<textBoxes.length;i++){
		aBox = textBoxes[i];
		if (aBox.type == "text"){
			if(aBox.value == "0"){
				aBox.value="";
			}
		}
	}
}
function ClearAllInput(){
	/*
	DeleteCookie('houseinput');
	DeleteCookie('housereduce');
	var aTable = document.getElementById("carTable");
	if (aTable != null){
		//delete all car rows except the firt row
		var CarNo = ToNumericValue(GetVariableFromCookie("carinfo","carno"));
		var firstCarRow = ReturnFirstCarRowIndex();
		for(i=2;i<=CarNo;i++){
			aTable.deleteRow(firstCarRow+1);
		}
	}
	var aTable = document.getElementById("airTable");
	if (aTable != null){
		//delete all air rows except the firt row
		var AirNo = ToNumericValue(GetVariableFromCookie("airinfo","airno"));
		var firstAirRow = ReturnFirstAirRowIndex();
		for(i=2;i<=AirNo;i++){
			aTable.deleteRow(firstAirRow+1);
		}
	}
	DeleteCookie('carinfo');
	DeleteCookie('airinfo');
	
	var aTable = document.getElementById("SiteGrandTable");
	if (aTable != null){
		//delete all site rows except the firt row
		var SiteNo = ToNumericValue(GetVariableFromCookie("bizsiteinfo","bizsiteno"));
		for(i=2;i<=SiteNo;i++){
			aTable.deleteRow(1);
		}
	}
	
	var aTable = document.getElementById("bizCarTable");
	if (aTable != null){
		//delete all biz car rows except the firt row
		var BizCarNo = ToNumericValue(GetVariableFromCookie("bizcarinfo","bizcarno"));
		var firstBizCarRow = ReturnFirstBizCarRowIndex();
		for(i=2;i<=BizCarNo;i++){
			aTable.deleteRow(firstBizCarRow+1);
		}
	}
	
	var aTable = document.getElementById("bizAirTable");
	if (aTable != null){
		//delete all biz air rows except the firt row
		var AirNo = ToNumericValue(GetVariableFromCookie("bizairinfo","bizairno"));
		var firstBizAirRow = ReturnFirstBizAirRowIndex();
		for(i=2;i<=BizAirNo;i++){
			aTable.deleteRow(firstBizAirRow+1);
		}
	}
	*/
	InitializeCookies(true);
	window.location.reload();
}
function ClearCarInput(){
	var aTable = document.getElementById("carTable");
	if (aTable != null){
		//delete all car rows except the firt row
		var CarNo = ToNumericValue(GetVariableFromCookie("carinfo","carno"));
		var firstCarRow = ReturnFirstCarRowIndex();
		for(i=2;i<=CarNo;i++){
			aTable.deleteRow(firstCarRow+1);
		}
	}
	DeleteCookie('carinfo');
}
function ClearBizCarInput(){
	var aTable = document.getElementById("bizCarTable");
	if (aTable != null){
		//delete all biz car rows except the firt row
		var BizCarNo = ToNumericValue(GetVariableFromCookie("bizcarinfo","bizcarno"));
		var firstBizCarRow = ReturnFirstBizCarRowIndex();
		for(i=2;i<=BizCarNo;i++){
			aTable.deleteRow(firstBizCarRow+1);
		}
	}
	DeleteCookie('bizcarinfo');
}
function ClearCarActionInput(){
	var CarNo = ToNumericValue(GetVariableFromCookie("carinfo","carno"));
	var ss;
	var thisCarInfo;
	var i;
	var k;
	var aComponent;
	SetVariableToCookie("carinfo","carlessmile","0");
	for (i=1;i<=CarNo;i++){
		thisCarInfo = GetVariableFromCookie("carinfo","car"+i)
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		//few miles to drive
		ss = thisCarInfo.split("|");
		ss[4] = "1";
		ss[5] = "0";
		ss[6] = "0"
		thisCarInfo = ss[0];
		for(k=1;k<ss.length;k++){
			thisCarInfo += "|"+ss[k];
		}
		SetVariableToCookie("carinfo","car"+i,thisCarInfo);
	}
	InitializePageComponents();
}
function ClearBizCarActionInput(){
	var BizCarNo = ToNumericValue(GetVariableFromCookie("bizcarinfo","bizcarno"));
	var ss;
	var thisBizCarInfo;
	var i;
	var k;
	var aComponent;
	SetVariableToCookie("bizcarinfo","bizcarlessmile","0");
	for (i=1;i<=BizCarNo;i++){
		thisBizCarInfo = GetVariableFromCookie("bizcarinfo","bizcar"+i)
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		//few miles to drive
		ss = thisBizCarInfo.split("|");
		ss[4] = "1";
		ss[5] = "0";
		ss[6] = "0"
		thisBizCarInfo = ss[0];
		for(k=1;k<ss.length;k++){
			thisBizCarInfo += "|"+ss[k];
		}
		SetVariableToCookie("bizcarinfo","bizcar"+i,thisBizCarInfo);
	}
	InitializePageComponents();
}
function ClearAirInput(){
	var aTable = document.getElementById("airTable");
	if (aTable != null){
		//delete all air rows except the firt row
		var AirNo = ToNumericValue(GetVariableFromCookie("airinfo","airno"));
		var firstAirRow = ReturnFirstAirRowIndex();
		for(i=2;i<=AirNo;i++){
			aTable.deleteRow(firstAirRow+1);
		}
	}
	DeleteCookie('airinfo');
}
function ClearBizAirInput(){
	var aTable = document.getElementById("bizAirTable");
	if (aTable != null){
		//delete all biz air rows except the firt row
		var AirNo = ToNumericValue(GetVariableFromCookie("bizairinfo","bizairno"));
		var firstBizAirRow = ReturnFirstBizAirRowIndex();
		for(i=2;i<=BizAirNo;i++){
			aTable.deleteRow(firstBizAirRow+1);
		}
	}
	DeleteCookie('bizairinfo');
}
/*
function ClearBizEquipInput(){
	var aTable = document.getElementById("bizEquipTable");
	if (aTable != null){
		//delete all biz air rows except the firt row
		var AirNo = ToNumericValue(GetVariableFromCookie("bizequipinfo","bizequipno"));
		var firstEquipRow = ReturnFirstBizEquipRowIndex();
		for(i=2;i<=EquipNo;i++){
			aTable.deleteRow(firstEquipRow+1);
		}
	}
	DeleteCookie('bizequipinfo');
}
*/
function InitializePageComponents(){
	InitializeCookies(false);
	var aComponent;
	var aSpan;
	var aRow;
	//*******house section
	aComponent = document.getElementById("resHouseMember");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","member");
	aComponent = document.getElementById("resHouseHeatMethod");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","heatmethod");
	/*
	aSpan = document.getElementById("resPrimaryHeatingText");
	if (aSpan != null) aSpan.innerHTML = "'"+aComponent.options[aComponent.selectedIndex].text+"' ";
	aRow = document.getElementById("resPrimaryHeatingPercentRow");
	if (aRow != null){
		if (aComponent.value == 5){
			//steam
			aRow.style.visibility = "hidden";
		}else{
			aRow.style.visibility = "visible";
		}
	}
	aComponent = document.getElementById("resHouseHeatSourcePercent");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","heatsourcepercent");
	*/
	aComponent = document.getElementById("resHouseSecHeatMethod");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","secheatmethod");
	aSpan = document.getElementById("resSecondaryHeatingText");
	aRow = document.getElementById("resSecondaryHeatingPercentRow");
	if (aSpan != null) {
		if (aComponent.selectedIndex == 0 || aComponent.selectedIndex == 5){
			aRow.style.visibility = "hidden";
			aSpan.innerHTML = "";
		}else{
			aRow.style.visibility = "visible";
			aSpan.innerHTML = "";	// "'"+aComponent.options[aComponent.selectedIndex].text+"' ";
		}
	}
	aComponent = document.getElementById("resHouseSecHeatSourcePercent");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","secheatsourcepercent");
	aComponent = document.getElementById("resElectricBill");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","electricbill");
	aComponent = document.getElementById("resGasBill");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","gasbill");
	aComponent = document.getElementById("resFuelOilBill");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","fueloilbill");
	aComponent = document.getElementById("resElectricKWH");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","electricity");
	aComponent = document.getElementById("resNatGasFeet");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","natgas");
	aComponent = document.getElementById("resFuelOilGallon");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","fueloil");
	aComponent = document.getElementById("resCoalTon");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","coal");
	aComponent = document.getElementById("resSteamPound");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","steam");
	aComponent = document.getElementById("resPropaneGallon");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","propane");
	aComponent = document.getElementById("resWoodCord");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("houseinput","wood");
	aComponent = document.getElementById("resNewsPaper");
	if (aComponent != null) aComponent.checked = ToBooleanValue(GetVariableFromCookie("houseinput","newspaper"));
	aComponent = document.getElementById("resMagazine");
	if (aComponent != null) aComponent.checked = ToBooleanValue(GetVariableFromCookie("houseinput","magazine"));
	aComponent = document.getElementById("resGlass");
	if (aComponent != null) aComponent.checked = ToBooleanValue(GetVariableFromCookie("houseinput","glass"));
	aComponent = document.getElementById("resPlastic");
	if (aComponent != null) aComponent.checked = ToBooleanValue(GetVariableFromCookie("houseinput","plastic"));
	aComponent = document.getElementById("resAluminum");
	if (aComponent != null) aComponent.checked = ToBooleanValue(GetVariableFromCookie("houseinput","aluminum"));
	//***** end of house section
	
	//**** house reduce section
	aComponent = document.getElementById("resReduceHeatingThermo");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("housereduce","heatingthermo");
	aComponent = document.getElementById("resReduceBulbs");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("housereduce","bulbs");
	if (ToBooleanValue(GetVariableFromCookie("housereduce","refri"))){
		aComponent = document.getElementById("resReduceRadioRefri1");
		if (aComponent != null) aComponent.checked = true;
	}else{
		aComponent = document.getElementById("resReduceRadioRefri2");
		if (aComponent != null) aComponent.checked = true;
	}
	if (ToBooleanValue(GetVariableFromCookie("housereduce","furnace"))){
		aComponent = document.getElementById("resReduceRadioFurnace1");
		if (aComponent != null) aComponent.checked = true;
	}else{
		aComponent = document.getElementById("resReduceRadioFurnace2");
		if (aComponent != null) aComponent.checked = true;
	}
	aComponent = document.getElementById("resReduceACThermo");
	if (aComponent != null) aComponent.value = GetVariableFromCookie("housereduce","acthermo");
	if (ToBooleanValue(GetVariableFromCookie("housereduce","window"))){
		aComponent = document.getElementById("resReduceRadioWindow1");
		if (aComponent != null) aComponent.checked = true;
	}else{
		aComponent = document.getElementById("resReduceRadioWindow2");
		if (aComponent != null) aComponent.checked = true;
	}
	if (ToBooleanValue(GetVariableFromCookie("housereduce","material"))){
		aComponent = document.getElementById("resReduceRadioMaterial1");
		if (aComponent != null) aComponent.checked = true;
	}else{
		aComponent = document.getElementById("resReduceRadioMaterial2");
		if (aComponent != null) aComponent.checked = true;
	}
	if (ToBooleanValue(GetVariableFromCookie("housereduce","plant"))){
		aComponent = document.getElementById("resReduceRadioPlant1");
		if (aComponent != null) aComponent.checked = true;
	}else{
		aComponent = document.getElementById("resReduceRadioPlant2");
		if (aComponent != null) aComponent.checked = true;
	}
	//**** end of house reduce section
		
	//**** air mile section
	//aComponent = document.getElementById("airMile");
	//if (aComponent != null) aComponent.value = ToNumericValue(GetVariableFromCookie("airinfo","airmile"));
	{
		var AirNo = ToNumericValue(GetVariableFromCookie("airinfo","airno"));
		var i;
		var firstRowIndex;
		var aTable = document.getElementById("airTable");
		if (aTable != null){
			for (i=1; i<=AirNo;i++){
				//Destination
				//round trip mile
				if(i!=1){
					//add an air row
					InsertAirRow();
				}
				var myAirInfo = GetVariableFromCookie("airinfo","air"+i);
				firstRowIndex = ReturnFirstAirRowIndex();
				if (firstRowIndex != -1){
					SetAirRowValue(firstRowIndex+i-1,myAirInfo);
				}
			}
		}
	}
	//***** end of air mile section
	
	//**** biz air mile section
	{
		var BizAirNo = ToNumericValue(GetVariableFromCookie("bizairinfo","bizairno"));
		var i;
		var firstRowIndex;
		var aTable = document.getElementById("bizAirTable");
		if (aTable != null){
			for (i=1; i<=BizAirNo;i++){
				//Destination
				//round trip mile
				if(i!=1){
					//add an biz air row
					InsertBizAirRow();
				}
				var myBizAirInfo = GetVariableFromCookie("bizairinfo","bizair"+i);
				firstRowIndex = ReturnFirstBizAirRowIndex();
				if (firstRowIndex != -1){
					SetBizAirRowValue(firstRowIndex+i-1,myBizAirInfo);
				}
			}
		}
	}
	//***** end of biz air mile section
	//**** biz equip section
	{
		/*
		var EquipNo = ToNumericValue(GetVariableFromCookie("bizequipinfo","bizequipno"));
		var i;
		var firstRowIndex;
		var aTable = document.getElementById("bizEquipTable");
		if (aTable != null){
			for (i=1; i<=EquipNo;i++){
				if(i!=1){
					//add an biz equip row
					InsertBizEquipRow();
				}
				var myEquipInfo = GetVariableFromCookie("bizequipinfo","bizequip"+i);
				firstRowIndex = ReturnFirstBizEquipRowIndex();
				if (firstRowIndex != -1){
					SetBizEquipRowValue(firstRowIndex+i-1,myEquipInfo);
				}
			}
		}
		*/
		//after 1-20-2009, use this
		var EquipGallonTimePeriod;
		var ss;
		var aBox;
		//for gasoline
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","gasoline");
		ss = EquipGallonTimePeriod.split("|");
		aBox = document.getElementById("bizEquipGasolineGallon");
		if (aBox) aBox.value=ss[0];
		aBox = document.getElementById("bizEquipGasolineTimePeriod");
		if (aBox) aBox.value=ss[1];
		//for diesel
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","diesel");
		ss = EquipGallonTimePeriod.split("|");
		aBox = document.getElementById("bizEquipDieselGallon");
		if (aBox) aBox.value=ss[0];
		aBox = document.getElementById("bizEquipDieselTimePeriod");
		if (aBox) aBox.value=ss[1];
		//for propane
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","propane");
		ss = EquipGallonTimePeriod.split("|");
		aBox = document.getElementById("bizEquipPropaneGallon");
		if (aBox) aBox.value=ss[0];
		aBox = document.getElementById("bizEquipPropaneTimePeriod");
		if (aBox) aBox.value=ss[1];
		//for jet fuel
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","jetfuel");
		ss = EquipGallonTimePeriod.split("|");
		aBox = document.getElementById("bizEquipJetFuelGallon");
		if (aBox) aBox.value=ss[0];
		aBox = document.getElementById("bizEquipJetFuelTimePeriod");
		if (aBox) aBox.value=ss[1];
		//for Aviation Gasoline
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","aviationgasoline");
		ss = EquipGallonTimePeriod.split("|");
		aBox = document.getElementById("bizEquipAviationGasolineGallon");
		if (aBox) aBox.value=ss[0];
		aBox = document.getElementById("bizEquipAviationGasolineTimePeriod");
		if (aBox) aBox.value=ss[1];
		//for biodiesel
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","biodiesel");
		ss = EquipGallonTimePeriod.split("|");
		aBox = document.getElementById("bizEquipBioDieselGallon");
		if (aBox) aBox.value=ss[0];
		aBox = document.getElementById("bizEquipBioDieselTimePeriod");
		if (aBox) aBox.value=ss[1];
		//end of after 1-20-2009
	}
	//***** end of biz equip section
	
	//***** car info
	{
		var CarNo = ToNumericValue(GetVariableFromCookie("carinfo","carno"));
		var i;
		var firstRowIndex;
		var aTable = document.getElementById("carTable");
		if (aTable != null){
			for (i=1; i<=CarNo;i++){
				//vehicle type index, 
				//actual gas mileage/gallon, 
				//No of vehicles, 
				//annual driving miles, 
				//no of vehicles to be replaced by efficient vehicles, 
				//improvement of gas mileage/gallon
				//few miles to drive
				if(i!=1){
					//add a car row
					InsertCarRow();
				}
				var myCarInfo = GetVariableFromCookie("carinfo","car"+i);
				firstRowIndex = ReturnFirstCarRowIndex();
				if (firstRowIndex != -1){
					SetCarRowValue(firstRowIndex+i-1,myCarInfo);
				}
			}
		}
	}
	//***** end of car info
	
	//***** biz car info
	{
		var BizCarNo = ToNumericValue(GetVariableFromCookie("bizcarinfo","bizcarno"));
		var i;
		var firstRowIndex;
		var aTable = document.getElementById("bizCarTable");
		if (aTable != null){
			for (i=1; i<=BizCarNo;i++){
				//vehicle type index, 
				//actual gas mileage/gallon, 
				//No of vehicles, 
				//annual driving miles, 
				//fuel type
				if(i!=1){
					//add a biz car row
					InsertBizCarRow();
				}
				var myBizCarInfo = GetVariableFromCookie("bizcarinfo","bizcar"+i);
				firstRowIndex = ReturnFirstBizCarRowIndex();
				if (firstRowIndex != -1){
					SetBizCarRowValue(firstRowIndex+i-1,myBizCarInfo);
				}
			}
		}
	}
	//***** end of biz car info
	
	//***** car reduce info
	
	{
		//aComponent = document.getElementById("carLessMile");
		//if (aComponent != null) aComponent.value = GetVariableFromCookie("carinfo","carlessmile");
		var CarNo = ToNumericValue(GetVariableFromCookie("carinfo","carno"));
		var i;
		var firstRowIndex;
		var ss;
		for (i=1; i<=CarNo;i++){
				//vehicle type index, 
				//actual gas mileage/gallon, 
				//No of vehicles, 
				//annual driving miles, 
				//no of vehicles to be replaced by efficient vehicles, 
				//improvement of gas mileage/gallon
				//few miles to drive
			var myCarInfo = GetVariableFromCookie("carinfo","car"+i);
			ss = myCarInfo.split("|");
			aComponent = document.getElementById("carInfo1_"+i);
			if (aComponent != null) aComponent.innerHTML = "Vehicle Type:" + VehicleReferences[ss[0]][0] + "; Gas Mileage/Gallon:" + ss[1] + "; Annual Miles:" + ss[3];
			aComponent = document.getElementById("carLessMile"+i);
			if (aComponent != null) aComponent.value = ss[6];
			
			aComponent = document.getElementById("carInfo"+i);
			//if (aComponent != null) aComponent.innerHTML = "Vehicle Type:" + VehicleReferences[ss[0]][0] + "; Gas Mileage/Gallon:" + ss[1] + "; Number of Vehicles:" + ss[2] + "; Annual Miles / Vehicle:" + ss[3];
			if (aComponent != null) aComponent.innerHTML = "Vehicle Type:" + VehicleReferences[ss[0]][0] + "; Gas Mileage/Gallon:" + ss[1] + "; Annual Miles:" + ss[3];
			aComponent = document.getElementById("carReplacementNo"+i);
			if (aComponent != null) aComponent.value = ss[4];
			aComponent = document.getElementById("carReplacementPlusMileage"+i);
			if (aComponent != null) aComponent.value = ss[5];
			
		}
	}
	
	//***** car reduce info
	
	//***** biz car reduce info
	
	{
		//aComponent = document.getElementById("carLessMile");
		//if (aComponent != null) aComponent.value = GetVariableFromCookie("carinfo","carlessmile");
		var BizCarNo = ToNumericValue(GetVariableFromCookie("bizcarinfo","bizcarno"));
		var i;
		var firstRowIndex;
		var ss;
		for (i=1; i<=BizCarNo;i++){
				//vehicle type index, 
				//actual gas mileage/gallon, 
				//No of vehicles, 
				//annual driving miles, 
				//no of vehicles to be replaced by efficient vehicles, 
				//improvement of gas mileage/gallon
				//few miles to drive
			var myBizCarInfo = GetVariableFromCookie("bizcarinfo","bizcar"+i);
			ss = myBizCarInfo.split("|");
			aComponent = document.getElementById("bizcarInfo1_"+i);
			if (aComponent != null) aComponent.innerHTML = "Vehicle Type:" + VehicleReferences[ss[0]][0] + "; Gas Mileage/Gallon:" + ss[1] + "; Annual Miles:" + ss[3];
			aComponent = document.getElementById("bizCarLessMile"+i);
			if (aComponent != null) aComponent.value = ss[6];
			
			aComponent = document.getElementById("bizcarInfo"+i);
			//if (aComponent != null) aComponent.innerHTML = "Vehicle Type:" + VehicleReferences[ss[0]][0] + "; Gas Mileage/Gallon:" + ss[1] + "; Number of Vehicles:" + ss[2] + "; Annual Miles / Vehicle:" + ss[3];
			if (aComponent != null) aComponent.innerHTML = "Vehicle Type:" + VehicleReferences[ss[0]][0] + "; Gas Mileage/Gallon:" + ss[1] + "; Annual Miles:" + ss[3];
			aComponent = document.getElementById("bizCarReplacementNo"+i);
			if (aComponent != null) aComponent.value = ss[4];
			aComponent = document.getElementById("bizCarReplacementPlusMileage"+i);
			if (aComponent != null) aComponent.value = ss[5];
			
		}
	}
	
	//***** biz car reduce info
	
	//biz freight
	{
		var ss;
		//for train
		var myFreight = GetVariableFromCookie("bizfreightinfo","train")
		ss = myFreight.split("|");
		aComponent = document.getElementById("bizFreightTrainTon");
		if (aComponent != null) aComponent.value = ss[0];
		aComponent = document.getElementById("bizFreightTrainDistance");
		if (aComponent != null) aComponent.value = ss[1];
		aComponent = document.getElementById("perTrainTimePeriod");
		if (aComponent != null) aComponent.value = ss[2];
		//for van
		var myFreight = GetVariableFromCookie("bizfreightinfo","van")
		ss = myFreight.split("|");
		aComponent = document.getElementById("bizFreightVanTon");
		if (aComponent != null) aComponent.value = ss[0];
		aComponent = document.getElementById("bizFreightVanDistance");
		if (aComponent != null) aComponent.value = ss[1];
		aComponent = document.getElementById("perVanTimePeriod");
		if (aComponent != null) aComponent.value = ss[2];
		//for truck
		var myFreight = GetVariableFromCookie("bizfreightinfo","truck")
		ss = myFreight.split("|");
		aComponent = document.getElementById("bizFreightTruckTon");
		if (aComponent != null) aComponent.value = ss[0];
		aComponent = document.getElementById("bizFreightTruckDistance");
		if (aComponent != null) aComponent.value = ss[1];
		aComponent = document.getElementById("perTruckTimePeriod");
		if (aComponent != null) aComponent.value = ss[2];
		//for ship
		var myFreight = GetVariableFromCookie("bizfreightinfo","ship")
		ss = myFreight.split("|");
		aComponent = document.getElementById("bizFreightShipTon");
		if (aComponent != null) aComponent.value = ss[0];
		aComponent = document.getElementById("bizFreightShipDistance");
		if (aComponent != null) aComponent.value = ss[1];
		aComponent = document.getElementById("perShipTimePeriod");
		if (aComponent != null) aComponent.value = ss[2];
		//for airgoods
		var myFreight = GetVariableFromCookie("bizfreightinfo","airgoods")
		ss = myFreight.split("|");
		aComponent = document.getElementById("bizFreightAirGoodsTon");
		if (aComponent != null) aComponent.value = ss[0];
		aComponent = document.getElementById("bizFreightAirGoodsDistance");
		if (aComponent != null) aComponent.value = ss[1];
		aComponent = document.getElementById("perAirGoodsTimePeriod");
		if (aComponent != null) aComponent.value = ss[2];
		//for messenger
		var myFreight = GetVariableFromCookie("bizfreightinfo","messenger")
		ss = myFreight.split("|");
		aComponent = document.getElementById("bizFreightMessengerTrips");
		if (aComponent != null) aComponent.value = ss[0];
		aComponent = document.getElementById("bizFreightMessengerDistance");
		if (aComponent != null) aComponent.value = ss[1];
		aComponent = document.getElementById("perMessengerTimePeriod");
		if (aComponent != null) aComponent.value = ss[2];
	}
	//end of biz freight
	
	//biz site section
	MatchBizSiteFormToCookie();
	ReOrderBizSites();
	SetBizSiteContent();
	//end of biz site section
	
	removeZeroInTextBox();
	CalculateEmission();
}

//****** house section page components events
function resHouseMemberChange(){
	//coming from change event 
	var aSelect = document.getElementById("resHouseMember");
	SetVariableToCookie("houseinput","member",aSelect.value);
	CalculateEmission();
}
function resHouseHeatMethodChange(){
	var aSelect = document.getElementById("resHouseHeatMethod");
	var secondarySelect = document.getElementById("resHouseSecHeatMethod");
	SetVariableToCookie("houseinput","heatmethod",aSelect.value);
	CalculateEmission();
	//set the text
	/*
	aSpan = document.getElementById("resPrimaryHeatingText");
	aSpan.innerHTML = "'"+aSelect.options[aSelect.selectedIndex].text+"' ";
	var aRow = document.getElementById("resPrimaryHeatingPercentRow");
	if (aSelect.value == 5){
		//steam
		aRow.style.visibility = "hidden";
	}else{
		aRow.style.visibility = "visible";
	}
	*/
	if (aSelect.value == secondarySelect.value){
		alert("Since the primary heating method is the same as the secondary heating method, please re-select the secondary heating method");
		secondarySelect.value=0;
		resHouseSecHeatMethodChange();
	}
}
function resHouseHeatSourcePercentChange(){
	var aBox = document.getElementById("resHouseHeatSourcePercent");
	SetVariableToCookie("houseinput","heatsourcepercent",aBox.value);
	CalculateEmission();
}
function resHouseSecHeatMethodChange(){
	var primarySelect = document.getElementById("resHouseHeatMethod");
	var aSelect = document.getElementById("resHouseSecHeatMethod");
	if (primarySelect.value == aSelect.value){
		aSelect.value = 0;
		alert("You can not select the same heating method as primary heating method.");
	}
	SetVariableToCookie("houseinput","secheatmethod",aSelect.value);
	CalculateEmission();
	//set the text
	var aSpan = document.getElementById("resSecondaryHeatingText");
	var aRow = document.getElementById("resSecondaryHeatingPercentRow");
	var aPercent = document.getElementById("resHouseSecHeatSourcePercent");
	if (aSelect.selectedIndex == 0 || aSelect.selectedIndex == 5){
		//5 is steam
		aRow.style.visibility = "hidden";
		aSpan.innerHTML = "";
	}else{
		aRow.style.visibility = "visible";
		aSpan.innerHTML = "";	//"'"+aSelect.options[aSelect.selectedIndex].text+"' ";
		if (aSelect.selectedIndex == 2){
			//2 is Electricity, default to 0.6%
			aPercent.value = 0.6;
		}
	}
}
function resHouseSecHeatSourcePercentChange(){
	var aBox = document.getElementById("resHouseSecHeatSourcePercent");
	SetVariableToCookie("houseinput","secheatsourcepercent",aBox.value);
	CalculateEmission();
}
function resElectricBillChange(e){
	if (e != null) {
		//coming from key up event
		if(e.keyCode != 13){
			// not the return key, so exit
			return 0;
		}
	}
	//coming from change event or keyup event of the return key
	var aSelect = document.getElementById("resElectricBill");
	SetVariableToCookie("houseinput","electricbill",aSelect.value);
	CalculateEmission();
}
function resGasBillChange(){
	var aSelect = document.getElementById("resGasBill");
	SetVariableToCookie("houseinput","gasbill",aSelect.value);
	CalculateEmission();
}
function resFuelOilBillChange(){
	var aSelect = document.getElementById("resFuelOilBill");
	SetVariableToCookie("houseinput","fueloilbill",aSelect.value);
	CalculateEmission();
}
function resElectricKWHChange(){
	var aSelect = document.getElementById("resElectricKWH");
	SetVariableToCookie("houseinput","electricity",aSelect.value);
	CalculateEmission();
}
function resNatGasFeetChange(){
	var aSelect = document.getElementById("resNatGasFeet");
	SetVariableToCookie("houseinput","natgas",aSelect.value);
	CalculateEmission();
}
function resFuelOilGallonChange(){
	var aSelect = document.getElementById("resFuelOilGallon");
	SetVariableToCookie("houseinput","fueloil",aSelect.value);
	CalculateEmission();
}
function resCoalTonChange(){
	var aSelect = document.getElementById("resCoalTon");
	SetVariableToCookie("houseinput","coal",aSelect.value);
	CalculateEmission();
}
function resSteamPoundChange(){
	var aSelect = document.getElementById("resSteamPound");
	SetVariableToCookie("houseinput","steam",aSelect.value);
	CalculateEmission();
}
function resPropaneGallonChange(){
	var aSelect = document.getElementById("resPropaneGallon");
	SetVariableToCookie("houseinput","propane",aSelect.value);
	CalculateEmission();
}
function resWoodCordChange(){
	var aSelect = document.getElementById("resWoodCord");
	SetVariableToCookie("houseinput","wood",aSelect.value);
	CalculateEmission();
}
function resNewsPaperClick(){
	var aSelect = document.getElementById("resNewsPaper");
	SetVariableToCookie("houseinput","newspaper",aSelect.checked);
	CalculateEmission();
}
function resMagazineClick(){
	var aSelect = document.getElementById("resMagazine");
	SetVariableToCookie("houseinput","magazine",aSelect.checked);
	CalculateEmission();
}
function resGlassClick(){
	var aSelect = document.getElementById("resGlass");
	SetVariableToCookie("houseinput","glass",aSelect.checked);
	CalculateEmission();
}
function resPlasticClick(){
	var aSelect = document.getElementById("resPlastic");
	SetVariableToCookie("houseinput","plastic",aSelect.checked);
	CalculateEmission();
}
function resAluminumClick(){
	var aSelect = document.getElementById("resAluminum");
	SetVariableToCookie("houseinput","aluminum",aSelect.checked);
	CalculateEmission();
}
//****** endof house section page components events

//***** house reduce section page components events
function resReduceHeatingThermoChange(){
	var aSelect = document.getElementById("resReduceHeatingThermo");
	SetVariableToCookie("housereduce","heatingthermo",aSelect.value);
	CalculateEmission();
}
function resReduceBulbsChange(){
	var aSelect = document.getElementById("resReduceBulbs");
	SetVariableToCookie("housereduce","bulbs",aSelect.value);
	CalculateEmission();
}
function resReduceRadioRefriClick(){
	var aSelect = document.getElementById("resReduceRadioRefri1");
	SetVariableToCookie("housereduce","refri",aSelect.checked);
	CalculateEmission();
}
function resReduceRadioFurnaceClick(){
	var aSelect = document.getElementById("resReduceRadioFurnace1");
	SetVariableToCookie("housereduce","furnace",aSelect.checked);
	CalculateEmission();
}
function resReduceACThermoChange(){
	var aSelect = document.getElementById("resReduceACThermo");
	SetVariableToCookie("housereduce","acthermo",aSelect.value);
	CalculateEmission();
}
function resReduceRadioWindowClick(){
	var aSelect = document.getElementById("resReduceRadioWindow1");
	SetVariableToCookie("housereduce","window",aSelect.checked);
	CalculateEmission();
}
function resReduceRadioMaterialClick(){
	var aSelect = document.getElementById("resReduceRadioMaterial1");
	SetVariableToCookie("housereduce","material",aSelect.checked);
	CalculateEmission();
}
function resReduceRadioPlantClick(){
	var aSelect = document.getElementById("resReduceRadioPlant1");
	SetVariableToCookie("housereduce","plant",aSelect.checked);
	CalculateEmission();
}
//***** end of house reduce section page components events

//****** air mile section page components events
function airMileChange(){
	//var aSelect = document.getElementById("airMile");
	//SetVariableToCookie("airinfo","airmile",aSelect.value);
	//CalculateEmission();
}
function flightDestinationChange(aTextBox){
	clearTimeout(mytime);
	FormingAirCookie();
	PopulateAirList(aTextBox);
}
function bizFlightDestinationChange(aTextBox){
	clearTimeout(mytime);
	FormingBizAirCookie();
	PopulateBizAirList(aTextBox);
}
function roundTripMileChange(){
	FormingAirCookie();
	CalculateEmission();
}
function tripTimesChange(){
	FormingAirCookie();
	CalculateEmission();
}
function bizRoundTripMileChange(){
	FormingBizAirCookie();
	CalculateEmission();
}
function bizTripTimesChange(){
	FormingBizAirCookie();
	CalculateEmission();
}
function airRemoveClick(removeButton){
	DeleteAirRow(removeButton); 
	FormingAirCookie();
	CalculateEmission();
}
function bizAirRemoveClick(removeButton){
	DeleteBizAirRow(removeButton); 
	FormingBizAirCookie();
	CalculateEmission();
}
//****** end of air mile section page components events

//biz equip section page components events
/*
function bizEquipChange(aTextBox){
	clearTimeout(mytime);
	FormingBizEquipCookie();
	PopulateBizEquipList(aTextBox);
}

function bizEquipNumberChange(){
	FormingBizEquipCookie();
	CalculateEmission();
}
function bizEquipFuelTypeChange(){
	FormingBizEquipCookie();
	CalculateEmission();
}
function bizEquipGallonChange(){
	FormingBizEquipCookie();
	CalculateEmission();
}
function bizEquipTimePeriodChange(){
	FormingBizEquipCookie();
	CalculateEmission();
}

function bizEquipRemoveClick(removeButton){
	DeleteBizEquipRow(removeButton); 
	FormingBizEquipCookie();
	CalculateEmission();
}
*/
//after 1-20-2009, use this
function bizEquipContentChange(){
	FormingBizEquipCookie();
	CalculateEmission();
}
//end of after 1-20-2009
//****** end of biz equip section page components events

// biz freight event
function bizFreightChange(){
	FormingBizFreightCookie();
	CalculateEmission();
}
// end of biz freight event

//******* for car event
function carRemoveClick(removeButton){
	DeleteCarRow(removeButton); 
	FormingCarCookie();
	CalculateEmission();
}
function carTypeChange(typeSelect){

	var i;
	var anIndex = ReturnCarRowIndex(typeSelect);
	var aTable = document.getElementById("carTable");
	var allRows = aTable.getElementsByTagName("tr");
	/*	//this column removed, so commented here
	var cpnts = allRows[anIndex].getElementsByTagName("div");
	for(i=0;i<cpnts.length;i++){
		if(cpnts[i].getAttribute('name')=="carAvgMileage"){
			cpnts[i].innerHTML = typeSelect.value;
		}
	}
	*/
	var cpnts = allRows[anIndex].getElementsByTagName("input");
	for(i=0;i<cpnts.length;i++){
		if(cpnts[i].getAttribute('name')=="carActualMileage"){
			//if (cpnts[i].value=="" || cpnts[i].value=="0"){
				cpnts[i].value = typeSelect.value;
			//}
		}
	}
	FormingCarCookie();
	CalculateEmission();
	
}
function carActualMileageChange(gasMileageTextBox){
	FormingCarCookie();
	CalculateEmission();
}
function carNumberChange(carNumberTextBox){
	FormingCarCookie();
	CalculateEmission();
}
function carDrivingMilesChange(carDrivingMilesTextBox){
	FormingCarCookie();
	CalculateEmission();
}
function carLessMileChange(aTextBox){
	//if (aTextBox != null){
	//	SetVariableToCookie("carinfo","carlessmile",aTextBox.value);
	//	CalculateEmission();
	//}
	
	//changed to this at 8/8/2007
	if (aTextBox != null){
		//id is carReplacementPlusMileage1, carReplacementPlusMileage2, etc
		var boxId = aTextBox.getAttribute("id");
		var anId = ToNumericValue(boxId.substr(11,boxId.length-11));
		var thisCarInfo = GetVariableFromCookie("carinfo","car"+anId);
		var i;
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		//few miles to drive
		var ss = thisCarInfo.split("|");
		if(ToNumericValue(aTextBox.value) == 0){
			aTextBox.value = "0";
		}
		if (ToNumericValue(aTextBox.value) > ToNumericValue(ss[3])){
			aTextBox.value = ss[3];
		}else{
			ss[6] = aTextBox.value;
		}
		thisCarInfo = ss[0];
		for(i=1;i<ss.length;i++){
			thisCarInfo += "|"+ss[i];
		}
		SetVariableToCookie("carinfo","car"+anId,thisCarInfo);
		CalculateEmission();
	}
}
function carReplacementNoChange(aTextBox){
	if (aTextBox != null){
		//id is carReplacementNo1, carReplacementNo2, etc
		var boxId = aTextBox.getAttribute("id");
		var anId = ToNumericValue(boxId.substr(16,boxId.length-16));
		var thisCarInfo = GetVariableFromCookie("carinfo","car"+anId);
		var i;
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		//few miles to drive
		var ss = thisCarInfo.split("|");
		if(ToNumericValue(aTextBox.value) == 0){
			aTextBox.value = "0";
		}
		if (ToNumericValue(aTextBox.value)>ToNumericValue(ss[2])){
			aTextBox.value = ToNumericValue(ss[2]);
			ss[4] = ss[2];
		}else{
			ss[4] = aTextBox.value;
		}
		thisCarInfo = ss[0];
		for(i=1;i<ss.length;i++){
			thisCarInfo += "|"+ss[i];
		}
		SetVariableToCookie("carinfo","car"+anId,thisCarInfo);
		CalculateEmission();
	}
}
function carReplacementPlusMileageChange(aTextBox){
	if (aTextBox != null){
		//id is carReplacementPlusMileage1, carReplacementPlusMileage2, etc
		var boxId = aTextBox.getAttribute("id");
		var anId = ToNumericValue(boxId.substr(25,boxId.length-25));
		var thisCarInfo = GetVariableFromCookie("carinfo","car"+anId);
		var i;
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		////few miles to drive
		var ss = thisCarInfo.split("|");
		if(ToNumericValue(aTextBox.value) == 0){
			aTextBox.value = "0";
		}
		ss[5] = aTextBox.value;
		thisCarInfo = ss[0];
		for(i=1;i<ss.length;i++){
			thisCarInfo += "|"+ss[i];
		}
		SetVariableToCookie("carinfo","car"+anId,thisCarInfo);
		CalculateEmission();
	}
}
//******* end of car event

//******* for biz car event
function bizCarRemoveClick(removeButton){
	DeleteBizCarRow(removeButton); 
	FormingBizCarCookie();
	CalculateEmission();
}
function bizCarTypeChange(typeSelect){

	var i;
	var anIndex = ReturnBizCarRowIndex(typeSelect);
	var aTable = document.getElementById("bizCarTable");
	var allRows = aTable.getElementsByTagName("tr");
	/*	//this column removed, so commented here
	var cpnts = allRows[anIndex].getElementsByTagName("div");
	for(i=0;i<cpnts.length;i++){
		if(cpnts[i].getAttribute('name')=="carAvgMileage"){
			cpnts[i].innerHTML = typeSelect.value;
		}
	}
	*/
	var cpnts = allRows[anIndex].getElementsByTagName("input");
	for(i=0;i<cpnts.length;i++){
		if(cpnts[i].getAttribute('name')=="bizCarActualMileage"){
			//if (cpnts[i].value=="" || cpnts[i].value=="0"){
				cpnts[i].value = typeSelect.value;
			//}
		}
	}
	FormingBizCarCookie();
	CalculateEmission();
	
}
function bizCarActualMileageChange(gasMileageTextBox){
	FormingBizCarCookie();
	CalculateEmission();
}
function bizCarNumberChange(bizCarNumberTextBox){
	FormingBizCarCookie();
	CalculateEmission();
}
function bizCarDrivingMilesChange(bizCarDrivingMilesTextBox){
	FormingBizCarCookie();
	CalculateEmission();
}
function bizCarFuelTypeChange(){
	FormingBizCarCookie();
	CalculateEmission();
}
function bizCarLessMileChange(aTextBox){
	//if (aTextBox != null){
	//	SetVariableToCookie("bizcarinfo","bizcarlessmile",aTextBox.value);
	//	CalculateEmission();
	//}
	
	//changed to this at 8/8/2007
	if (aTextBox != null){
		//id is bizCarReplacementPlusMileage1, bizCarReplacementPlusMileage2, etc
		var boxId = aTextBox.getAttribute("id");
		var anId = ToNumericValue(boxId.substr(11,boxId.length-11));
		var thisBizCarInfo = GetVariableFromCookie("bizcarinfo","bizcar"+anId);
		var i;
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		//few miles to drive
		var ss = thisBizCarInfo.split("|");
		if(ToNumericValue(aTextBox.value) == 0){
			aTextBox.value = "0";
		}
		if (ToNumericValue(aTextBox.value) > ToNumericValue(ss[3])){
			aTextBox.value = ss[3];
		}else{
			ss[6] = aTextBox.value;
		}
		thisBizCarInfo = ss[0];
		for(i=1;i<ss.length;i++){
			thisBizCarInfo += "|"+ss[i];
		}
		SetVariableToCookie("bizcarinfo","bizcar"+anId,thisBizCarInfo);
		CalculateEmission();
	}
}
function bizCarReplacementNoChange(aTextBox){
	if (aTextBox != null){
		//id is bizCarReplacementNo1, bizCarReplacementNo2, etc
		var boxId = aTextBox.getAttribute("id");
		var anId = ToNumericValue(boxId.substr(16,boxId.length-16));
		var thisBizCarInfo = GetVariableFromCookie("bizcarinfo","bizcar"+anId);
		var i;
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		//few miles to drive
		var ss = thisBizCarInfo.split("|");
		if(ToNumericValue(aTextBox.value) == 0){
			aTextBox.value = "0";
		}
		if (ToNumericValue(aTextBox.value)>ToNumericValue(ss[2])){
			aTextBox.value = ToNumericValue(ss[2]);
			ss[4] = ss[2];
		}else{
			ss[4] = aTextBox.value;
		}
		thisBizCarInfo = ss[0];
		for(i=1;i<ss.length;i++){
			thisBizCarInfo += "|"+ss[i];
		}
		SetVariableToCookie("bizcarinfo","bizcar"+anId,thisBizCarInfo);
		CalculateEmission();
	}
}
function bizCarReplacementPlusMileageChange(aTextBox){
	if (aTextBox != null){
		//id is bizCarReplacementPlusMileage1, bizCarReplacementPlusMileage2, etc
		var boxId = aTextBox.getAttribute("id");
		var anId = ToNumericValue(boxId.substr(25,boxId.length-25));
		var thisBizCarInfo = GetVariableFromCookie("bizcarinfo","bizcar"+anId);
		var i;
		//vehicle type index, 
		//actual gas mileage/gallon, 
		//No of vehicles, 
		//annual driving miles, 
		//no of vehicles to be replaced by efficient vehicles, 
		//improvement of gas mileage/gallon
		////few miles to drive
		var ss = thisBizCarInfo.split("|");
		if(ToNumericValue(aTextBox.value) == 0){
			aTextBox.value = "0";
		}
		ss[5] = aTextBox.value;
		thisBizCarInfo = ss[0];
		for(i=1;i<ss.length;i++){
			thisBizCarInfo += "|"+ss[i];
		}
		SetVariableToCookie("bizcarinfo","bizcar"+anId,thisBizCarInfo);
		CalculateEmission();
	}
}
//******* end of biz car event

//biz site section
	function AddBizSite(){
		//change cookie
		var BizSiteNo = ToNumericValue(GetVariableFromCookie("bizsiteinfo","bizsiteno"));
		//var aValue = "1|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|20";
		//after 1-20-2009 use this
		var aValue = "1|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|20";
		//end of after 1-20-2009
		var variableName = "bizsite" + (BizSiteNo+1);
		SetVariableToCookie("bizsiteinfo",variableName,aValue);
		SetVariableToCookie("bizsiteinfo","bizsiteno",(BizSiteNo+1));
		//add biz site in the form
		AddBizSiteInForm();
		ReOrderBizSites();
		//set the form value from cookie
		MatchBizSiteFormToCookie();
		SetBizSiteContent();
		//calculate emission
		CalculateEmission();
	}
	function AddBizSiteInForm(){
		var aTable = document.getElementById("SiteGrandTable");
		if (aTable != null){
			var firstRow = aTable.rows[0];
			var firstCell = firstRow.cells[0];
			var aRow = aTable.insertRow(aTable.rows.length-3);
			var aCell=aRow.insertCell(0);
			aCell.setAttribute("colSpan","2");
			aCell.innerHTML=firstCell.innerHTML;
		}
	}
	function ReOrderBizSites(){
		var colors = new Array();
		var obj;
		colors[0] = "FFFFFF";
		colors[1] = "FFFF99";
		var allTitles = document.getElementsByTagName("span");
		var anIndex;
		anIndex = 1;
		for (var i=0;i<allTitles.length;i++){
			if (allTitles[i].getAttribute("name") == "OfficeTitle"){
				allTitles[i].innerHTML = "Office or Building Basics (Site "+anIndex+")&nbsp;&nbsp;&nbsp;&nbsp;";
				allTitles[i].setAttribute("bgcolor",colors[1]);
				obj = allTitles[i];
				while(obj.offsetParent){
					if(obj.offsetParent.getAttribute("name") == "SiteTable"){
						obj.offsetParent.style.backgroundColor=colors[(anIndex+1) % 2];
					}
					obj=obj.offsetParent;
				}
				anIndex++;
			}
		}
		var allDeleteButtons = document.getElementsByTagName("input");
		anIndex = 1;
		for (var i=0;i<allDeleteButtons.length;i++){
			if (allDeleteButtons[i].getAttribute("name") == "DeleteBizSiteButton"){
				if (anIndex == 1){
					allDeleteButtons[i].style.visibility = "hidden";
				}else{
					allDeleteButtons[i].style.visibility = "visible";
				}
				anIndex++;
			}
		}
	}
	function DeleteBizSite(aButton){
		var aTable = document.getElementById("SiteGrandTable");
		if (aTable != null){
			for (var i=0;i<aTable.rows.length;i++){
				var allButtons = aTable.rows[i].getElementsByTagName("input");
				for (var j=0;j<allButtons.length;j++){
					if (aButton == allButtons[j]){
						aTable.deleteRow(i);
						FormingBizSiteCookie();
						CalculateEmission();
						alert("This site is removed");
						ReOrderBizSites();
						return true;
					}
				}
			}
		}
	}
	function bizSiteInfoChange(){
		FormingBizSiteCookie();
		CalculateEmission();
	}
	function getTotalSites(){
		var aTable = document.getElementById("SiteGrandTable");
		return aTable.rows.length-3;
	}
	function ReturnSingleSiteCookieValue(SingleSiteTable){
		var rowIndex;
		var theValue;
		var aRow;
		theValue="";
		//business type
		rowIndex = getFirstContentRow(SingleSiteTable);
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("select");
		theValue += cpnts[0].value;
		//heating methods
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//number of employee
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		//building type
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//square footage
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		//electricity
		rowIndex += 2;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//natural gas
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//fuel oil
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//coal
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//propane
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//wood
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//steam
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//waste paper
		rowIndex += 2;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value + "|" + cpnts[1].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//waste glass
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value + "|" + cpnts[1].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//waste plastic
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value + "|" + cpnts[1].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//waste alminum
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value + "|" + cpnts[1].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//waste steel
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value + "|" + cpnts[1].value;
		cpnts = aRow.getElementsByTagName("select");
		theValue += "|" + cpnts[0].value;
		//public transportation subsidy
		rowIndex += 2;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		theValue += "|" + cpnts[0].value + "|" + cpnts[1].value + "|" + cpnts[2].value;;
		return theValue;
	}
	function SetSingleSiteTableContent(SingleSiteTable, siteCookieValue){
		var rowIndex;
		var aRow;
		var ss;
		ss = siteCookieValue.split("|");
		//business type
		rowIndex = getFirstContentRow(SingleSiteTable);
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[0];
		//heating methods
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[1];
		//number of employee
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[2];
		//building type
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[3];
		//square footage
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[4];
		//electricity
		rowIndex += 2;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[5];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[6];
		//natural gas
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[7];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[8];
		//fuel oil
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[9];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[10];
		//coal
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[11];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[12];
		//propane
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[13];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[14];
		//wood
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[15];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[16];
		//steam
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[17];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[18];
		//waste paper
		rowIndex += 2;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[19];
		cpnts[1].value = ss[20];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[21];
		//waste glass
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[22];
		cpnts[1].value = ss[23];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[24];
		//waste plastic
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[25];
		cpnts[1].value = ss[26];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[27];
		//waste alminum
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[28];
		cpnts[1].value = ss[29];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[30];
		//waste steel
		rowIndex ++;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[31];
		cpnts[1].value = ss[32];
		cpnts = aRow.getElementsByTagName("select");
		cpnts[0].value = ss[33];
		//public transportation subsidy
		rowIndex += 2;
		aRow = SingleSiteTable.rows[rowIndex];
		cpnts = aRow.getElementsByTagName("input");
		cpnts[0].value = ss[34];
		cpnts[1].value = ss[35];
		cpnts[2].value = ss[36];
	}
	function FormingBizSiteCookie(){
		var aTable = document.getElementById("SiteGrandTable");
		if (aTable != null){
			var CookieValue = "";
			var TotalSites = getTotalSites();
			var AllTables = aTable.getElementsByTagName("table");
			var anIndex = 1;
			CookieValue = ":bizsiteno:" + TotalSites + ":"
			for (var i = 0; i<AllTables.length; i++){
				if (AllTables[i].getAttribute("name") == "SiteTable"){
					CookieValue += "bizsite" + anIndex + ":" + ReturnSingleSiteCookieValue(AllTables[i]) + ":";
					anIndex ++;
				}
			}
			DeleteCookie("bizsiteinfo","","");
			SetCookie("bizsiteinfo",CookieValue);
		}
	}
	function SetBizSiteContent(){
		var aTable = document.getElementById("SiteGrandTable");
		if (aTable != null){
			var siteCookieValue;
			var TotalSites = GetVariableFromCookie("bizsiteinfo","bizsiteno");
			var AllTables = aTable.getElementsByTagName("table");
			var anIndex = 1;
			for (var i = 0; i<AllTables.length; i++){
				if (AllTables[i].getAttribute("name") == "SiteTable"){
					siteCookieValue = GetVariableFromCookie("bizsiteinfo","bizsite"+anIndex);
					SetSingleSiteTableContent(AllTables[i], siteCookieValue);
					anIndex ++;
				}
			}
		}
	}
	function MatchBizSiteFormToCookie(){
		//delete extra sites if they exists
		var aTable = document.getElementById("SiteGrandTable");
		if (aTable != null){
			var TotalSitesFromCookie = ToNumericValue(GetVariableFromCookie("bizsiteinfo","bizsiteno"));
			var TotalSitesFromForm;
			var AllTables = aTable.getElementsByTagName("table");
			var TotalSitesFromForm = 0;
			for (var i = 0; i<AllTables.length; i++){
				if (AllTables[i].getAttribute("name") == "SiteTable"){
					if ((TotalSitesFromForm+1) > TotalSitesFromCookie){
						//delete it
						var allButtons = AllTables[i].getElementsByTagName("input");
						for (var j=0;j<allButtons.length;j++){
							if (allButtons[j].getAttribute("name") == "DeleteBizSiteButton"){
								DeleteBizSite(allButtons[j]);
							}
						}
					}else{
						TotalSitesFromForm ++;
					}
				}
			}
			for (var i = (TotalSitesFromForm+1); i<=TotalSitesFromCookie; i++){
				AddBizSiteInForm();
			}
		}
	}
	function getFirstContentRow(SingleSiteTable){
		for (var i = 0; i<SingleSiteTable.rows.length; i++){
			var cpnts = SingleSiteTable.rows[i].getElementsByTagName("select");
			if (cpnts.length>0){
				return i;
			}
		}
	}
	function DisplaySingleRowEmissionValue(aContainer,divName,aValue){
		var cpnts = aContainer.getElementsByTagName("div");
		for (var i = 0; i < cpnts.length; i++){
			if (cpnts[i].getAttribute("name") == divName){
				cpnts[i].innerHTML = aValue;
				return;
			}
		}
	}
	function getSiteTable(siteTableIndex){
		var aTable = document.getElementById("SiteGrandTable");
		if (aTable != null){
			var tables = aTable.getElementsByTagName("table");
			var anIndex = 0;
			for (var i = 0; i < tables.length; i++){
				if (tables[i].getAttribute("name") == "SiteTable"){
					anIndex ++;
					if (anIndex == siteTableIndex){
						return tables[i];
					}
				}
			}
		}
		return null;
	}
//end of biz site section


function CalculateEmission(){
	var headTotalCO = 0;
	var headTotalDollar = 0;
	var headBizTotalCO = 0;
	var headBizTotalDollar = 0;
	var aComponent;
	var anInput;
	var anEmission;
	var houseMembers;
	var houseHeatMethod;
	var houseSecHeatMethod;
	var houseEmission;
	var gasHeatingEmission;
	var electricHeatingEmission;
	var fueloilHeatingEmission;
	var coalHeatingEmission;
	var steamHeatingEmission;
	var propaneHeatingEmission;
	var woodHeatingEmission;
	//var gasSecHeatingEmission;
	//var electricSecHeatingEmission;
	//var fueloilSecHeatingEmission;
	//var coalSecHeatingEmission;
	//var steamSecHeatingEmission;
	//var propaneSecHeatingEmission;
	//var woodSecHeatingEmission;
	var carEmission;
	var carEmissionReduced;
	var bizCarEmission;
	var bizCarEmissionReduced;
	var airEmission;
	var bizAirEmission;
	var bizEquipEmission;
	var bizFreightEmission;
	var bizSiteEmission;
	var bizSingleSiteEmission;
	var aFlag;
	var tmpInput;
	var aMessage;
	
	//****** house section
	houseEmission = 0;
	//waste from house people number
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","member"));
	houseMembers = anInput;	// for later use
	anEmission = anInput * NationRef_WasteCO2PerPerson;
	aComponent=document.getElementById("resHouseMemberCO");
	if (aComponent != null) aComponent.innerHTML ="";	// NumberToString(anEmission/2.20462262,0);
	aComponent=document.getElementById("resWasteCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","heatmethod"));
	houseHeatMethod = anInput;	//for later use
	aComponent=document.getElementById("resHouseHeatMethodCO");
	if (aComponent != null) aComponent.innerHTML = "";
	
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","secheatmethod"));
	houseSecHeatMethod = anInput;	//for later use
	aComponent=document.getElementById("resHouseSecHeatMethodCO");
	if (aComponent != null) aComponent.innerHTML = "";
	
	//electric bill
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","electricbill"));
	anEmission = ((anInput-CityRef_ElectricityMonthlyServiceCharge) / (CityRef_KwhPrice+CityRef_KwhDeliveryCharge)) * NationRef_ElectricityEmissionFactor * 12;
	if (anEmission < 0){
		anEmission = 0;
	}
	electricHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resElectricBillCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	//gas bill
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","gasbill"));
	anEmission = (anInput / CityRef_NatGasPrice) * NationRef_NatGasEmissionFactor * 12;
	gasHeatingEmission = anEmission;	//for later use
	aComponent=document.getElementById("resGasBillCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	//fuel oil bill
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","fueloilbill"));
	anEmission = (anInput / CityRef_FuelOilPrice) * NationRef_FuelOilEmissionFactor * 12;
	fueloilHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resFuelOilBillCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	
	//electricity
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","electricity"));
	anEmission = anInput * NationRef_ElectricityEmissionFactor * 12;
	if (anEmission < 0){
		anEmission = 0;
	}
	electricHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resElectricKWHCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	//natural gas
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","natgas"));
	anEmission = anInput * NationRef_NatGasEmissionFactor * 12;
	gasHeatingEmission = anEmission;	//for later use
	aComponent=document.getElementById("resNatGasFeetCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	//fuel oil 
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","fueloil"));
	anEmission = anInput * NationRef_FuelOilEmissionFactor * 12;
	fueloilHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resFuelOilGallonCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	//coal 
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","coal"));
	anEmission = anInput * NationRef_CO2EmissionPerCoalTon * 12;
	coalHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resCoalTonCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	//steam
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","steam"));
	anEmission = anInput * NationRef_CO2EmissionPerSteamPound * 12;
	steamHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resSteamPoundCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	//propane 
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","propane"));
	anEmission = anInput * NationRef_CO2EmissionPerPropaneGallon * 12;
	propaneHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resPropaneGallonCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	//wood
	anInput = ToNumericValue(GetVariableFromCookie("houseinput","wood"));
	anEmission = anInput * 2 * NationRef_CO2EmissionPerWoodTon * 12;
	woodHeatingEmission = anEmission; // for later use
	aComponent=document.getElementById("resWoodCordCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseEmission += anEmission;
	headTotalCO += anEmission;
	
	
	var recycleCO = 0;
	//recycling news paper
	anInput = ToBooleanValue(GetVariableFromCookie("houseinput","newspaper"));
	if (anInput == true){
		anEmission = - houseMembers * NationRef_CO2SavingRecycNewspaper;
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resNewsPaperCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	recycleCO += anEmission;
	headTotalCO += anEmission;
	//recycling magazines
	anInput = ToBooleanValue(GetVariableFromCookie("houseinput","magazine"));
	if (anInput == true){
		anEmission = - houseMembers * NationRef_CO2SavingRecycMagzine;
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resMagazineCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	recycleCO += anEmission;
	headTotalCO += anEmission;
	//recycling glass
	anInput = ToBooleanValue(GetVariableFromCookie("houseinput","glass"));
	if (anInput == true){
		anEmission = -houseMembers * NationRef_CO2SavingRecycGlass;
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resGlassCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	recycleCO += anEmission;
	headTotalCO += anEmission;
	//recycling plastic
	anInput = ToBooleanValue(GetVariableFromCookie("houseinput","plastic"));
	if (anInput == true){
		anEmission = -houseMembers * NationRef_CO2SavingRecycPlastic;
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resPlasticCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	recycleCO += anEmission;
	headTotalCO += anEmission;
	//recycling aluminum
	anInput = ToBooleanValue(GetVariableFromCookie("houseinput","aluminum"));
	if (anInput == true){
		anEmission = -houseMembers * NationRef_CO2SavingRecycAluminum;
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resAluminumCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	recycleCO += anEmission;
	headTotalCO += anEmission;
	
	houseEmission += recycleCO;
	aComponent=document.getElementById("resTotalCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(houseEmission/2.20462262,0)+((houseEmission!=0)?"<br>("+NumberToString(houseEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(houseEmission);
	//******* end of house section
	
	//**** house reduce section, this section must be in the end of all other sections to calculate the reduced total emission
	var houseReduceEmission=0;
	//heating thermometer.  variables used which are calculated: earliergasHeatingEmission,electricHeatingEmission,fueloilHeatingEmission;
	anInput = ToNumericValue(GetVariableFromCookie("housereduce","heatingthermo"));
	aMessage = "";
	if (houseHeatMethod == 1){
		//natural gas
		anEmission = gasHeatingEmission * anInput * CityRef_PercNatGasForHeating / 100 * CityRef_PercFuelOilConsumDecrease/100;
		if (anInput > 0 && gasHeatingEmission == 0){
			//aMessage = "Enter your gas bill";
			aMessage = "Enter your natural gas usage";
		}
	}else if(houseHeatMethod == 2){
		//electric
		anEmission = electricHeatingEmission * anInput * CityRef_PercElecForHeating / 100 * CityRef_PercFuelOilConsumDecrease/100;
		if (anInput > 0 && electricHeatingEmission == 0){
			//aMessage = "Enter your electric bill";
			aMessage = "Enter your electric usage";
		}
	}else if(houseHeatMethod == 3){
		//oil
		anEmission = fueloilHeatingEmission * anInput * CityRef_PercFuelOilForHeating / 100 * CityRef_PercFuelOilConsumDecrease/100;
		if (anInput > 0 && fueloilHeatingEmission == 0){
			//aMessage = "Enter your fuel oil bill";
			aMessage = "Enter your fuel oil usage";
		}
	}else if(houseHeatMethod == 4){
		//coal
		anEmission = coalHeatingEmission * anInput * CityRef_PercFuelOilForHeating / 100 * CityRef_PercFuelOilConsumDecrease/100;
		if (anInput > 0 && coalHeatingEmission == 0){
			//aMessage = "Enter your coal bill";
			aMessage = "Enter your coal usage";
		}
	}else if(houseHeatMethod == 5){
		//steam
		anEmission = steamHeatingEmission * anInput * CityRef_PercFuelOilForHeating / 100 * CityRef_PercFuelOilConsumDecrease/100;
		if (anInput > 0 && steamHeatingEmission == 0){
			//aMessage = "Enter your steam bill";
			aMessage = "Enter your steam usage";
		}
	}else if(houseHeatMethod == 6){
		//propane
		anEmission = propaneHeatingEmission * anInput * CityRef_PercFuelOilForHeating / 100 * CityRef_PercFuelOilConsumDecrease/100;
		if (anInput > 0 && propaneHeatingEmission == 0){
			//aMessage = "Enter your propane bill";
			aMessage = "Enter your propane usage";
		}
	}else{
		//wood
		anEmission = woodHeatingEmission * anInput * CityRef_PercFuelOilForHeating / 100 * CityRef_PercFuelOilConsumDecrease/100;
		if (anInput > 0 && woodHeatingEmission == 0){
			//aMessage = "Enter your wood bill";
			aMessage = "Enter your wood usage";
		}
	}
	
	aComponent=document.getElementById("resReduceHeatingThermoCO");
	if (aMessage != ""){
		if (aComponent != null) aComponent.innerHTML = aMessage;
	}else{
		//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	}
	houseReduceEmission += anEmission;
	//replacing energy saving bulbs
	anInput = ToNumericValue(GetVariableFromCookie("housereduce","bulbs"));
	anEmission = anInput * NationRef_KwhSavingsPerLamp * NationRef_ElectricityEmissionFactor;
	aComponent=document.getElementById("resReduceBulbsCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseReduceEmission += anEmission;
	//replacing refrigirator true/false
	anInput = ToBooleanValue(GetVariableFromCookie("housereduce","refri"));
	if(anInput){
		anEmission = NationRef_KwhSavingsRefrigerator * NationRef_ElectricityEmissionFactor;
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resReduceRadioRefriCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseReduceEmission += anEmission;
	//replacing  furnace
	anInput = ToBooleanValue(GetVariableFromCookie("housereduce","furnace"));
	if(anInput){
		if (houseHeatMethod == 1){
			//natural gas
			anEmission = NationRef_BtuSavingsFurnace * NationRef_NatGasEmissionFactor;
		}else if(houseHeatMethod == 2){
			//electric
			anEmission = 0;
		}else{
			//oil
			anEmission = NationRef_BtuSavingsFurnace * NationRef_FuelOilEmissionFactor * (1000000/138874);
			//one gallon of fuel oil produces 138874 BTU
		}
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resReduceRadioFurnaceCO");
	if (anInput && houseHeatMethod == 2){
		if (aComponent != null) aComponent.innerHTML = "No saving from electric heating";
	}else{
		//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	}
	houseReduceEmission += anEmission;
	//air condition thermometer
	anInput = ToNumericValue(GetVariableFromCookie("housereduce","acthermo"));
	anEmission = anInput * electricHeatingEmission * CityRef_PercElecEmissForAirCond/100 *CityRef_PercAirCondDecrease/100 * CityRef_PercAirCondInUser/100;
	aComponent=document.getElementById("resReduceACThermoCO");
	if(anInput > 0 && electricHeatingEmission == 0){
		if (aComponent != null) aComponent.innerHTML = "Enter your electric bill";
	}else{
		//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	}
	houseReduceEmission += anEmission;
	//replacing sealed windows
	anInput = ToBooleanValue(GetVariableFromCookie("housereduce","window"));
	if(anInput){
		if (houseHeatMethod == 1){
			//natural gas, 1030466.73 BTU / thousand cubic feet
			anEmission = NationRef_BtuSavingsWindow /1030466.73 * NationRef_NatGasEmissionFactor;
		}else if(houseHeatMethod == 2){
			//electric, 3412.142 BTU/kw
			anEmission = NationRef_BtuSavingsWindow / 3412.142 * NationRef_ElectricityEmissionFactor;
		}else{
			//oil, 138874.158 BTU/gallon
			anEmission = NationRef_BtuSavingsWindow / 138874.158 * NationRef_FuelOilEmissionFactor;
		}
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resReduceRadioWindowCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseReduceEmission += anEmission;
	//recycle materials
	anInput = ToBooleanValue(GetVariableFromCookie("housereduce","material"));
	anEmission = 0;
	aFlag = 0;
	if(anInput){
		//check status of recycling news paper
		tmpInput = ToBooleanValue(GetVariableFromCookie("houseinput","newspaper"));
		if (tmpInput == false){
			aFlag ++;
			anEmission += houseMembers * NationRef_CO2SavingRecycNewspaper;
		}
		//check status of recycling magazine
		tmpInput = ToBooleanValue(GetVariableFromCookie("houseinput","magazine"));
		if (tmpInput == false){
			aFlag ++;
			anEmission += houseMembers * NationRef_CO2SavingRecycMagzine;
		}
		//check status of recycling glass
		tmpInput = ToBooleanValue(GetVariableFromCookie("houseinput","glass"));
		if (tmpInput == false){
			aFlag ++;
			anEmission += houseMembers * NationRef_CO2SavingRecycGlass;
		}
		//check status of recycling plastic
		tmpInput = ToBooleanValue(GetVariableFromCookie("houseinput","plastic"));
		if (tmpInput == false){
			aFlag ++;
			anEmission += houseMembers * NationRef_CO2SavingRecycPlastic;
		}
		//check status of recycling aluminum
		tmpInput = ToBooleanValue(GetVariableFromCookie("houseinput","aluminum"));
		if (tmpInput == false){
			aFlag ++;
			anEmission += houseMembers * NationRef_CO2SavingRecycAluminum;
		}
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resReduceRadioMaterialCO");
	if(anInput==true && aFlag == 0){
		if (aComponent != null) aComponent.innerHTML = "No saving since you already recyled all";
	}else{
		//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	}
	houseReduceEmission += anEmission;
	//plant a tree
	anInput = ToBooleanValue(GetVariableFromCookie("housereduce","plant"));
	if(anInput){
		anEmission = 955/57*2.20462262*44/12;	//44/12 is to convert C to CO2
	}else{
		anEmission = 0;
	}
	aComponent=document.getElementById("resReduceRadioPlantCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	houseReduceEmission += anEmission;
		
	aComponent=document.getElementById("houseReduceEmissionCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(houseReduceEmission/2.20462262,0)+((houseReduceEmission!=0)?"<br>("+NumberToString(houseReduceEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(houseReduceEmission);
	aComponent=document.getElementById("houseReducedTotalEmissionCO");
	//if (aComponent != null) aComponent.innerHTML = "Metric Tons: " + NumberToString((houseEmission-houseReduceEmission+recycleCO)/2204.62262,3);
	if (aComponent != null) aComponent.innerHTML = "Tons: " + NumberToString((houseEmission-houseReduceEmission+recycleCO)/2000,3);
	
	aComponent=document.getElementById("offsetHouseHoldCertificates");
	//if (aComponent != null) aComponent.innerHTML = "Metric Tons: " + NumberToString((houseEmission-houseReduceEmission+recycleCO)/2204.62262,3);
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round((houseEmission-houseReduceEmission+recycleCO) / 2000 * NationRef_CarbonPricePerTon) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetHouseHold");
	//if (aComponent != null) aComponent.innerHTML = "Metric Tons: " + NumberToString((houseEmission-houseReduceEmission+recycleCO)/2204.62262,3);
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round((houseEmission-houseReduceEmission+recycleCO) / 2000 * NationRef_CarbonPricePerTon);
	
	headTotalCO -= houseReduceEmission;
	
	//set the head house emission dollars
	aComponent=document.getElementById("headHouseDollar");
	if (aComponent != null) aComponent.value = "$" + Math.round((houseEmission-houseReduceEmission) / 2000 * NationRef_CarbonPricePerTon);
	//**** end of house reduce section
	
	//***** business section
	//set the head house emission dollars
	aComponent=document.getElementById("headBizDollar");
	if (aComponent != null) aComponent.value = "$0";
	//***** end of business section
	
	//**** car section
	carEmission = 0;
	carEmissionReduced = 0;
	{
		var CarNo = ToNumericValue(GetVariableFromCookie("carinfo","carno"));
		var i;
		var mVehicleTypeIndex;
		var mVehicleGasMileage;
		var mNoVehicle;
		var mDrivingMiles;
		var mNoVehicleReplacement;
		var mPlusGasMileage;
		var mLessMileDriving; // = ToNumericValue(GetVariableFromCookie("carinfo","carlessmile"));
		var myCarInfo;
		var firstRowIndex;
		var carEmissionReducedByLessMile=0;
		var carEmissionReducedByNewCar=0;
		var carMileAfterLessDriving;
		for (i=1; i<=CarNo;i++){
			anEmission = 0;
			//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, no of vehicles to be replaced by efficient vehicles, improvement of gas mileage/gallon, few miles to drive
			var myCarInfo = GetVariableFromCookie("carinfo","car"+i);
			var infos = myCarInfo.split("|");
			mVehicleGasMileage = ToNumericValue(infos[1]);
			mNoVehicle = ToNumericValue(infos[2]);
			mDrivingMiles = ToNumericValue(infos[3]);
			mNoVehicleReplacement = ToNumericValue(infos[4]);
			mPlusGasMileage = ToNumericValue(infos[5]);
			mLessMileDriving = ToNumericValue(infos[6]);
			if (mVehicleGasMileage == 0){
				anEmission = 0;
			}else{
				anEmission = mNoVehicle * mDrivingMiles / mVehicleGasMileage * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
			}
			carEmission += anEmission;
			//set calculated carbon emission by this car type
			firstRowIndex = ReturnFirstCarRowIndex();
			if (firstRowIndex != -1){
				//SetCarRowEmission(firstRowIndex+(i-1),NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":""));
				SetCarRowEmission(firstRowIndex+(i-1),Math.round(anEmission));
			}
			
			//calculate carEmissionReducedByLessMile, carEmissionReducedByNewCar here
			if (mLessMileDriving < mDrivingMiles){
				carMileAfterLessDriving = mDrivingMiles - mLessMileDriving;
				if (mVehicleGasMileage == 0){
					anEmission = 0;
				}else{
					anEmission = mNoVehicle * mLessMileDriving / mVehicleGasMileage * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
				}
			}else{
				carMileAfterLessDriving = 0;
				if (mVehicleGasMileage == 0){
					anEmission = 0;
				}else{
					anEmission = mNoVehicle * mDrivingMiles / mVehicleGasMileage * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
				}
			}
			aComponent=document.getElementById("carLessMileCO"+i);
			//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
			if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
			carEmissionReducedByLessMile += anEmission;
			if (mVehicleGasMileage == 0){
				anEmission = 0;
			}else{
				anEmission = ((mNoVehicleReplacement<mNoVehicle)?mNoVehicleReplacement:mNoVehicle) * carMileAfterLessDriving / (mVehicleGasMileage) * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
			}
			if ((mVehicleGasMileage + mPlusGasMileage) != 0){
				anEmission -= ((mNoVehicleReplacement<mNoVehicle)?mNoVehicleReplacement:mNoVehicle) * carMileAfterLessDriving / (mVehicleGasMileage + mPlusGasMileage) * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
			}
			carEmissionReducedByNewCar += anEmission;
			aComponent=document.getElementById("carReplacementSavingCO"+i);
			//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
			if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		}
		aComponent=document.getElementById("carLessMileCO");
		//if (aComponent != null) aComponent.innerHTML = NumberToString(carEmissionReducedByLessMile/2.20462262,0)+((carEmissionReducedByLessMile!=0)?"<br>("+NumberToString(carEmissionReducedByLessMile,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(carEmissionReducedByLessMile);
		carEmissionReduced = carEmissionReducedByLessMile + carEmissionReducedByNewCar;
		aComponent=document.getElementById("carReduceEmissionCO");
		//if (aComponent != null) aComponent.innerHTML = NumberToString(carEmissionReduced/2.20462262,0)+((carEmissionReduced!=0)?"<br>("+NumberToString(carEmissionReduced,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(carEmissionReduced);
		aComponent=document.getElementById("carReducedTotalEmissionCO");
		//if (aComponent != null) aComponent.innerHTML = NumberToString((carTotalEmission-carEmissionReduced)/2.20462262,0) + (((carTotalEmission-carEmissionReduced)!=0)?"<br>("+NumberToString((carTotalEmission-carEmissionReduced),0)+" <em>lb</em>)":"");
		//if (aComponent != null) aComponent.innerHTML = NumberToString((carEmission-carEmissionReduced)/2.20462262,0) + (((carEmission-carEmissionReduced)!=0)?"<br>("+NumberToString((carEmission-carEmissionReduced),0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round((carEmission-carEmissionReduced));
		
		aComponent=document.getElementById("carTotalEmission");
		//if (aComponent != null) aComponent.innerHTML = NumberToString(carEmission/2.20462262,0)+((carEmission!=0)?"<br>("+NumberToString(carEmission,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(carEmission);
	}
	headTotalCO += carEmission-carEmissionReduced;
	
	aComponent=document.getElementById("offsetCarTravelCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round((carEmission-carEmissionReduced) / 2000 * NationRef_CarbonPricePerTon) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetCarTravel");
	if (aComponent != null) aComponent.innerHTML = "$"+Math.round((carEmission-carEmissionReduced) / 2000 * NationRef_CarbonPricePerTon);
	
	//set car head emission dollars
	aComponent=document.getElementById("headCarDollar");
	if (aComponent != null) aComponent.value = "$"+Math.round((carEmission-carEmissionReduced) / 2000 * NationRef_CarbonPricePerTon);
	//**** end of car section
	
	
	//**** biz car section
	bizCarEmission = 0;
	bizCarEmissionReduced = 0;
	{
		var BizCarNo = ToNumericValue(GetVariableFromCookie("bizcarinfo","bizcarno"));
		var i;
		var mVehicleTypeIndex;
		var mVehicleGasMileage;
		var mNoVehicle;
		var mDrivingMiles;
		var mFuelTypeIndex;
		var mNoVehicleReplacement;
		var mPlusGasMileage;
		var mLessMileDriving; // = ToNumericValue(GetVariableFromCookie("carinfo","carlessmile"));
		var myBizCarInfo;
		var firstRowIndex;
		var bizCarEmissionReducedByLessMile=0;
		var bizCarEmissionReducedByNewCar=0;
		var bizCarMileAfterLessDriving;
		for (i=1; i<=BizCarNo;i++){
			anEmission = 0;
			//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, no of vehicles to be replaced by efficient vehicles, improvement of gas mileage/gallon, few miles to drive
			var myBizCarInfo = GetVariableFromCookie("bizcarinfo","bizcar"+i);
			var infos = myBizCarInfo.split("|");
			mVehicleGasMileage = ToNumericValue(infos[1]);
			mNoVehicle = ToNumericValue(infos[2]);
			mDrivingMiles = ToNumericValue(infos[3]);
			mFuelTypeIndex = ToNumericValue(infos[4]);
			//mNoVehicleReplacement = ToNumericValue(infos[4]);
			//mPlusGasMileage = ToNumericValue(infos[5]);
			//mLessMileDriving = ToNumericValue(infos[6]);
			if (mVehicleGasMileage == 0){
				anEmission = 0;
			}else{
				if (mFuelTypeIndex == 0){
					//gasoline
					anEmission = mNoVehicle * mDrivingMiles / mVehicleGasMileage * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
				}
				if (mFuelTypeIndex == 1){
					//diesel
					anEmission = mNoVehicle * mDrivingMiles / mVehicleGasMileage * NationRef_CO2EmissionPerDieselGallon; //* NationRef_NotCO2Emission;
				}
				if (mFuelTypeIndex == 2){
					//biodiesel
					anEmission = mNoVehicle * mDrivingMiles / mVehicleGasMileage * NationRef_CO2EmissionPerBioDieselGallon; //* NationRef_NotCO2Emission;
				}
			}
			bizCarEmission += anEmission;
			//set calculated carbon emission by this biz car type
			firstRowIndex = ReturnFirstBizCarRowIndex();
			if (firstRowIndex != -1){
				//SetCarRowEmission(firstRowIndex+(i-1),NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":""));
				SetBizCarRowEmission(firstRowIndex+(i-1),Math.round(anEmission));
			}
			/*
			//calculate carEmissionReducedByLessMile, carEmissionReducedByNewCar here
			if (mLessMileDriving < mDrivingMiles){
				carMileAfterLessDriving = mDrivingMiles - mLessMileDriving;
				if (mVehicleGasMileage == 0){
					anEmission = 0;
				}else{
					anEmission = mNoVehicle * mLessMileDriving / mVehicleGasMileage * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
				}
			}else{
				carMileAfterLessDriving = 0;
				if (mVehicleGasMileage == 0){
					anEmission = 0;
				}else{
					anEmission = mNoVehicle * mDrivingMiles / mVehicleGasMileage * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
				}
			}
			aComponent=document.getElementById("carLessMileCO"+i);
			//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
			if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
			carEmissionReducedByLessMile += anEmission;
			if (mVehicleGasMileage == 0){
				anEmission = 0;
			}else{
				anEmission = ((mNoVehicleReplacement<mNoVehicle)?mNoVehicleReplacement:mNoVehicle) * carMileAfterLessDriving / (mVehicleGasMileage) * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
			}
			if ((mVehicleGasMileage + mPlusGasMileage) != 0){
				anEmission -= ((mNoVehicleReplacement<mNoVehicle)?mNoVehicleReplacement:mNoVehicle) * carMileAfterLessDriving / (mVehicleGasMileage + mPlusGasMileage) * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
			}
			carEmissionReducedByNewCar += anEmission;
			aComponent=document.getElementById("carReplacementSavingCO"+i);
			//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
			if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		*/
		}
		/*
		aComponent=document.getElementById("carLessMileCO");
		//if (aComponent != null) aComponent.innerHTML = NumberToString(carEmissionReducedByLessMile/2.20462262,0)+((carEmissionReducedByLessMile!=0)?"<br>("+NumberToString(carEmissionReducedByLessMile,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(carEmissionReducedByLessMile);
		carEmissionReduced = carEmissionReducedByLessMile + carEmissionReducedByNewCar;
		aComponent=document.getElementById("carReduceEmissionCO");
		//if (aComponent != null) aComponent.innerHTML = NumberToString(carEmissionReduced/2.20462262,0)+((carEmissionReduced!=0)?"<br>("+NumberToString(carEmissionReduced,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(carEmissionReduced);
		aComponent=document.getElementById("carReducedTotalEmissionCO");
		//if (aComponent != null) aComponent.innerHTML = NumberToString((carTotalEmission-carEmissionReduced)/2.20462262,0) + (((carTotalEmission-carEmissionReduced)!=0)?"<br>("+NumberToString((carTotalEmission-carEmissionReduced),0)+" <em>lb</em>)":"");
		//if (aComponent != null) aComponent.innerHTML = NumberToString((carEmission-carEmissionReduced)/2.20462262,0) + (((carEmission-carEmissionReduced)!=0)?"<br>("+NumberToString((carEmission-carEmissionReduced),0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round((carEmission-carEmissionReduced));
		*/
		aComponent=document.getElementById("bizCarTotalEmission");
		if (aComponent != null) aComponent.innerHTML = Math.round(bizCarEmission);
		aComponent=document.getElementById("bizOffsetCarTravelCertificates");
		if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round((bizCarEmission-bizCarEmissionReduced) / 2000 * NationRef_CarbonPricePerTon) / CityRef_CostPerUnit);
		aComponent=document.getElementById("bizOffsetCarTravel");
		if (aComponent != null) aComponent.innerHTML = "$"+Math.round((bizCarEmission-bizCarEmissionReduced) / 2000 * NationRef_CarbonPricePerTon);
	}
	//headTotalCO += carEmission-carEmissionReduced;
	headBizTotalCO += bizCarEmission;
	/*
	aComponent=document.getElementById("offsetCarTravelCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round((carEmission-carEmissionReduced) / 2000 * 20) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetCarTravel");
	if (aComponent != null) aComponent.innerHTML = "$"+Math.round((carEmission-carEmissionReduced) / 2000 * 20);
	//set car head emission dollars
	aComponent=document.getElementById("headCarDollarCertificates");
	if (aComponent != null) aComponent.value = Math.ceil(Math.round((carEmission-carEmissionReduced) / 2000 * 20) / CityRef_CostPerUnit);
	*/
	aComponent=document.getElementById("headBizCarDollar");
	if (aComponent != null) aComponent.value = "$"+Math.round((bizCarEmission) / 2000 * NationRef_CarbonPricePerTon);
	//if (aComponent != null) aComponent.value = "$"+Math.round((carEmission-carEmissionReduced) / 2000 * 20);
	//**** end of biz car section
	
	
	//****** air mile section
	anInput = ToNumericValue(GetVariableFromCookie("airinfo","airmile"));
	anEmission = 0;
	if (anInput > 2*994){
			anEmission = (anInput-2*994) * NationRef_AirTravEmisRateOver994PerMile + (2*994-2*281) * NationRef_AirTravEmisRate281_994PerMile + 2*281 * NationRef_AirTravEmisRateBelow281PerMile;
	}else if (anInput > 2*281){
		anEmission = (anInput-2*281) * NationRef_AirTravEmisRate281_994PerMile + 2*281 * NationRef_AirTravEmisRateBelow281PerMile;
	}else{
		anEmission = anInput * NationRef_AirTravEmisRateBelow281PerMile;
	}
	//anEmission = anInput * NationRef_AirTravEmisRatePerMile; //* NationRef_NotCO2Emission;
	aComponent=document.getElementById("airMileCO");
	//if (aComponent != null) aComponent.innerHTML = NumberToString(anEmission/2.20462262,0)+((anEmission!=0)?"<br>("+NumberToString(anEmission,0)+" <em>lb</em>)":"");
	if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
	
	//**** air section
	airEmission = 0;
	{
		var AirNo = ToNumericValue(GetVariableFromCookie("airinfo","airno"));
		var i;
		var mFlightDestination;
		var mRoundTripMile;
		var mTripTimes;
		for (i=1; i<=AirNo;i++){
			anEmission = 0;
			//destination, mile, trip times
			var myAirInfo = GetVariableFromCookie("airinfo","air"+i);
			var infos = myAirInfo.split("|");
			mFlightDestination = ToNumericValue(infos[0]);
			mRoundTripMile = ToNumericValue(infos[1]);
			mTripTimes = ToNumericValue(infos[2]);
			if (mRoundTripMile == 0 || mTripTimes == 0){
				anEmission = 0;
			}else{
				if (mRoundTripMile > 2*994){
					anEmission = mTripTimes * ((mRoundTripMile-2*994) * NationRef_AirTravEmisRateOver994PerMile + (2*994-2*281) * NationRef_AirTravEmisRate281_994PerMile + 2*281 * NationRef_AirTravEmisRateBelow281PerMile);
				}else if (mRoundTripMile > 2*281){
					anEmission = mTripTimes * ((mRoundTripMile-2*281) * NationRef_AirTravEmisRate281_994PerMile + 2*281 * NationRef_AirTravEmisRateBelow281PerMile);
				}else{
					anEmission = mTripTimes * mRoundTripMile * NationRef_AirTravEmisRateBelow281PerMile;
				}
				//anEmission = mTripTimes * mRoundTripMile * NationRef_AirTravEmisRatePerMile; //* NationRef_NotCO2Emission;
			}
			airEmission += anEmission;
			//set calculated carbon emission by this round trip
			firstRowIndex = ReturnFirstAirRowIndex();
			if (firstRowIndex != -1){
				SetAirRowEmission(firstRowIndex+(i-1),Math.round(anEmission));
			}
			
		}
		
		aComponent=document.getElementById("airTotalEmission");
		//if (aComponent != null) aComponent.innerHTML = NumberToString(carEmission/2.20462262,0)+((carEmission!=0)?"<br>("+NumberToString(carEmission,0)+" <em>lb</em>)":"");
		if (aComponent != null) aComponent.innerHTML = Math.round(airEmission);
	}
	
	aComponent=document.getElementById("offsetAirTravelCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(airEmission / 2000 * NationRef_CarbonPricePerTon) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetAirTravel");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(airEmission / 2000 * NationRef_CarbonPricePerTon);
	
	aComponent=document.getElementById("headAirDollar");
	if (aComponent != null) aComponent.value = "$" + Math.round(airEmission / 2000 * NationRef_CarbonPricePerTon);
	
	headTotalCO += airEmission;
	//****** end of air mile section
	
	//**** biz air section
	bizAirEmission = 0;
	{
		var BizAirNo = ToNumericValue(GetVariableFromCookie("bizairinfo","bizairno"));
		var i;
		var mBizFlightDestination;
		var mBizRoundTripMile;
		var mBizTimes;
		for (i=1; i<=BizAirNo;i++){
			anEmission = 0;
			//destination, mile
			var myBizAirInfo = GetVariableFromCookie("bizairinfo","bizair"+i);
			var infos = myBizAirInfo.split("|");
			mBizFlightDestination = infos[0];// ToNumericValue(infos[0]);
			mBizRoundTripMile = ToNumericValue(infos[1]);
			mBizTimes = ToNumericValue(infos[2]);
			if (mBizRoundTripMile == 0 || mBizTimes == 0){
				anEmission = 0;
			}else{
				if (mBizRoundTripMile > 2*994){
					anEmission = mBizTimes * ((mBizRoundTripMile-2*994) * NationRef_AirTravEmisRateOver994PerMile + (2*994-2*281) * NationRef_AirTravEmisRate281_994PerMile + 2*281 * NationRef_AirTravEmisRateBelow281PerMile);
				}else if (mBizRoundTripMile > 2*281){
					anEmission = mBizTimes * ((mBizRoundTripMile-2*281) * NationRef_AirTravEmisRate281_994PerMile + 2*281 * NationRef_AirTravEmisRateBelow281PerMile);
				}else{
					anEmission = mBizTimes * mBizRoundTripMile * NationRef_AirTravEmisRateBelow281PerMile;
				}
				//anEmission = mBizTimes * mBizRoundTripMile * NationRef_AirTravEmisRatePerMile; //* NationRef_NotCO2Emission;
			}
			bizAirEmission += anEmission;
			//set calculated carbon emission by this round trip
			firstRowIndex = ReturnFirstBizAirRowIndex();
			if (firstRowIndex != -1){
				SetBizAirRowEmission(firstRowIndex+(i-1),Math.round(anEmission));
			}
			
		}
		aComponent=document.getElementById("bizAirTotalEmission");
		if (aComponent != null) aComponent.innerHTML = Math.round(bizAirEmission);
	}
	aComponent=document.getElementById("bizOffsetAirTravelCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(bizAirEmission / 2000 * NationRef_CarbonPricePerTon) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetAirTravel");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(bizAirEmission / 2000 * NationRef_CarbonPricePerTon);
	
	aComponent=document.getElementById("headBizAirDollar");
	if (aComponent != null) aComponent.value = "$" + Math.round(bizAirEmission / 2000 * NationRef_CarbonPricePerTon);
	
	headBizTotalCO += bizAirEmission;
	
	//**** biz equip section
	bizEquipEmission = 0;
	{
		/*
		var BizEquipNo = ToNumericValue(GetVariableFromCookie("bizequipinfo","bizequipno"));
		var i;
		var mBizEquip;
		var mBizEquipCount;
		var mBizEquipFuelTypeIndex;
		var mBizEquipGallon;
		var mBizEquipTimePeriodIndex;
		for (i=1; i<=BizEquipNo;i++){
			anEmission = 0;
			//equip name, equip count, Fuel Type, Gallon, Time Period
			var myBizEquipInfo = GetVariableFromCookie("bizequipinfo","bizequip"+i);
			var infos = myBizEquipInfo.split("|");
			mBizEquip = infos[0];
			mBizEquipCount = ToNumericValue(infos[1]);
			mBizEquipFuelTypeIndex = ToNumericValue(infos[2]);
			mBizEquipGallon = ToNumericValue(infos[3]);
			mBizEquipTimePeriodIndex = ToNumericValue(infos[4]);
			if (mBizEquipFuelTypeIndex == 0){
				//Gasoline
				anEmission = NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
			}
			if (mBizEquipFuelTypeIndex == 1){
				//Diesel
				anEmission = NationRef_CO2EmissionPerDieselGallon; //* NationRef_NotCO2Emission;
			}
			if (mBizEquipFuelTypeIndex == 2){
				//Propane
				anEmission = NationRef_CO2EmissionPerPropaneGallon; //* NationRef_NotCO2Emission;
			}
			if (mBizEquipFuelTypeIndex == 3){
				//Jet fuel
				anEmission = NationRef_CO2EmissionPerJetFuelGallon; //* NationRef_NotCO2Emission;
			}
			if (mBizEquipFuelTypeIndex == 4){
				//Biodiesel
				anEmission = NationRef_CO2EmissionPerBioDieselGallon; //* NationRef_NotCO2Emission;
			}
			if (mBizEquipTimePeriodIndex == 0){
				//Monthly
				anEmission *= 12;
			}
			if (mBizEquipTimePeriodIndex == 1){
				//Yearly, do nothing
			}
			if (mBizEquipTimePeriodIndex == 2){
				//Weekly
				anEmission *= 52;
			}
			anEmission *= mBizEquipCount * mBizEquipGallon;
			bizEquipEmission += anEmission;
			//set calculated carbon emission by this round trip
			firstRowIndex = ReturnFirstBizEquipRowIndex();
			if (firstRowIndex != -1){
				SetBizEquipRowEmission(firstRowIndex+(i-1),Math.round(anEmission));
			}
		}
		*/
		//after 1-20-2009, use this
		bizEquipEmission = 0;
		var EquipGallonTimePeriod;
		var infos;
		var aBox;
		//for gasoline
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","gasoline");
		infos = EquipGallonTimePeriod.split("|");
		anEmission = ToNumericValue(infos[0]) * NationRef_CO2EmissionPerGasGallon; //* NationRef_NotCO2Emission;
		if (ToNumericValue(infos[1]) == 0){
			//Monthly
			anEmission *= 12;
		}
		if (ToNumericValue(infos[1]) == 1){
			//Yearly, do nothing
		}
		if (ToNumericValue(infos[1]) == 2){
			//Weekly
			anEmission *= 52;
		}
		bizEquipEmission += anEmission;
		aBox = document.getElementById("bizEquipGasolineCO");
		if (aBox) aBox.innerHTML = Math.round(anEmission);
		
		//for diesel
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","diesel");
		infos = EquipGallonTimePeriod.split("|");
		anEmission = ToNumericValue(infos[0]) * NationRef_CO2EmissionPerDieselGallon; 
		if (ToNumericValue(infos[1]) == 0){
			//Monthly
			anEmission *= 12;
		}
		if (ToNumericValue(infos[1]) == 1){
			//Yearly, do nothing
		}
		if (ToNumericValue(infos[1]) == 2){
			//Weekly
			anEmission *= 52;
		}
		bizEquipEmission += anEmission;
		aBox = document.getElementById("bizEquipDieselCO");
		if (aBox) aBox.innerHTML = Math.round(anEmission);
		//for propane
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","propane");
		infos = EquipGallonTimePeriod.split("|");
		anEmission = ToNumericValue(infos[0]) * NationRef_CO2EmissionPerPropaneGallon; 
		if (ToNumericValue(infos[1]) == 0){
			//Monthly
			anEmission *= 12;
		}
		if (ToNumericValue(infos[1]) == 1){
			//Yearly, do nothing
		}
		if (ToNumericValue(infos[1]) == 2){
			//Weekly
			anEmission *= 52;
		}
		bizEquipEmission += anEmission;
		aBox = document.getElementById("bizEquipPropaneCO");
		if (aBox) aBox.innerHTML = Math.round(anEmission);
		//for jet fuel
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","jetfuel");
		infos = EquipGallonTimePeriod.split("|");
		anEmission = ToNumericValue(infos[0]) * NationRef_CO2EmissionPerJetFuelGallon; 
		if (ToNumericValue(infos[1]) == 0){
			//Monthly
			anEmission *= 12;
		}
		if (ToNumericValue(infos[1]) == 1){
			//Yearly, do nothing
		}
		if (ToNumericValue(infos[1]) == 2){
			//Weekly
			anEmission *= 52;
		}
		bizEquipEmission += anEmission;
		aBox = document.getElementById("bizEquipJetFuelCO");
		if (aBox) aBox.innerHTML = Math.round(anEmission);
		//for Aviation Gasoline
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","aviationgasoline");
		infos = EquipGallonTimePeriod.split("|");
		anEmission = ToNumericValue(infos[0]) * NationRef_CO2EmissionPerAviationGasolineGallon; 
		if (ToNumericValue(infos[1]) == 0){
			//Monthly
			anEmission *= 12;
		}
		if (ToNumericValue(infos[1]) == 1){
			//Yearly, do nothing
		}
		if (ToNumericValue(infos[1]) == 2){
			//Weekly
			anEmission *= 52;
		}
		bizEquipEmission += anEmission;
		aBox = document.getElementById("bizEquipAviationGasolineCO");
		if (aBox) aBox.innerHTML = Math.round(anEmission);
		//for bio diesel
		EquipGallonTimePeriod = GetVariableFromCookie("bizequipinfo2","biodiesel");
		infos = EquipGallonTimePeriod.split("|");
		anEmission = ToNumericValue(infos[0]) * NationRef_CO2EmissionPerBioDieselGallon; 
		if (ToNumericValue(infos[1]) == 0){
			//Monthly
			anEmission *= 12;
		}
		if (ToNumericValue(infos[1]) == 1){
			//Yearly, do nothing
		}
		if (ToNumericValue(infos[1]) == 2){
			//Weekly
			anEmission *= 52;
		}
		bizEquipEmission += anEmission;
		aBox = document.getElementById("bizEquipBioDieselCO");
		if (aBox) aBox.innerHTML = Math.round(anEmission);
		//end of after 1-20-2009
		aComponent=document.getElementById("bizEquipTotalEmission");
		if (aComponent != null) aComponent.innerHTML = Math.round(bizEquipEmission);
	}
	aComponent=document.getElementById("bizOffsetEquipmentCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(bizEquipEmission / 2000 * NationRef_CarbonPricePerTon) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetEquipment");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(bizEquipEmission / 2000 * NationRef_CarbonPricePerTon);
	aComponent=document.getElementById("headBizEquipmentDollar");
	if (aComponent != null) aComponent.value = "$" + Math.round(bizEquipEmission / 2000 * NationRef_CarbonPricePerTon);
	headBizTotalCO += bizEquipEmission;
	// end of biz equip section
	
	//**** biz freight section
	bizFreightEmission = 0;
	{
		var myFreight;
		var ss;
		//for train
		var myFreight = GetVariableFromCookie("bizfreightinfo","train")
		ss = myFreight.split("|");
		anEmission = CityRef_FreightEmissionPerTonMileByTrain * ToNumericValue(ss[0]) * ToNumericValue(ss[1]); 
		if(ss[2] == 0){
			//monthly
			anEmission *= 12;
		}else if(ss[2] == 1){
			//yearly
		}else{
			//weekly
			anEmission *= 52;
		}
		aComponent=document.getElementById("bizFreightTrainTonCO");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		bizFreightEmission += anEmission;
		//for van
		var myFreight = GetVariableFromCookie("bizfreightinfo","van")
		ss = myFreight.split("|");
		anEmission = CityRef_FreightEmissionPerTonMileByVan * ToNumericValue(ss[0]) * ToNumericValue(ss[1]); 
		if(ss[2] == 0){
			//monthly
			anEmission *= 12;
		}else if(ss[2] == 1){
			//yearly
		}else{
			//weekly
			anEmission *= 52;
		}
		aComponent=document.getElementById("bizFreightVanTonCO");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		bizFreightEmission += anEmission;
		//for truck
		var myFreight = GetVariableFromCookie("bizfreightinfo","truck")
		ss = myFreight.split("|");
		anEmission = CityRef_FreightEmissionPerTonMileByTruck * ToNumericValue(ss[0]) * ToNumericValue(ss[1]); 
		if(ss[2] == 0){
			//monthly
			anEmission *= 12;
		}else if(ss[2] == 1){
			//yearly
		}else{
			//weekly
			anEmission *= 52;
		}
		aComponent=document.getElementById("bizFreightTruckTonCO");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		bizFreightEmission += anEmission;
		//for ship
		var myFreight = GetVariableFromCookie("bizfreightinfo","ship")
		ss = myFreight.split("|");
		anEmission = CityRef_FreightEmissionPerTonMileByShip * ToNumericValue(ss[0]) * ToNumericValue(ss[1]); 
		if(ss[2] == 0){
			//monthly
			anEmission *= 12;
		}else if(ss[2] == 1){
			//yearly
		}else{
			//weekly
			anEmission *= 52;
		}
		aComponent=document.getElementById("bizFreightShipTonCO");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		bizFreightEmission += anEmission;
		//for airgoods
		var myFreight = GetVariableFromCookie("bizfreightinfo","airgoods")
		ss = myFreight.split("|");
		anEmission = CityRef_FreightEmissionPerTonMileByAir * ToNumericValue(ss[0]) * ToNumericValue(ss[1]); 
		if(ss[2] == 0){
			//monthly
			anEmission *= 12;
		}else if(ss[2] == 1){
			//yearly
		}else{
			//weekly
			anEmission *= 52;
		}
		aComponent=document.getElementById("bizFreightAirGoodsTonCO");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		bizFreightEmission += anEmission;
		//for messenger
		var myFreight = GetVariableFromCookie("bizfreightinfo","messenger")
		ss = myFreight.split("|");
		anEmission = ToNumericValue(ss[0]) * ToNumericValue(ss[1]) * NationRef_CO2EmissionPerGasGallon / 20.0; 
		if(ss[2] == 0){
			//monthly
			anEmission *= 12;
		}else if(ss[2] == 1){
			//yearly
		}else{
			//weekly
			anEmission *= 52;
		}
		aComponent=document.getElementById("bizFreightMessengerCO");
		if (aComponent != null) aComponent.innerHTML = Math.round(anEmission);
		bizFreightEmission += anEmission;
	}
	aComponent=document.getElementById("bizOffsetFreightCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(bizFreightEmission / 2000 * NationRef_CarbonPricePerTon) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetFreight");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(bizFreightEmission / 2000 * NationRef_CarbonPricePerTon);
	aComponent=document.getElementById("bizFreightTotalCO");
	if (aComponent != null) aComponent.innerHTML = Math.round(bizFreightEmission);
	aComponent=document.getElementById("headBizFreightDollar");
	if (aComponent != null) aComponent.value = "$" + Math.round(bizFreightEmission / 2000 * NationRef_CarbonPricePerTon);
	headBizTotalCO += bizFreightEmission;
	// end of biz freight section
	
	//biz site section
	//var bizSiteEmission;
	//var bizSingleSiteEmission;
	{
		bizSiteEmission = 0;
		var BizSiteNo = GetVariableFromCookie("bizsiteinfo","bizsiteno");
		var aSiteInfo;
		var ss;
		var SingleSiteTable;
		var Recycled;
		var NotRecycled;
		for (var kk = 1; kk <= BizSiteNo; kk++){
			aSiteInfo = GetVariableFromCookie("bizsiteinfo","bizsite"+kk);
			ss = aSiteInfo.split("|");
			SingleSiteTable = getSiteTable(kk);
			bizSingleSiteEmission = 0;
			//business type
			//ss[0];
			anEmission = 0;
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex = getFirstContentRow(SingleSiteTable);
				aRow = SingleSiteTable.rows[rowIndex];
			}
			//heating methods
			//ss[1];
			anEmission = 0;
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizHeatMethodCO","");
			}
			//number of employee
			//ss[2];
			anEmission = 0;
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizEmployeeNumberCO","");
			}
			//building type
			//ss[3];
			anEmission = 0;
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizBuildingTypeCO","");
			}
			//square footage
			//ss[4];
			anEmission = 0;
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizSquareFootageCO","");
			}
			//electricity
			//ss[5];ss[6];
			anEmission = ToNumericValue(ss[5]) * NationRef_ElectricityEmissionFactor;
			if (ss[6] == 0){
				anEmission *= 12;
			}else if (ss[6] == 2){
				anEmission *= 52;
			}
			if (anEmission < 0)anEmission = 0;
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex += 2;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizElectricKWHCO",Math.round(anEmission));
			}
			//natural gas
			//ss[7];ss[8];
			anEmission = ToNumericValue(ss[7]) / 1000 * NationRef_NatGasEmissionFactor;
			if (ss[8] == 0){
				anEmission *= 12;
			}else if (ss[8] == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizGasFeetCO",Math.round(anEmission));
			}
			//fuel oil
			//ss[9];ss[10];
			anEmission = ToNumericValue(ss[9]) * NationRef_CO2EmissionPerFuelOilGallon;
			if (ss[10] == 0){
				anEmission *= 12;
			}else if (ss[10] == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizFuelOilGallonCO",Math.round(anEmission));
			}
			//coal
			//ss[11];ss[12];
			anEmission = ToNumericValue(ss[11]) * NationRef_CO2EmissionPerCoalTon;
			if (ss[12] == 0){
				anEmission *= 12;
			}else if (ss[12] == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizCoalTonCO",Math.round(anEmission));
			}
			//propane
			//ss[13];ss[14];
			anEmission = ToNumericValue(ss[13]) * NationRef_CO2EmissionPerPropaneGallon;
			if (ss[14] == 0){
				anEmission *= 12;
			}else if (ss[14] == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizPropaneGallonCO",Math.round(anEmission));
			}
			//wood
			//ss[15];ss[16];
			anEmission = ToNumericValue(ss[15]) * NationRef_CO2EmissionPerWoodTon;
			if (ss[16] == 0){
				anEmission *= 12;
			}else if (ss[16] == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizWoodCordCO",Math.round(anEmission));
			}
			//steam
			//ss[17];ss[18];
			anEmission = ToNumericValue(ss[17]) * NationRef_CO2EmissionPerSteamPound;
			if (ss[18] == 0){
				anEmission *= 12;
			}else if (ss[18] == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizSteamCO",Math.round(anEmission));
			}
			//waste paper
			//ss[19];ss[20];ss[21]
			anEmission = 0;
			if (ToNumericValue(ss[20]) > ToNumericValue(ss[19])){
				Recycled = ToNumericValue(ss[19]);
				NotRecycled = 0;
			}else{
				Recycled = ToNumericValue(ss[20]);
				NotRecycled = ToNumericValue(ss[19]) - ToNumericValue(ss[20]);
			}
			anEmission = NotRecycled * 0.59;
			anEmission -= Recycled * (0.90 + 0.59);
			anEmission *= 2000;
			if (ToNumericValue(ss[21]) == 0){
				anEmission *= 12;
			}else if (ToNumericValue(ss[21]) == 1){
			}else if (ToNumericValue(ss[21]) == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex += 2;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizWastePaperTonCO",Math.round(anEmission));
			}
			//waste glass
			//ss[22];ss[23];ss[24]
			anEmission = 0;
			if (ToNumericValue(ss[23]) > ToNumericValue(ss[22])){
				Recycled = ToNumericValue(ss[22]);
				NotRecycled = 0;
			}else{
				Recycled = ToNumericValue(ss[23]);
				NotRecycled = ToNumericValue(ss[22]) - ToNumericValue(ss[23]);
			}
			anEmission = NotRecycled * 0.01;
			anEmission -= Recycled * (0.09 + 0.01);
			anEmission *= 2000;
			if (ToNumericValue(ss[24]) == 0){
				anEmission *= 12;
			}else if (ToNumericValue(ss[24]) == 1){
			}else if (ToNumericValue(ss[24]) == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizWasteGlassTonCO",Math.round(anEmission));
			}
			//waste plastic
			//ss[25];ss[26];ss[27]
			anEmission = 0;
			if (ToNumericValue(ss[26]) > ToNumericValue(ss[25])){
				Recycled = ToNumericValue(ss[25]);
				NotRecycled = 0;
			}else{
				Recycled = ToNumericValue(ss[26]);
				NotRecycled = ToNumericValue(ss[25]) - ToNumericValue(ss[26]);
			}
			anEmission = NotRecycled * 0.01;
			anEmission -= Recycled * (0.54 + 0.01);
			anEmission *= 2000;
			if (ToNumericValue(ss[27]) == 0){
				anEmission *= 12;
			}else if (ToNumericValue(ss[27]) == 1){
			}else if (ToNumericValue(ss[27]) == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizWastePlasticTonCO",Math.round(anEmission));
			}
			//waste alminum
			//ss[28];ss[29];ss[30]
			anEmission = 0;
			if (ToNumericValue(ss[29]) > ToNumericValue(ss[28])){
				Recycled = ToNumericValue(ss[28]);
				NotRecycled = 0;
			}else{
				Recycled = ToNumericValue(ss[29]);
				NotRecycled = ToNumericValue(ss[28]) - ToNumericValue(ss[29]);
			}
			anEmission = NotRecycled * 0.01;
			anEmission -= Recycled * (4.27 + 0.01);
			anEmission *= 2000;
			if (ToNumericValue(ss[30]) == 0){
				anEmission *= 12;
			}else if (ToNumericValue(ss[30]) == 1){
			}else if (ToNumericValue(ss[30]) == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizWasteAluminumTonCO",Math.round(anEmission));
			}
			//waste steel
			//ss[31];ss[32];ss[33]
			anEmission = 0;
			if (ToNumericValue(ss[32]) > ToNumericValue(ss[31])){
				Recycled = ToNumericValue(ss[31]);
				NotRecycled = 0;
			}else{
				Recycled = ToNumericValue(ss[32]);
				NotRecycled = ToNumericValue(ss[31]) - ToNumericValue(ss[32]);
			}
			anEmission = NotRecycled * 0.01;
			anEmission -= Recycled * (0.63 + 0.01);
			anEmission *= 2000;
			if (ToNumericValue(ss[33]) == 0){
				anEmission *= 12;
			}else if (ToNumericValue(ss[33]) == 1){
			}else if (ToNumericValue(ss[33]) == 2){
				anEmission *= 52;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizWasteSteelTonCO",Math.round(anEmission));
			}
			//public transportation subsidy
			//ss[34];ss[35];ss[36]
			if (ToNumericValue(ss[36]) == 0){
				anEmission = 0;
			}else{
				anEmission = -ToNumericValue(ss[34]) * ToNumericValue(ss[35]) / ToNumericValue(ss[36]) * NationRef_CO2EmissionPerGasGallon;
			}
			bizSingleSiteEmission += anEmission;
			if (SingleSiteTable != null){
				rowIndex += 2;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizPublicTransportationSubsidyCO",Math.round(anEmission));
			}
			//this single site total, display
			if (SingleSiteTable != null){
				rowIndex ++;
				aRow = SingleSiteTable.rows[rowIndex];
				DisplaySingleRowEmissionValue(aRow,"bizSingleSiteTotalCO",Math.round(bizSingleSiteEmission));
			}
			//add to biz site total
			bizSiteEmission += bizSingleSiteEmission;
		}
		//display biz site total
		aComponent=document.getElementById("bizSiteTotalCO");
		if (aComponent != null) aComponent.innerHTML = Math.round(bizSiteEmission);
		aComponent=document.getElementById("headBizSiteDollar");
		if (aComponent != null) aComponent.value = "$" + Math.round(bizSiteEmission / 2000 * NationRef_CarbonPricePerTon);
		
		aComponent=document.getElementById("bizOffsetBuildingCertificates");
		if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(bizSiteEmission / 2000 * NationRef_CarbonPricePerTon / CityRef_CostPerUnit));
		aComponent=document.getElementById("bizOffsetBuilding");
		if (aComponent != null) aComponent.innerHTML = "$" + Math.round((bizSiteEmission) / 2000 * NationRef_CarbonPricePerTon);
		headBizTotalCO += bizSiteEmission;	//add to biz total
	}
	//end of biz site section
	
	//convert to metric tons
	//headTotalCO = headTotalCO / 2204.62262;
	headTotalCO = headTotalCO / 2000;
	aComponent=document.getElementById("headTotalCO");
	if (aComponent != null) aComponent.value = NumberToString(headTotalCO,3);
	aComponent=document.getElementById("headTotalDollar");
	headTotalDollar = headTotalCO * NationRef_CarbonPricePerTon;
	if (aComponent != null) aComponent.value = "$" + Math.round(headTotalDollar);// + NumberToString(headTotalDollar,0);
	headBizTotalCO = headBizTotalCO / 2000;
	aComponent=document.getElementById("headBizTotalCO");
	if (aComponent != null) aComponent.value = NumberToString(headBizTotalCO,3);
	aComponent=document.getElementById("headBizTotalDollar");
	headBizTotalDollar = headBizTotalCO * NationRef_CarbonPricePerTon;
	if (aComponent != null) aComponent.value = "$" + Math.round(headBizTotalDollar);// + NumberToString(headTotalDollar,0);
	
	aComponent=document.getElementById("offsetOneWeekCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headTotalDollar / 52) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetOneWeek");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headTotalDollar / 52);// + NumberToString(headTotalDollar,0);
	aComponent=document.getElementById("offsetOneMonthCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headTotalDollar / 12) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetOneMonth");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headTotalDollar / 12);// + NumberToString(headTotalDollar,0);
	aComponent=document.getElementById("offsetThreeMonthsCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headTotalDollar / 4) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetThreeMonths");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headTotalDollar / 4);// + NumberToString(headTotalDollar,0);
	aComponent=document.getElementById("offsetSixMonthsCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headTotalDollar / 2) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetSixMonths");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headTotalDollar / 2);// + NumberToString(headTotalDollar,0);
	aComponent=document.getElementById("offsetOneYearCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headTotalDollar) / CityRef_CostPerUnit);
	aComponent=document.getElementById("offsetOneYear");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headTotalDollar);// + NumberToString(headTotalDollar,0);
	
	aComponent=document.getElementById("bizOffsetOneWeekCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headBizTotalDollar / 52) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetOneWeek");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headBizTotalDollar / 52);// + NumberToString(headBizTotalDollar,0);
	aComponent=document.getElementById("bizOffsetOneMonthCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headBizTotalDollar / 12) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetOneMonth");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headBizTotalDollar / 12);// + NumberToString(headBizTotalDollar,0);
	aComponent=document.getElementById("bizOffsetThreeMonthsCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headBizTotalDollar / 4) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetThreeMonths");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headBizTotalDollar / 4);// + NumberToString(headBizTotalDollar,0);
	aComponent=document.getElementById("bizOffsetSixMonthsCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headBizTotalDollar / 2) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetSixMonths");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headBizTotalDollar / 2);// + NumberToString(headBizTotalDollar,0);
	aComponent=document.getElementById("bizOffsetOneYearCertificates");
	if (aComponent != null) aComponent.innerHTML = Math.ceil(Math.round(headBizTotalDollar) / CityRef_CostPerUnit);
	aComponent=document.getElementById("bizOffsetOneYear");
	if (aComponent != null) aComponent.innerHTML = "$" + Math.round(headBizTotalDollar);// + NumberToString(headBizTotalDollar,0);
}

//******** for car table
	function ReturnCarRowIndex(anElement){
		var aTable = document.getElementById("carTable");
		var allRows = aTable.getElementsByTagName("tr");
		var i;
		var j;
		var aRow;
		var allElements;
		for(i=0;i<allRows.length;i++){
			aRow = allRows[i];
			allElements = aRow.getElementsByTagName(anElement.tagName);
			for(j=0;j<allElements.length;j++){
				if(anElement == allElements[j]) return i;
			}
		}
		return -1;
	}
	function InsertCarRow(){
		var fromCarType = document.getElementById("carType1");
		if (fromCarType != null){
			var carOptions = "";
			var i;
			for(i=0;i<fromCarType.options.length;i++){
				if(i == 0){
					carOptions += '<option value="' + fromCarType.options[i].value + '" selected>' + fromCarType.options[i].text + '</option>';
				}else{
					carOptions += '<option value="' + fromCarType.options[i].value + '">' + fromCarType.options[i].text + '</option>';
				}
			}
			var aTable = document.getElementById("carTable");
			var allRows = aTable.getElementsByTagName("tr");
			var aRow = aTable.insertRow(aTable.getElementsByTagName("tr").length-2);
			aRow.className = "row_color";
			var aCell;
			aCell=aRow.insertCell(0);
			aCell.setAttribute("height","40");
			aCell.innerHTML='<select name="carType" onchange="carTypeChange(this)" class="input_field">' + carOptions + '</select>&nbsp;<a href="javascript:help(\'includes/app_help.cfm?helpID=1401\');"><img src="images/help.gif" width="11" height="11" border="0" /></a>';
			aCell.className = "form_text";
			/* // this column removed, so commented here
			aCell = aRow.insertCell(1);
			aCell.setAttribute("height","40");
			aCell.innerHTML='<div name="carAvgMileage" align="center"></div>';
			aCell.className = GetCookie("gcityname").toLowerCase()+"_form_text";
			*/
			aCell = aRow.insertCell(1);
			aCell.setAttribute("height","40");
			aCell.innerHTML='<input type="text" name="carActualMileage" onkeyup="carActualMileageChange(this)" class="'+"input_field"+'" value="'+VehicleReferences[0][1]+'">';
			aCell = aRow.insertCell(2);
			aCell.setAttribute("height","40");
			//aCell.innerHTML='<input type="text" name="carNumber" value="1" onkeyup="carNumberChange()" class="'+GetCookie("gcityname").toLowerCase()+"_input_field"+'">';
			//aCell = aRow.insertCell(3);
			//aCell.setAttribute("height","40");
			aCell.innerHTML='<input type="text" name="carDrivingMiles" onkeyup="carDrivingMilesChange()" class="'+"input_field"+'">';
			aCell = aRow.insertCell(3);
			aCell.setAttribute("height","40");
			aCell.innerHTML='<div name="carEmission" align="center"></div>';
			aCell.className = "form_text";
			aCell = aRow.insertCell(4);
			aCell.setAttribute("height","40");
			aCell.innerHTML='<input type="button" name="carRemove" value="Remove" onclick="carRemoveClick(this)"><input type="hidden" name="carNumberEff" value="0"><input type="hidden" name="carPlusMileage" value="0">';
			aCell.setAttribute("align","center");
		}
	}
	function SetCarRowValue(rowIndex,aString){
		var aStrings = aString.split("|");
		//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, no of vehicles to be replaced by efficient vehicles, improvement of gas mileage/gallon, few miles to drive
		var aTable = document.getElementById("carTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = allRows[rowIndex];
		var allComps;
		var i;
		var refMileage;
		//assign car type
		allComps = aRow.getElementsByTagName("select");
		allComps[0].selectedIndex = aStrings[0];
		refMileage = allComps[0].value;
		//assign car average mileage
		allComps = aRow.getElementsByTagName("div");
		for (i=0;i<allComps.length;i++){
			if (allComps[i].getAttribute('name') == "carAvgMileage"){
				allComps[i].innerHTML = refMileage;
			}
		}
		//assign others
		allComps = aRow.getElementsByTagName("input");
		for (i=0;i<allComps.length;i++){
			//assign actual mileage
			if (allComps[i].getAttribute('name') == "carActualMileage"){
				allComps[i].value = aStrings[1];
			}
			//assign no of vehicles
			if (allComps[i].getAttribute('name') == "carNumber"){
				allComps[i].value = aStrings[2];
			}
			//assign annual driving miles
			if (allComps[i].getAttribute('name') == "carDrivingMiles"){
				allComps[i].value = aStrings[3];
			}
			//assign car number for replacement
			if (allComps[i].getAttribute('name') == "carNumberEff"){
				allComps[i].value = aStrings[4];
			}
			//assign Plus mileage of the new replacing car
			if (allComps[i].getAttribute('name') == "carPlusMileage"){
				allComps[i].value = aStrings[5];
			}
			//assign fewer miles to drive
			if (allComps[i].getAttribute('name') == "carLessMile"){
				allComps[i].value = aStrings[6];
			}
		}
	}
	function ReturnFirstCarRowIndex(){
		var aTable = document.getElementById("carTable");
		if (aTable == null){
			return -1;
		}else{
		
			var allRows = aTable.getElementsByTagName("tr");
			var i;
			var cpnts;
			for (i=0;i<allRows.length;i++){
				aRow = allRows[i];
				cpnts = aRow.getElementsByTagName("select");
				if (cpnts.length > 0){
					return i;
				}
			}
			
		}
		
	}
	function SetCarRowEmission(rowIndex,aString){
		var aTable = document.getElementById("carTable");
		if (aTable != null){
			var allRows = aTable.getElementsByTagName("tr");
			var aRow = allRows[rowIndex];
			var allComps;
			var i;
			var refMileage;
			allComps = aRow.getElementsByTagName("div");
			for (i=0;i<allComps.length;i++){
				//assign actual mileage
				if (allComps[i].getAttribute('name') == "carEmission"){
					allComps[i].innerHTML = aString;
				}
			}
		}
	}
	function DeleteCarRow(removeButton){
		var anIndex = ReturnCarRowIndex(removeButton);
		if (anIndex > -1){
			document.getElementById("carTable").deleteRow(anIndex);
		}
	}
	function FormingCarCookie(){
		var aTable = document.getElementById("carTable");
		var allRows = aTable.getElementsByTagName("tr");
		var startCarRow;
		var endCarRow;
		var aRow;
		var cpnts;
		var i;
		var mVehicleTypeIndex;
		var mVehicleGasMileage;
		var mNoVehicle;
		var mDrivingMiles;
		var mNoVehicleReplacement;
		var mPlusGasMileage;
		var mLessMiles;
		var j;
		var carlessmile;
		carlessmile = GetVariableFromCookie("carinfo","carlessmile");
		startCarRow = -1;
		endCarRow = -1;
		for (i=0;i<allRows.length;i++){
			aRow = allRows[i];
			cpnts = aRow.getElementsByTagName("select");
			if (cpnts.length > 0){
				if (startCarRow == -1){
					startCarRow = i;
				}
				endCarRow = i;
			}
		}
		var CookieValue = "";
		for (i=startCarRow; i<=endCarRow;i++){
			//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, no of vehicles to be replaced by efficient vehicles, improvement of gas mileage/gallon, few miles to drive
			aRow = allRows[i];
			cpnts = aRow.getElementsByTagName("select");
			mVehicleTypeIndex = cpnts[0].selectedIndex;
		
			cpnts = aRow.getElementsByTagName("input");
			for (j=0;j<cpnts.length;j++){
				if (cpnts[j].getAttribute('name') == "carActualMileage"){
					mVehicleGasMileage = ToNumericValue(cpnts[j].value);
				}
				mNoVehicle = 1;
				//if (cpnts[j].getAttribute('name') == "carNumber"){
				//	mNoVehicle = ToNumericValue(cpnts[j].value);
				//}
				if (cpnts[j].getAttribute('name') == "carDrivingMiles"){
					mDrivingMiles = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "carNumberEff"){
					if (ToNumericValue(cpnts[j].value) == 0){
						mNoVehicleReplacement = mNoVehicle;
					}else{
						mNoVehicleReplacement = ToNumericValue(cpnts[j].value);
					}
				}
				if (cpnts[j].getAttribute('name') == "carPlusMileage"){
					mPlusGasMileage = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "carLessMile"){
					mLessMiles = ToNumericValue(cpnts[j].value);
				}
			}
			CookieValue += "car"+(i-startCarRow+1)+":"+mVehicleTypeIndex+"|"+mVehicleGasMileage+"|"+mNoVehicle+"|"+mDrivingMiles+"|"+mNoVehicleReplacement+"|"+mPlusGasMileage+"|"+mLessMiles+":";
			
		}
		CookieValue = ":carno:"+(endCarRow-startCarRow+1)+":"+CookieValue+"carlessmile:"+carlessmile+":";
		DeleteCookie("carinfo","","");
		SetCookie("carinfo",CookieValue);
	}
//******** end of for car table

//******** for biz car table
	function ReturnBizCarRowIndex(anElement){
		var aTable = document.getElementById("bizCarTable");
		var allRows = aTable.getElementsByTagName("tr");
		var i;
		var j;
		var aRow;
		var allElements;
		for(i=0;i<allRows.length;i++){
			aRow = allRows[i];
			allElements = aRow.getElementsByTagName(anElement.tagName);
			for(j=0;j<allElements.length;j++){
				if(anElement == allElements[j]) return i;
			}
		}
		return -1;
	}
	function InsertBizCarRow(){
		var fromBizCarType = document.getElementById("bizCarType1");
		if (fromBizCarType != null){
			var bizCarOptions = "";
			var i;
			for(i=0;i<fromBizCarType.options.length;i++){
				if(i == 0){
					bizCarOptions += '<option value="' + fromBizCarType.options[i].value + '" selected>' + fromBizCarType.options[i].text + '</option>';
				}else{
					bizCarOptions += '<option value="' + fromBizCarType.options[i].value + '">' + fromBizCarType.options[i].text + '</option>';
				}
			}
			var aTable = document.getElementById("bizCarTable");
			var allRows = aTable.getElementsByTagName("tr");
			var aRow = aTable.insertRow(aTable.getElementsByTagName("tr").length-2);
			aRow.className = "row_color";
			var aCell;
			aCell=aRow.insertCell(0);
			aCell.setAttribute("height","40");
			aCell.innerHTML='<select name="bizCarType" onchange="bizCarTypeChange(this)" class="input_field">' + bizCarOptions + '</select>&nbsp;<a href="javascript:help(\'includes/app_help.cfm?helpID=2401\');"><img src="images/help.gif" width="11" height="11" border="0" /></a>';
			aCell.className = "form_text";
			aCell = aRow.insertCell(1);
			aCell.setAttribute("height","40");
			aCell.setAttribute("align","center");
			aCell.innerHTML='<input type="text" name="bizCarActualMileage" onkeyup="bizCarActualMileageChange(this)" class="'+"input_field_short"+'" value="'+VehicleReferences[0][1]+'">';
			aCell = aRow.insertCell(2);
			aCell.setAttribute("height","40");
			aCell.setAttribute("align","center");
			aCell.innerHTML='<input type="text" name="bizCarNumber" value="1" onkeyup="bizCarNumberChange()" class="input_field_short">';
			aCell = aRow.insertCell(3);
			aCell.setAttribute("height","40");
			aCell.setAttribute("align","center");
			aCell.innerHTML='<input type="text" name="bizCarDrivingMiles" onkeyup="bizCarDrivingMilesChange()" class="input_field_short">';
			aCell = aRow.insertCell(4);
			aCell.setAttribute("height","40");
			aCell.setAttribute("align","center");
			aCell.innerHTML='<select name="bizCarFuelType" class="input_field_short" onchange="bizCarFuelTypeChange()"><option value="Gasoline">Gasoline</option><option value="Diesel">Diesel</option><option value="BioDiesel">BioDiesel</option></select>';
			aCell = aRow.insertCell(5);
			aCell.setAttribute("height","40");
			aCell.setAttribute("align","center");
			aCell.innerHTML='<div name="bizCarEmission" align="center"></div>';
			aCell.className = "form_text";
			aCell = aRow.insertCell(6);
			aCell.setAttribute("height","40");
			aCell.innerHTML='<input type="button" name="bizCarRemove" value="Remove" onclick="bizCarRemoveClick(this)">';
			aCell.setAttribute("align","center");
		}
	}
	function SetBizCarRowValue(rowIndex,aString){
		var aStrings = aString.split("|");
		//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, no of vehicles to be replaced by efficient vehicles, improvement of gas mileage/gallon, few miles to drive
		var aTable = document.getElementById("bizCarTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = allRows[rowIndex];
		var allComps;
		var i;
		//assign biz car type
		allComps = aRow.getElementsByTagName("select");
		allComps[0].selectedIndex = aStrings[0];
		//assign fuel type
		allComps[1].selectedIndex = aStrings[4];
		//assign others
		allComps = aRow.getElementsByTagName("input");
		for (i=0;i<allComps.length;i++){
			//assign actual mileage
			if (allComps[i].getAttribute('name') == "bizCarActualMileage"){
				allComps[i].value = aStrings[1];
			}
			//assign no of vehicles
			if (allComps[i].getAttribute('name') == "bizCarNumber"){
				allComps[i].value = aStrings[2];
			}
			//assign annual driving miles
			if (allComps[i].getAttribute('name') == "bizCarDrivingMiles"){
				allComps[i].value = aStrings[3];
			}
		}
	}
	function ReturnFirstBizCarRowIndex(){
		var aTable = document.getElementById("bizCarTable");
		if (aTable == null){
			return -1;
		}else{
		
			var allRows = aTable.getElementsByTagName("tr");
			var i;
			var cpnts;
			for (i=0;i<allRows.length;i++){
				aRow = allRows[i];
				cpnts = aRow.getElementsByTagName("select");
				if (cpnts.length > 0){
					return i;
				}
			}
			
		}
		
	}
	function SetBizCarRowEmission(rowIndex,aString){
		var aTable = document.getElementById("bizCarTable");
		if (aTable != null){
			var allRows = aTable.getElementsByTagName("tr");
			var aRow = allRows[rowIndex];
			var allComps;
			var i;
			var refMileage;
			allComps = aRow.getElementsByTagName("div");
			for (i=0;i<allComps.length;i++){
				//assign actual mileage
				if (allComps[i].getAttribute('name') == "bizCarEmission"){
					allComps[i].innerHTML = aString;
				}
			}
		}
	}
	function DeleteBizCarRow(removeButton){
		var anIndex = ReturnBizCarRowIndex(removeButton);
		if (anIndex > -1){
			document.getElementById("bizCarTable").deleteRow(anIndex);
		}
	}
	function FormingBizCarCookie(){
		var aTable = document.getElementById("bizCarTable");
		var allRows = aTable.getElementsByTagName("tr");
		var startBizCarRow;
		var endBizCarRow;
		var aRow;
		var cpnts;
		var i;
		var mVehicleTypeIndex;
		var mVehicleGasMileage;
		var mNoVehicle;
		var mDrivingMiles;
		var mFuelTypeIndex;
		var j;
		startBizCarRow = -1;
		endBizCarRow = -1;
		for (i=0;i<allRows.length;i++){
			aRow = allRows[i];
			cpnts = aRow.getElementsByTagName("select");
			if (cpnts.length > 0){
				if (startBizCarRow == -1){
					startBizCarRow = i;
				}
				endBizCarRow = i;
			}
		}
		var CookieValue = "";
		for (i=startBizCarRow; i<=endBizCarRow;i++){
			//vehicle type index, actual gas mileage/gallon, No of vehicles, annual driving miles, fuel type
			aRow = allRows[i];
			cpnts = aRow.getElementsByTagName("select");
			mVehicleTypeIndex = cpnts[0].selectedIndex;
			mFuelTypeIndex = cpnts[1].selectedIndex;
			cpnts = aRow.getElementsByTagName("input");
			for (j=0;j<cpnts.length;j++){
				if (cpnts[j].getAttribute('name') == "bizCarActualMileage"){
					mVehicleGasMileage = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "bizCarNumber"){
					mNoVehicle = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "bizCarDrivingMiles"){
					mDrivingMiles = ToNumericValue(cpnts[j].value);
				}
			}
			CookieValue += "bizcar"+(i-startBizCarRow+1)+":"+mVehicleTypeIndex+"|"+mVehicleGasMileage+"|"+mNoVehicle+"|"+mDrivingMiles+"|"+mFuelTypeIndex+":";
			
		}
		CookieValue = ":bizcarno:"+(endBizCarRow-startBizCarRow+1)+":"+CookieValue;
		DeleteCookie("bizcarinfo","","");
		SetCookie("bizcarinfo",CookieValue);
	}
//******** end of for biz car table

//******** for air table
	var myTextBox;
	function DisplayAirWarning(aTextBox){
		var aWarningBox = document.getElementById("flightDestinationTypingWarning");
		var obj = aTextBox;
		var myX = 0;
		var myY = 0;
		
		myX = obj.offsetLeft;
		mtY = obj.offsetTop;
		while(obj.offsetParent){
			myX = myX + obj.offsetParent.offsetLeft;
			myY = myY + obj.offsetParent.offsetTop + 2;
			obj=obj.offsetParent;
		}
		myY = myY + aTextBox.offsetHeight;
		myY = myY - 40;
		aWarningBox.style.left = myX+"px";
		aWarningBox.style.top = myY+"px";
		var aTemp = aTextBox.value;
		if (aTemp.indexOf(":")>=0 || aTemp.indexOf("|")>=0){
			aWarningBox.style.visibility="visible";
		}else{
			aWarningBox.style.visibility="hidden";
		}			
	}
	function DisplayAirList(aTextBox){
		myTextBox = aTextBox;
		var theList = document.getElementById("airDestinationList");
		if (theList.innerHTML == ""){
			HideAirList();
			return;
		}
		var theListFrame = document.getElementById("airDestinationListFrame");
		var obj = aTextBox;
		var myX = 0;
		var myY = 0;
		
		myX = obj.offsetLeft;
		mtY = obj.offsetTop;
		while(obj.offsetParent){
			myX = myX + obj.offsetParent.offsetLeft;
			myY = myY + obj.offsetParent.offsetTop + 2;
			obj=obj.offsetParent;
		}
		myY = myY + aTextBox.offsetHeight;
		theListFrame.style.left = myX+"px";
		theListFrame.style.top = myY+"px";
		theListFrame.style.width = aTextBox.offsetWidth;
		theListFrame.style.visibility="visible";
	}
	function HideAirList(){
		var theListFrame = document.getElementById("airDestinationListFrame");
		theListFrame.style.visibility="hidden";
	}
	function PopulateAirList(aTextBox){
		var listContent = "";
		var i;
		var k;
		var theValue = aTextBox.value;
		var flag = true;
		var theSubString;
		theValue = theValue.toLowerCase();
		i = theValue.indexOf(",");
		if (i>0){
			theValue = theValue.substring(0,i-1);
		}
		var theLength = theValue.length;
		if (aTextBox != null){
			if (theValue == ""){
				i=0;
				while (i<10 && i<TotalCities){
					listContent += '<div id="AirListItem' + i +'" onMouseOver="this.style.backgroundColor=\'0099FF\';" onMouseOut="this.style.backgroundColor=\'\';" onclick="AirListClick(this.innerHTML);" >' + Cities[i] + ', ' + States[i] + ', ' + Mile[i] + ' miles</div>'
					
					i++;
				}
			}else{
				i=0;
				k=0;
				while (k<10 && i<TotalCities && flag == true){
					theSubString = Cities[i].substring( 0, theLength );
					theSubString = theSubString.toLowerCase();
					if (theSubString == theValue){
						listContent += '<div id="AirListItem' + k + '" onMouseOver="this.style.backgroundColor=\'0099FF\'" onMouseOut="this.style.backgroundColor=\'\'" onclick="AirListClick(this.innerHTML);">' + Cities[i] + ', ' + States[i] + ', ' + Mile[i] + ' miles</div>'
							
						k++;
					}else{
						if (theSubString > theValue){
							flag = false;
						}
					}
					i++;
				}
				
			}
			var theList = document.getElementById("airDestinationList");
			if (theList != null){
				theList.innerHTML = listContent;
			}
			
		}
		
	}
	function flightDestinationKeyUp(e)
		{
			var keynum;
			var obj;
			var theTarget;
			var i;
			if(window.event) // IE
			  {
			  	keynum = event.keyCode;
				theTarget=event.srcElement;
			  }
			else  // Netscape/Firefox/Opera
			 {
			 	keynum = e.which;
				theTarget=e.target;
			  }
			if (theTarget.name){
				if (theTarget.name.toLowerCase() == "flightdestination"){
					if (keynum == 38){
						//arrow up
						i = 0;
						obj = document.getElementById("AirListItem"+i);
						while (obj != null){
							if (obj.style.backgroundColor != ''){
								if (i == 0){
									//do nothing
									return;
								}else{
									obj.style.backgroundColor = '';
									obj = document.getElementById("AirListItem"+(i-1));
									obj.style.backgroundColor = '0099FF';
									//set value
									AirListClick(obj.innerHTML);
									return;
								}
							}
							i++;
							obj = document.getElementById("AirListItem"+i);
						}
						if (obj == null){
							//set to first item
							obj = document.getElementById("AirListItem0");
							if (obj != null){
								obj.style.backgroundColor = '0099FF';
								//set value
								AirListClick(obj.innerHTML);
							}
							return;
						}
					}
					else if (keynum == 40){
						//arrow down
						i = 0;
						obj = document.getElementById("AirListItem"+i);
						while (obj != null){
							if (obj.style.backgroundColor != ''){
								obj = document.getElementById("AirListItem"+(i+1));
								if (obj == null){
									//this is the last one, do nothing
									return;
								}else{
									obj.style.backgroundColor = '0099FF';
									//set value
									AirListClick(obj.innerHTML);
									obj = document.getElementById("AirListItem"+i);
									obj.style.backgroundColor = '';
									return;
								}
							}
							i++;
							obj = document.getElementById("AirListItem"+i);
						}
						if (obj == null){
							//set to first item
							obj = document.getElementById("AirListItem0");
							if (obj != null){
								obj.style.backgroundColor = '0099FF';
								//set value
								AirListClick(obj.innerHTML);
							}
							return;
						}
					}else{
						//other keys, value changed
						DisplayAirWarning(theTarget);
						flightDestinationChange(theTarget);
						DisplayAirList(theTarget);
					}
				}
				
				//biz air
				if (theTarget.name.toLowerCase() == "bizflightdestination"){	
					if (keynum == 38){
						//arrow up
						i = 0;
						obj = document.getElementById("BizAirListItem"+i);
						while (obj != null){
							if (obj.style.backgroundColor != ''){
								if (i == 0){
									//do nothing
									return;
								}else{
									obj.style.backgroundColor = '';
									obj = document.getElementById("BizAirListItem"+(i-1));
									obj.style.backgroundColor = '0099FF';
									//set value
									BizAirListClick(obj.innerHTML);
									return;
								}
							}
							i++;
							obj = document.getElementById("BizAirListItem"+i);
						}
						if (obj == null){
							//set to first item
							obj = document.getElementById("BizAirListItem0");
							if (obj != null){
								obj.style.backgroundColor = '0099FF';
								//set value
								BizAirListClick(obj.innerHTML);
							}
							return;
						}
					}
					else if (keynum == 40){
						//arrow down
						i = 0;
						obj = document.getElementById("BizAirListItem"+i);
						while (obj != null){
							if (obj.style.backgroundColor != ''){
								obj = document.getElementById("BizAirListItem"+(i+1));
								if (obj == null){
									//this is the last one, do nothing
									return;
								}else{
									obj.style.backgroundColor = '0099FF';
									//set value
									BizAirListClick(obj.innerHTML);
									obj = document.getElementById("BizAirListItem"+i);
									obj.style.backgroundColor = '';
									return;
								}
							}
							i++;
							obj = document.getElementById("BizAirListItem"+i);
						}
						if (obj == null){
							//set to first item
							obj = document.getElementById("BizAirListItem0");
							if (obj != null){
								obj.style.backgroundColor = '0099FF';
								//set value
								BizAirListClick(obj.innerHTML);
							}
							return;
						}
					}else{
						//other keys, value changed
						DisplayBizAirWarning(theTarget);
						bizFlightDestinationChange(theTarget);
						DisplayBizAirList(theTarget);
					}
				}
				
				//biz equip
				if (theTarget.name.toLowerCase() == "bizequip"){	
					if (keynum == 38){
						//arrow up
						i = 0;
						obj = document.getElementById("BizEquipListItem"+i);
						while (obj != null){
							if (obj.style.backgroundColor != ''){
								if (i == 0){
									//do nothing
									return;
								}else{
									obj.style.backgroundColor = '';
									obj = document.getElementById("BizEquipListItem"+(i-1));
									obj.style.backgroundColor = '0099FF';
									//set value
									BizEquipListClick(obj.innerHTML);
									return;
								}
							}
							i++;
							obj = document.getElementById("BizEquipListItem"+i);
						}
						if (obj == null){
							//set to first item
							obj = document.getElementById("BizEquipListItem0");
							if (obj != null){
								obj.style.backgroundColor = '0099FF';
								//set value
								BizEquipListClick(obj.innerHTML);
							}
							return;
						}
					}
					else if (keynum == 40){
						//arrow down
						i = 0;
						obj = document.getElementById("BizEquipListItem"+i);
						while (obj != null){
							if (obj.style.backgroundColor != ''){
								obj = document.getElementById("BizEquipListItem"+(i+1));
								if (obj == null){
									//this is the last one, do nothing
									return;
								}else{
									obj.style.backgroundColor = '0099FF';
									//set value
									BizEquipListClick(obj.innerHTML);
									obj = document.getElementById("BizEquipListItem"+i);
									obj.style.backgroundColor = '';
									return;
								}
							}
							i++;
							obj = document.getElementById("BizEquipListItem"+i);
						}
						if (obj == null){
							//set to first item
							obj = document.getElementById("BizEquipListItem0");
							if (obj != null){
								obj.style.backgroundColor = '0099FF';
								//set value
								BizEquipListClick(obj.innerHTML);
							}
							return;
						}
					}else{
						//other keys, value changed
						DisplayBizEquipWarning(theTarget);
						bizEquipChange(theTarget);
						DisplayBizEquipList(theTarget);
					}
				}
			}
			
		}

	function AirListClick(aString){
		if (myTextBox != null){
			var rowIndex = ReturnAirRowIndex(myTextBox);
			var i = aString.lastIndexOf(",");
			var valueString = aString.substring(i+1,aString.length);	//something like 1000 miles
			valueString = valueString.substring(0,valueString.length-6);
			valueString = aString.substring(0,i) + "|" +valueString.trim() + "|" + ReturnAirTripTimes(rowIndex);
			SetAirRowValue(rowIndex,valueString);
			FormingAirCookie();
			CalculateEmission();
		}
	}
	function ReturnAirTripTimes(aRowIndex){
		var aTable = document.getElementById("airTable");
		var allRows = aTable.getElementsByTagName("tr");
		var i;
		var j;
		var aRow;
		var allElements;
		var anElement;
		aRow = allRows[aRowIndex];
		allElements = aRow.getElementsByTagName("input");
		for(j=0;j<allElements.length;j++){
			anElement = allElements[j];
			if (anElement.name == "tripTimes") {
				if (anElement.value == null || (anElement.value).trim() == ""){
					return 0;
				}else{
					return ToNumericValue(anElement.value);
				}
			}
		}
		return 0;
	}
	function ReturnAirRowIndex(anElement){
		var aTable = document.getElementById("airTable");
		var allRows = aTable.getElementsByTagName("tr");
		var i;
		var j;
		var aRow;
		var allElements;
		for(i=0;i<allRows.length;i++){
			aRow = allRows[i];
			allElements = aRow.getElementsByTagName(anElement.tagName);
			for(j=0;j<allElements.length;j++){
				if(anElement == allElements[j]) return i;
			}
		}
		return -1;
	}
	function InsertAirRow(){
		var aTable = document.getElementById("airTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = aTable.insertRow(aTable.getElementsByTagName("tr").length-2);
		aRow.className = "row_color";
		var aCell;
		aCell=aRow.insertCell(0);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="flightDestination" class="input_field_long" onfocus="flightDestinationChange(this); DisplayAirList(this);DisplayAirWarning(this);" onblur="mytime=setTimeout(\'HideAirList()\', 400)">';
		
		aCell = aRow.insertCell(1);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="roundTripMile" class="input_field_air" onkeyup="roundTripMileChange()"> &nbsp;<a href="javascript:help(\'includes/app_help.cfm?helpID=1601\');"><img src="images/help.gif" width="11" height="11" border="0" /></a>';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(2);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="tripTimes" class="input_field_air" onkeyup="tripTimesChange()" value="1"/>';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(3);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<div name="roundTripMileCO" align="center">';
		aCell = aRow.insertCell(4);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<div align="center"><input type="button" name="airRemove" value="Remove" onclick="airRemoveClick(this)"></div>';
	}
	function SetAirRowValue(rowIndex,aString){
		var aStrings = aString.split("|");
		//destination name, air mile
		var aTable = document.getElementById("airTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = allRows[rowIndex];
		var allComps;
		var i;
		var refMileage;
		//assign values
		allComps = aRow.getElementsByTagName("input");
		for (i=0;i<allComps.length;i++){
			//assign destination
			if (allComps[i].getAttribute('name') == "flightDestination"){
				allComps[i].value = aStrings[0];
			}
			//assign round trip mile
			if (allComps[i].getAttribute('name') == "roundTripMile"){
				allComps[i].value = aStrings[1];
			}
			//assign round trip times
			if (allComps[i].getAttribute('name') == "tripTimes"){
				allComps[i].value = aStrings[2];
			}
		}
	}
	function ReturnFirstAirRowIndex(){
		var aTable = document.getElementById("airTable");
		if (aTable == null){
			return -1;
		}else{
		
			var allRows = aTable.getElementsByTagName("tr");
			var i;
			var cpnts;
			for (i=0;i<allRows.length;i++){
				aRow = allRows[i];
				cpnts = aRow.getElementsByTagName("input");
				if (cpnts.length > 0){
					for (j=0;j<cpnts.length;j++){
						if (cpnts[j].getAttribute('name') == "flightDestination"){
							return i;
						}
					}
				}
			}
			
		}
		
	}
	function SetAirRowEmission(rowIndex,aString){
		var aTable = document.getElementById("airTable");
		if (aTable != null){
			var allRows = aTable.getElementsByTagName("tr");
			var aRow = allRows[rowIndex];
			var allComps;
			var i;
			var refMileage;
			allComps = aRow.getElementsByTagName("div");
			for (i=0;i<allComps.length;i++){
				//assign actual mileage
				if (allComps[i].getAttribute('name') == "roundTripMileCO"){
					allComps[i].innerHTML = aString;
				}
			}
		}
	}
	function DeleteAirRow(removeButton){
		var anIndex = ReturnAirRowIndex(removeButton);
		if (anIndex > -1){
			document.getElementById("airTable").deleteRow(anIndex);
		}
	}
	function FormingAirCookie(){
		var aTable = document.getElementById("airTable");
		var allRows = aTable.getElementsByTagName("tr");
		var startAirRow;
		var endAirRow;
		var aRow;
		var cpnts;
		var i;
		var mFlightDestination;
		var mRoundTripMile;
		var mTripTimes;
		var j;
		startAirRow = -1;
		endAirRow = -1;
		for (i=0;i<allRows.length;i++){
			aRow = allRows[i];
			cpnts = aRow.getElementsByTagName("input");
			if (cpnts.length > 0){
				for (j=0;j<cpnts.length;j++){
					if (cpnts[j].getAttribute('name') == "flightDestination"){
						if (startAirRow == -1){
							startAirRow = i;
						}
						endAirRow = i;
					}
				}
			}
		}
		CookieValue = ":airno:"+(endAirRow-startAirRow+1)+":";
		for (i=startAirRow; i<=endAirRow;i++){
			//destination, round trip mile
			aRow = allRows[i];
		
			cpnts = aRow.getElementsByTagName("input");
			for (j=0;j<cpnts.length;j++){
				if (cpnts[j].getAttribute('name') == "flightDestination"){
					mFlightDestination = cpnts[j].value;
				}
				if (cpnts[j].getAttribute('name') == "roundTripMile"){
					mRoundTripMile = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "tripTimes"){
					mTripTimes = ToNumericValue(cpnts[j].value);
				}
			}
			CookieValue += "air"+(i-startAirRow+1)+":"+mFlightDestination+"|"+mRoundTripMile+"|"+mTripTimes+":";
			
		}
		DeleteCookie("airinfo","","");
		SetCookie("airinfo",CookieValue);
	}
//******** end of for air table

//******** for biz air table
	function DisplayBizAirWarning(aTextBox){
		var aWarningBox = document.getElementById("bizFlightDestinationTypingWarning");
		var obj = aTextBox;
		var myX = 0;
		var myY = 0;
		
		myX = obj.offsetLeft;
		mtY = obj.offsetTop;
		while(obj.offsetParent){
			myX = myX + obj.offsetParent.offsetLeft;
			myY = myY + obj.offsetParent.offsetTop + 2;
			obj=obj.offsetParent;
		}
		myY = myY + aTextBox.offsetHeight;
		myY = myY - 40;
		aWarningBox.style.left = myX+"px";
		aWarningBox.style.top = myY+"px";
		var aTemp = aTextBox.value;
		if (aTemp.indexOf(":")>=0 || aTemp.indexOf("|")>=0){
			aWarningBox.style.visibility="visible";
		}else{
			aWarningBox.style.visibility="hidden";
		}			
	}
	
	function DisplayBizAirList(aTextBox){
		myTextBox = aTextBox;
		var theList = document.getElementById("bizAirDestinationList");
		if (theList.innerHTML == ""){
			HideBizAirList();
			return;
		}
		var theListFrame = document.getElementById("bizAirDestinationListFrame");
		var obj = aTextBox;
		var myX = 0;
		var myY = 0;
		
		myX = obj.offsetLeft;
		mtY = obj.offsetTop;
		while(obj.offsetParent){
			myX = myX + obj.offsetParent.offsetLeft;
			myY = myY + obj.offsetParent.offsetTop + 2;
			obj=obj.offsetParent;
		}
		myY = myY + aTextBox.offsetHeight;
		theListFrame.style.left = myX+"px";
		theListFrame.style.top = myY+"px";
		theListFrame.style.width = aTextBox.offsetWidth;
		theListFrame.style.visibility="visible";
		myY = myY - 40;
	}
	
	function HideBizAirList(){
		var theListFrame = document.getElementById("bizAirDestinationListFrame");
		theListFrame.style.visibility="hidden";
	}
	function PopulateBizAirList(aTextBox){
		var listContent = "";
		var i;
		var k;
		var theValue = aTextBox.value;
		var flag = true;
		var theSubString;
		theValue = theValue.toLowerCase();
		i = theValue.indexOf(",");
		if (i>0){
			theValue = theValue.substring(0,i-1);
		}
		var theLength = theValue.length;
		if (aTextBox != null){
			if (theValue == ""){
				i=0;
				while (i<10 && i<TotalCities){
					listContent += '<div id="BizAirListItem' + i +'" onMouseOver="this.style.backgroundColor=\'0099FF\';" onMouseOut="this.style.backgroundColor=\'\';" onclick="BizAirListClick(this.innerHTML);" >' + Cities[i] + ', ' + States[i] + ', ' + Mile[i] + ' miles</div>'
					
					i++;
				}
			}else{
				i=0;
				k=0;
				while (k<10 && i<TotalCities && flag == true){
					theSubString = Cities[i].substring( 0, theLength );
					theSubString = theSubString.toLowerCase();
					if (theSubString == theValue){
						listContent += '<div id="BizAirListItem' + k + '" onMouseOver="this.style.backgroundColor=\'0099FF\'" onMouseOut="this.style.backgroundColor=\'\'" onclick="BizAirListClick(this.innerHTML);">' + Cities[i] + ', ' + States[i] + ', ' + Mile[i] + ' miles</div>'
							
						k++;
					}else{
						if (theSubString > theValue){
							flag = false;
						}
					}
					i++;
				}
				
			}
			var theList = document.getElementById("bizAirDestinationList");
			if (theList != null){
				theList.innerHTML = listContent;
			}
			
		}
		
	}
	
	
	// keyup event is in function flightDestinationKeyUp(e)
		

	function BizAirListClick(aString){
		if (myTextBox != null){
			var rowIndex = ReturnBizAirRowIndex(myTextBox);
			var i = aString.lastIndexOf(",");
			var valueString = aString.substring(i+1,aString.length);	//something like 1000 miles
			valueString = valueString.substring(0,valueString.length-6);
			valueString = aString.substring(0,i) + "|" +valueString.trim() + "|" + ReturnBizAirTripTimes(rowIndex);
			SetBizAirRowValue(rowIndex,valueString);
			FormingBizAirCookie();
			CalculateEmission();
		}
	}
	function ReturnBizAirTripTimes(aRowIndex){
		var aTable = document.getElementById("bizAirTable");
		var allRows = aTable.getElementsByTagName("tr");
		var i;
		var j;
		var aRow;
		var allElements;
		var anElement;
		aRow = allRows[aRowIndex];
		allElements = aRow.getElementsByTagName("input");
		for(j=0;j<allElements.length;j++){
			anElement = allElements[j];
			if (anElement.name == "bizTripTimes") {
				if (anElement.value == null || (anElement.value).trim() == ""){
					return 0;
				}else{
					return ToNumericValue(anElement.value);
				}
			}
		}
		return 0;
	}
	function ReturnBizAirRowIndex(anElement){
		var aTable = document.getElementById("bizAirTable");
		var allRows = aTable.getElementsByTagName("tr");
		var i;
		var j;
		var aRow;
		var allElements;
		for(i=0;i<allRows.length;i++){
			aRow = allRows[i];
			allElements = aRow.getElementsByTagName(anElement.tagName);
			for(j=0;j<allElements.length;j++){
				if(anElement == allElements[j]) return i;
			}
		}
		return -1;
	}
	function InsertBizAirRow(){
		var aTable = document.getElementById("bizAirTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = aTable.insertRow(aTable.getElementsByTagName("tr").length-2);
		aRow.className = "row_color";
		var aCell;
		aCell=aRow.insertCell(0);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="bizFlightDestination" class="input_field_long" onfocus="bizFlightDestinationChange(this); DisplayBizAirList(this);DisplayBizAirWarning(this);" onblur="mytime=setTimeout(\'HideBizAirList()\', 400)">';
		
		aCell = aRow.insertCell(1);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="bizRoundTripMile" class="input_field_air" onkeyup="bizRoundTripMileChange()"> &nbsp;<a href="javascript:help(\'includes/app_help.cfm?helpID=2601\');"><img src="images/help.gif" width="11" height="11" border="0" /></a>';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(2);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="bizTripTimes" class="input_field_air" onkeyup="bizTripTimesChange()" value="1" />';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(3);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<div name="bizRoundTripMileCO" align="center">';
		aCell = aRow.insertCell(4);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<div align="center"><input type="button" name="bizAirRemove" value="Remove" onclick="bizAirRemoveClick(this)"></div>';
	}
	function SetBizAirRowValue(rowIndex,aString){
		var aStrings = aString.split("|");
		//destination name, air mile, times
		var aTable = document.getElementById("bizAirTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = allRows[rowIndex];
		var allComps;
		var i;
		var refMileage;
		//assign values
		allComps = aRow.getElementsByTagName("input");
		for (i=0;i<allComps.length;i++){
			//assign destination
			if (allComps[i].getAttribute('name') == "bizFlightDestination"){
				allComps[i].value = aStrings[0];
			}
			//assign round trip miles
			if (allComps[i].getAttribute('name') == "bizRoundTripMile"){
				allComps[i].value = aStrings[1];
			}
			//assign trip times
			if (allComps[i].getAttribute('name') == "bizTripTimes"){
				allComps[i].value = aStrings[2];
			}
		}
	}
	function ReturnFirstBizAirRowIndex(){
		var aTable = document.getElementById("bizAirTable");
		if (aTable == null){
			return -1;
		}else{
		
			var allRows = aTable.getElementsByTagName("tr");
			var i;
			var cpnts;
			for (i=0;i<allRows.length;i++){
				aRow = allRows[i];
				cpnts = aRow.getElementsByTagName("input");
				if (cpnts.length > 0){
					for (j=0;j<cpnts.length;j++){
						if (cpnts[j].getAttribute('name') == "bizFlightDestination"){
							return i;
						}
					}
				}
			}
			
		}
		
	}
	function SetBizAirRowEmission(rowIndex,aString){
		var aTable = document.getElementById("bizAirTable");
		if (aTable != null){
			var allRows = aTable.getElementsByTagName("tr");
			var aRow = allRows[rowIndex];
			var allComps;
			var i;
			var refMileage;
			allComps = aRow.getElementsByTagName("div");
			for (i=0;i<allComps.length;i++){
				//assign emission
				if (allComps[i].getAttribute('name') == "bizRoundTripMileCO"){
					allComps[i].innerHTML = aString;
				}
			}
		}
	}
	function DeleteBizAirRow(removeButton){
		var anIndex = ReturnBizAirRowIndex(removeButton);
		if (anIndex > -1){
			document.getElementById("bizAirTable").deleteRow(anIndex);
		}
	}
	function FormingBizAirCookie(){
		var aTable = document.getElementById("bizAirTable");
		var allRows = aTable.getElementsByTagName("tr");
		var startBizAirRow;
		var endBizAirRow;
		var aRow;
		var cpnts;
		var i;
		var mBizFlightDestination;
		var mBizRoundTripMile;
		var mBizTripTimes;
		var j;
		startBizAirRow = -1;
		endBizAirRow = -1;
		for (i=0;i<allRows.length;i++){
			aRow = allRows[i];
			cpnts = aRow.getElementsByTagName("input");
			if (cpnts.length > 0){
				for (j=0;j<cpnts.length;j++){
					if (cpnts[j].getAttribute('name') == "bizFlightDestination"){
						if (startBizAirRow == -1){
							startBizAirRow = i;
						}
						endBizAirRow = i;
					}
				}
			}
		}
		CookieValue = ":bizairno:"+(endBizAirRow-startBizAirRow+1)+":";
		for (i=startBizAirRow; i<=endBizAirRow;i++){
			//destination, round trip mile
			aRow = allRows[i];
		
			cpnts = aRow.getElementsByTagName("input");
			for (j=0;j<cpnts.length;j++){
				if (cpnts[j].getAttribute('name') == "bizFlightDestination"){
					mBizFlightDestination = cpnts[j].value;
				}
				if (cpnts[j].getAttribute('name') == "bizRoundTripMile"){
					mBizRoundTripMile = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "bizTripTimes"){
					mBizTripTimes = ToNumericValue(cpnts[j].value);
				}
			}
			CookieValue += "bizair"+(i-startBizAirRow+1)+":"+mBizFlightDestination+"|"+mBizRoundTripMile+"|"+mBizTripTimes+":";
		}
		DeleteCookie("bizairinfo","","");
		SetCookie("bizairinfo",CookieValue);
	}
//******** end of for biz air table

//******** for biz equip table
	function DisplayBizEquipWarning(aTextBox){
		var aWarningBox = document.getElementById("bizEquipTypingWarning");
		var obj = aTextBox;
		var myX = 0;
		var myY = 0;
		
		myX = obj.offsetLeft;
		mtY = obj.offsetTop;
		while(obj.offsetParent){
			myX = myX + obj.offsetParent.offsetLeft;
			myY = myY + obj.offsetParent.offsetTop + 2;
			obj=obj.offsetParent;
		}
		myY = myY + aTextBox.offsetHeight;
		myY = myY - 40;
		aWarningBox.style.left = myX+"px";
		aWarningBox.style.top = myY+"px";
		var aTemp = aTextBox.value;
		if (aTemp.indexOf(":")>=0 || aTemp.indexOf("|")>=0){
			aWarningBox.style.visibility="visible";
		}else{
			aWarningBox.style.visibility="hidden";
		}			
	}
	
	function DisplayBizEquipList(aTextBox){
		myTextBox = aTextBox;
		var theList = document.getElementById("bizEquipList");
		if (theList.innerHTML == ""){
			HideBizEquipList();
			return;
		}
		var theListFrame = document.getElementById("bizEquipListFrame");
		var obj = aTextBox;
		var myX = 0;
		var myY = 0;
		
		myX = obj.offsetLeft;
		mtY = obj.offsetTop;
		while(obj.offsetParent){
			myX = myX + obj.offsetParent.offsetLeft;
			myY = myY + obj.offsetParent.offsetTop + 2;
			obj=obj.offsetParent;
		}
		myY = myY + aTextBox.offsetHeight;
		theListFrame.style.left = myX+"px";
		theListFrame.style.top = myY+"px";
		theListFrame.style.width = aTextBox.offsetWidth;
		theListFrame.style.visibility="visible";
		myY = myY - 40;
	}
	
	function HideBizEquipList(){
		var theListFrame = document.getElementById("bizEquipListFrame");
		theListFrame.style.visibility="hidden";
	}
	function PopulateBizEquipList(aTextBox){
		var listContent = "";
		var i;
		var k;
		var theValue = aTextBox.value;
		var flag = true;
		var theSubString;
		theValue = theValue.toLowerCase();
		var theLength = theValue.length;
		if (aTextBox != null){
			if (theValue == ""){
				i=0;
				while (i<10 && i<TotalEquipments){
					listContent += '<div id="BizEquipListItem' + i +'" onMouseOver="this.style.backgroundColor=\'0099FF\';" onMouseOut="this.style.backgroundColor=\'\';" onclick="BizEquipListClick(this.innerHTML);" >' + Equipments[i] + '</div>'
					i++;
				}
			}else{
				i=0;
				k=0;
				while (k<10 && i<TotalEquipments && flag == true){
					theSubString = Equipments[i].substring( 0, theLength );
					theSubString = theSubString.toLowerCase();
					if (theSubString == theValue){
						listContent += '<div id="BizEquipListItem' + k + '" onMouseOver="this.style.backgroundColor=\'0099FF\'" onMouseOut="this.style.backgroundColor=\'\'" onclick="BizEquipListClick(this.innerHTML);">' + Equipments[i] + '</div>';						
						k++;
					}else{
						if (theSubString > theValue){
							flag = false;
						}
					}
					i++;
				}
				
			}
			var theList = document.getElementById("bizEquipList");
			if (theList != null){
				theList.innerHTML = listContent;
			}
			
		}
		
	}
	
	
	// keyup event is in function flightDestinationKeyUp(e)
		

	function BizEquipListClick(aString){
		if (myTextBox != null){
			myTextBox.value=aString;
			FormingBizEquipCookie();
			//CalculateEmission();
		}
	}
	
	function ReturnBizEquipRowIndex(anElement){
		var aTable = document.getElementById("bizEquipTable");
		var allRows = aTable.getElementsByTagName("tr");
		var i;
		var j;
		var aRow;
		var allElements;
		for(i=0;i<allRows.length;i++){
			aRow = allRows[i];
			allElements = aRow.getElementsByTagName(anElement.tagName);
			for(j=0;j<allElements.length;j++){
				if(anElement == allElements[j]) return i;
			}
		}
		return -1;
	}
	function InsertBizEquipRow(){
		var aTable = document.getElementById("bizEquipTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = aTable.insertRow(aTable.getElementsByTagName("tr").length-2);
		aRow.className = "row_color";
		var aCell;
		aCell=aRow.insertCell(0);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="bizEquip" class="input_field_medium" onfocus="bizEquipChange(this);DisplayBizEquipList(this);DisplayBizEquipWarning(this);" onblur="mytime=setTimeout(\'HideBizEquipList()\', 400)">';
		aCell = aRow.insertCell(1);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="bizEquipNumber" class="input_field_air" onkeyup=" bizEquipNumberChange(this)">';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(2);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<select name="bizEquipFuelType" onchange="bizEquipFuelTypeChange()"><option value="0">Gasoline</option><option value="1">Diesel</option><option value="2">Propane</option><option value="3">Jet Fuel</option><option value="4">BioDiesel</option></select>&nbsp;<a href="javascript:help(\'includes/app_help.cfm?helpID=2801\');"><img src="images/help.gif" width="11" height="11" border="0" /></a>';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(3);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<input type="text" name="bizEquipGallon" class="input_field_air" onkeyup="bizEquipGallonChange()" />';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(4);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<select name="bizEquipTimePeriod" class="input_field_air" onchange="bizEquipTimePeriodChange();"><option value="0">Monthly</option><option value="1">Yearly</option><option value="2">Weekly</option></select>';
		aCell.setAttribute("align","center");
		aCell = aRow.insertCell(5);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<div name="bizEquipCO" align="center"><em>&lt;FORMULA&gt;</em></div>';
		aCell = aRow.insertCell(6);
		aCell.setAttribute("height","40");
		aCell.innerHTML='<div align="center"><input type="button" name="bizEquipRemove" value="Remove" onclick="bizEquipRemoveClick(this)"></div>';
	}
	function SetBizEquipRowValue(rowIndex,aString){
		var aStrings = aString.split("|");
		//equip name, equip count, equip fuel type index, gallon, time period index
		var aTable = document.getElementById("bizEquipTable");
		var allRows = aTable.getElementsByTagName("tr");
		var aRow = allRows[rowIndex];
		var allComps;
		var i;
		//assign values
		allComps = aRow.getElementsByTagName("input");
		for (i=0;i<allComps.length;i++){
			//assign equip name
			if (allComps[i].getAttribute('name') == "bizEquip"){
				allComps[i].value = aStrings[0];
			}
			//assign equip count
			if (allComps[i].getAttribute('name') == "bizEquipNumber"){
				allComps[i].value = aStrings[1];
			}
			//assign equip gallon
			if (allComps[i].getAttribute('name') == "bizEquipGallon"){
				allComps[i].value = aStrings[3];
			}
		}
		allComps = aRow.getElementsByTagName("select");
		for (i=0;i<allComps.length;i++){
			//assign equip fuel type index
			if (allComps[i].getAttribute('name') == "bizEquipFuelType"){
				allComps[i].value = aStrings[2];
			}
			//assign equip time period index
			if (allComps[i].getAttribute('name') == "bizEquipTimePeriod"){
				allComps[i].value = aStrings[4];
			}
		}
	}
	function ReturnFirstBizEquipRowIndex(){
		var aTable = document.getElementById("bizEquipTable");
		if (aTable == null){
			return -1;
		}else{
		
			var allRows = aTable.getElementsByTagName("tr");
			var i;
			var cpnts;
			for (i=0;i<allRows.length;i++){
				aRow = allRows[i];
				cpnts = aRow.getElementsByTagName("input");
				if (cpnts.length > 0){
					for (j=0;j<cpnts.length;j++){
						if (cpnts[j].getAttribute('name') == "bizEquip"){
							return i;
						}
					}
				}
			}
			
		}
		
	}
	function SetBizEquipRowEmission(rowIndex,aString){
		var aTable = document.getElementById("bizEquipTable");
		if (aTable != null){
			var allRows = aTable.getElementsByTagName("tr");
			var aRow = allRows[rowIndex];
			var allComps;
			var i;
			var refMileage;
			allComps = aRow.getElementsByTagName("div");
			for (i=0;i<allComps.length;i++){
				//assign emission
				if (allComps[i].getAttribute('name') == "bizEquipCO"){
					allComps[i].innerHTML = aString;
				}
			}
		}
	}
	function DeleteBizEquipRow(removeButton){
		var anIndex = ReturnBizEquipRowIndex(removeButton);
		if (anIndex > -1){
			document.getElementById("bizEquipTable").deleteRow(anIndex);
		}
	}
	function FormingBizEquipCookie(){
		/*
		var aTable = document.getElementById("bizEquipTable");
		var allRows = aTable.getElementsByTagName("tr");
		var startBizEquipRow;
		var endBizEquipRow;
		var aRow;
		var cpnts;
		var i;
		var mBizEquip;
		var mBizEquipCount;
		var mBizEquipFuelTypeIndex;
		var mBizEquipGallon;
		var mBizEquipTimePeriodIndex;
		var j;
		startBizEquipRow = -1;
		endBizEquipRow = -1;
		for (i=0;i<allRows.length;i++){
			aRow = allRows[i];
			cpnts = aRow.getElementsByTagName("input");
			if (cpnts.length > 0){
				for (j=0;j<cpnts.length;j++){
					if (cpnts[j].getAttribute('name') == "bizEquip"){
						if (startBizEquipRow == -1){
							startBizEquipRow = i;
						}
						endBizEquipRow = i;
					}
				}
			}
		}
		CookieValue = ":bizequipno:"+(endBizEquipRow-startBizEquipRow+1)+":";
		for (i=startBizEquipRow; i<=endBizEquipRow;i++){
			//destination, round trip mile
			aRow = allRows[i];
		
			cpnts = aRow.getElementsByTagName("input");
			for (j=0;j<cpnts.length;j++){
				if (cpnts[j].getAttribute('name') == "bizEquip"){
					mBizEquip = cpnts[j].value;
				}
				if (cpnts[j].getAttribute('name') == "bizEquipNumber"){
					mBizEquipCount = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "bizEquipGallon"){
					mBizEquipGallon = ToNumericValue(cpnts[j].value);
				}
			}
			cpnts = aRow.getElementsByTagName("select");
			for (j=0;j<cpnts.length;j++){
				if (cpnts[j].getAttribute('name') == "bizEquipFuelType"){
					mBizEquipFuelTypeIndex = ToNumericValue(cpnts[j].value);
				}
				if (cpnts[j].getAttribute('name') == "bizEquipTimePeriod"){
					mBizEquipTimePeriodIndex = ToNumericValue(cpnts[j].value);
				}
			}
			CookieValue += "bizequip"+(i-startBizEquipRow+1)+":"+mBizEquip+"|"+mBizEquipCount+"|"+mBizEquipFuelTypeIndex+"|"+mBizEquipGallon+"|"+mBizEquipTimePeriodIndex+":";
		}
		DeleteCookie("bizequipinfo","","");
		SetCookie("bizequipinfo",CookieValue);
		*/
		//after 1-20-2009, use this
		var aBox1;
		var aBox2;
		var CookieValue;
		CookieValue = ":";
		aBox1 = document.getElementById("bizEquipGasolineGallon");
		aBox2 = document.getElementById("bizEquipGasolineTimePeriod");
		CookieValue += "gasoline:" + aBox1.value + "|" + aBox2.value + ":";
		aBox1 = document.getElementById("bizEquipDieselGallon");
		aBox2 = document.getElementById("bizEquipDieselTimePeriod");
		CookieValue += "diesel:" + aBox1.value + "|" + aBox2.value + ":";
		aBox1 = document.getElementById("bizEquipPropaneGallon");
		aBox2 = document.getElementById("bizEquipPropaneTimePeriod");
		CookieValue += "propane:" + aBox1.value + "|" + aBox2.value + ":";
		aBox1 = document.getElementById("bizEquipJetFuelGallon");
		aBox2 = document.getElementById("bizEquipJetFuelTimePeriod");
		CookieValue += "jetfuel:" + aBox1.value + "|" + aBox2.value + ":";
		aBox1 = document.getElementById("bizEquipAviationGasolineGallon");
		aBox2 = document.getElementById("bizEquipAviationGasolineTimePeriod");
		CookieValue += "aviationgasoline:" + aBox1.value + "|" + aBox2.value + ":";
		aBox1 = document.getElementById("bizEquipBioDieselGallon");
		aBox2 = document.getElementById("bizEquipBioDieselTimePeriod");
		CookieValue += "biodiesel:" + aBox1.value + "|" + aBox2.value + ":";
		DeleteCookie("bizequipinfo2","","");
		SetCookie("bizequipinfo2",CookieValue);
		//end of after 1-20-2009
	}
//******** end of for biz equip table

//******** for biz freight table
	function FormingBizFreightCookie(){
		CookieValue = ":";
		var v1;
		var v2;
		var v3;
		var aComponent;
		//for train
		aComponent = document.getElementById("bizFreightTrainTon");
		v1=aComponent.value;
		aComponent = document.getElementById("bizFreightTrainDistance");
		v2=aComponent.value;
		aComponent = document.getElementById("perTrainTimePeriod");
		v3=aComponent.value;
		CookieValue += "train:"+v1+"|"+v2+"|"+v3+":";
		//for van
		aComponent = document.getElementById("bizFreightVanTon");
		v1=aComponent.value;
		aComponent = document.getElementById("bizFreightVanDistance");
		v2=aComponent.value;
		aComponent = document.getElementById("perVanTimePeriod");
		v3=aComponent.value;
		CookieValue += "van:"+v1+"|"+v2+"|"+v3+":";
		//for truck
		aComponent = document.getElementById("bizFreightTruckTon");
		v1=aComponent.value;
		aComponent = document.getElementById("bizFreightTruckDistance");
		v2=aComponent.value;
		aComponent = document.getElementById("perTruckTimePeriod");
		v3=aComponent.value;
		CookieValue += "truck:"+v1+"|"+v2+"|"+v3+":";
		//for ship
		aComponent = document.getElementById("bizFreightShipTon");
		v1=aComponent.value;
		aComponent = document.getElementById("bizFreightShipDistance");
		v2=aComponent.value;
		aComponent = document.getElementById("perShipTimePeriod");
		v3=aComponent.value;
		CookieValue += "ship:"+v1+"|"+v2+"|"+v3+":";
		//for airgoods
		aComponent = document.getElementById("bizFreightAirGoodsTon");
		v1=aComponent.value;
		aComponent = document.getElementById("bizFreightAirGoodsDistance");
		v2=aComponent.value;
		aComponent = document.getElementById("perAirGoodsTimePeriod");
		v3=aComponent.value;
		CookieValue += "airgoods:"+v1+"|"+v2+"|"+v3+":";
		//for messenger
		aComponent = document.getElementById("bizFreightMessengerTrips");
		v1=aComponent.value;
		aComponent = document.getElementById("bizFreightMessengerDistance");
		v2=aComponent.value;
		aComponent = document.getElementById("perMessengerTimePeriod");
		v3=aComponent.value;
		CookieValue += "messenger:"+v1+"|"+v2+"|"+v3+":";
		DeleteCookie("bizfreightinfo","","");
		SetCookie("bizfreightinfo",CookieValue);
	}
//******** end of for biz freight table


//******* general functions below
	function ExistCookie(name){
		var uname=name.toUpperCase();
		var start = document.cookie.indexOf( uname + "=" );
		if (start == 0){
			//first cookie
			return true;
		}else{
			//not first; try this
			start = document.cookie.indexOf( "; " + uname + "=" );
			if (start != -1)return true;
		}
		return false;
	}
	
	function DeleteCookie( name, path, domain ) {
		name=name.toUpperCase();
		if ( GetCookie( name ) != "" ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") +	( ( domain ) ? ";domain=" + domain : "" ) +	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}


	function SetCookie(CookieName,aValue){
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+100);
		document.cookie=CookieName.toUpperCase()+"="+escape(aValue)+";expires="+exdate.toGMTString();
	}
	
	function GetCookie( name ) {
		var uname=name.toUpperCase();
		var start = document.cookie.indexOf( uname + "=" );
		if (start == 0){
			//first cookie, ok;
		}else{
			//not first; try this
			start = document.cookie.indexOf( "; " + uname + "=" );
			if (start != -1)start=start+2;
		}
		var len = start + uname.length + 1;
		if ( ( !start ) && ( uname != document.cookie.substring( 0, uname.length ) ) )
			{
				return "";
			}
		if ( start == -1 ) return "";
		var end = document.cookie.indexOf( ";", len );
		if ( end == -1 ) end = document.cookie.length;
			return unescape( document.cookie.substring( len, end ) );
	}
	
	function GetVariableFromCookie(cookieName,variableName){
		variableName = variableName.toLowerCase();
		var aString = GetCookie(cookieName);
		var start = aString.indexOf(":"+variableName+":");
		if (start == -1) return "";
		start = start + variableName.length+2;
		var end = aString.indexOf( ":", start );
		if ( end == -1 ) end = aString.length;
		return unescape( aString.substring( start, end ) );
	}
	
	function SetVariableToCookie(cookieName,variableName,aValue){
		var aString = GetCookie(cookieName);
		variableName=variableName.toLowerCase();
		var start = aString.indexOf(":"+variableName+":");
		if (start == -1) {
			aString = aString+":"+variableName+":"+aValue+":";
			DeleteCookie(cookieName,"","");
			SetCookie(cookieName,aString);
		}else{
			var start1 = start + variableName.length+2;
			var end = aString.indexOf( ":", start1 );
			if ( end == -1 ){
				aString = aString.substring( 0, start ) +":"+ variableName+":"+aValue;
			}else{
			 	aString = aString.substring( 0, start ) +":"+ variableName+":"+aValue+ aString.substring( end, aString.length )
			}
			DeleteCookie(cookieName,"","");
			SetCookie(cookieName,aString);
		}
	}
	
	function ToNumericValue(aString){
		if (isNaN(Number(aString)) == true){
			return 0;
		}else{
			return Number(aString);
		}
	}
	
	function NumberToString(aNum,decimalNum){
		if (decimalNum == 0){
			return String(Math.round(aNum));
		}
		var aString = String(aNum);
		var pos = aString.indexOf(".");
		if (pos == -1){
			return aString;
		}else{
			if (decimalNum == 0){
				return aString.substr(0,pos+decimalNum);
			}else{
				return aString.substr(0,pos+decimalNum+1);
			}
		}
	}
	
	function ToBooleanValue(aString){
		aString=aString.toLowerCase();
		if (aString == "true") return true;
		if (aString == "yes") return true;
		if (aString == "t") return true;
		if (aString == "y") return true;
		return false;
	}	


	function DepressReturnKeyCode(e){
		if (e.keyCode == 13){
			try{
				e.preventDefault();	//for NS type of browser
			}catch(err){};
			try{
				e.returnValue = false;	//for Internet Explorer
			}catch(err){};
		}
	}