// JavaScript Document

<!--This code is not in the public domain. It is the sole property of Joseph Fusco.//-->

<!-- Begin Variable List //-->

var ns,base,basex,ht,va,vax,vay,pb,pbx,sa,sax,bc,sl,mga,mgax,hr,ha,hax,hl,c,d,e,f,da,mda;

<!-- Get information on box //-->

function calc(form) {



				// Gets information on box

				

ns = document.Get_Info.ns.value; 		//Gets number of sides

base = document.Get_Info.base.value; 	//Gets the length of each side

ht = document.Get_Info.ht.value; 			//Gets the overall height of the box



				// calculations



basex = (.5 * base)					// converts to 1/2 the base length

va = (180-(360/ns)); 				// contverts to vertex angle

	vay = va;

vax = (180-(360/ns))/2; 				// converts to half the vertex angle

	va = vax;

vax = vax * ((2*Math.PI)/360); 		// converts  vertex angle to radians

pb = basex * Math.tan(vax);			// determines the perpendicular bisector in radians.

	pbx = pb / ((2*Math.PI)/360);		// convert pb from radians

sa = Math.atan(ht/pb);				// determines slope angle in radians

	sax = sa / ((2*Math.PI)/360);		// convert sa from radians

bc = 90 - sax;						// determines the bottom cut angle

sl = pb / Math.cos(sa);				// determines the side length

mga = Math.atan(sl/basex)			// determines the miter gauge angle setting

	mgax = mga / ((2*Math.PI)/360);	// convert miter gauge angle from radians

hr = basex / Math.cos(vax);			// determines the hip run distance

ha = Math.atan(ht/hr);

	hax = ha / ((2*Math.PI)/360);		// convert hip angle from radians

hl = hr / Math.cos(ha);				// determines the hip length

				// determines the blade bevel angle

c = basex * Math.tan(ha);

d = c * Math.cos(ha);

e = d/pb;

f = Math.atan(e);

	fx = f / ((2*Math.PI)/360); 		// converts the bevel angle form radians

	

da = (90 - fx) * 2;

	

				//Writes Information to Form

va = round(va);

	document.Info_out.va.value =va;

vay = round(vay);	

	document.Info_out.vay.value =vay;

pb = round(pb);	

	document.Info_out.pb.value =pb;

sax = round(sax);	

	document.Info_out.sa.value =sax;

bc = round(bc);	

	document.Info_out.bc.value =bc;

sl = round(sl);	

	document.Info_out.sl.value =sl;

mgax = round(mgax);	

	document.Info_out.mga.value =mgax;

hr = round(hr);	

	document.Info_out.hr.value =hr;

hax = round(hax);	

	document.Info_out.ha.value =hax;

hl = round(hl);	

	document.Info_out.hl.value =hl;

da = round(da);	

	document.Info_out.da.value =da;

fx= round(fx);	

	document.Info_out.f.value =fx;

	

}

// Rounding Function

function round (x) {

	return Math.round (x*100)/100;

}

// Clears forms

function clear() {



document.Get_Info.ns.value =""; 		

document.Get_Info.base.value =""; 	

document.Get_Info.ht.value =""; 	



document.Info_out.va.value ="0";

document.Info_out.vay.value ="0";

document.Info_out.pb.value ="0";

document.Info_out.sa.value ="0";

document.Info_out.bc.value ="0";

document.Info_out.sl.value ="0";

document.Info_out.mga.value ="0";

document.Info_out.hr.value ="0";

document.Info_out.ha.value ="0";

document.Info_out.hl.value ="0";

document.Info_out.da.value ="0";

document.Info_out.f.value ="0";

}

//  End -->

// -->

