/*******************************************************************
 Created By:	Aaron Rustad (DBLounge.com)
 Created DT:	19 March 2003
 Client:	Global Computers Systems for Canadian Tool
 Purpose: 	To calculator the necessary fields based on the 
 		input provided by a user. The existing functionlality
		is based to pre-existing calcuations from an existing
		spread sheet.

 Revisions:
---------------------------------------------------------------------------------------------------
 Date 	16th September 2003
 Client Request to have html page broken into forms
		in order to handle submital of buttons
******************************************************************/
function jsCalc1()
{
	var fT, fDbw, fTmid, fDt, fDd, fDdr, fDcw, fDrb, fIts;
	var fDD2, fDT2;

	fT = parseFloat(T.value);
	
	fDcw = parseFloat(Dcw.value);

	fIts = parseFloat(ITS.value);

	fDdr = parseFloat(DDR.value);

	fDrb = parseFloat(DRB.value);

	fDbw = fDcw-(2*fT);

	fTmid = fDbw+fIts;

	fDt = Math.sqrt((fDdr*Math.pow(fDbw,2)*(Math.pow(fDcw,2)-Math.pow(fDbw,2)))/(Math.pow(fDrb,2)*Math.pow(fDcw,2)-Math.pow(fDbw,2)));
	
	fDd = (fDcw*fDrb*fDt)/(fDbw);

	Dd.value = Math.round(fDd*100000)/100000;
	
	Dt.value = Math.round(fDt*100000)/100000;

	Dbw.value = Math.round(fDbw*100000)/100000;

	TMID.value = Math.round(fTmid*100000)/100000;

	Dcw2.value = Math.round(fDcw*100000)/100000;

	T2.value = Math.round(fT*100000)/100000;

	Dbw2.value = Math.round(fDbw*100000)/100000;
}

function jsCalc2()
{

	var fDD2, fDT2, fDcw2, fDbw2;

	fDD2 = parseFloat(Dd2.value);
	fDT2 = parseFloat(Dt2.value);
	fDcw2 = parseFloat(Dcw2.value);
	fDbw2 = parseFloat(Dbw2.value);

	DDR2.value = Math.round((Math.pow(fDD2,2) - Math.pow(fDT2,2)) / (Math.pow(fDcw2,2) - Math.pow(fDbw2,2))*10000)/10000;
	DBR2.value = Math.round((fDD2/fDcw2)/(fDT2/fDbw2)*10000)/10000;	

}

function jsReset1()
{
	// inputs	
	Dcw.value = "0.1140";
	T.value = "0.0140";
	DDR.value = "10.000";
	DRB.value = "1.000";
	ITS.value = "0.0500";

	Dcw2.value = "0.1140";
	T2.value = "0.0140";
	Dbw2.value = "0.0860";

	// outputs
	Dd.value = "0.3650";
	Dt.value = "0.2720";
	TMID.value = "0.1360";
	Dbw.value = "0.0860";
}

function jsReset2()
{
	Dcw2.value = "0.1140";
	T2.value = "0.0140";
	Dbw2.value = "0.0860";
	Dd2.value = "0.3650";
	Dt2.value = "0.2700";
	DBR2.value = "1.0198";
	DDR2.value = "10.7723";	
}
