// JavaScript Document
function calculateCoaxLoss(form)
// calculate the lengths in decimal feet of vertical
// call other functions (above) to calculate fractional feet/inches and meters
// display results in form fields //
	{
		var frequency;
		var cable_length;
		var sample_loss;
		var calculated_loss;
		frequency = roundNumber(form.frequency.value,3);
		cable_length = roundNumber(form.cable_length.value,2);
		sample_loss = reportSelectedRadioButtonValue(form);
		if (sample_loss == 0)
		 {
			 form.coax_loss.value = "0"
			 return 0;
		 }
		calculated_loss = sample_loss * Math.pow((frequency/50),0.5);
		calculated_loss = roundNumber(((calculated_loss/100) * cable_length),2);
		if (calculated_loss > 0)
			{
				form.coax_loss.value = String(roundNumber(calculated_loss,2));
			}
		else
			{
				clearResults(form);
			}
	}

function reportSelectedRadioButtonValue(form)
// cycle through the passed radio group and insert the selected value into the factor field on the form
	{
		var selected_value="";
		var len=form.radio1.length;
		for (i=0; i<len; i++)
			{
				if (form.radio1[i].checked)
					{ 
						selected_value = form.radio1[i].value;
					}
				if (!selected_value=="")
					{
						break
					}
			}
		return selected_value;
	}
	
function clearResults(form)
	{
		form.coax_loss.value="";
	}
	
function checkEnter(form)
	{
		var characterCode
		if (window.event)
			{ 
				e = window.event;
				if (e.keyCode == 13)
					{
						calculateCoaxLoss(form);
					}
			}
	}
