// Auto Math Calculator Functions - Dan Gardner 2003-2004
//
// *** Engine Displacement Calculator
//
function compute_cid()
	{
	var bore = eval(document.calc_cid.bore.value)
	var stroke = eval(document.calc_cid.stroke.value)
	var cyls = eval(document.calc_cid.cyls.value)
	
	document.calc_cid.answer.value = Math.round(((Math.pow(bore/2,2)) * Math.PI * stroke * cyls) * 1000) / 1000
	}
//
// *** Piston Compression Height Calculator
//
function compute_pch()
	{
	var deck = eval(document.calc_pch.deck.value)
	var stroke = eval(document.calc_pch.stroke.value)
	var rod = eval(document.calc_pch.rod.value)
	var recess = eval(document.calc_pch.recess.value)
	
	document.calc_pch.answer.value = Math.round((deck - (((stroke/2) + rod) + recess)) * 1000) / 1000
	}
//
// *** Compression Ratio Calculator
//
function compute_cr() // Compression Ratio = (Swept Volume + TDC Volume) divided by TDC Volume
	{
	var bore = eval(document.calc_cr.bore.value)
	var stroke = eval(document.calc_cr.stroke.value)
	var piston = eval(document.calc_cr.piston.value)
	var chamber = eval(document.calc_cr.chamber.value)
	var gasket = eval(document.calc_cr.gasket.value)
	var recess = eval(document.calc_cr.recess.value)
	var CCtoCI = .0610237441
	var SweptVol = (Math.PI * (Math.pow((bore/2),2))) * stroke
	var ChamberVol = chamber * CCtoCI
	var PistonVol = piston * CCtoCI
	var GasketVol = gasket * (Math.PI * Math.pow(((bore + .125)/2),2))
	var DeckVol = recess * (Math.PI * Math.pow(((bore)/2),2))
	var TdcVol = (ChamberVol + (PistonVol + (GasketVol + (DeckVol))))

	document.calc_cr.answer.value = (Math.round((((SweptVol) + TdcVol) / TdcVol) * 100) / 100) + "  to 1"
	}
//
//
