// JavaScript Document

// CP_PumpReq.php
function calc_pumpReq( form )
	{	
		netAppUnit		= parseFloat( form.netAppUnit.value );
		areaUnit 		= parseFloat( form.areaUnit.value );
		totalFlowUnit	= parseFloat( form.totalFlowUnit.value );
		
		netApp			= parseFloat( form.netApplication.value ) / netAppUnit;
		area 			= parseFloat( form.area.value ) / areaUnit;
		operateHours 	= parseFloat( form.operateHours.value );
		operateDays 	= parseFloat( form.operateDays.value );
		
		minutes 		= 60 * operateHours * operateDays;
		efficiency 		= parseFloat( form.effic.value ) / 100;

		totalFlow = 27154 * netApp * area;
		totalFlow = totalFlow / minutes;
		totalFlow = totalFlow / totalFlowUnit;
		totalFlow = totalFlow / efficiency;
		totalFlow = Math.round( totalFlow * 10000 );
		totalFlow = totalFlow / 10000;
		
		form.totalFlow.value = totalFlow;
	}
	
// CP_1inAppTime.php
function calc_applicationTime( form )
{
	areaUnits	= parseFloat( form.areaUnits.value );
	timeUnits 	= parseFloat( form.timeUnits.value );
	flowUnits 	= parseFloat( form.flowRateUnits.value );

	area	 	= parseFloat( form.area.value ) / areaUnits;
	flowRate 	= parseFloat( form.flowRate.value ) * flowUnits;
	percentage 	= parseFloat( form.fullCirclePercent.value ) / 100;
	efficiency 	= parseFloat( form.irrEfficiency.value ) / 100;

	
	// equation for finding time (hours)
	time = ( 452.6 * area ) / flowRate;
	time = ( time * percentage ) / efficiency;
	time = time * timeUnits;
	time = Math.round( time * 10000 );
	
	form.time.value =  time / 10000;

} 

function calc_fullRotationTime( form )
{
	distanceUnit	= parseFloat( form.distanceUnit.value);
	speedUnit 	= parseFloat( form.speedUnit.value);
	timeUnit		= parseFloat( form.timeUnit.value);

	distance	= parseFloat( form.distance.value) / distanceUnit;
	speed 		= parseFloat( form.speed.value) / speedUnit;
	timer		= parseFloat( form.timer.value) / 100;

	time = 2 * distance * Math.PI;
	time = time / ( speed * 60 );
	time = time / timer;
	time = time * timeUnit;
	time = Math.round( time * 10000 );
	time = time / 10000;

	form.time.value = time;
}
function clearText( thefield )
{
	if ( thefield.defaultValue == thefield.value )
	{
		thefield.value = "";
	}
} 
function calc_percentTimer( form )
	{
		rotationTimeUnit 	= parseFloat(form.rotationTimeUnit.value);
		appTimeUnit		= parseFloat(form.appTimeUnit.value);
		requiredAppUnit	= parseFloat(form.requiredAppUnit.value);

		rotationTime	= parseFloat(form.rotationTime.value) / rotationTimeUnit;
		appTime 		= parseFloat(form.appTime.value) / appTimeUnit;
		requiredApp 	= parseFloat(form.requiredApp.value) / requiredAppUnit;

		timerSetting = rotationTime / ( appTime * requiredApp );
		timerSetting = timerSetting * 100;
		timerSetting = Math.round( timerSetting * 10000 );
		timerSetting = timerSetting / 10000;
		
		form.timerSetting.value = timerSetting;
}

function calc_centerPivotArea( form )
{

	pivotLengthUnit	= parseFloat(form.pivotLengthUnit.value);
	radiusUnit		= parseFloat(form.radiusUnit.value);
	
	pivotLength	= parseFloat(form.pivotLength.value) * pivotLengthUnit;
	areaUnit	= parseFloat(form.areaUnit.value);
	radius		= parseFloat(form.radius.value) * radiusUnit;

	area = pivotLength + radius;
	area = Math.pow( area, 2 );
	area = area * Math.PI;
	area = area / 43560;
	area = area * areaUnit;
	area = Math.round( area * 10000 );
	
	form.area.value = area / 10000;
} 