number=0.00;
amount=1;
value=0;
total=0.00;
units=0.00;
activityListNum=1;

prelim_total=0.00;
labour_total=0.00;
material_total=0.00;
equipment_total=0.00;
additional_total=0.00;

PTotal=0.00;
LTotal=0.00;
MTotal=0.00;
ETotal=0.00;
TTotal=0.00;

overTotal=0.00;

arrLoaderActivity = new Array()
arrLoaderQuanitiy = new Array()
CustomerStrVal = "";
CustomerStrQuant = "";

unitList = new Array()
unitList[0] = new Array("1.00")
unitList[1] = new Array("0.00352","0.00264","0.00250","0.00150")
unitList[2] = new Array("0.25000","0.15000","2.15000","0.02000")
unitList[3] = new Array("0.02500")
unitList[4] = new Array("0.03500","0.00200")
unitList[5] = new Array("0.03200","0.06300","0.00400")
unitList[6] = new Array("1.41500","0.04000","0.04000")
unitList[7] = new Array("1.58000","0.04000","0.04000")
unitList[8] = new Array("2.83000","0.04000","0.04000")
unitList[9] = new Array("0.03486","0.03486","0.06972")
unitList[10] = new Array("1.00000","0.25000","0.88310","1.21832","1.21832","0.15000","0.15229","0.13330")
unitList[11] = new Array("0.93177","1.53018","0.11740","0.14000","0.23480","0.39622","0.50000","0.70000","0.22275")
unitList[12] = new Array("0.60000","0.40000")
unitList[13] = new Array("0.60000","0.40000")
unitList[14] = new Array("0.60000","0.40000")
unitList[15] = new Array("0.02807","0.02807","0.02807","0.16839")
unitList[16] = new Array("0.31000")
unitList[17] = new Array("0.62000")
unitList[18] = new Array("0.03500","0.03500","0.01000","0.01500")
unitList[19] = new Array("0.00511","0.00311","0.00311","0.00031","0.00187")
unitList[20] = new Array("1.30000","0.04000","0.02947","0.03684","0.01842","0.03684")
unitList[21] = new Array("1.10000","0.04000","0.02947","0.03684","0.01842","0.03684")
unitList[22] = new Array("1.30000","0.04000","0.02947","0.03684","0.01842","0.03684","0.36535")
unitList[23] = new Array("0.13000","0.01000","0.02246","0.00281","0.00140","0.00281","0.01200")
unitList[24] = new Array("0.33000")
unitList[25] = new Array("1.30000","0.04000","0.05000","0.03684","0.01500")
unitList[26] = new Array("0.04534","0.02500","0.04000")
unitList[27] = new Array("0.00025","0.00144","0.00350","0.00040","0.00518","0.90000")
unitList[28] = new Array("0.00518","0.00078","0.00155","0.90000","0.00150")
unitList[29] = new Array("2.31000","0.02000","0.01000","0.00172","0.00072","0.00250","0.00018") 
unitList[30] = new Array("1.35823","0.01495","0.00172","0.00172","0.00036","0.00018")
unitList[31] = new Array("0.04038","0.90000","0.00100","0.03000","0.03000","0.01000","0.02100","0.00420")
unitList[32] = new Array("0.07690","0.90000","0.00100","0.03000","0.03000","0.01000","0.02100","0.00420")
unitList[33] = new Array("0.15930","0.90000","0.00100","0.06000","0.06000","0.01000","0.02100","0.00420")
unitList[34] = new Array("0.00607","0.01500","0.00579","1.76000")
unitList[35] = new Array("0.01117","0.00150","1.29900","0.01400","0.00150","0.01700")
unitList[36] = new Array("0.06782","0.09947","0.00942","0.01500","0.02800")
unitList[37] = new Array("0.08472","0.18240","0.01400","0.01500","0.02800")
unitList[38] = new Array("6.50000","0.05600","0.03300","0.02841","0.00266","1.03412","0.00079","0.31000","0.37500")
unitList[39] = new Array("6.50000","0.05600","0.07400","0.00666","0.00266","0.00120","0.05000","4.00000","1.65000","0.02100","0.37500","0.43800")
unitList[40] = new Array("9.90000","0.08400","0.13500","0.01119","0.00532","0.00133","0.00120","0.05000","4.00000","1.25000","1.25000","0.50000","0.56000")
unitList[41] = new Array("16.50000","0.13900","0.19800","0.01918","0.00746","0.00267","0.00120","0.05000","4.00000","1.50000","0.03500","0.62000","0.68800")
unitList[42] = new Array("1.00000","0.18240","0.01400","0.03100","0.06300")
unitList[43] = new Array("2.33000","0.41940","0.03262","0.07223","0.14679")
unitList[44] = new Array("2.00000","0.07347","0.65000","0.01900","0.06300","0.09400")
unitList[45] = new Array("0.11000","0.02250","0.03700","0.03700","0.06300")
unitList[46] = new Array("0.35000","0.20000","0.10000","0.03100")
unitList[47] = new Array("0.06250")
unitList[48] = new Array("0.83333","0.32633","0.02500","0.06300","1.21858","0.18750","0.18750")
unitList[49] = new Array("0.83333","0.48900","0.03800","0.09500","1.81500","0.28100","0.28100")
unitList[50] = new Array("0.83333","0.32633","0.02500","0.06300","1.21858","0.18750","0.18750")
unitList[51] = new Array("0.83333","0.48900","0.03800","0.09500","1.81500","0.28100","0.28100")
unitList[52] = new Array("0.67300","0.13500","0.17800","0.03000","1.50000","0.19857","0.67012","0.78000","1.53000","0.26372","0.11302")
unitList[53] = new Array("7.12000","1.42000","0.71200","0.40100","0.12000","4.50000","1.09100","3.68100","8.45000","4.30400","1.44000","0.62000")
unitList[54] = new Array("0.79200","6.67000","4.57000","2.13300","0.16629","10.20000","2.85656","1.22424")
unitList[55] = new Array("0.10600","0.03561","0.53000","0.13460","0.45427","0.37600","0.18800","0.17877","0.07661")
unitList[56] = new Array("1.53776","0.34700","0.09900","0.04500","2.52559","0.19378","3.00000","1.53000","0.76500","0.25736","0.11030")
unitList[57] = new Array("3.02031","0.39600","0.19800","0.04500","4.96038","0.38059","4.50000","2.94900","1.47500","0.50541","0.21660")
unitList[58] = new Array("4.53062","0.39600","0.19800","0.04500","1.51032","1.53434","5.50000","4.42000","2.25000","0.75822","0.32495")
unitList[59] = new Array("6.04061","0.39600","0.66000","0.04500","9.92076","0.76118","2.16667","5.89900","3.00500","1.01092","0.43325")
unitList[60] = new Array("0.50000","0.01000","1.20000","0.56300")
unitList[61] = new Array("0.15400","0.02000","0.15000","0.87600")
unitList[62] = new Array("15.00000","0.25000","2.00000")
unitList[63] = new Array("0.04038","0.90000","0.01500","0.03000","0.02100","0.02100","0.00420")
unitList[64] = new Array("0.07690","0.90000","0.01500","0.03000","0.02100","0.02100","0.00420")
unitList[65] = new Array("0.07700","0.90000","0.03700","0.04000","0.01500","0.04000","0.04100","0.02100","0.00420")
unitList[66] = new Array("0.07700","0.90000","0.11300","0.04000","0.03150","0.04000","0.06300","0.02100","0.00420")
unitList[67] = new Array("0.07700","0.90000","0.26300","0.04000","0.06250","0.04000","0.12600","0.02100","0.00420")
unitList[68] = new Array("0.07700","0.90000","0.26300","0.04000","0.15000","0.04000","0.18900","0.02100","0.00420")
unitList[69] = new Array("0.99970","11.70000","0.01300","0.39000","0.39000","0.13000","0.15600")
unitList[70] = new Array("1.00")
unitList[71] = new Array("1.00")
unitList[72] = new Array("1.00")
unitList[73] = new Array("1.00")
unitList[74] = new Array("1.00")
unitList[75] = new Array("1.00")
unitList[76] = new Array("1.00")
unitList[77] = new Array("1.00")
unitList[78] = new Array("1.00")
unitList[79] = new Array("1.00")
unitList[80] = new Array("1.00")
unitList[81] = new Array("1.00")
unitList[82] = new Array("1.00")
unitList[83] = new Array("1.00")
unitList[84] = new Array("1.00")
unitList[85] = new Array("1.00")
unitList[86] = new Array("1.00")
unitList[87] = new Array("1.00")
unitList[88] = new Array("1.00")
unitList[89] = new Array("1.00")
unitList[90] = new Array("1.00")
unitList[91] = new Array("1.00")
unitList[92] = new Array("1.00")
unitList[93] = new Array("1.00")
unitList[94] = new Array("1.00")
unitList[95] = new Array("1.00")
unitList[96] = new Array("1.00")
unitList[97] = new Array("1.00")
unitList[98] = new Array("1.00")
unitList[99] = new Array("1.00")
unitList[100] = new Array("1.00")
unitList[101] = new Array("1.00")
unitList[102] = new Array("1.00")
unitList[103] = new Array("1.00")
unitList[104] = new Array("1.00")
unitList[105] = new Array("1.00")
unitList[106] = new Array("1.00")
unitList[107] = new Array("1.00")
unitList[108] = new Array("1.00")
unitList[109] = new Array("1.00")
unitList[110] = new Array("1.00")
unitList[111] = new Array("1.00")
unitList[112] = new Array("1.00")
unitList[113] = new Array("1.00")
unitList[114] = new Array("1.00")
unitList[115] = new Array("1.00")
unitList[116] = new Array("1.00")
unitList[117] = new Array("1.00")
unitList[118] = new Array("1.00")
unitList[119] = new Array("1.00")
unitList[120] = new Array("1.00")
unitList[121] = new Array("1.00")
unitList[122] = new Array("1.00")
unitList[123] = new Array("1.00")
unitList[124] = new Array("1.00")
unitList[125] = new Array("1.00")
unitList[126] = new Array("1.00")
unitList[127] = new Array("1.00")
unitList[128] = new Array("1.00")
unitList[129] = new Array("1.00")
unitList[130] = new Array("1.00")
unitList[131] = new Array("1.00")

arrList = new Array()
arrList[0] = new Array("0")
arrList[1] = new Array("126","122","28","116")
arrList[2] = new Array("28","114","121","116")
arrList[3] = new Array("28")
arrList[4] = new Array("28","116")
arrList[5] = new Array("28","28","116")
arrList[6] = new Array("28","116","114")
arrList[7] = new Array("28","116","114")
arrList[8] = new Array("28","116","114")
arrList[9] = new Array("114","116","28")
arrList[10] = new Array("86","67","127","114","123","28","35","116")
arrList[11] = new Array("77","67","127","69","128","108","28","35","104")
arrList[12] = new Array("69","28")
arrList[13] = new Array("69","28")
arrList[14] = new Array("69","28")
arrList[15] = new Array("114","116","113","28")
arrList[16] = new Array("28")
arrList[17] = new Array("28")
arrList[18] = new Array("114","116","113","28")
arrList[19] = new Array("113","115","124","116","28")
arrList[20] = new Array("75","116","28","113","124","115")
arrList[21] = new Array("78","116","28","113","124","115")
arrList[22] = new Array("75","116","28","113","124","115","67")
arrList[23] = new Array("75","116","28","113","124","115","67")
arrList[24] = new Array("28")
arrList[25] = new Array("78","116","114","115","28")
arrList[26] = new Array("114","28","116")
arrList[27] = new Array("124","28","70","116","127","80")
arrList[28] = new Array("127","114","116","80","28")
arrList[29] = new Array("79","72","74","28","114","119","117") 
arrList[30] = new Array("79","72","28","114","119","117")
arrList[31] = new Array("82","80","130","115","119","129","33","30")
arrList[32] = new Array("82","80","130","115","119","129","33","30")
arrList[33] = new Array("82","80","130","115","119","129","33","30")
arrList[34] = new Array("125","30","127","81")
arrList[35] = new Array("125","28","81","72","30","119")
arrList[36] = new Array("69","67","127","28","35")
arrList[37] = new Array("69","67","127","28","35")
arrList[38] = new Array("85","69","68","131","131","67","127","28","35")
arrList[39] = new Array("85","69","68","131","131","131","68","108","67","127","28","35")
arrList[40] = new Array("85","69","68","131","131","131","131","68","108","67","127","28","35")
arrList[41] = new Array("85","69","68","131","131","131","131","68","108","67","127","28","35")
arrList[42] = new Array("89","67","127","28","35")
arrList[43] = new Array("89","67","127","28","35")
arrList[44] = new Array("90","69","67","127","28","35")
arrList[45] = new Array("69","75","28","123","35")
arrList[46] = new Array("108","108","107","10")
arrList[47] = new Array("35")
arrList[48] = new Array("86","67","127","114","123","28","35")
arrList[49] = new Array("87","67","127","114","123","28","35")
arrList[50] = new Array("88","67","127","114","123","28","35")
arrList[51] = new Array("88","67","127","114","123","28","35")
arrList[52] = new Array("77","69","69","68","67","127","110","28","35","97","29")
arrList[53] = new Array("77","68","69","68","68","67","127","110","28","35","97","29")
arrList[54] = new Array("68","28","57","35","131","108","111","29")
arrList[55] = new Array("77","68","67","127","110","28","35","111","29")
arrList[56] = new Array("77","69","68","68","67","127","110","28","35","111","29")
arrList[57] = new Array("77","69","68","68","67","127","110","28","35","111","29")
arrList[58] = new Array("77","69","68","68","67","127","110","28","35","111","29")
arrList[59] = new Array("77","69","68","68","67","127","110","28","35","111","29")
arrList[60] = new Array("112","116","77","28")
arrList[61] = new Array("112","116","77","28")
arrList[62] = new Array("28","116","114")
arrList[63] = new Array("82","80","121","119","28","33","29")
arrList[64] = new Array("82","80","121","119","28","33","29")
arrList[65] = new Array("82","80","75","121","123","119","28","33","29")
arrList[66] = new Array("82","80","75","121","123","119","28","33","29")
arrList[67] = new Array("82","80","75","121","123","119","28","33","29")
arrList[68] = new Array("82","80","75","121","123","119","28","33","29")
arrList[69] = new Array("82","80","130","115","119","129","33")
arrList[70] = new Array("132")
arrList[71] = new Array("133")
arrList[72] = new Array("134")
arrList[73] = new Array("135")
arrList[74] = new Array("136")
arrList[75] = new Array("137")
arrList[76] = new Array("138")
arrList[77] = new Array("139")
arrList[78] = new Array("140")
arrList[79] = new Array("141")
arrList[80] = new Array("142")
arrList[81] = new Array("143")
arrList[82] = new Array("144")
arrList[83] = new Array("145")
arrList[84] = new Array("146")
arrList[85] = new Array("147")
arrList[86] = new Array("148")
arrList[87] = new Array("149")
arrList[88] = new Array("150")
arrList[89] = new Array("151")
arrList[90] = new Array("152")
arrList[91] = new Array("153")
arrList[92] = new Array("154")
arrList[93] = new Array("155")
arrList[94] = new Array("156")
arrList[95] = new Array("157")
arrList[96] = new Array("158")
arrList[97] = new Array("159")
arrList[98] = new Array("160")
arrList[99] = new Array("161")
arrList[100] = new Array("162")
arrList[101] = new Array("163")
arrList[102] = new Array("164")
arrList[103] = new Array("165")
arrList[104] = new Array("166")
arrList[105] = new Array("167")
arrList[106] = new Array("168")
arrList[107] = new Array("169")
arrList[108] = new Array("170")
arrList[109] = new Array("171")
arrList[110] = new Array("172")
arrList[111] = new Array("173")
arrList[112] = new Array("174")
arrList[113] = new Array("175")
arrList[114] = new Array("176")
arrList[115] = new Array("177")
arrList[116] = new Array("178")
arrList[117] = new Array("179")
arrList[118] = new Array("180")
arrList[119] = new Array("181")
arrList[120] = new Array("182")
arrList[121] = new Array("183")
arrList[122] = new Array("184")
arrList[123] = new Array("185")
arrList[124] = new Array("186")
arrList[125] = new Array("187")
arrList[126] = new Array("188")
arrList[127] = new Array("189")
arrList[128] = new Array("190")
arrList[129] = new Array("191")
arrList[130] = new Array("192")
arrList[131] = new Array("193")

function clearTotals(){
var ans;

var input_box=confirm("Are You Sure? ...RESET VALUES?");
if (input_box==false){ 
   return false;
}

ans=document.estimate_costing;
ans.subFormat_activity.value="0";
ans.preFormat_qty.value="1.00";
ans.job_activity_rate.value="0.00";
ans.job_imperial_rate.value="0.00";
ans.profit.value="0.00";
ans.haul_rate.value="0.00";
ans.estimateTotal.value="0.00";
ans.estimateSub_rate.value="0.00";
ans.prelim_rate.value="0.00";
ans.labour_rate.value="0.00";
ans.mate_rate.value="0.00";
ans.equip_rate.value="0.00";

ans.prelim_qty.value="1.00";
ans.labour_qty.value="1.00";
ans.material_qty.value="1.00";
ans.equipment_qty.value="1.00";

ans.prelim_cost.value="0.00";
ans.labour_cost.value="0.00";
ans.material_cost.value="0.00";
ans.equipment_cost.value="0.00";
ans.additional_cost.value="0.00";
ans.Total.value="0.00";
ans.tarea.value="";
ans.tarea2.value="";

ans.preFormat_unit.value="[Unit]";
ans.job_imperial_unit.value="[Unit]";
ans.preFormat_unit2.value="[Unit]";
ans.activity_job_element.value="[Job Element]";
ans.prelim_qty_cost.value="0.00";
ans.labour_qty_cost.value="0.00";
ans.material_qty_cost.value="0.00";
ans.equipment_qty_cost.value="0.00";
ans.prelim_unit.value="[Unit]";
ans.labour_unit.value="[Unit]";
ans.material_unit.value="[Unit]";
ans.equip_unit.value="[Unit]";
ans.overall_profit.value="0";
ans.overall_profit_cost.value="0.00";
ans.SUBTotal.value="0.00";

ans.job_activities.selectedIndex=0;
ans.job_elements.selectedIndex=0;
ans.prelim_comp.selectedIndex=0;
ans.labour_comp.selectedIndex=0;
ans.material_comp.selectedIndex=0;
ans.equipment_comp.selectedIndex=0;
ans.project_description.selectedIndex=0;
ans.faqs.selectedIndex=0;

number=0.00;
amount=1;
value=0;
total=0.00;
units=0.00;
activityListNum=1;

prelim_total=0.00;
labour_total=0.00;
material_total=0.00;
equipment_total=0.00;
additional_total=0.00;

PTotal=0.00;
LTotal=0.00;
MTotal=0.00;
ETotal=0.00;
TTotal=0.00;

overTotal=0.00;

Totaladditions=0.00;
ProfitTotal=0.00;
CustomerStrVal = "";
CustomerStrQuant = "";
}

function clearTotals2(){
var ans;

ans=document.estimate_costing;
ans.subFormat_activity.value="0";
ans.preFormat_qty.value="1.00";
ans.job_activity_rate.value="0.00";
ans.job_imperial_rate.value="0.00";
ans.profit.value="0.00";
ans.haul_rate.value="0.00";
ans.estimateTotal.value="0.00";
ans.estimateSub_rate.value="0.00";
ans.labour_rate.value="0.00";
ans.mate_rate.value="0.00";
ans.equip_rate.value="0.00";

ans.prelim_qty.value="1.00";
ans.labour_qty.value="1.00";
ans.material_qty.value="1.00";
ans.equipment_qty.value="1.00";

ans.prelim_cost.value="0.00";
ans.labour_cost.value="0.00";
ans.material_cost.value="0.00";
ans.equipment_cost.value="0.00";
ans.additional_cost.value="0.00";
ans.Total.value="0.00";
ans.tarea.value="";
ans.tarea2.value="";

ans.preFormat_unit.value="";
ans.job_imperial_unit.value="";
ans.preFormat_unit2.value="";
ans.activity_job_element.value="";
ans.labour_qty_cost.value="0.00";
ans.material_qty_cost.value="0.00";
ans.equipment_qty_cost.value="0.00";
ans.labour_unit.value="";
ans.material_unit.value="";
ans.equip_unit.value="";
ans.overall_profit.value="0";
ans.overall_profit_cost.value="0.00";
ans.SUBTotal.value="0.00";

number=0.00;
amount=1;
value=0;
total=0.00;
units=0.00;
activityListNum=1;

prelim_total=0.00;
labour_total=0.00;
material_total=0.00;
equipment_total=0.00;
additional_total=0.00;

PTotal=0.00;
LTotal=0.00;
MTotal=0.00;
ETotal=0.00;
TTotal=0.00;

overTotal=0.00;

Totaladditions=0.00;
ProfitTotal=0.00;
CustomerStrVal = "";
CustomerStrQuant = "";
}

function addLabourItems(){
var ans;
ans=document.estimate_costing;
PageIndex2=ans.labour_comp.selectedIndex 
var qty5="";
qty5=""+parseFloat(ans.labour_qty.value);

 if(qty5 == "NaN"){
    alert("INCORRECT LABOUR QUANTITY:");
	return false;
 }
 
 
amount=parseFloat(ans.labour_qty.value);
value=parseFloat(ans.labour_comp.value);
total=value*amount;
ans.estimateSub_rate.value=total.toFixed(2);
number+=total;
ans.estimateTotal.value=number.toFixed(2);
ans.labour_rate.value=ans.labour_comp.value;
ans.labour_unit.value=("Day");
ans.tarea.value+=("\n[Individual LABOUR Component] "+ans.labour_comp[ans.labour_comp.selectedIndex].label+"\t"+amount+" [days]"+"\t$"+total.toFixed(2));

labour_total+=total;
displayTotals(labour_total,material_total,equipment_total,prelim_total);
}

function addMaterialItems(){
var ans;
ans=document.estimate_costing;
PageIndex2=ans.material_comp.selectedIndex 
var qty6="";
qty6=""+parseFloat(ans.material_qty.value);

 if(qty6 == "NaN"){
    alert("INCORRECT MATERIAL QUANTITY:");
	return false;
 }
 
amount=parseFloat(ans.material_qty.value);
value=parseFloat(ans.material_comp.value);
total=value*amount;
ans.estimateSub_rate.value=total.toFixed(2);
number+=total;
ans.estimateTotal.value=number.toFixed(2);
ans.mate_rate.value=ans.material_comp.value;
ans.material_unit.value=ans.material_comp[ans.material_comp.selectedIndex].id;
ans.tarea.value+=("\n[Individual MATERIAL Component] "+ans.material_comp[ans.material_comp.selectedIndex].label+"\t"+amount+" ["+ans.material_comp[ans.material_comp.selectedIndex].id+"]"+"\t$"+total.toFixed(2));

material_total+=total;
displayTotals(labour_total,material_total,equipment_total,prelim_total);
}

function addEquipmentItems(){
var ans;
ans=document.estimate_costing;
PageIndex2=ans.equipment_comp.selectedIndex 
var qty7="";
qty7=""+parseFloat(ans.equipment_qty.value);

 if(qty7 == "NaN"){
    alert("INCORRECT EQUIPMENT QUANTITY:");
	return false;
 }
 
amount=parseFloat(ans.equipment_qty.value);
value=parseFloat(ans.equipment_comp.value);
total=value*amount;
ans.estimateSub_rate.value=total.toFixed(2);
number+=total;
ans.estimateTotal.value=number.toFixed(2);
ans.equip_rate.value=ans.equipment_comp.value;
ans.equip_unit.value=ans.equipment_comp[ans.equipment_comp.selectedIndex].id;
ans.tarea.value+=("\n[Individual EQUIPMENT Component] "+ans.equipment_comp[ans.equipment_comp.selectedIndex].label+"\t"+amount+" ["+ans.equipment_comp[ans.equipment_comp.selectedIndex].id+"]"+"\t$"+total.toFixed(2));

equipment_total+=total;
displayTotals(labour_total,material_total,equipment_total,prelim_total);
}

function addPreElementsItems(){
var ans,i,n,x,y,z;
var addTotals=0.00;
var overTotal=0.00;
TTotal=0.00;

ans=document.estimate_costing;
PageIndex2=ans.equipment_comp.selectedIndex 

amount=parseFloat(ans.preFormat_qty.value);
value=parseFloat(ans.job_elements.value);
ans.preFormat_unit.value="...";
ans.tarea.value+=("\nJOB ELEMENT: "+ans.job_elements[ans.job_elements.selectedIndex].label+" [0"+ans.job_elements[ans.job_elements.selectedIndex].value+"] :");
 for(i=0;i<131;i++){
     if(value==ans.job_activities[i].value){
		
		ans.tarea.value+=("\n ACTIVITY: "+ans.job_activities[i].title);
		ans.tarea.value+=("\n ACTIVITY UNIT: "+ans.job_activities[i].unit);
	    ans.tarea.value+=("\n ACTIVITY SPECS: "+ans.job_activities[i].label+"\t"+amount+"\t"+ans.job_activities[i].id+"\t"+total.toFixed(2));
	
		 for(x=0;x<arrList[ans.job_activities[i].unit].length;x++){
			 showElements(arrList[ans.job_activities[i].unit],unitList[ans.job_activities[i].unit],x,ans.job_activities[i].unit);   
			 addTotals+=TTotal;
		  }
		 ans.tarea.value+=("\n\t\t\t\t\t\t\t\t\t ==> ACTIVITY TOTAL: "+"\t$"+addTotals.toFixed(2)+"/"+ans.job_activities[i].id);
		 overTotal+=addTotals;
		 addTotals=0.00;
		}
      }
}


function addActiveElementsItems(){
var ans,i,n,x,y,z;
var addTotals=0.00;
var amount=0;
TTotal=0.00;

ans=document.estimate_costing;
amount=parseFloat(ans.preFormat_qty.value);
PageIndex2=ans.equipment_comp.selectedIndex; 

var qty1="";

qty1=""+parseFloat(ans.preFormat_qty.value);
if(qty1 == "NaN"){
    alert("INCORRECT QUANTITY:");
	return false;
 }
 if(ans.job_activities[ans.job_activities.selectedIndex].unit == 0){
	return false;
 }
else{
//amount=parseFloat(ans.preFormat_qty.value);
loadCustomerString(ans.job_activities.selectedIndex, amount);
        ans.tarea2.value+=("\n[NOTE:] ***ACTIVITY ["+ans.job_activities[ans.job_activities.selectedIndex].unit+"] INSERTED!***");
	    ans.preFormat_unit.value="["+ans.job_activities[ans.job_activities.selectedIndex].id+"]";
		ans.tarea.value+=("\n\n[No. "+activityListNum+"]");
		ans.tarea.value+=("\n JOB ELEMENT: "+ans.job_elements[ans.job_activities[ans.job_activities.selectedIndex].value].label);
		ans.tarea.value+=("\n ACTIVITY: "+ans.job_activities[ans.job_activities.selectedIndex].title);
		ans.tarea.value+=("\n ACTIVITY UNIT: "+ans.job_activities[ans.job_activities.selectedIndex].unit);
		ans.tarea.value+=("\n ACTIVITY QUANTITY: "+amount.toFixed(2)+" / "+ans.job_activities[ans.job_activities.selectedIndex].id);
		ans.tarea.value+=("\n ACTIVITY COMPONENTS: "+ans.job_activities[ans.job_activities.selectedIndex].label);
		
		 for(x=0;x<arrList[ans.job_activities[ans.job_activities.selectedIndex].unit].length;x++){
			 showElements(arrList[ans.job_activities[ans.job_activities.selectedIndex].unit],unitList[ans.job_activities[ans.job_activities.selectedIndex].unit],x,ans.job_activities[ans.job_activities.selectedIndex].unit);	    	    
			 addTotals+=TTotal;
		  }
  	    ans.tarea.value+=("\n ACTIVITY METRIC["+ans.job_activities[ans.job_activities.selectedIndex].id+"] RATE: "+" $"+SingleNumber.toFixed(2)+"/"+ans.job_activities[ans.job_activities.selectedIndex].id);
		ans.tarea.value+=("\n ACTIVITY IMPERIAL["+ans.job_activities[ans.job_activities.selectedIndex].id2+"] RATE: "+" $"+imperialRate.toFixed(2)+"/"+ans.job_activities[ans.job_activities.selectedIndex].id2);
		ans.tarea.value+=("\n ==> ACTIVITY TOTAL: "+"\t$"+addTotals.toFixed(2)+"(JMD)\n\n");
		
		activityListNum++;
		overTotal+=addTotals;
		addTotals=0.00;
	}
}

function showElements(arr,arr2,x,sel){
var ans,z;
PTotal=0.00;
LTotal=0.00;
MTotal=0.00;
ETotal=0.00;
TTotal=0.00;
ans=document.estimate_costing;

ans.tarea.value+=("<table align='center' border='0' cellpadding='0' cellspacing='0' class='debo3' width='680'>");

   for(y=0;y<102;y++){
	 if(arr[x]==ans.prelim_comp[y].unit){ 
	   calcTotal(ans.prelim_comp[y].value,arr2[x]);
	   //ans.tarea.value+=("\n\t"+ans.labour_comp[y].label+"\t\t [day]"+"\t\t$"+ans.labour_comp[y].value+"\t\t"+units+"/"+ans.job_activities[sel].id+"\t\t$"+total.toFixed(2));
	   ans.tarea.value+=("<tr><td width='300'>"+ans.prelim_comp[y].label+"</td><td width='100'> [Sum]"+"</td><td width='100'>$"+ans.prelim_comp[y].value+"</td><td width='100'>"+units.toFixed(5)+"/Sum</td><td width='100'>$"+total.toFixed(2))+"</td></tr>";
	   
	   prelim_total+=total;
	   PTotal=total;
       } 
    }
	
  for(y=0;y<66;y++){
	 if(arr[x]==ans.labour_comp[y].unit){ 
	   calcTotal(ans.labour_comp[y].value,arr2[x]);
	   //ans.tarea.value+=("\n\t"+ans.labour_comp[y].label+"\t\t [day]"+"\t\t$"+ans.labour_comp[y].value+"\t\t"+units+"/"+ans.job_activities[sel].id+"\t\t$"+total.toFixed(2));
	   ans.tarea.value+=("<tr><td width='300'>"+ans.labour_comp[y].label+"</td><td width='100'> [Day]"+"</td><td width='100'>$"+ans.labour_comp[y].value+"</td><td width='100'>"+units.toFixed(5)+"/Day</td><td width='100'>$"+total.toFixed(2))+"</td></tr>";
	   
	   labour_total+=total;
	   LTotal=total;
       } 
    }
	
	for(y=0;y<47;y++){
	 if(arr[x]==ans.material_comp[y].unit){
	   calcTotal(ans.material_comp[y].value,arr2[x]);
	   //ans.tarea.value+=("\n\t"+ans.material_comp[y].label+"\t\t ["+ans.material_comp[y].id+"] \t\t$"+ans.material_comp[y].value+"\t\t"+units+"/"+ans.job_activities[sel].id+"\t\t$"+total.toFixed(2));    			  
	   ans.tarea.value+=("<tr><td width='300'>"+ans.material_comp[y].label+"</td><td width='100'> ["+ans.material_comp[y].id+"] </td><td width='100'>$"+ans.material_comp[y].value+"</td><td width='100'>"+units.toFixed(5)+"/"+ans.material_comp[y].id+"</td><td width='100'>$"+total.toFixed(2))+"</td></tr>";
	   
	   material_total+=total;
	   MTotal=total;
       }
    }
	
	for(y=0;y<16;y++){
	 if(arr[x]==ans.equipment_comp[y].unit){
	   calcTotal(ans.equipment_comp[y].value,arr2[x]);
	   //ans.tarea.value+=("\n\t"+ans.equipment_comp[y].label+"\t\t ["+ans.equipment_comp[y].id+"] \t\t$"+ans.equipment_comp[y].value+"\t\t"+units+"/"+ans.job_activities[sel].id+"\t\t$"+total.toFixed(2));    			  
	   ans.tarea.value+=("<tr><td width='300'>"+ans.equipment_comp[y].label+"</td><td width='100'> ["+ans.equipment_comp[y].id+"] </td><td width='100'>$"+ans.equipment_comp[y].value+"</td><td width='100'>"+units.toFixed(5)+"/"+ans.equipment_comp[y].id+"</td><td width='100'>$"+total.toFixed(2))+"</td></tr>";
	   
	    equipment_total+=total;
		ETotal=total;
       } 
    }
	
	ans.tarea.value+=("</table>");
	TTotal+=PTotal+LTotal+MTotal+ETotal;
	displayTotals(labour_total,material_total,equipment_total,prelim_total);
}

function displayTotals(lab,mat,equip,prelim){
var totals=0.00;
ans=document.estimate_costing;

ans.labour_cost.value=lab.toFixed(2);
ans.material_cost.value=mat.toFixed(2);
ans.equipment_cost.value=equip.toFixed(2);
ans.prelim_cost.value=prelim.toFixed(2);
totals=parseFloat(lab)+parseFloat(mat)+parseFloat(equip)+parseFloat(prelim);
ans.Total.value=totals.toFixed(2);
ans.estimateTotal.value=totals.toFixed(2);  
calcEstimateTotal();
}

function calcTotal(arrValue,arrValue2){
ans=document.estimate_costing;
var price=0.00;
var netPrice=0.00;
units=0.00;

units=parseFloat(arrValue2);
amount=parseFloat(ans.preFormat_qty.value);
units=units*amount;
price=parseFloat(arrValue);
netPrice=parseFloat(price*units);

total=netPrice;
ans.estimateSub_rate.value=total.toFixed(2); 
}

function calcEstimateTotal(){
ans=document.estimate_costing;
var haul_rate=0.00;
var profit=0.00;
var estimate=0.00;
var estimate2=0.00;
var estimate3=0.00;
var total_noTax=0.00;
var qty2="";
var qty3="";
qty2=""+parseFloat(ans.profit.value);
qty3=""+parseFloat(ans.haul_rate.value);


 if(qty2 == "NaN" || parseFloat(qty2) > 100 ){
    alert("INCORRECT OVERALL PROFIT (%):");
	return false;
 }
 if(qty3 == "NaN"){
    alert("INCORRECT PRELIMINARY / ADDITIONAL COST:");
	return false;
 }
 
total_noTax=parseFloat(ans.Total.value);
profit=parseFloat(ans.profit.value);
profit=parseFloat(profit/100.00);
haul_rate=parseFloat(ans.haul_rate.value);

estimate=total_noTax+haul_rate;
estimate2=total_noTax*profit;
estimate3=estimate+estimate2;

ans.overall_profit.value=profit*100.00;
ans.overall_profit_cost.value=estimate2.toFixed(2);
ans.additional_cost.value=haul_rate.toFixed(2);

ans.estimateTotal.value=estimate3.toFixed(2);   
ans.SUBTotal.value=estimate3.toFixed(2);

ans.profit.value="0.00";
ans.haul_rate.value="0.00";
}

function displayPreliminaryUnits(){
var quantity=0.00;
var rate=0.00;
var Rate=0.00;
var SingleRate=0.00;
ans=document.estimate_costing;
ans.prelim_unit.value="SUM";  
quantity=parseFloat(ans.prelim_qty.value);
rate=parseFloat(ans.prelim_comp[ans.prelim_comp.selectedIndex].value);
Rate=rate*quantity;
SingleRate=rate;
ans.prelim_qty_cost.value=Rate.toFixed(2);   
ans.prelim_rate.value=SingleRate.toFixed(2);   
}

function displayLabourUnits(){
var quantity=0.00;
var rate=0.00;
var Rate=0.00;
var SingleRate=0.00;
ans=document.estimate_costing;
ans.labour_unit.value="Day";  
quantity=parseFloat(ans.labour_qty.value);
rate=parseFloat(ans.labour_comp[ans.labour_comp.selectedIndex].value);
Rate=rate*quantity;
SingleRate=rate;
ans.labour_qty_cost.value=Rate.toFixed(2);   
ans.labour_rate.value=SingleRate.toFixed(2);   
}

function displayMaterialUnits(){
var quantity=0.00;
var rate=0.00;
var Rate=0.00;
var SingleRate=0.00;
ans=document.estimate_costing;
quantity=parseFloat(ans.material_qty.value);
rate=parseFloat(ans.material_comp[ans.material_comp.selectedIndex].value);
Rate=rate*quantity;
SingleRate=rate;
ans.material_unit.value=ans.material_comp[ans.material_comp.selectedIndex].id;   
ans.material_qty_cost.value=Rate.toFixed(2); 
ans.mate_rate.value=SingleRate.toFixed(2); 
}

function displayEquipUnits(){
var quantity=0.00;
var rate=0.00;
var Rate=0.00;
var SingleRate=0.00;
ans=document.estimate_costing;
quantity=parseFloat(ans.equipment_qty.value);
rate=parseFloat(ans.equipment_comp[ans.equipment_comp.selectedIndex].value);
Rate=rate*quantity;
SingleRate=rate;
ans.equip_unit.value=ans.equipment_comp[ans.equipment_comp.selectedIndex].id;   
ans.equipment_qty_cost.value=Rate.toFixed(2);   
ans.equip_rate.value=SingleRate.toFixed(2); 

}

function displayActiveUnits(){
ans=document.estimate_costing;
ans.preFormat_unit.value=ans.job_activities[ans.job_activities.selectedIndex].id;  
ans.preFormat_unit2.value=ans.job_activities[ans.job_activities.selectedIndex].id;   
}