function cmd_calculate(my_form) {
   var rx_lon, rx_lat, sat_lon, rx_az, rx_el;
   var delta_lon, num, den;	// Temporary values
   var R0 = 6370;		// Earth's radius: 6370 km
   var h = 35800;		// Satellite height: 35800 km

   rx_lon = parseFloat(my_form.rx_lon.value);
   if (isNaN(rx_lon) || (rx_lon < -180) || (rx_lon > 180)) {
      my_form.rx_lon.value = "";
      window.alert("Por Favor coloque a longitude da antena \n(decimal format, positive = east, negative = west,\nvalid values between -180° and 180°).");
      return(0);
      }
   rx_lat = parseFloat(my_form.rx_lat.value);
   if (isNaN(rx_lat) || (rx_lat < -90) || (rx_lat > 90)) {
      my_form.rx_lat.value = "";
      window.alert("Please enter the latitude of the receiver\n(decimal format, positive = north, negative = south,\nvalid values between -90° and 90°).");
      return(0);
      }
   sat_lon = parseFloat(my_form.sat_lon.value);
   if (isNaN(sat_lon) || (sat_lon < -180) || (sat_lon > 180)) {
      my_form.sat_lon.value = "";
      window.alert("Please enter the longitude of the satellite\n(decimal format, positive = east, negative = west,\nvalid values between -180° and 180°).");
      return(0);
      }

   delta_lon = rx_lon - sat_lon;
   rx_az = Math.atan((Math.tan((Math.PI/180)*delta_lon)/Math.sin((Math.PI/180)*rx_lat)))*(180/Math.PI)+180;
   num = Math.cos(rx_lat*(Math.PI/180))*Math.cos(delta_lon*(Math.PI/180))-R0/(R0+h);
   den = Math.sqrt(1-Math.pow(Math.cos(rx_lat*(Math.PI/180))*Math.cos(delta_lon*(Math.PI/180)),2));
   rx_el = (180/Math.PI)*Math.atan(num/den);

   my_form.rx_az.value = rx_az;
   my_form.rx_el.value = rx_el;
   return(1);
}


// --------------------------------------------------------------------------

function init_form_values() {
   document.sat_calc.rx_lon.value = "9.0000";
   document.sat_calc.rx_lat.value = "46.000";
   document.sat_calc.sat_lon.value = "13.0";
   document.sat_calc.rx_az.value = "";
   document.sat_calc.rx_el.value = "";
   return(1);
}

// --------------------------------------------------------------------------

//-->
