function calculate()
{
// Variables
var panel_cost_perfoot	= 3
var panel_type = new Array()
var estimate_array = new Array()
var worksheet		= new Array()
var panelindex	= document.forms[0].panelprices.selectedIndex;
var top1index		= document.forms[0].TOPTRACK1.selectedIndex;
var bot1index		= document.forms[0].BOTTRACK1.selectedIndex;
var top2index		= document.forms[0].TOPTRACK2.selectedIndex;
var bot2index		= document.forms[0].BOTTRACK2.selectedIndex;
var top3index		= document.forms[0].TOPTRACK3.selectedIndex;
var bot3index		= document.forms[0].BOTTRACK3.selectedIndex;
var top4index		= document.forms[0].TOPTRACK4.selectedIndex;
var bot4index		= document.forms[0].BOTTRACK4.selectedIndex;
var top5index		= document.forms[0].TOPTRACK5.selectedIndex;
var bot5index		= document.forms[0].BOTTRACK5.selectedIndex;
var top6index		= document.forms[0].TOPTRACK6.selectedIndex;
var bot6index		= document.forms[0].BOTTRACK6.selectedIndex;
var top7index		= document.forms[0].TOPTRACK7.selectedIndex;
var bot7index		= document.forms[0].BOTTRACK7.selectedIndex;
var top8index		= document.forms[0].TOPTRACK8.selectedIndex;
var bot8index		= document.forms[0].BOTTRACK8.selectedIndex;
var top9index		= document.forms[0].TOPTRACK9.selectedIndex;
var bot9index		= document.forms[0].BOTTRACK9.selectedIndex;
var top10index		= document.forms[0].TOPTRACK10.selectedIndex;
var bot10index		= document.forms[0].BOTTRACK10.selectedIndex;
var top11index		= document.forms[0].TOPTRACK11.selectedIndex;
var bot11index		= document.forms[0].BOTTRACK11.selectedIndex;
var top12index		= document.forms[0].TOPTRACK12.selectedIndex;
var bot12index		= document.forms[0].BOTTRACK12.selectedIndex;
var top13index		= document.forms[0].TOPTRACK13.selectedIndex;
var bot13index		= document.forms[0].BOTTRACK13.selectedIndex;
var top14index		= document.forms[0].TOPTRACK14.selectedIndex;
var bot14index		= document.forms[0].BOTTRACK14.selectedIndex;
var top15index		= document.forms[0].TOPTRACK15.selectedIndex;
var bot15index		= document.forms[0].BOTTRACK15.selectedIndex;
var top16index		= document.forms[0].TOPTRACK16.selectedIndex;
var bot16index		= document.forms[0].BOTTRACK16.selectedIndex;
var top17index		= document.forms[0].TOPTRACK17.selectedIndex;
var bot17index		= document.forms[0].BOTTRACK17.selectedIndex;
var top18index		= document.forms[0].TOPTRACK18.selectedIndex;
var bot18index		= document.forms[0].BOTTRACK18.selectedIndex;
var top19index		= document.forms[0].TOPTRACK19.selectedIndex;
var bot19index		= document.forms[0].BOTTRACK19.selectedIndex;
var top20index		= document.forms[0].TOPTRACK20.selectedIndex;
var bot20index		= document.forms[0].BOTTRACK20.selectedIndex;
var inches1index	= document.forms[0].INCHES1.selectedIndex;
var inches2index	= document.forms[0].INCHES2.selectedIndex;
var inches3index	= document.forms[0].INCHES3.selectedIndex;
var inches4index	= document.forms[0].INCHES4.selectedIndex;
var inches5index	= document.forms[0].INCHES5.selectedIndex;
var inches6index	= document.forms[0].INCHES6.selectedIndex;
var inches7index	= document.forms[0].INCHES7.selectedIndex;
var inches8index	= document.forms[0].INCHES8.selectedIndex;
var inches9index	= document.forms[0].INCHES9.selectedIndex;
var inches10index	= document.forms[0].INCHES10.selectedIndex;
var inches11index	= document.forms[0].INCHES11.selectedIndex;
var inches12index	= document.forms[0].INCHES12.selectedIndex;
var inches13index	= document.forms[0].INCHES13.selectedIndex;
var inches14index	= document.forms[0].INCHES14.selectedIndex;
var inches15index	= document.forms[0].INCHES15.selectedIndex;
var inches16index	= document.forms[0].INCHES16.selectedIndex;
var inches17index	= document.forms[0].INCHES17.selectedIndex;
var inches18index	= document.forms[0].INCHES18.selectedIndex;
var inches19index	= document.forms[0].INCHES19.selectedIndex;
var inches20index	= document.forms[0].INCHES20.selectedIndex;











document.forms[0].totalopenings.value = 0;
document.forms[0].costofpanels.value	= parseInt(0);
document.forms[0].costoftracks.value = parseInt(0);
document.forms[0].totalsquarefeet.value = parseInt(0);
panel_type[0,1]	= "Aluminum .040"
panel_type[0,2]	=	2.5
panel_type[1,1]	= "Aluminum .050"
panel_type[1,2]	=	2.75 
function loadsheet(Width,Height,toptrack,bottrack,inches)
{
	var track_price	= new Array()
//	1  h-header
//	2  Stud
//	3  F
// 	4  U header	
//	5  1" BO-U
//	6  2" BO-U
//	7  3" BO-U
//	8  1" BO-F
//	9  2" BO-F
//	10 3" BO-F
//	11 rev stud angle
//	12 no tracks
//
	track_price [1]   = 4.25
	track_price [2]   = 3.95
	track_price [3]   = 2.50
	track_price [4]   = 4.25
	track_price [5]   = 5.25
	track_price [6]   = 5.95
	track_price [7]   = 6.95
	track_price [8]   = 3.95
	track_price [9]   = 4.50
	track_price [10]   = 4.95
	track_price [11]   = 4.25
	track_price [12]   = 0


	panel_cost_perfoot	= document.forms[0].panelprices.options[panelindex].value;
	document.forms[0].DUMMY.value 	= parseInt("ABC");
	bottrack_cost			= track_price[parseInt(toptrack)];
	toptrack_cost			= track_price[parseInt(bottrack)];
	this.Width 				= parseInt(Width);
	this.Height 			= parseInt(Height);
   this.Numberpanels		= Math.ceil(parseFloat(Width)/ 12);
	this.Panelheight  	= parseFloat(Height)+ parseInt(inches);
   this.square_feet		= (this.Numberpanels * this.Panelheight)/12;
	this.toptrack_cost	= parseFloat((this.Numberpanels+.25)  * toptrack_cost);
   this.bottrack_cost	= parseFloat((this.Numberpanels + .25)  * bottrack_cost);
	document.forms[0].DUMMY1.value = parseFloat((this.square_feet * panel_cost_perfoot) + 
      							 this.toptrack_cost + this.bottrack_cost);
	if (document.forms[0].DUMMY.value == document.forms[0].DUMMY1.value)
	{
		this.cost			= 0;
		this.Numberpanels = 0;
		this.Panelheight  = "   ";
	}
	else
	{
		this.cost			= document.forms[0].DUMMY1.value;
		document.forms[0].totalopenings.value = parseInt(document.forms[0].totalopenings.value) + parseInt(1);
		document.forms[0].costofpanels.value	=  parseFloat(document.forms[0].costofpanels.value) + 
												parseFloat(this.square_feet * panel_cost_perfoot);
      document.forms[0].costoftracks.value =  parseFloat(document.forms[0].costoftracks.value) +
                                    this.toptrack_cost + this.bottrack_cost;
		document.forms[0].totalsquarefeet.value = parseFloat(document.forms[0].totalsquarefeet.value) + 
												this.square_feet;
	}
}


worksheet[1] = new loadsheet(	document.forms[0].WIDTH1.value,document.forms[0].HEIGHT1.value,
										document.forms[0].TOPTRACK1.options[top1index].value,
										document.forms[0].BOTTRACK1.options[bot1index].value,
										document.forms[0].INCHES1.options[inches1index].value);

worksheet[2] = new loadsheet(	document.forms[0].WIDTH2.value,document.forms[0].HEIGHT2.value,
										document.forms[0].TOPTRACK2.options[top2index].value,
										document.forms[0].BOTTRACK2.options[bot2index].value,
										document.forms[0].INCHES1.options[inches2index].value);

worksheet[3] = new loadsheet(	document.forms[0].WIDTH3.value,document.forms[0].HEIGHT3.value,
										document.forms[0].TOPTRACK3.options[top3index].value,
										document.forms[0].BOTTRACK3.options[bot3index].value,
										document.forms[0].INCHES1.options[inches3index].value);

worksheet[4] = new loadsheet(	document.forms[0].WIDTH4.value,document.forms[0].HEIGHT4.value,
										document.forms[0].TOPTRACK4.options[top4index].value,
										document.forms[0].BOTTRACK4.options[bot4index].value,
										document.forms[0].INCHES1.options[inches4index].value);

worksheet[5] = new loadsheet(	document.forms[0].WIDTH5.value,document.forms[0].HEIGHT5.value,
										document.forms[0].TOPTRACK5.options[top5index].value,
										document.forms[0].BOTTRACK5.options[bot5index].value,
										document.forms[0].INCHES1.options[inches5index].value);

worksheet[6] = new loadsheet(	document.forms[0].WIDTH6.value,document.forms[0].HEIGHT6.value,
										document.forms[0].TOPTRACK6.options[top6index].value,
										document.forms[0].BOTTRACK6.options[bot6index].value,
										document.forms[0].INCHES1.options[inches6index].value);

worksheet[7] = new loadsheet(	document.forms[0].WIDTH7.value,document.forms[0].HEIGHT7.value,
										document.forms[0].TOPTRACK7.options[top7index].value,
										document.forms[0].BOTTRACK7.options[bot7index].value,
										document.forms[0].INCHES1.options[inches7index].value);

worksheet[8] = new loadsheet(	document.forms[0].WIDTH8.value,document.forms[0].HEIGHT8.value,
										document.forms[0].TOPTRACK8.options[top8index].value,
										document.forms[0].BOTTRACK8.options[bot8index].value,
										document.forms[0].INCHES1.options[inches8index].value);

worksheet[9] = new loadsheet(	document.forms[0].WIDTH9.value,document.forms[0].HEIGHT9.value,
										document.forms[0].TOPTRACK9.options[top9index].value,
										document.forms[0].BOTTRACK9.options[bot9index].value,
										document.forms[0].INCHES1.options[inches9index].value);

worksheet[10] = new loadsheet(	document.forms[0].WIDTH10.value,document.forms[0].HEIGHT10.value,
										document.forms[0].TOPTRACK10.options[top10index].value,
										document.forms[0].BOTTRACK10.options[bot10index].value,
										document.forms[0].INCHES1.options[inches10index].value);

worksheet[11] = new loadsheet(	document.forms[0].WIDTH11.value,document.forms[0].HEIGHT11.value,
										document.forms[0].TOPTRACK11.options[top11index].value,
										document.forms[0].BOTTRACK11.options[bot11index].value,
										document.forms[0].INCHES1.options[inches11index].value);

worksheet[12] = new loadsheet(	document.forms[0].WIDTH12.value,document.forms[0].HEIGHT12.value,
										document.forms[0].TOPTRACK12.options[top12index].value,
										document.forms[0].BOTTRACK12.options[bot12index].value,
										document.forms[0].INCHES1.options[inches12index].value);

worksheet[13] = new loadsheet(	document.forms[0].WIDTH13.value,document.forms[0].HEIGHT13.value,
										document.forms[0].TOPTRACK13.options[top13index].value,
										document.forms[0].BOTTRACK13.options[bot13index].value,
										document.forms[0].INCHES1.options[inches13index].value);

worksheet[14] = new loadsheet(	document.forms[0].WIDTH14.value,document.forms[0].HEIGHT14.value,
										document.forms[0].TOPTRACK14.options[top14index].value,
										document.forms[0].BOTTRACK14.options[bot14index].value,
										document.forms[0].INCHES1.options[inches14index].value);

worksheet[15] = new loadsheet(	document.forms[0].WIDTH15.value,document.forms[0].HEIGHT15.value,
										document.forms[0].TOPTRACK15.options[top15index].value,
										document.forms[0].BOTTRACK15.options[bot15index].value,
										document.forms[0].INCHES1.options[inches15index].value);

worksheet[16] = new loadsheet(	document.forms[0].WIDTH16.value,document.forms[0].HEIGHT16.value,
										document.forms[0].TOPTRACK16.options[top16index].value,
										document.forms[0].BOTTRACK16.options[bot16index].value,
										document.forms[0].INCHES1.options[inches16index].value);

worksheet[17] = new loadsheet(	document.forms[0].WIDTH17.value,document.forms[0].HEIGHT17.value,
										document.forms[0].TOPTRACK17.options[top17index].value,
										document.forms[0].BOTTRACK17.options[bot17index].value,
										document.forms[0].INCHES1.options[inches17index].value);

worksheet[18] = new loadsheet(	document.forms[0].WIDTH18.value,document.forms[0].HEIGHT18.value,
										document.forms[0].TOPTRACK18.options[top18index].value,
										document.forms[0].BOTTRACK18.options[bot18index].value,
										document.forms[0].INCHES1.options[inches18index].value);

worksheet[19] = new loadsheet(	document.forms[0].WIDTH19.value,document.forms[0].HEIGHT19.value,
										document.forms[0].TOPTRACK19.options[top19index].value,
										document.forms[0].BOTTRACK19.options[bot19index].value,
										document.forms[0].INCHES1.options[inches19index].value);

worksheet[20] = new loadsheet(	document.forms[0].WIDTH20.value,document.forms[0].HEIGHT20.value,
										document.forms[0].TOPTRACK20.options[top20index].value,
										document.forms[0].BOTTRACK20.options[bot20index].value,
										document.forms[0].INCHES1.options[inches20index].value);

//
document.forms[0].NUMBERPANELS1.value   = worksheet[1].Numberpanels;
document.forms[0].PANHEIGHT1.value		= worksheet[1].Panelheight;
document.forms[0].COST1.value				= Math.ceil(worksheet[1].cost*100)/100;
document.forms[0].NUMBERPANELS2.value   = worksheet[2].Numberpanels;
document.forms[0].PANHEIGHT2.value		= worksheet[2].Panelheight;
document.forms[0].COST2.value				= Math.ceil(worksheet[2].cost*100)/100;
document.forms[0].NUMBERPANELS3.value   = worksheet[3].Numberpanels;
document.forms[0].PANHEIGHT3.value		= worksheet[3].Panelheight;
document.forms[0].COST3.value				= Math.ceil(worksheet[3].cost*100)/100;
document.forms[0].NUMBERPANELS4.value   = worksheet[4].Numberpanels;
document.forms[0].PANHEIGHT4.value		= worksheet[4].Panelheight;
document.forms[0].COST4.value				= Math.ceil(worksheet[4].cost*100)/100;
document.forms[0].NUMBERPANELS5.value   = worksheet[5].Numberpanels;
document.forms[0].PANHEIGHT5.value		= worksheet[5].Panelheight;
document.forms[0].COST5.value				= Math.ceil(worksheet[5].cost*100)/100;
document.forms[0].NUMBERPANELS6.value   = worksheet[6].Numberpanels;
document.forms[0].PANHEIGHT6.value		= worksheet[6].Panelheight;
document.forms[0].COST6.value				= Math.ceil(worksheet[6].cost*100)/100;
document.forms[0].NUMBERPANELS7.value   = worksheet[7].Numberpanels;
document.forms[0].PANHEIGHT7.value		= worksheet[7].Panelheight;
document.forms[0].COST7.value				= Math.ceil(worksheet[7].cost*100)/100;
document.forms[0].NUMBERPANELS8.value   = worksheet[8].Numberpanels;
document.forms[0].PANHEIGHT8.value		= worksheet[8].Panelheight;
document.forms[0].COST8.value				= Math.ceil(worksheet[8].cost*100)/100;
document.forms[0].NUMBERPANELS9.value   = worksheet[9].Numberpanels;
document.forms[0].PANHEIGHT9.value		= worksheet[9].Panelheight;
document.forms[0].COST9.value				= Math.ceil(worksheet[9].cost*100)/100;
document.forms[0].NUMBERPANELS10.value	= worksheet[10].Numberpanels;
document.forms[0].PANHEIGHT10.value		= worksheet[10].Panelheight;
document.forms[0].COST10.value				= Math.ceil(worksheet[10].cost*100)/100;
document.forms[0].NUMBERPANELS11.value  = worksheet[11].Numberpanels;
document.forms[0].PANHEIGHT11.value		= worksheet[11].Panelheight;
document.forms[0].COST11.value				= Math.ceil(worksheet[11].cost*100)/100;
document.forms[0].NUMBERPANELS12.value  = worksheet[12].Numberpanels;
document.forms[0].PANHEIGHT12.value		= worksheet[12].Panelheight;
document.forms[0].COST12.value				= Math.ceil(worksheet[12].cost*100)/100;
document.forms[0].NUMBERPANELS13.value  = worksheet[13].Numberpanels;
document.forms[0].PANHEIGHT13.value		= worksheet[13].Panelheight;
document.forms[0].COST13.value				= Math.ceil(worksheet[13].cost*100)/100;
document.forms[0].NUMBERPANELS14.value  = worksheet[14].Numberpanels;
document.forms[0].PANHEIGHT14.value		= worksheet[14].Panelheight;
document.forms[0].COST14.value				= Math.ceil(worksheet[14].cost*100)/100;
document.forms[0].NUMBERPANELS15.value  = worksheet[15].Numberpanels;
document.forms[0].PANHEIGHT15.value		= worksheet[15].Panelheight;
document.forms[0].COST15.value				= Math.ceil(worksheet[15].cost*100)/100;
document.forms[0].NUMBERPANELS16.value  = worksheet[16].Numberpanels;
document.forms[0].PANHEIGHT16.value		= worksheet[16].Panelheight;
document.forms[0].COST16.value				= Math.ceil(worksheet[16].cost*100)/100;
document.forms[0].NUMBERPANELS17.value  = worksheet[17].Numberpanels;
document.forms[0].PANHEIGHT17.value		= worksheet[17].Panelheight;
document.forms[0].COST17.value				= Math.ceil(worksheet[17].cost*100)/100;
document.forms[0].NUMBERPANELS18.value  = worksheet[18].Numberpanels;
document.forms[0].PANHEIGHT18.value		= worksheet[18].Panelheight;
document.forms[0].COST18.value				= Math.ceil(worksheet[18].cost*100)/100;
document.forms[0].NUMBERPANELS19.value  = worksheet[19].Numberpanels;
document.forms[0].PANHEIGHT19.value		= worksheet[19].Panelheight;
document.forms[0].COST19.value				= Math.ceil(worksheet[19].cost*100)/100;
document.forms[0].NUMBERPANELS20.value  = worksheet[20].Numberpanels;
document.forms[0].PANHEIGHT20.value		= worksheet[20].Panelheight;
document.forms[0].COST20.value				= Math.ceil(worksheet[20].cost*100)/100;

document.forms[0].Totalpanels.value		=  (parseFloat(document.forms[0].NUMBERPANELS1.value) +
											 parseFloat(document.forms[0].NUMBERPANELS2.value) +
											 parseFloat(document.forms[0].NUMBERPANELS3.value) +
    										 parseFloat(document.forms[0].NUMBERPANELS4.value) +
											 parseFloat(document.forms[0].NUMBERPANELS5.value) +
											 parseFloat(document.forms[0].NUMBERPANELS6.value) +
											 parseFloat(document.forms[0].NUMBERPANELS7.value) +
											 parseFloat(document.forms[0].NUMBERPANELS8.value) +
											 parseFloat(document.forms[0].NUMBERPANELS9.value) +
											 parseFloat(document.forms[0].NUMBERPANELS10.value) +
    										 parseFloat(document.forms[0].NUMBERPANELS11.value) +
											 parseFloat(document.forms[0].NUMBERPANELS12.value) +
											 parseFloat(document.forms[0].NUMBERPANELS13.value) +
											 parseFloat(document.forms[0].NUMBERPANELS14.value) +
											 parseFloat(document.forms[0].NUMBERPANELS15.value) +
											 parseFloat(document.forms[0].NUMBERPANELS16.value) +
											 parseFloat(document.forms[0].NUMBERPANELS17.value) +
    										 parseFloat(document.forms[0].NUMBERPANELS18.value) +
											 parseFloat(document.forms[0].NUMBERPANELS19.value) +
											 parseFloat(document.forms[0].NUMBERPANELS20.value));									


document.forms[0].TOTALCOST.value			=  Math.ceil(
											(parseFloat(document.forms[0].COST1.value) +
											 parseFloat(document.forms[0].COST2.value) +
											 parseFloat(document.forms[0].COST3.value) +
											 parseFloat(document.forms[0].COST4.value) +
											 parseFloat(document.forms[0].COST5.value) +
											 parseFloat(document.forms[0].COST6.value) +
											 parseFloat(document.forms[0].COST7.value) +
											 parseFloat(document.forms[0].COST8.value) +
											 parseFloat(document.forms[0].COST9.value) +
											 parseFloat(document.forms[0].COST10.value) +
											 parseFloat(document.forms[0].COST11.value) +
											 parseFloat(document.forms[0].COST12.value) +
											 parseFloat(document.forms[0].COST13.value) +
											 parseFloat(document.forms[0].COST14.value) +
											 parseFloat(document.forms[0].COST15.value) +
											 parseFloat(document.forms[0].COST16.value) +
											 parseFloat(document.forms[0].COST17.value) +
											 parseFloat(document.forms[0].COST18.value) +
											 parseFloat(document.forms[0].COST19.value) +
											 parseFloat(document.forms[0].COST20.value))*100)/100.0;

document.forms[0].totalanchors.value		= (document.forms[0].Totalpanels.value*2) +(document.forms[0].totalopenings.value*2);
document.forms[0].costofpanels.value		= (Math.ceil(document.forms[0].costofpanels.value*100.00))/100.00;
document.forms[0].costoftracks.value    = (Math.ceil(document.forms[0].costoftracks.value*100.00))/100.00;
document.forms[0].panelcostfoot.value	   = document.forms[0].panelprices.options[panelindex].value;
document.forms[0].totalsquarefeet.value = (Math.ceil(document.forms[0].totalsquarefeet.value*100.00))/100.00;
document.forms[0].salestax.value			= (Math.ceil((document.forms[0].TOTALCOST.value*.07)*100))/100;
document.forms[0].subtotal.value			= document.forms[0].TOTALCOST.value;
document.forms[0].totalcosttax.value		= (Math.ceil((document.forms[0].TOTALCOST.value*1.07)*100))/100;
}

