home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 1999 July / www_07_1999.iso / prez / amiga / KidHTML1_25.lha / KidHTML1.25 / Script / airportcalculator.js < prev    next >
Text File  |  1998-08-25  |  2KB  |  77 lines

  1.  
  2.  
  3.  
  4. <!-- TWO STEPS TO INSTALL AIRPORT:
  5.  
  6.    1.  Paste the first code in the HEAD of your HTML document
  7.    2.  Add the last coding to the BODY of your HTML document  -->
  8.  
  9. <!-- STEP ONE: Paste the first code in the HEAD of your HTML document  -->
  10.  
  11.  
  12.  
  13. <SCRIPT LANGUAGE="JavaScript">
  14. <!-- Original:  Joe Josey (jjosey@foxberry.net) -->
  15. <!-- Web Site:  http://www.foxberry.net/jjosey -->
  16.  
  17. <!-- This script and many more are available online from -->
  18. <!-- The JavaScript Source!! http://javascriptsource.com -->
  19.  
  20. <!-- Begin
  21. var Orig=new Array();
  22. var Dest=new Array();
  23. var nm=0;
  24. var tc=0;
  25. function DoCalc(form) {
  26. from_airport=form.from.options[form.from.selectedIndex].value;
  27. dest_airport=form.to.options[form.to.selectedIndex].value;
  28.  
  29. if (from_airport=="" || dest_airport=="") {
  30. alert("Please enter both an Originating and Destination Airport.");
  31. }
  32. else {
  33. Orig=from_airport.split("/");
  34. Dest=dest_airport.split("/");
  35. d=Math.acos(Math.sin(Orig[2])
  36. *Math.sin(Dest[2])
  37. +Math.cos(Orig[2])
  38. *Math.cos(Dest[2])
  39. *Math.cos(Orig[4]-Dest[4]));
  40. nm=Math.round(3437.747*d);
  41. if (Math.sin(Dest[4]-Orig[4]) < 0) {
  42. tc=Math.acos((Math.sin(Dest[2])
  43. -Math.sin(Orig[2])*Math.cos(d))
  44. /(Math.sin(d)*Math.cos(Orig[2])));
  45. else { 
  46. tc=2*Math.PI
  47. -Math.acos((Math.sin(Dest[2])
  48. -Math.sin(Orig[2])
  49. *Math.cos(d))/(Math.sin(d)
  50. *Math.cos(Orig[2])));
  51. }
  52. tc=Math.round(tc*(180/Math.PI));
  53. message=(Orig[0] + " to " + Dest[0] + "\n\n");
  54. message+=("Degrees:  " +tc+ "\n");
  55. message+=("Nautical Miles: "+nm+"\n");
  56. message+=("Statute Miles: "+Math.round(nm*1.13636)+"\n");
  57. message+=("Kilometers: "+Math.round(nm*1.6094));
  58. alert(message);
  59.    }
  60. }
  61. // End -->
  62. </script>
  63.  
  64. <!-- STEP TWO: Add the last coding to the BODY of your HTML document  -->
  65.  
  66. <BODY>
  67.  
  68. <center>
  69. <form>
  70. <table width=225 border=1 cellpadding=3>
  71. <tr><td colspan=2><center><font size="+2"><b>Airport Calculator</b></font></center></td></tr>
  72. <tr><td>From:</td><td><select name="from">
  73. <option value="">Originating Airport
  74. <option value="ABQ/1/0.61156/1/1.86064">Albuerque, NM
  75. <option value="ABY/1/0.55039/
  76.