almanac_v2.js 136 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689
  1. /*
  2. Almanac v2.2
  3. Commented out 2009-specific event list Jan 27, 2010 -- DAF
  4. JavaScript programming and graphics,
  5. copyright: Adrian R. Ashford, December 29th, 2008.
  6. Used with permission by Sky Publishing Corporation.
  7. http://www.skyandtelescope.com/templates/almanac_v2.js
  8. Parts of sunrise, sunset, moonrise and moonset from
  9. moonup.bas and sunup.bas by Roger W. Sinnott,
  10. Sky and Telescope magazine.
  11. Free date & time validation scripts:
  12. Sandeep Tamhankar
  13. stamhankar@hotmail.com
  14. http://javascript.internet.com
  15. Free dynamic form event script:
  16. http://www.hscripts.com
  17. Free variable passing in URL script:
  18. http://javascript.internet.com
  19. Public domain cookie scripts:
  20. Dustin Diaz
  21. http://www.dustindiaz.com/top-ten-javascript/
  22. */
  23. /*
  24. Cycle through moon phase images, to select correct Moonphase image on page load- write to page
  25. */
  26. var myImage = ["almanac_files/mp0.gif","almanac_files/mp1.gif","almanac_files/mp2.gif","almanac_files/mp3.gif","almanac_files/mp4.gif","almanac_files/mp5.gif","almanac_files/mp6.gif","almanac_files/mp7.gif","almanac_files/mp8.gif","almanac_files/mp9.gif","almanac_files/mp10.gif","almanac_files/mp11.gif","almanac_files/mp12.gif","almanac_files/mp13.gif","almanac_files/mp14.gif","almanac_files/mp15.gif","almanac_files/mp16.gif","almanac_files/mp17.gif","almanac_files/mp18.gif","almanac_files/mp19.gif","almanac_files/mp20.gif","almanac_files/mp21.gif","almanac_files/mp22.gif","almanac_files/mp23.gif","almanac_files/mp24.gif","almanac_files/mp25.gif","almanac_files/mp26.gif","almanac_files/mp27.gif"];
  27. thisImage = 0;
  28. images = myImage.length - 1;
  29. /*
  30. Get parameters for Latitude, Longitude, and time from URL
  31. */
  32. function getParams()
  33. {
  34. var idx = document.URL.indexOf('?');
  35. var params = [];
  36. if (idx != -1) {
  37. var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
  38. for (var i=0; i<pairs.length; i++)
  39. {
  40. nameVal = pairs[i].split('=');
  41. params[nameVal[0]] = nameVal[1];
  42. }
  43. }
  44. return params;
  45. }
  46. /*
  47. Initialize variables from URL
  48. */
  49. params = getParams();
  50. /*
  51. Set variables from custom URL set in the params
  52. */
  53. if(window.location.href.indexOf("latitude") != -1) {
  54. latitude = parseFloat(decodeURI(params["latitude"]));
  55. longitude = parseFloat(decodeURI(params["longitude"]));
  56. t_zone = parseFloat(decodeURI(params["tzone"]));
  57. UTdate = decodeURI(params["UTdate"]);
  58. UTtime = decodeURI(params["UTtime"]);
  59. }
  60. /*
  61. Initialize default variables
  62. */
  63. else {
  64. latitude = 42.383;
  65. longitude = 71.133;
  66. t_zone = -5;
  67. UTdate = "now";
  68. UTtime = "now";
  69. }
  70. /*
  71. Set country option variables in array
  72. */
  73. var country = [
  74. "Select",
  75. "USA",
  76. "Canada",
  77. "Afghanistan",
  78. "Albania",
  79. "Algeria",
  80. "Angola",
  81. "Argentina",
  82. "Armenia",
  83. "Australia",
  84. "Austria",
  85. "Azerbaijan",
  86. "Bahamas",
  87. "Bangladesh",
  88. "Belarus",
  89. "Belgium",
  90. "Belize",
  91. "Benin",
  92. "Bhutan",
  93. "Bolivia",
  94. "Bosnia_and_Herzegovina",
  95. "Botswana",
  96. "Brazil",
  97. "Brunei",
  98. "Bulgaria",
  99. "Burkina_Faso",
  100. "Burma",
  101. "Burundi",
  102. "Cambodia",
  103. "Cameroon",
  104. "Cape_Verde",
  105. "Central_African_Rep",
  106. "Chad",
  107. "Chile",
  108. "China",
  109. "Colombia",
  110. "Congo",
  111. "Congo_Dem_Rep",
  112. "Costa_Rica",
  113. "Cote_dIvoire",
  114. "Croatia",
  115. "Cuba",
  116. "Cyprus",
  117. "Czech_Republic",
  118. "Denmark",
  119. "Djibouti",
  120. "Dominican_Rep",
  121. "East_Timor",
  122. "Ecuador",
  123. "Egypt",
  124. "El_Salvador",
  125. "Eritrea",
  126. "Estonia",
  127. "Ethiopia",
  128. "Falkland_Islands",
  129. "Fiji",
  130. "Finland",
  131. "France",
  132. "French_Guiana",
  133. "French_Polynesia",
  134. "Gabon",
  135. "Gambia",
  136. "Georgia",
  137. "Germany",
  138. "Ghana",
  139. "Greece",
  140. "Greenland",
  141. "Guatemala",
  142. "Guinea",
  143. "Guinea_Bissau",
  144. "Guyana",
  145. "Haiti",
  146. "Honduras",
  147. "Hungary",
  148. "Iceland",
  149. "India",
  150. "Indonesia",
  151. "Iran",
  152. "Iraq",
  153. "Ireland",
  154. "Israel",
  155. "Italy",
  156. "Jamaica",
  157. "Japan",
  158. "Jordan",
  159. "Kazakhstan",
  160. "Kenya",
  161. "Korea_North",
  162. "Korea_South",
  163. "Kyrgyzstan",
  164. "Laos",
  165. "Latvia",
  166. "Lebanon",
  167. "Lesotho",
  168. "Liberia",
  169. "Libya",
  170. "Lithuania",
  171. "Macedonia",
  172. "Madagascar",
  173. "Malawi",
  174. "Malaysia",
  175. "Mali",
  176. "Mauritania",
  177. "Mexico",
  178. "Moldova",
  179. "Mongolia",
  180. "Morocco",
  181. "Mozambique",
  182. "Namibia",
  183. "Nepal",
  184. "Netherlands",
  185. "New_Zealand",
  186. "Nicaragua",
  187. "Niger",
  188. "Nigeria",
  189. "Northern_Ireland",
  190. "Norway",
  191. "Pakistan",
  192. "Panama",
  193. "Papua_New_Guinea",
  194. "Paraguay",
  195. "Peru",
  196. "Philippines",
  197. "Poland",
  198. "Portugal",
  199. "Puerto_Rico",
  200. "Qatar",
  201. "Romania",
  202. "Russia",
  203. "Rwanda",
  204. "Saudi_Arabia",
  205. "Senegal",
  206. "Sierra_Leone",
  207. "Singapore",
  208. "Slovakia",
  209. "Slovenia",
  210. "Somalia",
  211. "South_Africa",
  212. "Spain",
  213. "Sri_Lanka",
  214. "Sudan",
  215. "Suriname",
  216. "Swaziland",
  217. "Sweden",
  218. "Switzerland",
  219. "Syria",
  220. "Taiwan",
  221. "Tajikistan",
  222. "Tanzania",
  223. "Tasmania",
  224. "Thailand",
  225. "Togo",
  226. "Trinidad_and_Tobago",
  227. "Tunisia",
  228. "Turkey",
  229. "Turkmenistan",
  230. "Uganda",
  231. "Ukraine",
  232. "United_Arab_Emirates",
  233. "United_Kingdom",
  234. "Uruguay",
  235. "Uzbekistan",
  236. "Vatican_City",
  237. "Venezuela",
  238. "Vietnam",
  239. "Yemen",
  240. "Yugoslavia",
  241. "Zambia",
  242. "Zimbabwe"];
  243. /*
  244. Create array that holds all Cities
  245. */
  246. Select = new Array("City");
  247. /*
  248. Set American Cities into new array
  249. */
  250. var USA = ["---",
  251. "Albany, NY",
  252. "Albuquerque, NM",
  253. "Amarillo, TX",
  254. "Anchorage, AK",
  255. "Atlanta, GA",
  256. "Austin, TX",
  257. "Baker, OR",
  258. "Baltimore, MD",
  259. "Bangor, ME",
  260. "Birmingham, AL",
  261. "Bismarck, ND",
  262. "Boise, ID",
  263. "Boston, MA",
  264. "Buffalo, NY",
  265. "Carlsbad, NM",
  266. "Charleston, SC",
  267. "Charleston, WV",
  268. "Charlotte, NC",
  269. "Cheyenne, WY",
  270. "Chicago, IL",
  271. "Cincinnati, OH",
  272. "Cleveland, OH",
  273. "Columbia, SC",
  274. "Columbus, OH",
  275. "Dallas, TX",
  276. "Denver, CO",
  277. "Des Moines, IA",
  278. "Detroit, MI",
  279. "Dubuque, IA",
  280. "Duluth, MN",
  281. "Eastport, ME",
  282. "El Centro, CA",
  283. "El Paso, TX",
  284. "Eugene, OR",
  285. "Fargo, ND",
  286. "Flagstaff, AZ",
  287. "Fort Worth, TX",
  288. "Fresno, CA",
  289. "Grand Junction, CO",
  290. "Grand Rapids, MI",
  291. "Havre, MT",
  292. "Helena, MT",
  293. "Honolulu, HI",
  294. "Hot Springs, AR",
  295. "Houston, TX",
  296. "Idaho Falls, ID",
  297. "Indianapolis, IN",
  298. "Jackson, MS",
  299. "Jacksonville, FL",
  300. "Juneau, AK",
  301. "Kansas City, MO",
  302. "Key West, FL",
  303. "Klamath Falls, OR",
  304. "Knoxville, TN",
  305. "Las Vegas, NV",
  306. "Lewiston, ID",
  307. "Lincoln, NE",
  308. "Long Beach, CA",
  309. "Los Angeles, CA",
  310. "Louisville, KY",
  311. "Manchester, NH",
  312. "Memphis, TN",
  313. "Miami, FL",
  314. "Milwaukee, WI",
  315. "Minneapolis, MN",
  316. "Mobile, AL",
  317. "Montgomery, AL",
  318. "Montpelier, VT",
  319. "Nashville, TN",
  320. "Newark, NJ",
  321. "New Haven, CT",
  322. "New Orleans, LA",
  323. "New York, NY",
  324. "Nome, AK",
  325. "Oakland, CA",
  326. "Oklahoma City, OK",
  327. "Omaha, NE",
  328. "Philadelphia, PA",
  329. "Phoenix, AZ",
  330. "Pierre, SD",
  331. "Pittsburgh, PA",
  332. "Portland, ME",
  333. "Portland, OR",
  334. "Providence, RI",
  335. "Raleigh, NC",
  336. "Reno, NV",
  337. "Richfield, UT",
  338. "Richmond, VA",
  339. "Roanoke, VA",
  340. "Sacramento, CA",
  341. "St Louis, MO",
  342. "Salt Lake City, UT",
  343. "San Antonio, TX",
  344. "San Diego, CA",
  345. "San Francisco, CA",
  346. "San Jose, CA",
  347. "Santa Fe, NM",
  348. "Savannah, GA",
  349. "Seattle, WA",
  350. "Shreveport, LA",
  351. "Sioux Falls, SD",
  352. "Sitka, AK",
  353. "Spokane, WA",
  354. "Springfield, IL",
  355. "Springfield, MA",
  356. "Springfield, MO",
  357. "Syracuse, NY",
  358. "Tampa, FL",
  359. "Toledo, OH",
  360. "Tulsa, OK",
  361. "Virginia Beach, VA",
  362. "Washington, D.C.",
  363. "Wichita, KS",
  364. "Wilmington, NC"];
  365. /*
  366. Set Canadian Cities into new array
  367. */
  368. var Canada = ["---",
  369. "Calgary, AB",
  370. "Charlottetown, PE",
  371. "Chicoutimi, QC",
  372. "Edmonton, AB",
  373. "Guelph, ON",
  374. "Halifax, NS",
  375. "Hamilton, ON",
  376. "Hull, QC",
  377. "Iqaluit, NU",
  378. "Kelowna, BC",
  379. "Kingston, ON",
  380. "Kitchener, ON",
  381. "London, ON",
  382. "Montreal, QC",
  383. "Oshawa, ON",
  384. "Ottawa, ON",
  385. "Quebec City, QC",
  386. "Regina, SK",
  387. "Saint John, NB",
  388. "Saskatoon, SK",
  389. "Sherbrooke, QC",
  390. "St Catharines, ON",
  391. "St Johns, NL",
  392. "Sudbury, ON",
  393. "Thunder Bay, ON",
  394. "Toronto, ON",
  395. "Trois-Rivieres, QC",
  396. "Vancouver, BC",
  397. "Victoria, BC",
  398. "Whitehorse, YT",
  399. "Windsor, ON",
  400. "Winnipeg, MB",
  401. "Yellowknife, NT"];
  402. /*
  403. Set Misc. Cities into new array
  404. */
  405. Afghanistan = ["---","Kabul"];
  406. Albania = ["---","Tirana"];
  407. Algeria = ["---","Algiers"];
  408. Angola = ["---","Luanda"];
  409. Argentina = ["---","Buenos Aires","Cordoba"];
  410. Armenia = ["---","Yerevan"];
  411. Australia = ["---","Adelaide","Brisbane","Darwin","Melbourne","Perth","Sydney"];
  412. Austria = ["---","Vienna"];
  413. Azerbaijan = ["---","Baku"];
  414. Bahamas = ["---"," Nassau"];
  415. Bangladesh = ["---","Chittagong"];
  416. Belarus = ["---","Minsk"];
  417. Belgium = ["---","Brussels"];
  418. Belize = ["---","Belmopan"];
  419. Benin = ["---","Porto Novo"];
  420. Bhutan = ["---","Thimphu"];
  421. Bolivia = ["---","La Paz"];
  422. Bosnia_and_Herzegovina = ["---","Sarajevo"];
  423. Botswana = ["---","Gaborone"];
  424. Brazil =["---","Belem","Rio de Janeiro","Salvador","Sao Paulo"];
  425. Brunei = ["---","Bandar Seri Begawan"];
  426. Bulgaria = ["---","Sofia"];
  427. Burkina_Faso = ["---","Ouagadougou"];
  428. Burma = ["---","Rangoon"];
  429. Burundi = ["---","Bujumbura"];
  430. Cambodia = ["---","Phnom Penh"];
  431. Cameroon = ["---","Yaounde"];
  432. Cape_Verde = ["---","Praia"];
  433. Central_African_Rep = ["---","Bangui"];
  434. Chad = ["---","Ndjamena"];
  435. Chile = ["---","Iquique","Santiago"];
  436. China = ["---","Beijing","Canton","Chongqing","Hong Kong","Nanjing","Shanghai"];
  437. Colombia = ["---","Bogota"];
  438. Congo = ["---","Brazzaville"];
  439. Congo_Dem_Rep = ["---","Kinshasa"];
  440. Costa_Rica = ["---","San Jose"];
  441. Cote_dIvoire = ["---","Abidjan"];
  442. Croatia = ["---","Zagreb"];
  443. Cuba = ["---","Havana"];
  444. Cyprus = ["---","Nicosia"];
  445. Czech_Republic = ["---","Prague"];
  446. Denmark = ["---","Copenhagen"];
  447. Djibouti = ["---","Djibouti"];
  448. Dominican_Rep = ["---","Santo Domingo"];
  449. East_Timor = ["---","Dili"];
  450. Ecuador = ["---","Guayaquil"];
  451. Egypt = ["---","Cairo"];
  452. El_Salvador = ["---","San Salvador"];
  453. Eritrea = ["---","Asmera"];
  454. Estonia = ["---","Tallinn"];
  455. Ethiopia = ["---","Addis Ababa"];
  456. Falkland_Islands = ["---","Port Stanley"];
  457. Fiji = ["---","Suva"];
  458. Finland = ["---","Helsinki"];
  459. France = ["---","Bordeaux","Lyons","Marseilles","Paris"];
  460. French_Guiana = ["---","Cayenne"];
  461. French_Polynesia = ["---","Papeete"];
  462. Gabon = ["---","Libreville"];
  463. Gambia = ["---","Banjul"];
  464. Georgia = ["---","Tbilisi"];
  465. Germany = ["---","Berlin","Bremen","Frankfurt","Hamburg","Munich"];
  466. Ghana = ["---","Accra"];
  467. Greece = ["---","Athens"];
  468. Greenland = ["---","Nuuk"];
  469. Guatemala = ["---","Guatemala City"];
  470. Guinea = ["---","Conakry"];
  471. Guinea_Bissau = ["---","Bissau"];
  472. Guyana = ["---","Georgetown"];
  473. Haiti = ["---","Port-au-Prince"];
  474. Honduras = ["---","Tegucigalpa"];
  475. Hungary = ["---","Budapest"];
  476. Iceland = ["---","Reykjavik"];
  477. India = ["---","Bombay","Calcutta","Delhi"];
  478. Indonesia = ["---","Jakarta"];
  479. Iran = ["---","Teheran"];
  480. Iraq = ["---","Baghdad"];
  481. Ireland = ["---","Dublin"];
  482. Israel = ["---","Jerusalem","Tel Aviv"];
  483. Italy = ["---","Milan","Naples","Rome","Venice"];
  484. Jamaica =["---","Kingston"];
  485. Japan = ["---","Nagasaki","Nagoya","Osaka","Tokyo"];
  486. Jordan = ["---","Amman"];
  487. Kazakhstan = ["---","Almaty"];
  488. Kenya =["---","Nairobi"];
  489. Korea_North = ["---","Pyongyang"];
  490. Korea_South = ["---","Seoul"];
  491. Kyrgyzstan = ["---","Bishkek"];
  492. Laos = ["---","Vientiane"];
  493. Latvia = ["---","Riga"];
  494. Lebanon =["---","Beirut"];
  495. Lesotho = ["---","Maseru"];
  496. Liberia = ["---","Monrovia"];
  497. Libya = ["---","Tripoli"];
  498. Lithuania = ["---","Vilnius"];
  499. Macedonia = ["---","Skopje"];
  500. Madagascar = ["---","Tananarive"];
  501. Malawi = ["---","Lilongwe"];
  502. Malaysia = ["---","Kuala Lumpur"];
  503. Mali = ["---","Bamako"];
  504. Mauritania = ["---","Nouakchott"];
  505. Mexico = ["---","Chihuahua","Mazatlan","Mexico City","Veracruz"];
  506. Moldova = ["---","Kishinev"];
  507. Mongolia = ["---","Ulaanbaatar"];
  508. Morocco = ["---","Casablanca"];
  509. Mozambique = ["---","Maputo"];
  510. Namibia = ["---","Windhoek"];
  511. Nepal = ["---","Kathmandu"];
  512. Netherlands = ["---","Amsterdam"];
  513. New_Zealand = ["---","Auckland","Christchurch","Wellington"];
  514. Nicaragua = ["---","Managua"];
  515. Niger = ["---","Niamey"];
  516. Nigeria = ["---","Lagos"];
  517. Northern_Ireland = ["---","Belfast"];
  518. Norway = ["---","Hammerfest","Oslo"];
  519. Pakistan = ["---","Islamabad"];
  520. Panama = ["---","Panama City"];
  521. Papua_New_Guinea = ["---","Port Moresby"];
  522. Paraguay = ["---","Asuncion"];
  523. Peru = ["---","Lima"];
  524. Philippines = ["---","Manila"];
  525. Poland = ["---","Warsaw"];
  526. Portugal = ["---","Lisbon"];
  527. Puerto_Rico = ["---","San Juan"];
  528. Qatar = ["---","Doha"];
  529. Romania = ["---","Bucharest"];
  530. Russia = ["---","Irkutsk","Moscow","St Petersburg","Vladivostok"];
  531. Rwanda = ["---","Kigali"];
  532. Saudi_Arabia = ["---","Mecca"];
  533. Senegal = ["---","Dakar"];
  534. Sierra_Leone = ["---","Freetown"];
  535. Singapore = ["---","Singapore"];
  536. Slovakia = ["---","Bratislava"];
  537. Slovenia = ["---","Ljubljana"];
  538. Somalia = ["---","Mogadishu"];
  539. South_Africa = ["---","Johannesburg","CapeTown","Durban"];
  540. Spain =["---","Barcelona","Madrid"];
  541. Sri_Lanka = ["---","Colombo"];
  542. Sudan = ["---","Khartoum"];
  543. Suriname = ["---","Paramaribo"];
  544. Swaziland = ["---","Mbabane"];
  545. Sweden = ["---","Stockholm"];
  546. Switzerland = ["---","Zurich"];
  547. Syria = ["---","Damascus"];
  548. Taiwan = ["---","Taipei"];
  549. Tajikistan = ["---","Dushanbe"];
  550. Tanzania = ["---","Dar es Salaam"];
  551. Tasmania = ["---","Hobart"];
  552. Thailand = ["---","Bangkok"];
  553. Togo = ["---","Lome"];
  554. Trinidad_and_Tobago = ["---","Port of Spain"];
  555. Tunisia = ["---","Tunis"];
  556. Turkey = ["---","Ankara"];
  557. Turkmenistan = ["---","Ashgabat"];
  558. Uganda = ["---","Kampala"];
  559. Ukraine = ["---","Odessa"];
  560. United_Arab_Emirates = ["---","Dubai"];
  561. United_Kingdom = ["---","Aberdeen","Birmingham","Bristol","Cardiff","Edinburgh","Glasgow","Leeds","Liverpool","London","Manchester","Newcastle","Norwich","Plymouth"];
  562. Uruguay = ["---","Montevideo"];
  563. Uzbekistan = ["---","Tashkent"];
  564. Vatican_City = ["---","Vatican City"];
  565. Venezuela = ["---","Caracas"];
  566. Vietnam = ["---","Hanoi"];
  567. Yemen = ["---","Sana"];
  568. Yugoslavia = ["---","Belgrade"];
  569. Zambia = ["---","Lusaka"];
  570. Zimbabwe = ["---","Harare"];
  571. City = "...";
  572. /*
  573. Set city list to match selected state/country- e.g. if "USA" selected city list only shows US cities
  574. */
  575. function changeval()
  576. {
  577. var val1 = document.planets.sel1.value;
  578. var optionArray = eval(val1);
  579. for (var df=0; df<optionArray.length; df++)
  580. {
  581. var ss = document.planets.sel2;
  582. ss.options.length = 0;
  583. for (var ff=0; ff<optionArray.length; ff++)
  584. {
  585. var val = optionArray[ff];
  586. ss.options[ff] = new Option(val,val);
  587. }
  588. }
  589. }
  590. /*
  591. Assign correct latitude + longitude to selected city
  592. */
  593. function recordval()
  594. {
  595. City = document.planets.sel2.value;
  596. switch (City) {
  597. /* US cities listing */
  598. case 'Albany, NY' :
  599. latitude = 42.666667;
  600. longitude = 73.75;
  601. t_zone = -5;
  602. break;
  603. case 'Albuquerque, NM':
  604. latitude = 35.85;
  605. longitude = 106.65;
  606. t_zone = -7;
  607. break;
  608. case 'Amarillo, TX':
  609. latitude = 35.183333;
  610. longitude = 101.833333;
  611. t_zone = -6;
  612. break;
  613. case 'Anchorage, AK':
  614. latitude = 61.216667;
  615. longitude = 149.9;
  616. t_zone = -9;
  617. break;
  618. case 'Atlanta, GA':
  619. latitude = 33.75;
  620. longitude = 84.383333;
  621. t_zone = -5;
  622. break;
  623. case 'Austin, TX':
  624. latitude = 30.266667;
  625. longitude = 97.733333;
  626. t_zone = -6;
  627. break;
  628. case 'Baker, OR':
  629. latitude = 44.783333;
  630. longitude = 117.833333;
  631. t_zone = -8;
  632. break;
  633. case 'Baltimore, MD':
  634. latitude = 39.3;
  635. longitude = 76.633333;
  636. t_zone = -5;
  637. break;
  638. case 'Bangor, ME':
  639. latitude = 44.8;
  640. longitude = 68.783333;
  641. t_zone = -5;
  642. break;
  643. case 'Birmingham, AL':
  644. latitude = 33.5;
  645. longitude = 86.833333;
  646. t_zone = -6;
  647. break;
  648. case 'Bismarck, ND':
  649. latitude = 46.8;
  650. longitude = 100.783333;
  651. t_zone = -6;
  652. break;
  653. case 'Boise, ID':
  654. latitude = 43.6;
  655. longitude = 116.216667;
  656. t_zone = -7;
  657. break;
  658. case 'Boston, MA':
  659. latitude = 42.35;
  660. longitude = 71.083333;
  661. t_zone = -5;
  662. break;
  663. case 'Buffalo, NY':
  664. latitude = 42.916667;
  665. longitude = 78.833333;
  666. t_zone = -5;
  667. break;
  668. case 'Carlsbad, NM':
  669. latitude = 32.433333;
  670. longitude = 104.25;
  671. t_zone = -7;
  672. break;
  673. case 'Charleston, SC':
  674. latitude = 32.783333;
  675. longitude = 79.933333;
  676. t_zone = -5;
  677. break;
  678. case 'Charleston, WV':
  679. latitude = 38.35;
  680. longitude = 81.633333;
  681. t_zone = -5;
  682. break;
  683. case 'Charlotte, NC':
  684. latitude = 35.233333;
  685. longitude = 80.833333;
  686. t_zone = -5;
  687. break;
  688. case 'Cheyenne, WY':
  689. latitude = 41.15;
  690. longitude = 104.866667;
  691. t_zone = -7;
  692. break;
  693. case 'Chicago, IL':
  694. latitude = 41.833333;
  695. longitude = 87.616667;
  696. t_zone = -6;
  697. break;
  698. case 'Cincinnati, OH':
  699. latitude = 39.133333;
  700. longitude = 84.5;
  701. t_zone = -5;
  702. break;
  703. case 'Cleveland, OH':
  704. latitude = 41.466667;
  705. longitude = 81.616667;
  706. t_zone = -5;
  707. break;
  708. case 'Columbia, SC':
  709. latitude = 34;
  710. longitude = 81.033333;
  711. t_zone = -5;
  712. break;
  713. case 'Columbus, OH':
  714. latitude = 40;
  715. longitude = 83.016667;
  716. t_zone = -5;
  717. break;
  718. case 'Dallas, TX':
  719. latitude = 32.766667;
  720. longitude = 96.766667;
  721. t_zone = -6;
  722. break;
  723. case 'Denver, CO':
  724. latitude = 39.75;
  725. longitude = 105;
  726. t_zone = -7;
  727. break;
  728. case 'Des Moines, IA':
  729. latitude = 41.583333;
  730. longitude = 93.616667;
  731. t_zone = -6;
  732. break;
  733. case 'Detroit, MI':
  734. latitude = 42.333333;
  735. longitude = 83.05;
  736. t_zone = -5;
  737. break;
  738. case 'Dubuque, IA':
  739. latitude = 42.516667;
  740. longitude = 90.666667;
  741. t_zone = -6;
  742. break;
  743. case 'Duluth, MN':
  744. latitude = 46.816667;
  745. longitude = 92.083333;
  746. t_zone = -6;
  747. break;
  748. case 'Eastport, ME':
  749. latitude = 44.9;
  750. longitude = 67;
  751. t_zone = -5;
  752. break;
  753. case 'El Centro, CA':
  754. latitude = 32.633333;
  755. longitude = 115.55;
  756. t_zone = -8;
  757. break;
  758. case 'El Paso, TX':
  759. latitude = 31.766667;
  760. longitude = 106.483333;
  761. t_zone = -7;
  762. break;
  763. case 'Eugene, OR':
  764. latitude = 44.05;
  765. longitude = 123.083333;
  766. t_zone = -8;
  767. break;
  768. case 'Fargo, ND':
  769. latitude = 46.866667;
  770. longitude = 96.8;
  771. t_zone = -6;
  772. break;
  773. case 'Flagstaff, AZ':
  774. latitude = 35.216667;
  775. longitude = 111.683333;
  776. t_zone = -7;
  777. break;
  778. case 'Fort Worth, TX':
  779. latitude = 32.716667;
  780. longitude = 97.316667;
  781. t_zone = -6;
  782. break;
  783. case 'Fresno, CA':
  784. latitude = 36.733333;
  785. longitude = 119.8;
  786. t_zone = -8;
  787. break;
  788. case 'Grand Junction, CO':
  789. latitude = 39.083333;
  790. longitude = 108.55;
  791. t_zone = -7;
  792. break;
  793. case 'Grand Rapids, MI':
  794. latitude = 42.966667;
  795. longitude = 85.666667;
  796. t_zone = -5;
  797. break;
  798. case 'Havre, MT':
  799. latitude = 48.55;
  800. longitude = 109.716667;
  801. t_zone = -7;
  802. break;
  803. case 'Helena, MT':
  804. latitude = 46.583333;
  805. longitude = 112.033333;
  806. t_zone = -7;
  807. break;
  808. case 'Honolulu, HI':
  809. latitude = 21.3;
  810. longitude = 157.833333;
  811. t_zone = -10;
  812. break;
  813. case 'Hot Springs, AR':
  814. latitude = 34.516667;
  815. longitude = 93.05;
  816. t_zone = -6;
  817. break;
  818. case 'Houston, TX':
  819. latitude = 29.75;
  820. longitude = 95.35;
  821. t_zone = -6;
  822. break;
  823. case 'Idaho Falls, ID':
  824. latitude = 43.5;
  825. longitude = 112.016667;
  826. t_zone = -7;
  827. break;
  828. case 'Indianapolis, IN':
  829. latitude = 39.766667;
  830. longitude = 86.166667;
  831. t_zone = -5;
  832. break;
  833. case 'Jackson, MS':
  834. latitude = 32.333333;
  835. longitude = 90.2;
  836. t_zone = -6;
  837. break;
  838. case 'Jacksonville, FL':
  839. latitude = 30.366667;
  840. longitude = 81.666667;
  841. t_zone = -5;
  842. break;
  843. case 'Juneau, AK':
  844. latitude = 58.3;
  845. longitude = 134.4;
  846. t_zone = -9;
  847. break;
  848. case 'Kansas City, MO':
  849. latitude = 39.1;
  850. longitude = 94.583333;
  851. t_zone = -6;
  852. break;
  853. case 'Key West, FL':
  854. latitude = 24.55;
  855. longitude = 81.8;
  856. t_zone = -5;
  857. break;
  858. case 'Klamath Falls, OR':
  859. latitude = 42.166667;
  860. longitude = 121.733333;
  861. t_zone = -8;
  862. break;
  863. case 'Knoxville, TN':
  864. latitude = 35.95;
  865. longitude = 83.933333;
  866. t_zone = -5;
  867. break;
  868. case 'Las Vegas, NV':
  869. latitude = 36.166667;
  870. longitude = 115.2;
  871. t_zone = -8;
  872. break;
  873. case 'Lewiston, ID':
  874. latitude = 46.4;
  875. longitude = 117.033333;
  876. t_zone = -8;
  877. break;
  878. case 'Lincoln, NE':
  879. latitude = 40.833333;
  880. longitude = 96.666667;
  881. t_zone = -6;
  882. break;
  883. case 'Long Beach, CA':
  884. latitude = 33.766667;
  885. longitude = 118.183333;
  886. t_zone = -8;
  887. break;
  888. case 'Los Angeles, CA':
  889. latitude = 34.05;
  890. longitude = 118.25;
  891. t_zone = -8;
  892. break;
  893. case 'Louisville, KY':
  894. latitude = 38.25;
  895. longitude = 85.766667;
  896. t_zone = -5;
  897. break;
  898. case 'Manchester, NH':
  899. latitude = 43;
  900. longitude = 71.5;
  901. t_zone = -5;
  902. break;
  903. case 'Memphis, TN':
  904. latitude = 35.15;
  905. longitude = 90.05;
  906. t_zone = -6;
  907. break;
  908. case 'Miami, FL':
  909. latitude = 25.766667;
  910. longitude = 80.2;
  911. t_zone = -5;
  912. break;
  913. case 'Milwaukee, WI':
  914. latitude = 43.033333;
  915. longitude = 87.916667;
  916. t_zone = -6;
  917. break;
  918. case 'Minneapolis, MN':
  919. latitude = 44.983333;
  920. longitude = 93.233333;
  921. t_zone = -6;
  922. break;
  923. case 'Mobile, AL':
  924. latitude = 30.7;
  925. longitude = 88.05;
  926. t_zone = -6;
  927. break;
  928. case 'Montgomery, AL':
  929. latitude = 32.35;
  930. longitude = 86.3;
  931. t_zone = -6;
  932. break;
  933. case 'Montpelier, VT':
  934. latitude = 44.25;
  935. longitude = 72.533333;
  936. t_zone = -5;
  937. break;
  938. case 'Nashville, TN':
  939. latitude = 36.166667;
  940. longitude = 86.783333;
  941. t_zone = -6;
  942. break;
  943. case 'Newark, NJ':
  944. latitude = 40.733333;
  945. longitude = 74.166667;
  946. t_zone = -5;
  947. break;
  948. case 'New Haven, CT':
  949. longitude = 72.916667;
  950. t_zone = -5;
  951. break;
  952. case 'New Orleans, LA':
  953. latitude = 29.95;
  954. longitude = 90.066667;
  955. t_zone = -6;
  956. break;
  957. case 'New York, NY':
  958. latitude = 40.783333;
  959. longitude = 73.966667;
  960. t_zone = -5;
  961. break;
  962. case 'Nome, AK':
  963. latitude = 64.416667;
  964. longitude = 165.5;
  965. t_zone = -9;
  966. break;
  967. case 'Oakland, CA':
  968. latitude = 37.8;
  969. longitude = 122.266667;
  970. t_zone = -8;
  971. break;
  972. case 'Oklahoma City, OK':
  973. latitude = 35.433333;
  974. longitude = 97.466667;
  975. t_zone = -6;
  976. break;
  977. case 'Omaha, NE':
  978. latitude = 41.25;
  979. longitude = 95.933333;
  980. t_zone = -6;
  981. break;
  982. case 'Philadelphia, PA':
  983. latitude = 39.95;
  984. longitude = 75.166667;
  985. t_zone = -5;
  986. break;
  987. case 'Phoenix, AZ':
  988. latitude = 33.483333;
  989. longitude = 112.066667;
  990. t_zone = -7;
  991. break;
  992. case 'Pierre, SD':
  993. latitude = 44.366667;
  994. longitude = 100.35;
  995. t_zone = -6;
  996. break;
  997. case 'Pittsburgh, PA':
  998. latitude = 40.45;
  999. longitude = 79.95;
  1000. t_zone = -5;
  1001. break;
  1002. case 'Portland, ME':
  1003. latitude = 43.666667;
  1004. longitude = 70.25;
  1005. t_zone = -5;
  1006. break;
  1007. case 'Portland, OR':
  1008. latitude = 45.516667;
  1009. longitude = 122.683333;
  1010. t_zone = -8;
  1011. break;
  1012. case 'Providence, RI':
  1013. latitude = 41.833333;
  1014. longitude = 71.4;
  1015. t_zone = -5;
  1016. break;
  1017. case 'Raleigh, NC':
  1018. latitude = 35.766667;
  1019. longitude = 78.65;
  1020. t_zone = -5;
  1021. break;
  1022. case 'Reno, NV':
  1023. latitude = 39.5;
  1024. longitude = 119.816667;
  1025. t_zone = -8;
  1026. break;
  1027. case 'Richfield, UT':
  1028. latitude = 38.766667;
  1029. longitude = 112.083333;
  1030. t_zone = -7;
  1031. break;
  1032. case 'Richmond, VA':
  1033. latitude = 37.55;
  1034. longitude = 77.483333;
  1035. t_zone = -5;
  1036. break;
  1037. case 'Roanoke, VA':
  1038. latitude = 37.283333;
  1039. longitude = 79.95;
  1040. t_zone = -5;
  1041. break;
  1042. case 'Sacramento, CA':
  1043. latitude = 38.583333;
  1044. longitude = 121.5;
  1045. t_zone = -8;
  1046. break;
  1047. case 'St Louis, MO':
  1048. latitude = 38.583333;
  1049. longitude = 90.2;
  1050. t_zone = -6;
  1051. break;
  1052. case 'Salt Lake City, UT':
  1053. latitude = 40.766667;
  1054. longitude = 111.9;
  1055. t_zone = -7;
  1056. break;
  1057. case 'San Antonio, TX':
  1058. latitude = 29.383333;
  1059. longitude = 98.55;
  1060. t_zone = -6;
  1061. break;
  1062. case 'San Diego, CA':
  1063. latitude = 32.7;
  1064. longitude = 117.166667;
  1065. t_zone = -8;
  1066. break;
  1067. case 'San Francisco, CA':
  1068. latitude = 37.783333;
  1069. longitude = 122.433333;
  1070. t_zone = -8;
  1071. break;
  1072. case 'San Jose, CA':
  1073. latitude = 37.333333;
  1074. longitude = 121.883333;
  1075. t_zone = -8;
  1076. break;
  1077. case 'Santa Fe, NM':
  1078. latitude = 35.683333;
  1079. longitude = 105.95;
  1080. t_zone = -7;
  1081. break;
  1082. case 'Savannah, GA':
  1083. latitude = 32.083333;
  1084. longitude = 81.083333;
  1085. t_zone = -5;
  1086. break;
  1087. case 'Seattle, WA':
  1088. latitude = 47.616667;
  1089. longitude = 122.333333;
  1090. t_zone = -8;
  1091. break;
  1092. case 'Shreveport, LA':
  1093. latitude = 32.466667;
  1094. longitude = 93.7;
  1095. t_zone = -6;
  1096. break;
  1097. case 'Sioux Falls, SD':
  1098. latitude = 43.55;
  1099. longitude = 96.733333;
  1100. t_zone = -6;
  1101. break;
  1102. case 'Sitka, AK':
  1103. latitude = 57.166667;
  1104. longitude = 135.25;
  1105. t_zone = -9;
  1106. break;
  1107. case 'Spokane, WA':
  1108. latitude = 47.666667;
  1109. longitude = 117.433333;
  1110. t_zone = -8;
  1111. break;
  1112. case 'Springfield, IL':
  1113. latitude = 39.8;
  1114. longitude = 89.633333;
  1115. t_zone = -6;
  1116. break;
  1117. case 'Springfield, MA':
  1118. latitude = 42.1;
  1119. longitude = 72.566667;
  1120. t_zone = -5;
  1121. break;
  1122. case 'Springfield, MO':
  1123. latitude = 37.216667;
  1124. longitude = 93.283333;
  1125. t_zone = -6;
  1126. break;
  1127. case 'Syracuse, NY':
  1128. latitude = 43.033333;
  1129. longitude = 76.133333;
  1130. t_zone = -5;
  1131. break;
  1132. case 'Tampa, FL':
  1133. latitude = 27.95;
  1134. longitude = 82.45;
  1135. t_zone = -5;
  1136. break;
  1137. case 'Toledo, OH':
  1138. latitude = 41.65;
  1139. longitude = 83.55;
  1140. t_zone = -5;
  1141. break;
  1142. case 'Tulsa, OK':
  1143. latitude = 36.15;
  1144. longitude = 95.983333;
  1145. t_zone = -6;
  1146. break;
  1147. case 'Virginia Beach, VA':
  1148. latitude = 36.85;
  1149. longitude = 75.966667;
  1150. t_zone = -5;
  1151. break;
  1152. case 'Washington, D.C.':
  1153. latitude = 38.883333;
  1154. longitude = 77.033333;
  1155. t_zone = -5;
  1156. break;
  1157. case 'Wichita, KS':
  1158. latitude = 37.716667;
  1159. longitude = 97.283333;
  1160. t_zone = -6;
  1161. break;
  1162. case 'Wilmington, NC':
  1163. latitude = 34.233333;
  1164. longitude = 77.95;
  1165. t_zone = -5;
  1166. break;
  1167. /* Canadian cities listing */
  1168. case 'Calgary, AB':
  1169. latitude = 51 + 6 / 60;
  1170. longitude = 114 + 1 / 60;
  1171. t_zone = -7;
  1172. break;
  1173. case 'Charlottetown, PE':
  1174. latitude = 46 + 14 / 60;
  1175. longitude = 63 + 9 / 60;
  1176. t_zone = -4;
  1177. break;
  1178. case 'Chicoutimi, QC':
  1179. latitude = 48 + 25 / 60;
  1180. longitude = 71 + 5 / 60;
  1181. t_zone = -5;
  1182. break;
  1183. case 'Edmonton, AB':
  1184. latitude = 53 + 34 / 60;
  1185. longitude = 113 + 31 / 60;
  1186. t_zone = -7;
  1187. break;
  1188. case 'Guelph, ON':
  1189. latitude = 43 + 33 / 60;
  1190. longitude = 80 + 15 / 60;
  1191. t_zone = -5;
  1192. break;
  1193. case 'Halifax, NS':
  1194. latitude = 44 + 39 / 60;
  1195. longitude = 63 + 34 / 60;
  1196. t_zone = -4;
  1197. break;
  1198. case 'Hamilton, ON':
  1199. latitude = 43 + 16 / 60;
  1200. longitude = 79 + 54 / 60;
  1201. t_zone = -5;
  1202. break;
  1203. case 'Hull, QC':
  1204. latitude = 45 + 26 / 60;
  1205. longitude = 75 + 44 / 60;
  1206. t_zone = -5;
  1207. break;
  1208. case 'Iqaluit, NU':
  1209. latitude = 63 + 45 / 60;
  1210. longitude = 68 + 31 / 60;
  1211. t_zone = -6;
  1212. break;
  1213. case 'Kelowna, BC':
  1214. latitude = 49 + 53 / 60;
  1215. longitude = 119 + 30 / 60;
  1216. t_zone = -8;
  1217. break;
  1218. case 'Kingston, ON':
  1219. latitude = 44 + 16 / 60;
  1220. longitude = 76 + 30 / 60;
  1221. t_zone = -5;
  1222. break;
  1223. case 'Kitchener, ON':
  1224. latitude = 43 + 26 / 60;
  1225. longitude = 80 + 30 / 60;
  1226. t_zone = -5;
  1227. break;
  1228. case 'London, ON':
  1229. latitude = 43 + 2 / 60;
  1230. longitude = 81 + 9 / 60;
  1231. t_zone = -5;
  1232. break;
  1233. case 'Montreal, QC':
  1234. latitude = 45 + 28 / 60;
  1235. longitude = 73 + 45 / 60;
  1236. t_zone = -5;
  1237. break;
  1238. case 'Oshawa, ON':
  1239. latitude = 43 + 54 / 60;
  1240. longitude = 78 + 52 / 60;
  1241. t_zone = -5;
  1242. break;
  1243. case 'Ottawa, ON':
  1244. latitude = 45 + 19 / 60;
  1245. longitude = 75 + 40 / 60;
  1246. t_zone = -5;
  1247. break;
  1248. case 'Quebec City, QC':
  1249. latitude = 46 + 48 / 60;
  1250. longitude = 71 + 23 / 60;
  1251. t_zone = -5;
  1252. break;
  1253. case 'Regina, SK':
  1254. latitude = 50 + 26 / 60;
  1255. longitude = 104 + 40 / 60;
  1256. t_zone = -7;
  1257. break;
  1258. case 'Saint John, NB':
  1259. latitude = 46 + 6 / 60;
  1260. longitude = 64 + 46 / 60;
  1261. t_zone = -4;
  1262. break;
  1263. case 'Saskatoon, SK':
  1264. latitude = 52 + 10 / 60;
  1265. longitude = 106 + 41 / 60;
  1266. t_zone = -7;
  1267. break;
  1268. case 'Sherbrooke, QC':
  1269. latitude = 45 + 24 / 60;
  1270. longitude = 71 + 54 / 60;
  1271. t_zone = -5;
  1272. break;
  1273. case 'St Catharines, ON':
  1274. latitude = 43 + 11 / 60;
  1275. longitude = 79 + 14 / 60;
  1276. t_zone = -5;
  1277. break;
  1278. case 'St Johns, NL':
  1279. latitude = 47 + 37 / 60;
  1280. longitude = 52 + 45 / 60;
  1281. t_zone = -3.5;
  1282. break;
  1283. case 'Sudbury, ON':
  1284. latitude = 46 + 37 / 60;
  1285. longitude = 80 + 48 / 60;
  1286. t_zone = -5;
  1287. break;
  1288. case 'Thunder Bay, ON':
  1289. latitude = 48 + 22 / 60;
  1290. longitude = 89 + 19 / 60;
  1291. t_zone = -5;
  1292. break;
  1293. case 'Toronto, ON':
  1294. latitude = 43 + 41 / 60;
  1295. longitude = 79 + 38 / 60;
  1296. t_zone = -5;
  1297. break;
  1298. case 'Trois-Rivieres, QC':
  1299. latitude = 46 + 21 / 60;
  1300. longitude = 72 + 35 / 60;
  1301. t_zone = -5;
  1302. break;
  1303. case 'Vancouver, BC':
  1304. latitude = 49 + 11 / 60;
  1305. longitude = 123 + 10 / 60;
  1306. t_zone = -8;
  1307. break;
  1308. case 'Victoria, BC':
  1309. latitude = 48 + 25 / 60;
  1310. longitude = 123 + 19 / 60;
  1311. t_zone = -8;
  1312. break;
  1313. case 'Whitehorse, YT':
  1314. latitude = 60 + 43 / 60;
  1315. longitude = 135 + 3 / 60;
  1316. t_zone = -8;
  1317. break;
  1318. case 'Windsor, ON':
  1319. latitude = 42 + 16 / 60;
  1320. longitude = 82 + 58 / 60;
  1321. t_zone = -4;
  1322. break;
  1323. case 'Winnipeg, MB':
  1324. latitude = 49 + 54 / 60;
  1325. longitude = 97 + 14 / 60;
  1326. t_zone = -6;
  1327. break;
  1328. case 'Yellowknife, NT':
  1329. latitude = 62 + 27 / 60;
  1330. longitude = 114 + 24 / 60;
  1331. t_zone = -7;
  1332. break;
  1333. case 'Kabul':
  1334. latitude = 34 + 35 / 60;
  1335. longitude = -(69 + 12 / 60);
  1336. t_zone = 4.5;
  1337. break;
  1338. case 'Luanda':
  1339. latitude = -(8 + 50 / 60);
  1340. longitude = -(13 + 20 / 60);
  1341. t_zone = 0;
  1342. break;
  1343. case 'Algiers':
  1344. latitude = 36.833333;
  1345. longitude = -3;
  1346. t_zone = 1;
  1347. break;
  1348. case 'Buenos Aires':
  1349. latitude = -34.583333;
  1350. longitude = 58.366667;
  1351. t_zone = -3;
  1352. break;
  1353. case 'Cordoba':
  1354. latitude = -31.466667;
  1355. longitude = 64.166667;
  1356. t_zone = -3;
  1357. break;
  1358. case 'Yerevan':
  1359. latitude = 40 + 16 / 60;
  1360. longitude = -(44 + 34 / 60);
  1361. t_zone = 4;
  1362. break;
  1363. case 'Adelaide':
  1364. latitude = -34.916667;
  1365. longitude = -138.6;
  1366. t_zone = 9.5;
  1367. break;
  1368. case 'Brisbane':
  1369. latitude = -27.483333;
  1370. longitude = -153.133333;
  1371. t_zone = 10;
  1372. break;
  1373. case 'Darwin':
  1374. latitude = -12.466667;
  1375. longitude = -130.85;
  1376. t_zone = 9.5;
  1377. break;
  1378. case 'Melbourne':
  1379. latitude = -37.783333;
  1380. longitude = -144.966667;
  1381. t_zone = 10;
  1382. break;
  1383. case 'Perth':
  1384. latitude = -31.95;
  1385. longitude = -115.866667;
  1386. t_zone = 8;
  1387. break;
  1388. case 'Sydney':
  1389. latitude = -34;
  1390. longitude = -151;
  1391. t_zone = 10;
  1392. break;
  1393. case 'Vienna':
  1394. latitude = 48.233333;
  1395. longitude = -16.333333;
  1396. t_zone = 1;
  1397. break;
  1398. case 'Baku':
  1399. latitude = 40 + 22 / 60;
  1400. longitude = -(49 + 53 / 60);
  1401. t_zone = 4;
  1402. break;
  1403. case 'Chittagong':
  1404. latitude = 22 + 21 / 60;
  1405. longitude = -(91 + 50 / 60);
  1406. t_zone = 6;
  1407. break;
  1408. case 'Minsk':
  1409. latitude = 53 + 54 / 60;
  1410. longitude = -(27 + 33 / 60);
  1411. t_zone = 2;
  1412. break;
  1413. case 'Brussels':
  1414. latitude = 50.866667;
  1415. longitude = -4.366667;
  1416. t_zone = 1;
  1417. break;
  1418. case 'La Paz':
  1419. latitude = -16.45;
  1420. longitude = 68.366667;
  1421. t_zone = -4;
  1422. break;
  1423. case 'Belem':
  1424. latitude = -1.466667;
  1425. longitude = 48.483333;
  1426. t_zone = -3;
  1427. break;
  1428. case 'Rio de Janeiro':
  1429. latitude = -22.95;
  1430. longitude = 43.2;
  1431. t_zone = -3;
  1432. break;
  1433. case 'Salvador':
  1434. latitude = -12.933333;
  1435. longitude = 38.45;
  1436. t_zone = -3;
  1437. break;
  1438. case 'Sao Paulo':
  1439. latitude = -23.516667;
  1440. longitude = 46.516667;
  1441. t_zone = -3;
  1442. break;
  1443. case 'Sofia':
  1444. latitude = 42.666667;
  1445. longitude = -23.333333;
  1446. t_zone = 2;
  1447. break;
  1448. case 'Rangoon':
  1449. latitude = 16 + 47 / 60;
  1450. longitude = -(96 + 9 / 60);
  1451. t_zone = 6.5;
  1452. break;
  1453. case 'Phnom Penh':
  1454. latitude = 11 + 33 / 60;
  1455. longitude = -(104 + 51 / 60);
  1456. t_zone = 7;
  1457. break;
  1458. case 'Iquique':
  1459. latitude = -20.166667;
  1460. longitude = 70.116667;
  1461. t_zone = -4;
  1462. break;
  1463. case 'Santiago':
  1464. latitude = -33.466667;
  1465. longitude = 70.75;
  1466. t_zone = -4;
  1467. break;
  1468. case 'Beijing':
  1469. latitude = 39.916667;
  1470. longitude = -116.416667;
  1471. t_zone = 8;
  1472. break;
  1473. case 'Canton':
  1474. latitude = 23.116667;
  1475. longitude = -113.25;
  1476. t_zone = 8;
  1477. break;
  1478. case 'Chongqing':
  1479. latitude = 29.766667;
  1480. longitude = -106.566667;
  1481. t_zone = 8;
  1482. break;
  1483. case 'Hong Kong':
  1484. latitude = 22 + 17 / 60;
  1485. longitude = -(114 + 8 / 60);
  1486. t_zone = 8;
  1487. break;
  1488. case 'Nanjing':
  1489. latitude = 32.05;
  1490. longitude = -118.883333;
  1491. t_zone = 8;
  1492. break;
  1493. case 'Shanghai':
  1494. latitude = 31.166667;
  1495. longitude = -121.466667;
  1496. t_zone = 8;
  1497. break;
  1498. case 'Bogota':
  1499. latitude = 4.533333;
  1500. longitude = 74.25;
  1501. t_zone = -5;
  1502. break;
  1503. case 'Kinshasa':
  1504. latitude = -4.3;
  1505. longitude = -15.283333;
  1506. t_zone = 1;
  1507. break;
  1508. case 'Havana':
  1509. latitude = 23.133333;
  1510. longitude = 82.383333;
  1511. t_zone = -5;
  1512. break;
  1513. case 'Prague':
  1514. latitude = 50.083333;
  1515. longitude = -14.433333;
  1516. t_zone = 1;
  1517. break;
  1518. case 'Copenhagen':
  1519. latitude = 55.666667;
  1520. longitude = -12.566667;
  1521. t_zone = 1;
  1522. break;
  1523. case 'Djibouti':
  1524. latitude = 11.5;
  1525. longitude = -43.05;
  1526. t_zone = 3;
  1527. break;
  1528. case 'Guayaquil':
  1529. latitude = -2.166667;
  1530. longitude = 79.933333;
  1531. t_zone = -5;
  1532. break;
  1533. case 'Cairo':
  1534. latitude = 30.033333;
  1535. longitude = -31.35;
  1536. t_zone = 2;
  1537. break;
  1538. case 'Birmingham':
  1539. latitude = 52.416667;
  1540. longitude = 1.916667;
  1541. t_zone = 0;
  1542. break;
  1543. case 'Bristol':
  1544. latitude = 51.466667;
  1545. longitude = 2.583333;
  1546. t_zone = 0;
  1547. break;
  1548. case 'Leeds':
  1549. latitude = 53.75;
  1550. longitude = 1.5;
  1551. t_zone = 0;
  1552. break;
  1553. case 'Liverpool':
  1554. latitude = 53.416667;
  1555. longitude = 3;
  1556. t_zone = 0;
  1557. break;
  1558. case 'London':
  1559. latitude = 51.533333;
  1560. longitude = 0.083333;
  1561. t_zone = 0;
  1562. break;
  1563. case 'Manchester':
  1564. latitude = 53.5;
  1565. longitude = 2.25;
  1566. t_zone = 0;
  1567. break;
  1568. case 'Newcastle':
  1569. latitude = 54.966667;
  1570. longitude = 1.616667;
  1571. t_zone = 0;
  1572. break;
  1573. case 'Norwich':
  1574. latitude = 52.6309;
  1575. longitude = -1.2973;
  1576. t_zone = 0;
  1577. break;
  1578. case 'Plymouth':
  1579. latitude = 50.416667;
  1580. longitude = 4.083333;
  1581. t_zone = 0;
  1582. break;
  1583. case 'Helsinki':
  1584. latitude = 60.166667;
  1585. longitude = -25;
  1586. t_zone = 2;
  1587. break;
  1588. case 'Bordeaux':
  1589. latitude = 44.833333;
  1590. longitude = 0.516667;
  1591. t_zone = 1;
  1592. break;
  1593. case 'Lyons':
  1594. latitude = 45.75;
  1595. longitude = -4.833333;
  1596. t_zone = 1;
  1597. break;
  1598. case 'Marseilles':
  1599. latitude = 43.333333;
  1600. longitude = -5.333333;
  1601. t_zone = 1;
  1602. break;
  1603. case 'Paris':
  1604. latitude = 48.8;
  1605. longitude = -2.333333;
  1606. t_zone = 1;
  1607. break;
  1608. case 'Cayenne':
  1609. latitude = 4.816667;
  1610. longitude = 52.3;
  1611. t_zone = -4;
  1612. break;
  1613. case 'Berlin':
  1614. latitude = 52.5;
  1615. longitude = -13.416667;
  1616. t_zone = 1;
  1617. break;
  1618. case 'Bremen':
  1619. latitude = 53.083333;
  1620. longitude = -8.816667;
  1621. t_zone = 1;
  1622. break;
  1623. case 'Frankfurt':
  1624. latitude = 50.116667;
  1625. longitude = -8.683333;
  1626. t_zone = 1;
  1627. break;
  1628. case 'Hamburg':
  1629. latitude = 53.55;
  1630. longitude = -10.033333;
  1631. t_zone = 1;
  1632. break;
  1633. case 'Munich':
  1634. latitude = 48.133333;
  1635. longitude = -11.583333;
  1636. t_zone = 1;
  1637. break;
  1638. case 'Athens':
  1639. latitude = 37.966667;
  1640. longitude = -23.716667;
  1641. t_zone = 2;
  1642. break;
  1643. case 'Guatemala City':
  1644. latitude = 14.616667;
  1645. longitude = 90.516667;
  1646. t_zone = -6;
  1647. break;
  1648. case 'Georgetown':
  1649. latitude = 6.75;
  1650. longitude = 58.25;
  1651. t_zone = -3.75;
  1652. break;
  1653. case 'Budapest':
  1654. latitude = 47.5;
  1655. longitude = -19.083333;
  1656. t_zone = 1;
  1657. break;
  1658. case 'Reykjavik':
  1659. latitude = 64.066667;
  1660. longitude = 21.966667;
  1661. t_zone = -1;
  1662. break;
  1663. case 'Bombay':
  1664. latitude = 19;
  1665. longitude = -72.8;
  1666. t_zone = 5.5;
  1667. break;
  1668. case 'Calcutta':
  1669. latitude = 22.566667;
  1670. longitude = -88.4;
  1671. t_zone = 5.5;
  1672. break;
  1673. case 'Delhi':
  1674. latitude = 28.667;
  1675. longitude = -77.233;
  1676. t_zone = 5.5;
  1677. break;
  1678. case 'Jakarta':
  1679. latitude = -6.266667;
  1680. longitude = -106.8;
  1681. t_zone = 7.5;
  1682. break;
  1683. case 'Teheran':
  1684. latitude = 35.75;
  1685. longitude = -51.75;
  1686. t_zone = 3.5;
  1687. break;
  1688. case 'Baghdad':
  1689. latitude = 33 + 20 / 60;
  1690. longitude = -(44 + 26 / 60);
  1691. t_zone = 3;
  1692. break;
  1693. case 'Dublin':
  1694. latitude = 53.333333;
  1695. longitude = 6.25;
  1696. t_zone = 0;
  1697. break;
  1698. case 'Jerusalem':
  1699. latitude = 31 + 47 / 60;
  1700. longitude = -(35 + 13 / 60);
  1701. t_zone = 2;
  1702. break;
  1703. case 'Tel Aviv':
  1704. latitude = 32 + 5 / 60;
  1705. longitude = -(34 + 46 / 60);
  1706. t_zone = 2;
  1707. break;
  1708. case 'Milan':
  1709. latitude = 45.45;
  1710. longitude = -9.166667;
  1711. t_zone = 1;
  1712. break;
  1713. case 'Naples':
  1714. latitude = 40.833333;
  1715. longitude = -14.25;
  1716. t_zone = 1;
  1717. break;
  1718. case 'Rome':
  1719. latitude = 41.9;
  1720. longitude = -12.45;
  1721. t_zone = 1;
  1722. break;
  1723. case 'Venice':
  1724. latitude = 45.433333;
  1725. longitude = -12.333333;
  1726. t_zone = 1;
  1727. break;
  1728. case 'Kingston':
  1729. latitude = 17.983333;
  1730. longitude = 76.816667;
  1731. t_zone = -5;
  1732. break;
  1733. case 'Nagasaki':
  1734. latitude = 32.8;
  1735. longitude = -129.95;
  1736. t_zone = 9;
  1737. break;
  1738. case 'Nagoya':
  1739. latitude = 35.116667;
  1740. longitude = -136.933333;
  1741. t_zone = 9;
  1742. break;
  1743. case 'Osaka':
  1744. latitude = 34.533333;
  1745. longitude = -135.5;
  1746. t_zone = 9;
  1747. break;
  1748. case 'Tokyo':
  1749. latitude = 35.666667;
  1750. longitude = -139.75;
  1751. t_zone = 9;
  1752. break;
  1753. case 'Nairobi':
  1754. latitude = -1.416667;
  1755. longitude = -36.916667;
  1756. t_zone = 3;
  1757. break;
  1758. case 'Beirut':
  1759. latitude = 33 + 54 / 60;
  1760. longitude = -(35 + 32 / 60);
  1761. t_zone = 2;
  1762. break;
  1763. case 'Tripoli':
  1764. latitude = 32.95;
  1765. longitude = -13.2;
  1766. t_zone = 2;
  1767. break;
  1768. case 'Tananarive':
  1769. latitude = -18.833333;
  1770. longitude = -47.55;
  1771. t_zone = 3;
  1772. break;
  1773. case 'Chihuahua':
  1774. latitude = 28.616667;
  1775. longitude = 106.083333;
  1776. t_zone = -6;
  1777. break;
  1778. case 'Mazatlan':
  1779. latitude = 23.2;
  1780. longitude = 106.416667;
  1781. t_zone = -7;
  1782. break;
  1783. case 'Mexico City':
  1784. latitude = 19.433333;
  1785. longitude = 99.116667;
  1786. t_zone = -6;
  1787. break;
  1788. case 'Veracruz':
  1789. latitude = 19.166667;
  1790. longitude = 96.166667;
  1791. t_zone = -6;
  1792. break;
  1793. case 'Amsterdam':
  1794. latitude = 52.366667;
  1795. longitude = -4.883333;
  1796. t_zone = 1;
  1797. break;
  1798. case 'Auckland':
  1799. latitude = -36.883333;
  1800. longitude = -174.75;
  1801. t_zone = 12;
  1802. break;
  1803. case 'Christchurch':
  1804. latitude = -(43 + 31.8 / 60);
  1805. longitude = -(172 + 37.2 / 60);
  1806. t_zone = 12;
  1807. break;
  1808. case 'Wellington':
  1809. latitude = -41.283333;
  1810. longitude = -174.783333;
  1811. t_zone = 12;
  1812. break;
  1813. case 'Belfast':
  1814. latitude = 54.616667;
  1815. longitude = 5.933333;
  1816. t_zone = 0;
  1817. break;
  1818. case 'Hammerfest':
  1819. latitude = 70.633333;
  1820. longitude = -23.633333;
  1821. t_zone = 1;
  1822. break;
  1823. case 'Oslo':
  1824. latitude = 59.95;
  1825. longitude = -10.7;
  1826. t_zone = 1;
  1827. break;
  1828. case 'Islamabad':
  1829. latitude = 33 + 40 / 60;
  1830. longitude = -(73 + 10 / 60);
  1831. t_zone = 5;
  1832. break;
  1833. case 'Panama City':
  1834. latitude = 8.966667;
  1835. longitude = 79.533333;
  1836. t_zone = -5;
  1837. break;
  1838. case 'Port Moresby':
  1839. latitude = -9.416667;
  1840. longitude = -147.133333;
  1841. t_zone = 10;
  1842. break;
  1843. case 'Asuncion':
  1844. latitude = -25.25;
  1845. longitude = 57.666667;
  1846. t_zone = -4;
  1847. break;
  1848. case 'Lima':
  1849. latitude = -12;
  1850. longitude = 77.033333;
  1851. t_zone = -5;
  1852. break;
  1853. case 'Manila':
  1854. latitude = 14.583333;
  1855. longitude = -120.95;
  1856. t_zone = 8;
  1857. break;
  1858. case 'Warsaw':
  1859. latitude = 52.233333;
  1860. longitude = -21;
  1861. t_zone = 1;
  1862. break;
  1863. case 'Lisbon':
  1864. latitude = 38.733333;
  1865. longitude = 9.15;
  1866. t_zone = 0;
  1867. break;
  1868. case 'Bucharest':
  1869. latitude = 44.416667;
  1870. longitude = -26.116667;
  1871. t_zone = 2;
  1872. break;
  1873. case 'Irkutsk':
  1874. latitude = 52.5;
  1875. longitude = -104.333333;
  1876. t_zone = 8;
  1877. break;
  1878. case 'Moscow':
  1879. latitude = 55.75;
  1880. longitude = -37.6;
  1881. t_zone = 3;
  1882. break;
  1883. case 'St Petersburg':
  1884. latitude = 59.933333;
  1885. longitude = -30.3;
  1886. t_zone = 3;
  1887. break;
  1888. case 'Vladivostok':
  1889. latitude = 43.166667;
  1890. longitude = -132;
  1891. t_zone = 10;
  1892. break;
  1893. case 'Mecca':
  1894. latitude = 21.483333;
  1895. longitude = -39.75;
  1896. t_zone = 3;
  1897. break;
  1898. case 'Aberdeen':
  1899. latitude = 57.15;
  1900. longitude = 2.15;
  1901. t_zone = 0;
  1902. break;
  1903. case 'Edinburgh':
  1904. latitude = 55.916667;
  1905. longitude = 3.166667;
  1906. t_zone = 0;
  1907. break;
  1908. case 'Glasgow':
  1909. latitude = 55.833333;
  1910. longitude = 4.25;
  1911. t_zone = 0;
  1912. break;
  1913. case 'Dakar':
  1914. latitude = 14.666667;
  1915. longitude = 17.466667;
  1916. t_zone = 0;
  1917. break;
  1918. case 'Singapore':
  1919. latitude = 1.233333;
  1920. longitude = -103.916667;
  1921. t_zone = 7.5;
  1922. break;
  1923. case 'Johannesburg':
  1924. latitude = -26.2;
  1925. longitude = -28.066667;
  1926. t_zone = 2;
  1927. break;
  1928. case 'CapeTown':
  1929. latitude = -33.916667;
  1930. longitude = -18.366667;
  1931. t_zone = 2;
  1932. break;
  1933. case 'Durban':
  1934. latitude = -29.883333;
  1935. longitude = -30.883333;
  1936. t_zone = 2;
  1937. break;
  1938. case 'Barcelona':
  1939. latitude = 41.383333;
  1940. longitude = -2.15;
  1941. t_zone = 1;
  1942. break;
  1943. case 'Madrid':
  1944. latitude = 40.433333;
  1945. longitude = 3.7;
  1946. t_zone = 1;
  1947. break;
  1948. case 'Paramaribo':
  1949. latitude = 5.75;
  1950. longitude = 55.25;
  1951. t_zone = -3.5;
  1952. break;
  1953. case 'Stockholm':
  1954. latitude = 59.283333;
  1955. longitude = -18.05;
  1956. t_zone = 1;
  1957. break;
  1958. case 'Zurich':
  1959. latitude = 47.35;
  1960. longitude = -8.516667;
  1961. t_zone = 1;
  1962. break;
  1963. case 'Hobart':
  1964. latitude = -42.866667;
  1965. longitude = -147.166667;
  1966. t_zone = 10;
  1967. break;
  1968. case 'Bangkok':
  1969. latitude = 13.75;
  1970. longitude = -100.5;
  1971. t_zone = 7;
  1972. break;
  1973. case 'Ankara':
  1974. latitude = 39.916667;
  1975. longitude = -32.916667;
  1976. t_zone = 2;
  1977. break;
  1978. case 'Odessa':
  1979. latitude = 46.45;
  1980. longitude = -30.8;
  1981. t_zone = 3;
  1982. break;
  1983. case 'Montevideo':
  1984. latitude = -34.883333;
  1985. longitude = 56.166667;
  1986. t_zone = -3;
  1987. break;
  1988. case 'Caracas':
  1989. latitude = 10.466667;
  1990. longitude = 67.033333;
  1991. t_zone = -4;
  1992. break;
  1993. case 'Hanoi':
  1994. latitude = 21 + 2 / 60;
  1995. longitude = -(105 + 51 / 60);
  1996. t_zone = 7;
  1997. break;
  1998. case 'Cardiff':
  1999. latitude = 51 + 29 / 60;
  2000. longitude = 3 + 11 / 60;
  2001. t_zone = 0;
  2002. break;
  2003. case 'Belgrade':
  2004. latitude = 44.866667;
  2005. longitude = -20.533333;
  2006. t_zone = 1;
  2007. break;
  2008. /* Added August 6th */
  2009. case 'Tirana':
  2010. latitude = 41.33;
  2011. longitude = -19.82;
  2012. t_zone = 1;
  2013. break;
  2014. case 'Nassau':
  2015. latitude = 25.06;
  2016. longitude = 77.33;
  2017. t_zone = -5;
  2018. break;
  2019. case 'Belmopan':
  2020. latitude = 17 + 25 / 60;
  2021. longitude = 88 + 46 / 60;
  2022. t_zone = -6;
  2023. break;
  2024. case 'Porto Novo':
  2025. latitude = 6.5;
  2026. longitude = -(2 + 47 / 60);
  2027. t_zone = 1;
  2028. break;
  2029. case 'Thimphu':
  2030. latitude = 27.48;
  2031. longitude = -89.70;
  2032. t_zone = 6;
  2033. break;
  2034. case 'Sarajevo':
  2035. latitude = 43.85;
  2036. longitude = -18.38;
  2037. t_zone = 1;
  2038. break;
  2039. case 'Gaborone':
  2040. latitude = -24.65;
  2041. longitude = -25.91;
  2042. t_zone = 2;
  2043. break;
  2044. case 'Bandar Seri Begawan':
  2045. latitude = 4.93;
  2046. longitude = -114.95;
  2047. t_zone = 8;
  2048. break;
  2049. case 'Ouagadougou':
  2050. latitude = 12.37;
  2051. longitude = 1.53;
  2052. t_zone = 0;
  2053. break;
  2054. case 'Bujumbura':
  2055. latitude = -3.37;
  2056. longitude = -29.35;
  2057. t_zone = 2;
  2058. break;
  2059. case 'Yaounde':
  2060. latitude = 3 + 51 / 60;
  2061. longitude = -(11 + 31 / 60);
  2062. t_zone = 1;
  2063. break;
  2064. case 'Praia':
  2065. latitude = 14.93;
  2066. longitude = 23.54;
  2067. t_zone = -1;
  2068. break;
  2069. case 'Bangui':
  2070. latitude = 4.36;
  2071. longitude = -18.56;
  2072. t_zone = 1;
  2073. break;
  2074. case 'Ndjamena':
  2075. latitude = 12.11;
  2076. longitude = -15.05;
  2077. t_zone = 1;
  2078. break;
  2079. case 'Brazzaville':
  2080. latitude = -4.25;
  2081. longitude = -15.26;
  2082. t_zone = 1;
  2083. break;
  2084. case 'San Jose':
  2085. latitude = 9.93;
  2086. longitude = 84.08;
  2087. t_zone = -6;
  2088. break;
  2089. case 'Abidjan':
  2090. latitude = 5.33;
  2091. longitude = 4.03;
  2092. t_zone = 0;
  2093. break;
  2094. case 'Zagreb':
  2095. latitude = 45.80;
  2096. longitude = -15.97;
  2097. t_zone = 1;
  2098. break;
  2099. case 'Nicosia':
  2100. latitude = 35.16;
  2101. longitude = -33.38;
  2102. t_zone = 2;
  2103. break;
  2104. case 'Santo Domingo':
  2105. latitude = 18.48;
  2106. longitude = 69.91;
  2107. t_zone = -4;
  2108. break;
  2109. case 'Dili':
  2110. latitude = -8.57;
  2111. longitude = -125.58;
  2112. t_zone = 9;
  2113. break;
  2114. case 'San Salvador':
  2115. latitude = 13.69;
  2116. longitude = 89.19;
  2117. t_zone = -6;
  2118. break;
  2119. case 'Asmera':
  2120. latitude = 15.33;
  2121. longitude = -38.94;
  2122. t_zone = 3;
  2123. break;
  2124. case 'Tallinn':
  2125. latitude = 59.44;
  2126. longitude = -24.74;
  2127. t_zone = 2;
  2128. break;
  2129. case 'Addis Ababa':
  2130. latitude = 9.03;
  2131. longitude = -38.74;
  2132. t_zone = 3;
  2133. break;
  2134. case 'Port Stanley':
  2135. latitude = -51.70;
  2136. longitude = 57.82;
  2137. t_zone = -4;
  2138. break;
  2139. case 'Suva':
  2140. latitude = -18.13;
  2141. longitude = -178.43;
  2142. t_zone = 12;
  2143. break;
  2144. case 'Papeete':
  2145. latitude = -(17 + 32 / 60);
  2146. longitude = 149 + 34 / 60;
  2147. t_zone = -10;
  2148. break;
  2149. case 'Libreville':
  2150. latitude = 0.39;
  2151. longitude = -9.45;
  2152. t_zone = 1;
  2153. break;
  2154. case 'Banjul':
  2155. latitude = 13.45;
  2156. longitude = 16.68;
  2157. t_zone = 0;
  2158. break;
  2159. case 'Tbilisi':
  2160. latitude = 41.72;
  2161. longitude = -44.79;
  2162. t_zone = 4;
  2163. break;
  2164. case 'Accra':
  2165. latitude = 5.56;
  2166. longitude = 0.20;
  2167. t_zone = 0;
  2168. break;
  2169. case 'Nuuk':
  2170. latitude = 64 + 10 / 60;
  2171. longitude = 51 + 40 / 60;
  2172. t_zone = -3;
  2173. break;
  2174. case 'Conakry':
  2175. latitude = 9.55;
  2176. longitude = 13.67;
  2177. t_zone = 0;
  2178. break;
  2179. case 'Bissau':
  2180. latitude = 11.87;
  2181. longitude = 15.60;
  2182. t_zone = 0;
  2183. break;
  2184. case 'Port-au-Prince':
  2185. latitude = 18.54;
  2186. longitude = 72.34;
  2187. t_zone = -5;
  2188. break;
  2189. case 'Tegucigalpa':
  2190. latitude = 14.09;
  2191. longitude = 87.22;
  2192. t_zone = -6;
  2193. break;
  2194. case 'Amman':
  2195. latitude = 31.95;
  2196. longitude = -35.93;
  2197. t_zone = 2;
  2198. break;
  2199. case 'Almaty':
  2200. latitude = 43.32;
  2201. longitude = -76.92;
  2202. t_zone = 6;
  2203. break;
  2204. case 'Pyongyang':
  2205. latitude = 39.02;
  2206. longitude = -125.75;
  2207. t_zone = 9;
  2208. break;
  2209. case 'Seoul':
  2210. latitude = 37.56;
  2211. longitude = -126.99;
  2212. t_zone = 9;
  2213. break;
  2214. case 'Bishkek':
  2215. latitude = 42.87;
  2216. longitude = -74.57;
  2217. t_zone = 6;
  2218. break;
  2219. case 'Vientiane':
  2220. latitude = 17.97;
  2221. longitude = -102.61;
  2222. t_zone = 7;
  2223. break;
  2224. case 'Riga':
  2225. latitude = 56.97;
  2226. longitude = -24.13;
  2227. t_zone = 2;
  2228. break;
  2229. case 'Maseru':
  2230. latitude = -29.31;
  2231. longitude = -27.49;
  2232. t_zone = 2;
  2233. break;
  2234. case 'Monrovia':
  2235. latitude = 6.31;
  2236. longitude = 10.80;
  2237. t_zone = 0;
  2238. break;
  2239. case 'Vilnius':
  2240. latitude = 54.70;
  2241. longitude = -25.27;
  2242. t_zone = 2;
  2243. break;
  2244. case 'Skopje':
  2245. latitude = 42.00;
  2246. longitude = -21.47;
  2247. t_zone = 1;
  2248. break;
  2249. case 'Lilongwe':
  2250. latitude = -13.97;
  2251. longitude = -33.80;
  2252. t_zone = 2;
  2253. break;
  2254. case 'Kuala Lumpur':
  2255. latitude = 3.16;
  2256. longitude = -101.71;
  2257. t_zone = 8;
  2258. break;
  2259. case 'Bamako':
  2260. latitude = 12.65;
  2261. longitude = 7.99;
  2262. t_zone = 0;
  2263. break;
  2264. case 'Nouakchott':
  2265. latitude = 18.09;
  2266. longitude = 15.98;
  2267. t_zone = 0;
  2268. break;
  2269. case 'Kishinev':
  2270. latitude = 47.03;
  2271. longitude = -28.83;
  2272. t_zone = 2;
  2273. break;
  2274. case 'Ulaanbaatar':
  2275. latitude = 47.93;
  2276. longitude = -106.91;
  2277. t_zone = 8;
  2278. break;
  2279. case 'Casablanca':
  2280. latitude = 33.60;
  2281. longitude = 7.62;
  2282. t_zone = 0;
  2283. break;
  2284. case 'Maputo':
  2285. latitude = -25.95;
  2286. longitude = -32.57;
  2287. t_zone = 2;
  2288. break;
  2289. case 'Windhoek':
  2290. latitude = -22.56;
  2291. longitude = -17.09;
  2292. t_zone = 1;
  2293. break;
  2294. case 'Kathmandu':
  2295. latitude = 27.71;
  2296. longitude = -85.31;
  2297. t_zone = 5.75;
  2298. break;
  2299. case 'Managua':
  2300. latitude = 12.15;
  2301. longitude = 86.27;
  2302. t_zone = -6;
  2303. break;
  2304. case 'Niamey':
  2305. latitude = 13.52;
  2306. longitude = -2.12;
  2307. t_zone = 1;
  2308. break;
  2309. case 'Lagos':
  2310. latitude = 6.45;
  2311. longitude = -3.47;
  2312. t_zone = 1;
  2313. break;
  2314. case 'San Juan':
  2315. latitude = 18.44;
  2316. longitude = 66.13;
  2317. t_zone = -4;
  2318. break;
  2319. case 'Doha':
  2320. latitude = 25.30;
  2321. longitude = -51.51;
  2322. t_zone = 3;
  2323. break;
  2324. case 'Kigali':
  2325. latitude = -1.94;
  2326. longitude = -30.06;
  2327. t_zone = 2;
  2328. break;
  2329. case 'Freetown':
  2330. latitude = 8.49;
  2331. longitude = 13.24;
  2332. t_zone = 0;
  2333. break;
  2334. case 'Bratislava':
  2335. latitude = 48.16;
  2336. longitude = -17.13;
  2337. t_zone = 1;
  2338. break;
  2339. case 'Ljubljana':
  2340. latitude = 46.06;
  2341. longitude = -14.51;
  2342. t_zone = 1;
  2343. break;
  2344. case 'Mogadishu':
  2345. latitude = 2.05;
  2346. longitude = -45.33;
  2347. t_zone = 3;
  2348. break;
  2349. case 'Colombo':
  2350. latitude = 6.93;
  2351. longitude = -79.85;
  2352. t_zone = 5.5;
  2353. break;
  2354. case 'Khartoum':
  2355. latitude = 15.58;
  2356. longitude = -32.52;
  2357. t_zone = 3;
  2358. break;
  2359. case 'Mbabane':
  2360. latitude = -(26 + 19 / 60);
  2361. longitude = -(31 + 7 / 60);
  2362. t_zone = 2;
  2363. break;
  2364. case 'Damascus':
  2365. latitude = 33.4;
  2366. longitude = -36.5;
  2367. t_zone = 2;
  2368. break;
  2369. case 'Taipei':
  2370. latitude = 25.02;
  2371. longitude = -121.45;
  2372. t_zone = 8;
  2373. break;
  2374. case 'Dushanbe':
  2375. latitude = 38.57;
  2376. longitude = -68.78;
  2377. t_zone = 5;
  2378. break;
  2379. case 'Dar es Salaam':
  2380. latitude = -6.82;
  2381. longitude = -39.28;
  2382. t_zone = 3;
  2383. break;
  2384. case 'Lome':
  2385. latitude = 6.17;
  2386. longitude = -1.35;
  2387. t_zone = 0;
  2388. break;
  2389. case 'Port of Spain':
  2390. latitude = 10 + 38 / 60;
  2391. longitude = 61 + 31 / 60;
  2392. t_zone = -4;
  2393. break;
  2394. case 'Tunis':
  2395. latitude = 36.84;
  2396. longitude = -10.22;
  2397. t_zone = 1;
  2398. break;
  2399. case 'Ashgabat':
  2400. latitude = 37.95;
  2401. longitude = -58.38;
  2402. t_zone = 5;
  2403. break;
  2404. case 'Kampala':
  2405. latitude = 0.32;
  2406. longitude = -32.58;
  2407. t_zone = 3;
  2408. break;
  2409. case 'Dubai':
  2410. latitude = 25.27;
  2411. longitude = -55.33;
  2412. t_zone = 4;
  2413. break;
  2414. case 'Tashkent':
  2415. latitude = 41.31;
  2416. longitude = -69.30;
  2417. t_zone = 5;
  2418. break;
  2419. case 'Vatican City':
  2420. latitude = 41.90;
  2421. longitude = -12.46;
  2422. t_zone = 1;
  2423. break;
  2424. case 'Sana':
  2425. latitude = 15.38;
  2426. longitude = -44.21;
  2427. t_zone = 3;
  2428. break;
  2429. case 'Lusaka':
  2430. latitude = -15.42;
  2431. longitude = -28.29;
  2432. t_zone = 2;
  2433. break;
  2434. case 'Harare':
  2435. latitude = -17.82;
  2436. longitude = -31.05;
  2437. t_zone = 2;
  2438. break;
  2439. }
  2440. planets();
  2441. }
  2442. /*
  2443. Set current date and time
  2444. */
  2445. function setup()
  2446. {
  2447. planet_name = ["the Sun","Mercury","Venus","Mars","Jupiter","Saturn","Moon","the Pleiades","Aldebaran","the Beehive","Regulus","Spica","Antares","Pollux","Elnath","Alhena","Nunki"];
  2448. planet_decl = new Array(16);
  2449. planet_r_a = new Array(16);
  2450. planet_altitude = new Array(6);
  2451. planet_azimuth = new Array(6);
  2452. planet_mag = new Array(6);
  2453. planet_decl[7] = 0.42121;
  2454. planet_r_a[7] = 0.99222;
  2455. planet_decl[8] = 0.28827;
  2456. planet_r_a[8] = 1.20559;
  2457. planet_decl[9] = 0.34296;
  2458. planet_r_a[9] = 2.27242;
  2459. planet_decl[10] = 0.20828;
  2460. planet_r_a[10] = 2.65595;
  2461. planet_decl[11] = -0.19548;
  2462. planet_r_a[11] = 3.51466;
  2463. planet_decl[12] = -0.46164;
  2464. planet_r_a[12] = 4.31882;
  2465. planet_decl[13] = 0.48898;
  2466. planet_r_a[13] = 2.03199;
  2467. planet_decl[14] = 0.49946;
  2468. planet_r_a[14] = 1.42549;
  2469. planet_decl[15] = 0.28623;
  2470. planet_r_a[15] = 1.73704;
  2471. planet_decl[16] = -0.45873;
  2472. planet_r_a[16] = 4.95543;
  2473. phenomena = "...";
  2474. phases = new Array(3);
  2475. phase = new Array(3);
  2476. moon_data = "...";
  2477. new_moon = 0;
  2478. var nowdate = new Date();
  2479. var utc_day = nowdate.getUTCDate();
  2480. var utc_month = nowdate.getUTCMonth() + 1;
  2481. var utc_year = nowdate.getUTCFullYear();
  2482. zone_comp = nowdate.getTimezoneOffset() / 1440;
  2483. var utc_hours = nowdate.getUTCHours();
  2484. var utc_mins = nowdate.getUTCMinutes();
  2485. var utc_secs = nowdate.getUTCSeconds();
  2486. utc_mins += utc_secs / 60.0;
  2487. utc_mins = Math.floor((utc_mins + 0.5));
  2488. if (utc_mins < 10) utc_mins = "0" + utc_mins;
  2489. if (utc_mins > 59) utc_mins = 59;
  2490. if (utc_hours < 10) utc_hours = "0" + utc_hours;
  2491. if (utc_month < 10) utc_month = "0" + utc_month;
  2492. if (utc_day < 10) utc_day = "0" + utc_day;
  2493. if (UTdate == "now")
  2494. {
  2495. document.planets.date_txt.value = utc_month + "/" + utc_day + "/" + utc_year;
  2496. }
  2497. else
  2498. {
  2499. document.planets.date_txt.value = UTdate;
  2500. }
  2501. if (UTtime == "now")
  2502. {
  2503. document.planets.ut_h_m.value = utc_hours + ":" + utc_mins;
  2504. }
  2505. else
  2506. {
  2507. document.planets.ut_h_m.value = UTtime;
  2508. }
  2509. planets();
  2510. dst();
  2511. }
  2512. /*
  2513. Reset date and time to current local time
  2514. */
  2515. function back_to_now()
  2516. {
  2517. var nowdate = new Date();
  2518. var utc_day = nowdate.getUTCDate();
  2519. var utc_month = nowdate.getUTCMonth() + 1;
  2520. var utc_year = nowdate.getUTCFullYear();
  2521. zone_comp = nowdate.getTimezoneOffset() / 1440;
  2522. var utc_hours = nowdate.getUTCHours();
  2523. var utc_mins = nowdate.getUTCMinutes();
  2524. var utc_secs = nowdate.getUTCSeconds();
  2525. utc_mins += utc_secs / 60.0;
  2526. utc_mins = Math.floor((utc_mins + 0.5));
  2527. if (utc_mins < 10) utc_mins = "0" + utc_mins;
  2528. if (utc_mins > 59) utc_mins = 59;
  2529. if (utc_hours < 10) utc_hours = "0" + utc_hours;
  2530. if (utc_month < 10) utc_month = "0" + utc_month;
  2531. if (utc_day < 10) utc_day = "0" + utc_day;
  2532. document.planets.date_txt.value = utc_month + "/" + utc_day + "/" + utc_year;
  2533. document.planets.ut_h_m.value = utc_hours + ":" + utc_mins;
  2534. /*
  2535. if (UTdate == "now")
  2536. {
  2537. document.planets.date_txt.value = utc_month + "/" + utc_day + "/" + utc_year;
  2538. }
  2539. else
  2540. {
  2541. document.planets.date_txt.value = UTdate;
  2542. }
  2543. if (UTtime == "now")
  2544. {
  2545. document.planets.ut_h_m.value = utc_hours + ":" + utc_mins;
  2546. }
  2547. else
  2548. {
  2549. document.planets.ut_h_m.value = UTtime;
  2550. }
  2551. */
  2552. planets();
  2553. }
  2554. /*
  2555. todo: Unnecessary function
  2556. */
  2557. function resizeDocumentTo(setw,seth)
  2558. {
  2559. return window.resizeTo(setw,seth),window.resizeTo(setw*2-((typeof window.innerWidth == 'undefined')?document.body.clientWidth:window.innerWidth),seth*2-((typeof window.innerHeight == 'undefined')?document.body.clientHeight:window.innerHeight));
  2560. }
  2561. /*
  2562. Determine if "x" is 0, 1, or -1
  2563. */
  2564. function sign_of(x)
  2565. {
  2566. return x == 0 ? 0 : (x > 0 ? 1 : -1);
  2567. }
  2568. /*
  2569. todo: Do not know what this function does
  2570. */
  2571. function proper_ang(big)
  2572. {
  2573. with (Math)
  2574. {
  2575. var tmp = 0;
  2576. if (big > 0)
  2577. {
  2578. tmp = big / 360.0;
  2579. tmp = (tmp - floor(tmp)) * 360.0;
  2580. }
  2581. else
  2582. {
  2583. tmp = ceil(abs(big / 360.0));
  2584. tmp = big + tmp * 360.0;
  2585. }
  2586. }
  2587. return tmp;
  2588. }
  2589. /*
  2590. todo: Do not know what this function does
  2591. */
  2592. function proper_ang_rad(big)
  2593. {
  2594. with (Math)
  2595. {
  2596. var tmp = 0;
  2597. if (big > 0)
  2598. {
  2599. tmp = big / 2 / PI;
  2600. tmp = (tmp - floor(tmp)) * 2 * PI;
  2601. }
  2602. else
  2603. {
  2604. tmp = ceil(abs(big / 2 / PI));
  2605. tmp = big + tmp * 2 * PI;
  2606. }
  2607. }
  2608. return tmp;
  2609. }
  2610. /*
  2611. todo: Do not know what this function does
  2612. */
  2613. function range_1(num)
  2614. {
  2615. var temp = num;
  2616. if (num > 1) temp = num - 1;
  2617. if (num < 0) temp = num + 1;
  2618. return temp;
  2619. }
  2620. /*
  2621. fixme: Unecessary function
  2622. */
  2623. //function range_24(big)
  2624. //{
  2625. // with (Math)
  2626. // {
  2627. // var tmp = 0;
  2628. // if (big > 0)
  2629. // {
  2630. // tmp = big / 24.0;
  2631. // tmp = (tmp - floor(tmp)) * 24.0;
  2632. // }
  2633. // else
  2634. // {
  2635. // tmp = ceil(abs(big / 24.0));
  2636. // tmp = big + tmp * 24.0;
  2637. // }
  2638. // }
  2639. // return tmp;
  2640. //}
  2641. /*
  2642. Math functions to round to nearest whole number
  2643. */
  2644. function round_10(num)
  2645. {
  2646. return Math.floor((num + 0.05) * 10) / 10;
  2647. }
  2648. function round_100(num)
  2649. {
  2650. return Math.floor((num + 0.005) * 100) / 100;
  2651. }
  2652. function round_1000(num)
  2653. {
  2654. return Math.floor((num + 0.0005) * 1000) / 1000;
  2655. }
  2656. function hundred_miles(num)
  2657. {
  2658. return Math.floor((num / 100) + 0.5) * 100;
  2659. }
  2660. /*
  2661. Validate date and time
  2662. */
  2663. function isValidDate(dateStr)
  2664. {
  2665. if (IsValidTime(document.planets.ut_h_m.value) == true)
  2666. {
  2667. var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
  2668. var matchArray = dateStr.match(datePat);
  2669. if (matchArray == null) {
  2670. alert("Date is not in a valid format.");
  2671. return false;
  2672. }
  2673. var month = matchArray[1];
  2674. var day = matchArray[3];
  2675. var year = matchArray[4];
  2676. if (month < 1 || month > 12) {
  2677. alert("Month must be between 1 and 12.");
  2678. return false;
  2679. }
  2680. if (year < 1600 || year > 2400) {
  2681. alert("Year must be between 1600 and 2400.");
  2682. return false;
  2683. }
  2684. if (day < 1 || day > 31) {
  2685. alert("Day must be between 1 and 31.");
  2686. return false;
  2687. }
  2688. if ((month == 4 || month == 6 || month == 9 || month == 11) && day == 31) {
  2689. alert("Month " + month + " doesn't have 31 days!");
  2690. return false
  2691. }
  2692. if (month == 2) {
  2693. var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
  2694. if (day > 29 || (day == 29 && !isleap))
  2695. {
  2696. alert("February " + year + " doesn't have " + day + " days!");
  2697. return false;
  2698. }
  2699. }
  2700. if (month < 10 && month.length == 1) month = "0" + month;
  2701. if (day < 10 && day.length == 1) day = "0" + day;
  2702. document.planets.date_txt.value = month + "/" + day + "/" + year;
  2703. var dt_str = document.planets.date_txt.value;
  2704. if ((dt_str.substring(2,3) != "/") || (dt_str.substring(5,6) != "/"))
  2705. {
  2706. alert ("Date is not in a valid format.");
  2707. return false;
  2708. }
  2709. planets();
  2710. return true;
  2711. }
  2712. else
  2713. {
  2714. return false;
  2715. }
  2716. }
  2717. /*
  2718. Error messages for invalid times
  2719. */
  2720. function IsValidTime(timeStr)
  2721. {
  2722. var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
  2723. var matchArray = timeStr.match(timePat);
  2724. if (matchArray == null)
  2725. {
  2726. alert("Time is not in a valid format.");
  2727. return false;
  2728. }
  2729. var hour = matchArray[1];
  2730. var minute = matchArray[2];
  2731. if (hour < 0 || hour > 23)
  2732. {
  2733. alert("Hour must be between 0 and 23.");
  2734. return false;
  2735. }
  2736. if (minute < 0 || minute > 59)
  2737. {
  2738. alert ("Minute must be between 0 and 59.");
  2739. return false;
  2740. }
  2741. if (hour < 10 && hour.length == 1) hour = "0" + hour;
  2742. if (minute < 10 && minute.length == 1) minute = "0" + minute;
  2743. document.planets.ut_h_m.value = hour + ":" + minute;
  2744. var tm_str = document.planets.ut_h_m.value;
  2745. if ((tm_str.substring(2,3) != ":") && (dt_str.length != 5))
  2746. {
  2747. alert ("Time is not in a valid format.");
  2748. return false;
  2749. }
  2750. return true;
  2751. }
  2752. /*
  2753. Manually change time from almanac
  2754. */
  2755. function time_change(tmp)
  2756. {
  2757. if (isValidDate(document.planets.date_txt.value) == true)
  2758. {
  2759. var jd_temp, zz, ff, alpha, aa, bb, cc, dd, ee;
  2760. var calendar_day, calendar_month, calendar_year;
  2761. var int_day, hours, minutes;
  2762. var tm_as_str, ut_hrs, ut_mns, part_day;
  2763. var jd = julian_date();
  2764. tm_as_str = document.planets.ut_h_m.value;
  2765. ut_hrs = eval(tm_as_str.substring(0,2));
  2766. ut_mns = eval(tm_as_str.substring(3,5));
  2767. part_day = ut_hrs / 24.0 + ut_mns / 1440.0;
  2768. with (Math) {
  2769. jd_temp = jd + part_day + tmp / 24.0 + 0.5;
  2770. zz = floor(jd_temp);
  2771. ff = jd_temp - zz;
  2772. alpha = floor((zz - 1867216.25) / 36524.25);
  2773. aa = zz + 1 + alpha - floor(alpha / 4);
  2774. bb = aa + 1524;
  2775. cc = floor((bb - 122.1) / 365.25);
  2776. dd = floor(365.25 * cc);
  2777. ee = floor((bb - dd) / 30.6001);
  2778. calendar_day = bb - dd - floor(30.6001 * ee) + ff;
  2779. calendar_month = ee;
  2780. if (ee < 13.5) calendar_month = ee - 1;
  2781. if (ee > 13.5) calendar_month = ee - 13;
  2782. calendar_year = cc;
  2783. if (calendar_month > 2.5) calendar_year = cc - 4716;
  2784. if (calendar_month < 2.5) calendar_year = cc - 4715;
  2785. int_day = floor(calendar_day);
  2786. hours = (calendar_day - int_day) * 24;
  2787. minutes = floor((hours - floor(hours)) * 60 + 0.5);
  2788. hours = floor(hours);
  2789. if (minutes > 59)
  2790. {minutes = 0; hours = hours + 1;}
  2791. if (calendar_month < 10) calendar_month = "0" + calendar_month;
  2792. if (int_day < 10) int_day = "0" + int_day;
  2793. if (hours < 10) hours = "0" + floor(hours);
  2794. if (minutes < 10) minutes = "0" + minutes;
  2795. }
  2796. document.planets.date_txt.value = calendar_month + "/" + int_day + "/" + calendar_year;
  2797. document.planets.ut_h_m.value = hours + ":" + minutes;
  2798. planets();
  2799. return true;
  2800. }
  2801. else
  2802. {
  2803. return false;
  2804. }
  2805. }
  2806. /*
  2807. Calculate t-zone and compass direction of location
  2808. */
  2809. function zone_date_time()
  2810. {
  2811. var jd_temp, zz, ff, alpha, aa, bb, cc, dd, ee;
  2812. var calendar_day, calendar_month, calendar_year;
  2813. var int_day, hours, minutes, daylight_saving;
  2814. var d_of_w, dow_str, x, y, lat_long = "", dst = 0;
  2815. var tm_as_str, ut_hrs, ut_mns, part_day;
  2816. var jd = julian_date();
  2817. tm_as_str = document.planets.ut_h_m.value;
  2818. ut_hrs = eval(tm_as_str.substring(0,2));
  2819. ut_mns = eval(tm_as_str.substring(3,5));
  2820. part_day = ut_hrs / 24.0 + ut_mns / 1440.0;
  2821. with (Math) {
  2822. x = floor(abs(latitude));
  2823. y = floor((abs(latitude) - x) * 60 + 0.5);
  2824. if (x < 10) lat_long += "0";
  2825. lat_long = lat_long + x + "\u00B0" + " ";
  2826. if (y < 10) lat_long += "0";
  2827. lat_long = lat_long + y + "\'";
  2828. if (latitude >= 0)
  2829. {
  2830. lat_long += " N ";
  2831. }
  2832. else
  2833. {
  2834. lat_long += " S ";
  2835. }
  2836. x = floor(abs(longitude));
  2837. y = floor((abs(longitude) - x) * 60 + 0.5);
  2838. if (x < 100) lat_long += "0";
  2839. if (x < 10) lat_long += "0";
  2840. lat_long = lat_long + x + "\u00B0" + " ";
  2841. if (y < 10) lat_long += "0";
  2842. lat_long = lat_long + y + "\'";
  2843. if (longitude >= 0)
  2844. {
  2845. lat_long += " W";
  2846. }
  2847. else
  2848. {
  2849. lat_long += " E";
  2850. }
  2851. document.planets.lat_long.value = lat_long;
  2852. daylight_saving = document.planets.d_s_t.checked;
  2853. if (daylight_saving == true)
  2854. {
  2855. dst = 1;
  2856. zone = t_zone + dst;
  2857. }
  2858. else
  2859. {
  2860. zone = t_zone;
  2861. }
  2862. document.planets.timezone.value = zone;
  2863. jd_temp = jd + part_day + zone / 24 + 0.5;
  2864. d_of_w = floor(jd_temp + 1.0) % 7;
  2865. if (d_of_w == 0) dow_str = "Sun.";
  2866. if (d_of_w == 1) dow_str = "Mon.";
  2867. if (d_of_w == 2) dow_str = "Tue.";
  2868. if (d_of_w == 3) dow_str = "Wed.";
  2869. if (d_of_w == 4) dow_str = "Thu.";
  2870. if (d_of_w == 5) dow_str = "Fri.";
  2871. if (d_of_w == 6) dow_str = "Sat.";
  2872. zz = floor(jd_temp);
  2873. ff = jd_temp - zz;
  2874. alpha = floor((zz - 1867216.25) / 36524.25);
  2875. aa = zz + 1 + alpha - floor(alpha / 4);
  2876. bb = aa + 1524;
  2877. cc = floor((bb - 122.1) / 365.25);
  2878. dd = floor(365.25 * cc);
  2879. ee = floor((bb - dd) / 30.6001);
  2880. calendar_day = bb - dd - floor(30.6001 * ee) + ff;
  2881. calendar_month = ee;
  2882. if (ee < 13.5) calendar_month = ee - 1;
  2883. if (ee > 13.5) calendar_month = ee - 13;
  2884. calendar_year = cc;
  2885. if (calendar_month > 2.5) calendar_year = cc - 4716;
  2886. if (calendar_month < 2.5) calendar_year = cc - 4715;
  2887. int_day = floor(calendar_day);
  2888. hours = (calendar_day - int_day) * 24;
  2889. minutes = floor((hours - floor(hours)) * 60 + 0.5);
  2890. hours = floor(hours);
  2891. if (minutes > 59)
  2892. {minutes = 0; hours = hours + 1;}
  2893. if (calendar_month < 10) calendar_month = "0" + calendar_month;
  2894. if (int_day < 10) int_day = "0" + int_day;
  2895. }
  2896. document.planets.date_zone.value = dow_str + " " + calendar_month + "/" + int_day + "/" + calendar_year + " " + am_pm(hours + minutes / 60.0);
  2897. }
  2898. function dst () {
  2899. var arr = [];
  2900. for (var i = 0; i < 365; i++) {
  2901. var d = new Date();
  2902. d.setDate(i);
  2903. newoffset1 = d.getTimezoneOffset();
  2904. arr.push(newoffset1);
  2905. }
  2906. DST = Math.min.apply(null, arr);
  2907. nonDST = Math.max.apply(null, arr);
  2908. var dstDate = new Date();
  2909. var newOffset = dstDate.getTimezoneOffset();
  2910. if (DST == newOffset) {
  2911. document.getElementById("d_s_t").checked = true;
  2912. }
  2913. }
  2914. /*
  2915. Convert UT to am/pm
  2916. */
  2917. function am_pm(h)
  2918. {
  2919. with (Math) {
  2920. var hours, minutes, ampm, result="";
  2921. hours = floor(h);
  2922. minutes = floor((h - hours) * 60 + 0.5);
  2923. if (minutes == 60)
  2924. {
  2925. hours += 1;
  2926. minutes = 0;
  2927. }
  2928. if (hours > 11)
  2929. {
  2930. hours -= 12;
  2931. ampm = " pm";
  2932. }
  2933. else
  2934. {ampm = " am";}
  2935. if (hours < 1) hours = 12;
  2936. if (hours < 10)
  2937. {result = result + "0" + floor(hours);}
  2938. else
  2939. {result = result + floor(hours);}
  2940. result = result + ":";
  2941. if (minutes < 10)
  2942. {result = result + "0" + minutes;}
  2943. else
  2944. {result = result + minutes;}
  2945. }
  2946. result = result + ampm;
  2947. return result;
  2948. }
  2949. /*
  2950. Find julian Moon date
  2951. */
  2952. function julian_date()
  2953. {
  2954. var dt_as_str, mm, dd, yy;
  2955. var a, b;
  2956. dt_as_str = document.planets.date_txt.value;
  2957. mm = eval(dt_as_str.substring(0,2));
  2958. dd = eval(dt_as_str.substring(3,5));
  2959. yy = eval(dt_as_str.substring(6,10));
  2960. with (Math) {
  2961. var yyy=yy;
  2962. var mmm=mm;
  2963. if (mm < 3)
  2964. {
  2965. yyy = yy - 1;
  2966. mmm = mm + 12;
  2967. }
  2968. a = floor(yyy/100);
  2969. b = 2 - a + floor(a/4);
  2970. return floor(365.25*yyy) + floor(30.6001*(mmm+1)) + dd + 1720994.5 + b;
  2971. }
  2972. }
  2973. /*
  2974. find Julian t-zone
  2975. */
  2976. function julian_date_zoned()
  2977. {
  2978. var dt_as_str, mm, dd, yy;
  2979. var a, b;
  2980. dt_as_str = document.planets.date_zone.value;
  2981. mm = eval(dt_as_str.substring(5,7));
  2982. dd = eval(dt_as_str.substring(8,10));
  2983. yy = eval(dt_as_str.substring(11,15));
  2984. with (Math) {
  2985. var yyy=yy;
  2986. var mmm=mm;
  2987. if (mm < 3)
  2988. {
  2989. yyy = yy - 1;
  2990. mmm = mm + 12;
  2991. }
  2992. a = floor(yyy/100);
  2993. b = 2 - a + floor(a/4);
  2994. return floor(365.25*yyy) + floor(30.6001*(mmm+1)) + dd + 1720994.5 + b;
  2995. }
  2996. }
  2997. /*
  2998. Calculate moon age, phase, and other facts
  2999. */
  3000. function moon_facts()
  3001. {
  3002. with (Math) {
  3003. var dt_as_str, mm, yy, i, tmp, k, t;
  3004. var M, M1, F, NM_FM, FQ_LQ, RAD = 180 / PI;
  3005. var jd_temp, d_of_w, dow_str, zz, ff, alpha;
  3006. var aa, bb, cc, dd, ee, calendar_day, month;
  3007. var calendar_month, int_day, hours, minutes;
  3008. moon_data = "";
  3009. phase[0] = "New Moon ";
  3010. phase[1] = "Moon at first quarter ";
  3011. phase[2] = "Full Moon ";
  3012. phase[3] = "Moon at last quarter ";
  3013. dt_as_str = document.planets.date_txt.value;
  3014. yy = eval(dt_as_str.substring(6,10));
  3015. mm = eval(dt_as_str.substring(0,2));
  3016. dd = eval(dt_as_str.substring(3,5));
  3017. tmp = floor(((yy + (mm - 1) / 12 + dd / 365.25) - 1900.0) * 12.3685);
  3018. for (i=0; i<4; i++)
  3019. {
  3020. k = tmp + i * 0.25;
  3021. t = k / 1236.85;
  3022. M = proper_ang(359.2242 + 29.10535608 * k - 0.0000333 * pow(t,2) - 0.00000347 * pow(t,3)) / RAD;
  3023. M1 = proper_ang(306.0253 + 385.81691806 * k + 0.0107306 * pow(t,2) + 0.00001236 * pow(t,3)) / RAD;
  3024. F = proper_ang(21.2964 + 390.67050646 * k - 0.0016528 * pow(t,2) - 0.00000239 * pow(t,3)) / RAD;
  3025. NM_FM = (0.1734 - 0.000393 * t) * sin(M) + 0.0021 * sin(2 * M) - 0.4068 * sin(M1) + 0.0161 * sin(2 * M1) - 0.0004 * sin(3 * M1) + 0.0104 * sin(2 * F) - 0.0051 * sin(M + M1) - 0.0074 * sin(M - M1) + 0.0004 * sin(2 * F + M) - 0.0004 * sin(2 * F - M) - 0.0006 * sin(2 * F + M1) + 0.0010 * sin(2 * F - M1) + 0.0005 * sin(M + 2 * M1);
  3026. FQ_LQ = (0.1721 - 0.0004 * t) * sin(M) + 0.0021 * sin(2 * M) - 0.628 * sin(M1) + 0.0089 * sin(2 * M1) - 0.0004 * sin(3 * M1) + 0.0079 * sin(2 * F) - 0.0119 * sin(M + M1) - 0.0047 * sin(M - M1) + 0.0003 * sin(2 * F + M) - 0.0004 * sin(2 * F - M) - 0.0006 * sin(2 * F + M1) + 0.0021 * sin(2 * F - M1) + 0.0003 * sin(M + 2 * M1) + 0.0004 * sin(M - 2 * M1) - 0.0003 * sin(2 * M + M1);
  3027. phases[i] = 2415020.75933 + 29.53058868 * k + 0.0001178 * pow(t,2) - 0.000000155 * pow(t,3) + 0.00033 * sin(2.907 + 2.319 * t - 1.6e-4 * pow(t,2));
  3028. if (i == 0 || i == 2) phases[i] += NM_FM;
  3029. if (i == 1) phases[i] = phases[i] + FQ_LQ + 0.0028 - 0.0004 * cos(M) + 0.0003 * cos(M1);
  3030. if (i == 3) phases[i] = phases[i] + FQ_LQ - 0.0028 + 0.0004 * cos(M) - 0.0003 * cos(M1);
  3031. }
  3032. new_moon = phases[0];
  3033. for (i=0; i<4; i++)
  3034. {
  3035. jd_temp = phases[i] + 0.5;
  3036. d_of_w = floor(jd_temp + 1.0) % 7;
  3037. if (d_of_w == 0) dow_str = "Sun.";
  3038. if (d_of_w == 1) dow_str = "Mon.";
  3039. if (d_of_w == 2) dow_str = "Tue.";
  3040. if (d_of_w == 3) dow_str = "Wed.";
  3041. if (d_of_w == 4) dow_str = "Thu.";
  3042. if (d_of_w == 5) dow_str = "Fri.";
  3043. if (d_of_w == 6) dow_str = "Sat.";
  3044. zz = floor(jd_temp);
  3045. ff = jd_temp - zz;
  3046. alpha = floor((zz - 1867216.25) / 36524.25);
  3047. aa = zz + 1 + alpha - floor(alpha / 4);
  3048. bb = aa + 1524;
  3049. cc = floor((bb - 122.1) / 365.25);
  3050. dd = floor(365.25 * cc);
  3051. ee = floor((bb - dd) / 30.6001);
  3052. calendar_day = bb - dd - floor(30.6001 * ee) + ff;
  3053. calendar_month = ee;
  3054. if (ee < 13.5) calendar_month = ee - 1;
  3055. if (ee > 13.5) calendar_month = ee - 13;
  3056. calendar_year = cc;
  3057. if (calendar_month > 2.5) calendar_year = cc - 4716;
  3058. if (calendar_month < 2.5) calendar_year = cc - 4715;
  3059. int_day = floor(calendar_day);
  3060. hours = (calendar_day - int_day) * 24;
  3061. minutes = floor((hours - floor(hours)) * 60 + 0.5);
  3062. hours = floor(hours);
  3063. if (minutes > 59)
  3064. {minutes = 0; hours = hours + 1;}
  3065. if (hours < 10) hours = "0" + hours;
  3066. if (minutes < 10) minutes = "0" + minutes;
  3067. if (int_day < 10) int_day = "0" + int_day;
  3068. if (calendar_month == 1) month = "Jan.";
  3069. if (calendar_month == 2) month = "Feb.";
  3070. if (calendar_month == 3) month = "Mar.";
  3071. if (calendar_month == 4) month = "Apr.";
  3072. if (calendar_month == 5) month = "May ";
  3073. if (calendar_month == 6) month = "Jun.";
  3074. if (calendar_month == 7) month = "Jul.";
  3075. if (calendar_month == 8) month = "Aug.";
  3076. if (calendar_month == 9) month = "Sep.";
  3077. if (calendar_month == 10) month = "Oct.";
  3078. if (calendar_month == 11) month = "Nov.";
  3079. if (calendar_month == 12) month = "Dec.";
  3080. moon_data += dow_str + " " + month + " " + int_day + ", " + calendar_year + " " + phase[i] + "(" + hours + ":" + minutes + " UT)";
  3081. if (i == 1 || i == 3)
  3082. {
  3083. moon_data += "\n"
  3084. }
  3085. else
  3086. {
  3087. moon_data += " ";
  3088. }
  3089. }
  3090. }
  3091. }
  3092. /*
  3093. Calculate planet location's based on user location, along with values for R.A., Dec, etc.
  3094. */
  3095. function planets()
  3096. {
  3097. with (Math) {
  3098. var RAD = 180 / PI;
  3099. document.planets.size6.value = "";
  3100. document.planets.size7.value = "";
  3101. document.planets.phase7.value = "";
  3102. document.planets.phase6.value = "";
  3103. document.planets.dawn.value = "";
  3104. document.planets.dusk.value = "";
  3105. document.planets.tr0.value = "...";
  3106. document.planets.tr1.value = "...";
  3107. document.planets.tr2.value = "...";
  3108. document.planets.tr3.value = "...";
  3109. document.planets.tr4.value = "...";
  3110. document.planets.tr5.value = "...";
  3111. document.planets.tr6.value = "...";
  3112. var planet_dec = new Array(9);
  3113. var planet_ra = new Array(9);
  3114. var planet_dist = new Array(9);
  3115. var planet_phase = new Array(9);
  3116. var planet_size = new Array(9);
  3117. var planet_alt = new Array(9);
  3118. var planet_az = new Array(9);
  3119. var ang_at_1au = [1,6.68,16.82,9.36,196.94,166.6];
  3120. var planet_a = new Array(5);
  3121. var planet_l = new Array(5);
  3122. var planet_i = new Array(5);
  3123. var planet_e = new Array(5);
  3124. var planet_n = new Array(5);
  3125. var planet_m = new Array(5);
  3126. var planet_r = new Array(5);
  3127. var jd, t, l, m, e, c, sl, r, R, Rm, u, p, q, v, z, a, b, ee, oe, t0, gt;
  3128. var g0, x, y, i, indx, count, hl, ha, eg, et, dr, en, de, ra, la, lo, height;
  3129. var az, al, size, il, dist, rho_sin_lat, rho_cos_lat, rise_str, set_str;
  3130. var dawn, dusk, gt_dawn, gt_dusk, dawn_planets, dusk_planets, morn, eve;
  3131. var sunrise_set, moonrise_set, twilight_begin_end, twilight_start, twilight_end;
  3132. var sat_lat, phase_angle, dt_as_str, tm_as_str, ut_hrs, ut_mns, part_day, dt;
  3133. var moon_days, Days, age, N, M_sun, Ec, lambdasun, P0, N0, rise, set, tr, h0;
  3134. var i_m, e_m, l_m, M_m, N_m, Ev, Ae, A3, A4, lambda_moon, beta_moon, phase;
  3135. var transit, lambda_transit, beta_transit, ra_transit;
  3136. var ra_np, d_beta, d_lambda, lambda_moon_D, beta_moon_D, yy;
  3137. la = latitude / RAD;
  3138. lo = longitude / RAD;
  3139. height = 10.0;
  3140. tm_as_str = document.planets.ut_h_m.value;
  3141. ut_hrs = eval(tm_as_str.substring(0,2));
  3142. ut_mns = eval(tm_as_str.substring(3,5));
  3143. dt_as_str = document.planets.date_txt.value;
  3144. yy = eval(dt_as_str.substring(6,10));
  3145. part_day = ut_hrs / 24.0 + ut_mns / 1440.0;
  3146. jd = julian_date() + part_day;
  3147. document.planets.phase8.value = round_1000(jd);
  3148. y = floor(yy / 50 + 0.5) * 50;
  3149. if (y == 1600) dt = 2;
  3150. if (y == 1650) dt = 0.8;
  3151. if (y == 1700) dt = 0.1;
  3152. if (y == 1750) dt = 0.2;
  3153. if (y == 1800) dt = 0.2;
  3154. if (y == 1850) dt = 0.1;
  3155. if (y == 1900) dt = 0;
  3156. if (y == 1950) dt = 0.5;
  3157. if (y == 2000) dt = 1.1;
  3158. if (y == 2050) dt = 3;
  3159. if (y == 2100) dt = 5;
  3160. if (y == 2150) dt = 6;
  3161. if (y == 2200) dt = 8;
  3162. if (y == 2250) dt = 11;
  3163. if (y == 2300) dt = 13;
  3164. if (y == 2350) dt = 16;
  3165. if (y == 2400) dt = 19;
  3166. dt = dt / 1440;
  3167. jd += dt;
  3168. zone_date_time();
  3169. moon_facts();
  3170. t=(jd-2415020.0)/36525;
  3171. oe=.409319747-2.271109689e-4*t-2.8623e-8*pow(t,2)+8.779e-9*pow(t,3);
  3172. t0=(julian_date()-2415020.0)/36525;
  3173. g0=.276919398+100.0021359*t0+1.075e-6*pow(t0,2);
  3174. g0=(g0-floor(g0))*2*PI;
  3175. gt=proper_ang_rad(g0+part_day*6.30038808);
  3176. l=proper_ang_rad(4.88162797+628.331951*t+5.27962099e-6*pow(t,2));
  3177. m=proper_ang_rad(6.2565835+628.3019457*t-2.617993878e-6*pow(t,2)-5.759586531e-8*pow(t,3));
  3178. e=.01675104-4.18e-5*t-1.26e-7*pow(t,2);
  3179. c=proper_ang_rad(3.3500896e-2-8.358382e-5*t-2.44e-7*pow(t,2))*sin(m)+(3.50706e-4-1.7e-6*t)*sin(2*m)+5.1138e-6*sin(3*m);
  3180. sl=proper_ang_rad(l+c);
  3181. R=1.0000002*(1-pow(e,2))/(1+e*cos(m+c));
  3182. de = asin(sin(oe) * sin(sl));
  3183. y = sin(sl) * cos(oe);
  3184. x = cos(sl);
  3185. ra = proper_ang_rad(atan2(y,x));
  3186. dist = R;
  3187. size = 31.9877 / dist;
  3188. ha=proper_ang_rad(gt-lo-ra);
  3189. al=asin(sin(la)*sin(de)+cos(la)*cos(de)*cos(ha));
  3190. az=acos((sin(de)-sin(la)*sin(al))/(cos(la)*cos(al)));
  3191. if (sin(ha)>=0) az=2*PI-az;
  3192. planet_decl[0] = de;
  3193. planet_r_a[0] = ra;
  3194. planet_mag[0] = -26.7;
  3195. planet_dec[8] = "";
  3196. planet_ra[8] = "";
  3197. planet_dist[8] = "";
  3198. planet_size[8] = "";
  3199. planet_alt[8] = "";
  3200. planet_az[8] = "";
  3201. y = sin(-0.8333/RAD) - sin(la) * sin(de);
  3202. x = cos(la) * cos(de);
  3203. if (y/x >= 1)
  3204. {
  3205. //rise_str = "No rise";
  3206. //set_str = "No rise";
  3207. h0 = 0;
  3208. }
  3209. if (y/x <= -1)
  3210. {
  3211. //rise_str = "No set";
  3212. //set_str = "No set";
  3213. h0 = 0;
  3214. }
  3215. if (abs(y/x) < 1)
  3216. {
  3217. h0 = acos(y/x) * RAD;
  3218. tr = range_1((ra * RAD + lo * RAD - g0 * RAD) / 360);
  3219. document.planets.tr0.value = am_pm(range_1(tr + zone / 24 - dt) * 24);
  3220. document.planets.tr0_2.value = am_pm(range_1(tr + zone / 24 - dt) * 24);
  3221. }
  3222. y = sin(-18/RAD) - sin(la) * sin(de);
  3223. x = cos(la) * cos(de);
  3224. if (y/x >= 1)
  3225. {
  3226. twilight_start = "No twilight";
  3227. twilight_end = "No twilight";
  3228. h0 = 0;
  3229. }
  3230. if (y/x <= -1)
  3231. {
  3232. twilight_start = "All night";
  3233. twilight_end = "All night";
  3234. h0 = 0;
  3235. }
  3236. if (abs(y/x) < 1)
  3237. {
  3238. h0 = acos(y/x) * RAD;
  3239. tr = range_1((ra * RAD + lo * RAD - g0 * RAD) / 360);
  3240. twilight_start = am_pm(range_1(tr - h0 / 360 + zone / 24 - dt) * 24);
  3241. twilight_end = am_pm(range_1(tr + h0 / 360 + zone / 24 - dt) * 24);
  3242. }
  3243. al = al * RAD;
  3244. az = az * RAD;
  3245. if (al >= 0)
  3246. {
  3247. al += 1.2 / (al + 2);
  3248. }
  3249. else
  3250. {
  3251. al += 1.2 / (abs(al) + 2);
  3252. }
  3253. planet_altitude[0] = al;
  3254. planet_azimuth[0] = az;
  3255. de = de * RAD;
  3256. ra = ra * RAD / 15;
  3257. x = round_10(abs(de));
  3258. if (de < 0)
  3259. {
  3260. planet_dec[8] += "-";
  3261. }
  3262. else
  3263. {
  3264. planet_dec[8] += "+";
  3265. }
  3266. if (x < 10) planet_dec[8] += "0";
  3267. planet_dec[8] += x;
  3268. if (x == floor(x)) planet_dec[8] += ".0";
  3269. planet_dec[8] += "\u00B0";
  3270. x = floor(ra);
  3271. y = floor((ra - x) * 60 + 0.5);
  3272. if (y == 60)
  3273. {
  3274. x += 1;
  3275. y = 0;
  3276. }
  3277. if (x < 10) planet_ra[8] += "0";
  3278. planet_ra[8] += x + "h ";
  3279. if (y < 10) planet_ra[8] += "0";
  3280. planet_ra[8] += y + "m";
  3281. dist = round_100(dist);
  3282. if (dist < 10)
  3283. planet_dist[8] += "0";
  3284. planet_dist[8] += dist;
  3285. size = round_10(size);
  3286. planet_size[8] += size;
  3287. if (size == floor(size)) planet_size[8] += ".0";
  3288. planet_size[8] += "\'";
  3289. sunrise_set = sun_rise_set(la,lo,zone);
  3290. rise_str = sunrise_set.substring(0,8);
  3291. set_str = sunrise_set.substring(11,19);
  3292. planet_alt[8] = rise_str;
  3293. planet_az[8] = set_str;
  3294. /*
  3295. planet_alt[8] = rise_str;
  3296. planet_az[8] = set_str;
  3297. sunrise_set = rise_str + " / " + set_str;
  3298. */
  3299. moon_days = 29.53058868;
  3300. Days = jd - 2444238.5;
  3301. N = proper_ang(Days / 1.01456167);
  3302. M_sun = proper_ang(N - 3.762863);
  3303. Ec = 1.91574168 * sin(M_sun / RAD);
  3304. lambdasun = proper_ang(N + Ec + 278.83354);
  3305. l0 = 64.975464;
  3306. P0 = 349.383063;
  3307. N0 = 151.950429;
  3308. i_m = 5.145396;
  3309. e_m = 0.0549;
  3310. l_m = proper_ang(13.1763966 * Days + l0);
  3311. M_m = proper_ang(l_m - 0.111404 * Days - P0);
  3312. N_m = proper_ang(N0 - 0.0529539 * Days);
  3313. Ev = 1.2739 * sin((2 * (l_m - lambdasun) - M_m) / RAD);
  3314. Ae = 0.1858 * sin(M_sun / RAD);
  3315. A3 = 0.37 * sin(M_sun / RAD);
  3316. M_m += Ev - Ae - A3;
  3317. Ec = 6.2886 * sin(M_m / RAD);
  3318. dist = hundred_miles(238855.7 * (1 - pow(e_m,2)) / (1 + e_m * cos((M_m + Ec) / RAD)));
  3319. A4 = 0.214 * sin(2 * M_m / RAD);
  3320. l_m += Ev + Ec - Ae + A4;
  3321. l_m += 0.6583 * sin(2 * (l_m - lambdasun) / RAD);
  3322. N_m -= 0.16 * sin(M_sun / RAD);
  3323. y = sin((l_m - N_m) / RAD) * cos(i_m / RAD);
  3324. x = cos((l_m - N_m) / RAD);
  3325. lambda_moon = proper_ang_rad(atan2(y,x) + N_m / RAD);
  3326. beta_moon = asin(sin((l_m - N_m) / RAD) * sin(i_m / RAD));
  3327. d_beta = 8.727e-4 * cos((l_m - N_m) / RAD);
  3328. d_lambda = 9.599e-3 + 1.047e-3 * cos(M_m / RAD);
  3329. de = asin(sin(beta_moon) * cos(oe) + cos(beta_moon) * sin(oe) * sin(lambda_moon));
  3330. y = sin(lambda_moon) * cos(oe) - tan(beta_moon) * sin(oe);
  3331. x = cos(lambda_moon);
  3332. ra = proper_ang_rad(atan2(y,x));
  3333. ra_np = ra;
  3334. size = 2160 / dist * RAD * 60;
  3335. x = proper_ang(l_m - lambdasun);
  3336. phase = 50.0 * (1.0 - cos(x / RAD));
  3337. age = jd - new_moon;
  3338. if (age > moon_days) age -= moon_days;
  3339. if (age < 0) age += moon_days;
  3340. /*
  3341. age = (x / 360 * moon_days);
  3342. */
  3343. Rm = R - dist * cos(x / RAD) / 92955800;
  3344. phase_angle = acos((pow(Rm,2) + pow((dist/92955800),2) - pow(R,2)) / (2 * Rm * dist/92955800)) * RAD / 100;
  3345. planet_mag[6] = round_10(0.21 + 5 * log(Rm * dist / 92955800)/log(10) + 3.05 * (phase_angle) - 1.02 * pow(phase_angle,2) + 1.05 * pow(phase_angle,3));
  3346. if (planet_mag[6] == floor(planet_mag[6])) planet_mag[6] += ".0";
  3347. /*
  3348. thisImage = floor(age / moon_days * 28);
  3349. */
  3350. thisImage = floor(age / moon_days * 27 + 0.5);
  3351. document.myPicture.src = myImage[thisImage];
  3352. age = round_10(age);
  3353. x = atan(0.996647 * tan(la));
  3354. rho_sin_lat = 0.996647 * sin(x) + height * sin(la) / 6378140;
  3355. rho_cos_lat = cos(x) + height * cos(la) / 6378140;
  3356. r = dist / 3963.2;
  3357. ha = proper_ang_rad(gt - lo - ra);
  3358. x = atan(rho_cos_lat * sin(ha) / (r * cos(de) - rho_cos_lat * cos(ha)));
  3359. ra -= x;
  3360. y = ha;
  3361. ha += x;
  3362. de = atan(cos(ha) * (r * sin(de) - rho_sin_lat) / (r * cos(de) * cos(y) - rho_cos_lat));
  3363. ha = proper_ang_rad(gt - lo - ra);
  3364. al = asin(sin(de) * sin(la) + cos(de) * cos(la) * cos(ha));
  3365. az = acos((sin(de) - sin(la) * sin(al)) / (cos(la) * cos(al)));
  3366. if (sin(ha) >= 0) az = 2 * PI - az;
  3367. planet_decl[6] = de;
  3368. planet_r_a[6] = ra;
  3369. planet_dec[9] = "";
  3370. planet_ra[9] = "";
  3371. planet_dist[9] = "";
  3372. planet_dist[6] = "";
  3373. planet_phase[9] = "";
  3374. planet_size[9] = "";
  3375. planet_alt[9] = "";
  3376. planet_az[9] = "";
  3377. lambda_moon_D = lambda_moon - d_lambda * part_day * 24;
  3378. beta_moon_D = beta_moon - d_beta * part_day * 24;
  3379. tr = range_1((ra_np * RAD + lo * RAD - g0 * RAD) / 360);
  3380. transit = tr * 24;
  3381. lambda_transit = lambda_moon_D + transit * d_lambda;
  3382. beta_transit = beta_moon_D + transit * d_beta;
  3383. y = sin(lambda_transit) * cos(oe) - tan(beta_transit) * sin(oe);
  3384. x = cos(lambda_transit);
  3385. ra_transit = proper_ang_rad(atan2(y,x));
  3386. tr = range_1((ra_transit * RAD + lo * RAD - g0 * RAD) / 360);
  3387. document.planets.tr6.value = am_pm(range_1(tr + zone / 24 - dt) * 24);
  3388. document.planets.tr6_2.value = am_pm(range_1(tr + zone / 24 - dt) * 24);
  3389. al = al * RAD;
  3390. az = az * RAD;
  3391. if (al >= 0)
  3392. {
  3393. al += 1.2 / (al + 2);
  3394. }
  3395. else
  3396. {
  3397. al += 1.2 / (abs(al) + 2);
  3398. }
  3399. planet_altitude[6] = al;
  3400. planet_azimuth[6] = az;
  3401. de = de * RAD;
  3402. ra = ra * RAD / 15;
  3403. x = round_10(abs(de));
  3404. if (de < 0)
  3405. {
  3406. planet_dec[9] += "-";
  3407. }
  3408. else
  3409. {
  3410. planet_dec[9] += "+";
  3411. }
  3412. if (x < 10) planet_dec[9] += "0";
  3413. planet_dec[9] += x;
  3414. if (x == floor(x)) planet_dec[9] += ".0";
  3415. planet_dec[9] += "\u00B0";
  3416. x = floor(ra);
  3417. y = floor((ra - x) * 60 + 0.5);
  3418. if (y == 60)
  3419. {
  3420. x += 1;
  3421. y = 0;
  3422. }
  3423. if (x < 10) planet_ra[9] += "0";
  3424. planet_ra[9] += x + "h ";
  3425. if (y < 10) planet_ra[9] += "0";
  3426. planet_ra[9] += y + "m";
  3427. if (age < 10)
  3428. planet_dist[6] += "0";
  3429. planet_dist[6] += age;
  3430. if (age == floor(age)) planet_dist[6] += ".0";
  3431. planet_dist[6] += " days";
  3432. planet_dist[9] += dist;
  3433. size = round_10(size);
  3434. planet_size[9] += size;
  3435. if (size == floor(size)) planet_size[9] += ".0";
  3436. planet_size[9] += "\'";
  3437. phase = floor(phase + 0.5);
  3438. planet_phase[9] += phase + "%";
  3439. moonrise_set = moon_rise_set(la,lo,zone);
  3440. rise_str = moonrise_set.substring(0,8);
  3441. set_str = moonrise_set.substring(11,19);
  3442. planet_alt[9] = rise_str;
  3443. planet_az[9] = set_str;
  3444. if (twilight_start == "All night")
  3445. {
  3446. twilight_begin_end = "twilight all night";
  3447. }
  3448. else if (twilight_start == "No twilight")
  3449. {
  3450. twilight_begin_end = "Sky dark for 24h";
  3451. }
  3452. else
  3453. {
  3454. twilight_begin_end = twilight_start + " / " + twilight_end;
  3455. }
  3456. u=t/5+.1;
  3457. p=proper_ang_rad(4.14473024+52.96910393*t);
  3458. q=proper_ang_rad(4.64111846+21.32991139*t);
  3459. v=5*q-2*p;
  3460. z=proper_ang_rad(q-p);
  3461. if (v >= 0)
  3462. {
  3463. v=proper_ang_rad(v);
  3464. }
  3465. else
  3466. {
  3467. v=proper_ang_rad(abs(v))+2*PI;
  3468. }
  3469. planet_a[1]=0.3870986;
  3470. planet_l[1]=proper_ang_rad(3.109811569+2608.814681*t+5.2552e-6*pow(t,2));
  3471. planet_e[1]=.20561421+2.046e-5*t-3e-8*pow(t,2);
  3472. planet_i[1]=.12222333+3.247708672e-5*t-3.194e-7*pow(t,2);
  3473. planet_n[1]=.822851951+.020685787*t+3.035127569e-6*pow(t,2);
  3474. planet_m[1]=proper_ang_rad(1.785111938+2608.787533*t+1.22e-7*pow(t,2));
  3475. planet_a[2]=0.7233316;
  3476. planet_l[2]=proper_ang_rad(5.982413642+1021.352924*t+5.4053e-6*pow(t,2));
  3477. planet_e[2]=.00682069-4.774e-5*t+9.1e-8*pow(t,2);
  3478. planet_i[2]=.059230034+1.75545e-5*t-1.7e-8*pow(t,2);
  3479. planet_n[2]=1.322604346+.0157053*t+7.15585e-6*pow(t,2);
  3480. planet_m[2]=proper_ang_rad(3.710626189+1021.328349*t+2.2445e-5*pow(t,2));
  3481. planet_a[3]=1.5236883;
  3482. planet_l[3]=proper_ang_rad(5.126683614+334.0856111*t+5.422738e-6*pow(t,2));
  3483. planet_e[3]=.0933129+9.2064e-5*t-7.7e-8*pow(t,2);
  3484. planet_i[3]=.032294403-1.178097e-5*t+2.199e-7*pow(t,2);
  3485. planet_n[3]=.851484043+.013456343*t-2.44e-8*pow(t,2)-9.3026e-8*pow(t,3);
  3486. planet_m[3]=proper_ang_rad(5.576660841+334.0534837*t+3.159e-6*pow(t,2));
  3487. planet_l[4]=proper_ang_rad(4.154743317+52.99346674*t+5.841617e-6*pow(t,2)-2.8798e-8*pow(t,3));
  3488. a=.0058*sin(v)-1.1e-3*u*cos(v)+3.2e-4*sin(2*z)-5.8e-4*cos(z)*sin(q)-6.2e-4*sin(z)*cos(q)+2.4e-4*sin(z);
  3489. b=-3.5e-4*cos(v)+5.9e-4*cos(z)*sin(q)+6.6e-4*sin(z)*cos(q);
  3490. ee=3.6e-4*sin(v)-6.8e-4*sin(z)*sin(q);
  3491. planet_e[4]=.04833475+1.6418e-4*t-4.676e-7*pow(t,2)-1.7e-9*pow(t,3);
  3492. planet_a[4]=5.202561+7e-4*cos(2*z);
  3493. planet_i[4]=.022841752-9.941569952e-5*t+6.806784083e-8*pow(t,2);
  3494. planet_n[4]=1.735614994+.017637075*t+6.147398691e-6*pow(t,2)-1.485275193e-7*pow(t,3);
  3495. planet_m[4]=proper_ang_rad(3.932721257+52.96536753*t-1.26012772e-5*pow(t,2));
  3496. planet_m[4]=proper_ang_rad(planet_m[4]+a-b/planet_e[4]);
  3497. planet_l[4]=proper_ang_rad(planet_l[4]+a);
  3498. planet_e[4]=planet_e[4]+ee;
  3499. planet_a[5]=9.554747;
  3500. planet_l[5]=proper_ang_rad(4.652426047+21.35427591*t+5.663593422e-6*pow(t,2)-1.01229e-7*pow(t,3));
  3501. a=-.014*sin(v)+2.8e-3*u*cos(v)-2.6e-3*sin(z)-7.1e-4*sin(2*z)+1.4e-3*cos(z)*sin(q);
  3502. a=a+1.5e-3*sin(z)*cos(q)+4.4e-4*cos(z)*cos(q);
  3503. a=a-2.7e-4*sin(3*z)-2.9e-4*sin(2*z)*sin(q)+2.6e-4*cos(2*z)*sin(q);
  3504. a=a+2.5e-4*cos(2*z)*cos(q);
  3505. b=1.4e-3*sin(v)+7e-4*cos(v)-1.3e-3*sin(z)*sin(q);
  3506. b=b-4.3e-4*sin(2*z)*sin(q)-1.3e-3*cos(q)-2.6e-3*cos(z)*cos(q)+4.7e-4*cos(2*z)*cos(q);
  3507. b=b+1.7e-4*cos(3*z)*cos(q)-2.4e-4*sin(z)*sin(2*q);
  3508. b=b+2.3e-4*cos(2*z)*sin(2*q)-2.3e-4*sin(z)*cos(2*q)+2.1e-4*sin(2*z)*cos(2*q);
  3509. b=b+2.6e-4*cos(z)*cos(2*q)-2.4e-4*cos(2*z)*cos(2*q);
  3510. planet_l[5]=proper_ang_rad(planet_l[5]+a);
  3511. planet_e[5]=.05589232-3.455e-4*t-7.28e-7*pow(t,2)+7.4e-10*pow(t,3);
  3512. planet_i[5]=.043502663-6.839770806e-5*t-2.703515011e-7*pow(t,2)+6.98e-10*pow(t,3);
  3513. planet_n[5]=1.968564089+.015240129*t-2.656042056e-6*pow(t,2)-9.2677e-8*pow(t,3);
  3514. planet_m[5]=proper_ang_rad(3.062463265+21.32009513*t-8.761552845e-6*pow(t,2));
  3515. planet_m[5]=proper_ang_rad(planet_m[5]+a-b/planet_e[5]);
  3516. planet_a[5]=planet_a[5]+.0336*cos(z)-.00308*cos(2*z)+.00293*cos(v);
  3517. planet_e[5]=planet_e[5]+1.4e-3*cos(v)+1.2e-3*sin(q)+2.7e-3*cos(z)*sin(q)-1.3e-3*sin(z)*cos(q);
  3518. for (i=1; i<6; i++)
  3519. {
  3520. e = planet_m[i];
  3521. for (count = 1; count <= 50; count++)
  3522. {
  3523. de = e - planet_e[i] * sin(e) - planet_m[i];
  3524. if (abs(de) <= 5e-8) break;
  3525. e = e - de / (1 - planet_e[i] * cos(e));
  3526. }
  3527. v=2*atan(sqrt((1+planet_e[i])/(1-planet_e[i]))*tan(e/2));
  3528. planet_r[i]=planet_a[i]*(1-planet_e[i]*cos(e));
  3529. u=proper_ang_rad(planet_l[i]+v-planet_m[i]-planet_n[i]);
  3530. x=cos(planet_i[i])*sin(u);
  3531. y=cos(u);
  3532. y=acos(y/sqrt(pow(x,2)+pow(y,2)));
  3533. if (x<0) y=2*PI-y;
  3534. hl=proper_ang_rad(y+planet_n[i]);
  3535. ha=asin(sin(u)*sin(planet_i[i]));
  3536. x=planet_r[i]*cos(ha)*sin(proper_ang_rad(hl-sl));
  3537. y=planet_r[i]*cos(ha)*cos(proper_ang_rad(hl-sl))+R;
  3538. y=acos(y/sqrt(pow(x,2)+pow(y,2)));
  3539. if (x<0) y=2*PI-y;
  3540. eg=proper_ang_rad(y+sl);
  3541. dr=sqrt(pow(R,2)+pow(planet_r[i],2)+2*planet_r[i]*R*cos(ha)*cos(proper_ang_rad(hl-sl)));
  3542. size=ang_at_1au[i]/dr;
  3543. il=floor((pow((planet_r[i]+dr),2)-pow(R,2))/(4*planet_r[i]*dr)*100+.5);
  3544. phase_angle=acos((pow(planet_r[i],2)+pow(dr,2)-pow(R,2))/(2*planet_r[i]*dr))*RAD;
  3545. et=asin(planet_r[i]/dr*sin(ha));
  3546. en=acos(cos(et)*cos(proper_ang_rad(eg-sl)));
  3547. de=asin(sin(et)*cos(oe)+cos(et)*sin(oe)*sin(eg));
  3548. y=cos(eg);
  3549. x=sin(eg)*cos(oe)-tan(et)*sin(oe);
  3550. y=acos(y/sqrt(pow(x,2)+pow(y,2)));
  3551. if (x<0) y=2*PI-y;
  3552. ra=y;
  3553. ha=proper_ang_rad(gt-lo-ra);
  3554. al=asin(sin(la)*sin(de)+cos(la)*cos(de)*cos(ha));
  3555. az=acos((sin(de)-sin(la)*sin(al))/(cos(la)*cos(al)));
  3556. if (sin(ha)>=0) az=2*PI-az;
  3557. planet_decl[i] = de;
  3558. planet_r_a[i] = ra;
  3559. planet_mag[i]=5*log(planet_r[i]*dr)/log(10);
  3560. if (i == 1) planet_mag[i] = -0.42 + planet_mag[i] + 0.038*phase_angle - 0.000273*pow(phase_angle,2) + 0.000002*pow(phase_angle,3);
  3561. if (i == 2) planet_mag[i] = -4.4 + planet_mag[i] + 0.0009*phase_angle + 0.000239*pow(phase_angle,2) - 0.00000065*pow(phase_angle,3);
  3562. if (i == 3) planet_mag[i] = -1.52 + planet_mag[i] + 0.016*phase_angle;
  3563. if (i == 4) planet_mag[i] = -9.4 + planet_mag[i] + 0.005*phase_angle;
  3564. if (i == 5)
  3565. {
  3566. sat_lat = asin(0.47063*cos(et)*sin(eg-2.9585)-0.88233*sin(et));
  3567. planet_mag[i] = -8.88 + planet_mag[i] + 0.044*phase_angle - 2.6*sin(abs(sat_lat)) + 1.25*pow(sin(sat_lat),2);
  3568. }
  3569. planet_mag[i] = round_10(planet_mag[i]);
  3570. if (planet_mag[i] == floor(planet_mag[i])) planet_mag[i] += ".0";
  3571. if (planet_mag[i] >= 0) planet_mag[i] = "+" + planet_mag[i];
  3572. planet_dec[i] = "";
  3573. planet_ra[i] = "";
  3574. planet_dist[i] = "";
  3575. planet_size[i] = "";
  3576. planet_phase[i] = "";
  3577. planet_alt[i] = "";
  3578. planet_az[i] = "";
  3579. y = sin(-0.5667/RAD) - sin(la) * sin(de);
  3580. x = cos(la) * cos(de);
  3581. if (y/x >= 1)
  3582. {
  3583. rise_str = "No rise";
  3584. set_str = "No rise";
  3585. h0 = 0;
  3586. }
  3587. if (y/x <= -1)
  3588. {
  3589. rise_str = "No set";
  3590. set_str = "No set";
  3591. h0 = 0;
  3592. }
  3593. if (abs(y/x) < 1)
  3594. {
  3595. h0 = acos(y/x) * RAD;
  3596. tr = range_1((ra * RAD + lo * RAD - g0 * RAD) / 360);
  3597. rise_str = am_pm(range_1(tr - h0 / 360 + zone / 24 - dt) * 24);
  3598. set_str = am_pm(range_1(tr + h0 / 360 + zone / 24 - dt) * 24);
  3599. tr = am_pm(range_1(tr + zone / 24 - dt) * 24);
  3600. if (i == 1) document.planets.tr1.value = tr;
  3601. if (i == 2) document.planets.tr2.value = tr;
  3602. if (i == 3) document.planets.tr3.value = tr;
  3603. if (i == 4) document.planets.tr4.value = tr;
  3604. if (i == 5) document.planets.tr5.value = tr;
  3605. if (i == 1) document.planets.tr1_2.value = tr;
  3606. if (i == 2) document.planets.tr2_2.value = tr;
  3607. if (i == 3) document.planets.tr3_2.value = tr;
  3608. if (i == 4) document.planets.tr4_2.value = tr;
  3609. if (i == 5) document.planets.tr5_2.value = tr;
  3610. }
  3611. al = al * RAD;
  3612. az = az * RAD;
  3613. planet_altitude[i] = al;
  3614. planet_azimuth[i] = az;
  3615. de = de * RAD;
  3616. ra = ra * RAD / 15;
  3617. x = round_10(abs(de));
  3618. if (de < 0)
  3619. {
  3620. planet_dec[i] += "-";
  3621. }
  3622. else
  3623. {
  3624. planet_dec[i] += "+";
  3625. }
  3626. if (x < 10) planet_dec[i] += "0";
  3627. planet_dec[i] += x;
  3628. if (x == floor(x)) planet_dec[i] += ".0";
  3629. planet_dec[i] += "\u00B0";
  3630. x = floor(ra);
  3631. y = floor((ra - x) * 60 + 0.5);
  3632. if (y == 60)
  3633. {
  3634. x += 1;
  3635. y = 0;
  3636. }
  3637. if (x < 10) planet_ra[i] += "0";
  3638. planet_ra[i] += x + "h ";
  3639. if (y < 10) planet_ra[i] += "0";
  3640. planet_ra[i] += y + "m";
  3641. dr = round_100(dr);
  3642. if (dr < 10)
  3643. planet_dist[i] += "0";
  3644. planet_dist[i] += dr;
  3645. size = round_10(size);
  3646. if (size < 10)
  3647. planet_size[i] += "0";
  3648. planet_size[i] += size;
  3649. if (size == floor(size)) planet_size[i] += ".0";
  3650. planet_size[i] += "\"";
  3651. planet_phase[i] += il + "%";
  3652. planet_alt[i] = rise_str;
  3653. planet_az[i] = set_str;
  3654. }
  3655. dawn_planets = "";
  3656. dusk_planets = "";
  3657. phenomena = "";
  3658. y = sin(-9/RAD) - sin(la) * sin(planet_decl[0]);
  3659. x = cos(la) * cos(planet_decl[0]);
  3660. if (y/x >= 1)
  3661. {
  3662. dawn_planets = "-----";
  3663. dusk_planets = "-----";
  3664. }
  3665. if (y/x <= -1)
  3666. {
  3667. dawn_planets = "-----";
  3668. dusk_planets = "-----";
  3669. }
  3670. if (abs(y/x) < 1)
  3671. {
  3672. h0 = acos(y/x) * RAD;
  3673. tr = range_1((planet_r_a[0] * RAD + lo * RAD - g0 * RAD) / 360);
  3674. dawn = range_1(tr - h0 / 360 - dt);
  3675. dusk = range_1(tr + h0 / 360 - dt);
  3676. }
  3677. gt_dawn = proper_ang_rad(g0 + dawn * 6.30038808);
  3678. gt_dusk = proper_ang_rad(g0 + dusk * 6.30038808);
  3679. indx = 0;
  3680. morn = 0;
  3681. eve = 0;
  3682. for (i=0; i<17; i++)
  3683. {
  3684. if (i < 6)
  3685. {
  3686. ha = proper_ang_rad(gt_dawn - lo - planet_r_a[i]);
  3687. al = asin(sin(la) * sin(planet_decl[i]) + cos(la) * cos(planet_decl[i]) * cos(ha));
  3688. if (al >= 0)
  3689. {
  3690. if (morn > 0) dawn_planets += ", ";
  3691. dawn_planets += planet_name[i];
  3692. morn ++;
  3693. }
  3694. ha = proper_ang_rad(gt_dusk - lo - planet_r_a[i]);
  3695. al = asin(sin(la) * sin(planet_decl[i]) + cos(la) * cos(planet_decl[i]) * cos(ha));
  3696. if (al >= 0)
  3697. {
  3698. if (eve > 0) dusk_planets += ", ";
  3699. dusk_planets += planet_name[i];
  3700. eve ++;
  3701. }
  3702. }
  3703. x = round_10(acos(sin(planet_decl[6]) * sin(planet_decl[i]) + cos(planet_decl[6]) * cos(planet_decl[i]) * cos(planet_r_a[6] - planet_r_a[i])) * RAD);
  3704. if (x <= 10 && i != 6)
  3705. {
  3706. if (indx > 0) phenomena += " and ";
  3707. if (x < 1)
  3708. {
  3709. phenomena += "less than 1";
  3710. }
  3711. else
  3712. {
  3713. phenomena += floor(x + 0.5);
  3714. }
  3715. phenomena += "\u00B0" + " from " + planet_name[i];
  3716. if (x < 0.5)
  3717. {
  3718. if (i == 0)
  3719. {
  3720. phenomena += " (eclipse possible)";
  3721. }
  3722. else
  3723. {
  3724. phenomena += " (occultation possible)";
  3725. }
  3726. }
  3727. indx ++
  3728. }
  3729. }
  3730. if (dawn_planets == "") dawn_planets = "-----";
  3731. if (dusk_planets == "") dusk_planets = "-----";
  3732. if (indx > 0)
  3733. {
  3734. phenomena = "The Moon is " + phenomena + ". ";
  3735. }
  3736. indx = 0;
  3737. for (i=1; i<16; i++)
  3738. {
  3739. for (count=i+1; count<17; count++)
  3740. {
  3741. if (i != 6 && count != 6)
  3742. {
  3743. x = round_10(acos(sin(planet_decl[count]) * sin(planet_decl[i]) + cos(planet_decl[count]) * cos(planet_decl[i]) * cos(planet_r_a[count] - planet_r_a[i])) * RAD);
  3744. if (x <= 5)
  3745. {
  3746. if (indx > 0) phenomena += " and ";
  3747. phenomena += planet_name[count] + " is ";
  3748. if (x < 1)
  3749. {
  3750. phenomena += "less than 1";
  3751. }
  3752. else
  3753. {
  3754. phenomena += floor(x + 0.5);
  3755. }
  3756. phenomena += "\u00B0" + " from " + planet_name[i];
  3757. indx ++
  3758. }
  3759. x = 0;
  3760. }
  3761. }
  3762. }
  3763. if (indx > 0) phenomena += ".";
  3764. if (jd > 2454048.3007 && jd < 2454048.5078)
  3765. {
  3766. phenomena += "\nMercury is transiting the face of the Sun. ";
  3767. x = round_10((2454048.50704 - jd) * 24);
  3768. if (x >= 0.1)
  3769. {
  3770. phenomena += "The spectacle continues for a further " + x + " hours."
  3771. }
  3772. }
  3773. if (phenomena != "") { phenomena += "\n"; }
  3774. if (planet_altitude[0] < -18) phenomena += "The sky is dark. ";
  3775. if (planet_altitude[0] >= -18 && planet_altitude[0] < -12) phenomena += "The Sun is below the horizon (altitude " + floor(planet_altitude[0] + 0.5) + "\u00B0) and the sky is in deep twilight. ";
  3776. if (planet_altitude[0] >= -12 && planet_altitude[0] < -6) phenomena += "The Sun is below the horizon (altitude " + floor(planet_altitude[0] + 0.5) + "\u00B0) and the sky is in twilight. ";
  3777. if (planet_altitude[0] >= -6 && planet_altitude[0] < -0.3) phenomena += "The Sun is below the horizon (altitude " + floor(planet_altitude[0] + 0.5) + "\u00B0) and the sky is in bright twilight. ";
  3778. if (planet_altitude[0] >= -0.3) phenomena += "The Sun is above the horizon (altitude " + floor(planet_altitude[0] + 0.5) + "\u00B0). ";
  3779. if (planet_altitude[6] >= -0.3) phenomena += "The Moon is above the horizon (altitude " + floor(planet_altitude[6] + 0.5) + "\u00B0). ";
  3780. if (planet_altitude[6] < -0.3) phenomena += "The Moon is below the horizon. ";
  3781. phenomena += "\n";
  3782. phenomena += moon_data;
  3783. /* Commented out 2009-specific events 2010/01/27 - DAF
  3784. phenomena += "-----\n2009 Phenomena\n";
  3785. phenomena += "yyyy mm dd hh UT All dates and times are UT\n"
  3786. + "2009 01 02 04 UT Mercury at greatest illuminated extent (evening)\n"
  3787. + "2009 01 03 13 UT Meteor shower peak -- Quadrantids\n"
  3788. + "2009 01 04 14 UT Mercury at greatest elongation, 19.3\u00B0 east of Sun (evening)\n"
  3789. + "2009 01 04 16 UT Earth at perihelion 91,400,939 miles (147,095,552 km)\n"
  3790. + "2009 01 10 11 UT Moon at perigee, 222,137 miles (357,495 km)\n"
  3791. + "2009 01 14 21 UT Venus at greatest elongation, 47.1\u00B0 east of Sun (evening)\n"
  3792. + "2009 01 23 00 UT Moon at apogee, 252,350 miles (406,118 km)\n"
  3793. + "2009 01 26 Annular eclipse of the Sun (South Atlantic, Indonesia)\n"
  3794. + "2009 02 07 20 UT Moon at perigee, 224,619 miles (361,489 km)\n"
  3795. + "2009 02 09 14:38 UT Penumbral lunar eclipse (midtime)\n"
  3796. + "2009 02 11 01 UT Mercury at greatest illuminated extent (morning)\n"
  3797. + "2009 02 13 21 UT Mercury at greatest elongation, 26.1\u00B0 west of Sun (morning)\n"
  3798. + "2009 02 19 16 UT Venus at greatest illuminated extent (evening)\n"
  3799. + "2009 02 19 17 UT Moon at apogee, 251,736 miles (405,129 km)\n"
  3800. + "2009 03 07 15 UT Moon at perigee, 228,053 miles (367,016 km)\n"
  3801. + "2009 03 08 20 UT Saturn at opposition\n"
  3802. + "2009 03 19 13 UT Moon at apogee, 251,220 miles (404,299 km)\n"
  3803. + "2009 03 20 11:44 UT Spring (Northern Hemisphere) begins at the equinox\n"
  3804. + "2009 03 27 19 UT Venus at inferior conjunction with Sun\n"
  3805. + "2009 04 02 02 UT Moon at perigee, 229,916 miles (370,013 km)\n"
  3806. + "2009 04 13 05 UT Mercury at greatest illuminated extent (evening)\n"
  3807. + "2009 04 16 09 UT Moon at apogee, 251,178 miles (404,232 km)\n"
  3808. + "2009 04 22 11 UT Meteor shower peak -- Lyrids\n"
  3809. + "2009 04 26 08 UT Mercury at greatest elongation, 20.4\u00B0 east of Sun (evening)\n"
  3810. + "2009 04 28 06 UT Moon at perigee, 227,446 miles (366,039 km)\n"
  3811. + "2009 05 02 14 UT Venus at greatest illuminated extent (morning)\n"
  3812. + "2009 05 06 00 UT Meteor shower peak -- Eta Aquarids\n"
  3813. + "2009 05 14 03 UT Moon at apogee, 251,603 miles (404,915 km)\n"
  3814. + "2009 05 26 04 UT Moon at perigee, 224,410 miles (361,153 km)\n"
  3815. + "2009 06 05 21 UT Venus at greatest elongation, 45.8\u00B0 west of Sun (morning)\n"
  3816. + "2009 06 10 16 UT Moon at apogee, 252,144 miles (405,787 km)\n"
  3817. + "2009 06 13 12 UT Mercury at greatest elongation, 23.5\u00B0 west of Sun (morning)\n"
  3818. + "2009 06 21 05:46 UT Summer (Northern Hemisphere) begins at the solstice\n"
  3819. + "2009 06 23 11 UT Moon at perigee, 222,459 miles (358,013 km)\n"
  3820. + "2009 07 03 21 UT Mercury at greatest illuminated extent (morning)\n"
  3821. + "2009 07 04 02 UT Earth at aphelion 94,505,048 miles (152,091,132 km)\n"
  3822. + "2009 07 07 09:39 UT Penumbral lunar eclipse (too slight to see)\n"
  3823. + "2009 07 07 22 UT Moon at apogee, 252,421 miles (406,232 km)\n"
  3824. + "2009 07 21 20 UT Moon at perigee, 222,118 miles (357,464 km)\n"
  3825. + "2009 07 22 Total solar eclipse (India, China, and a few Pacific islands)\n"
  3826. + "2009 07 28 02 UT Meteor shower peak -- Delta Aquarids\n"
  3827. + "2009 08 04 01 UT Moon at apogee, 252,294 miles (406,028 km)\n"
  3828. + "2009 08 06 00:39 UT Weak penumbral lunar eclipse (midtime)\n"
  3829. + "2009 08 12 17 UT Meteor shower peak -- Perseids\n"
  3830. + "2009 08 14 18 UT Jupiter at opposition\n"
  3831. + "2009 08 17 21 UT Neptune at opposition\n"
  3832. + "2009 08 19 05 UT Moon at perigee, 223,469 miles (359,638 km)\n"
  3833. + "2009 08 24 16 UT Mercury at greatest elongation, 27.4\u00B0 east of Sun (evening)\n"
  3834. + "2009 08 26 09 UT Mercury at greatest illuminated extent (evening)\n"
  3835. + "2009 08 31 11 UT Moon at apogee, 251,823 miles (405,269 km)\n"
  3836. + "2009 09 16 08 UT Moon at perigee, 226,211 miles (364,052 km)\n"
  3837. + "2009 09 17 09 UT Uranus at opposition\n"
  3838. + "2009 09 22 21:19 UT Fall (Northern Hemisphere) begins at the equinox\n"
  3839. + "2009 09 28 04 UT Moon at apogee, 251,302 miles (404,432 km)\n"
  3840. + "2009 10 06 02 UT Mercury at greatest elongation, 17.9\u00B0 west of Sun (morning)\n"
  3841. + "2009 10 11 07 UT Mercury at greatest illuminated extent (morning)\n"
  3842. + "2009 10 13 12 UT Moon at perigee, 229,327 miles (369,066 km)\n"
  3843. + "2009 10 21 10 UT Meteor shower peak -- Orionids\n"
  3844. + "2009 10 25 23 UT Moon at apogee, 251,137 miles (404,166 km)\n"
  3845. + "2009 11 05 10 UT Meteor shower peak -- Southern Taurids\n"
  3846. + "2009 11 07 07 UT Moon at perigee, 229,225 miles (368,902 km)\n"
  3847. + "2009 11 12 10 UT Meteor shower peak -- Northern Taurids\n"
  3848. + "2009 11 17 15 UT Meteor shower peak -- Leonids\n"
  3849. + "2009 11 22 20 UT Moon at apogee, 251,489 miles (404,733 km)\n"
  3850. + "2009 12 04 14 UT Moon at perigee, 225,856 miles (363,481 km)\n"
  3851. + "2009 12 14 05 UT Meteor shower peak -- Geminids\n"
  3852. + "2009 12 17 13 UT Mercury at greatest illuminated extent (evening)\n"
  3853. + "2009 12 18 17 UT Mercury at greatest elongation, 20.3\u00B0 east of Sun (evening)\n"
  3854. + "2009 12 20 15 UT Moon at apogee, 252,109 miles (405,731 km)\n"
  3855. + "2009 12 21 17:47 UT Winter (Northern Hemisphere) begins at the solstice\n"
  3856. + "2009 12 31 Partial lunar eclipse, 18:52 UT to 19:54 UT\n-----\n";
  3857. END Comment DAF */
  3858. document.planets.ra1.value = planet_ra[1];
  3859. document.planets.dec1.value = planet_dec[1];
  3860. document.planets.dist1.value = planet_mag[1];
  3861. document.planets.size1.value = planet_size[1];
  3862. document.planets.phase1.value = planet_phase[1];
  3863. document.planets.alt1.value = planet_alt[1];
  3864. document.planets.az1.value = planet_az[1];
  3865. document.planets.ra1_2.value = planet_ra[1];
  3866. document.planets.dec1_2.value = planet_dec[1];
  3867. document.planets.dist1_2.value = planet_mag[1];
  3868. document.planets.size1_2.value = planet_size[1];
  3869. document.planets.phase1_2.value = planet_phase[1];
  3870. document.planets.alt1_2.value = planet_alt[1];
  3871. document.planets.az1_2.value = planet_az[1];
  3872. document.planets.ra2.value = planet_ra[2];
  3873. document.planets.dec2.value = planet_dec[2];
  3874. document.planets.dist2.value = planet_mag[2];
  3875. document.planets.size2.value = planet_size[2];
  3876. document.planets.phase2.value = planet_phase[2];
  3877. document.planets.alt2.value = planet_alt[2];
  3878. document.planets.az2.value = planet_az[2];
  3879. document.planets.ra2_2.value = planet_ra[2];
  3880. document.planets.dec2_2.value = planet_dec[2];
  3881. document.planets.dist2_2.value = planet_mag[2];
  3882. document.planets.size2_2.value = planet_size[2];
  3883. document.planets.phase2_2.value = planet_phase[2];
  3884. document.planets.alt2_2.value = planet_alt[2];
  3885. document.planets.az2_2.value = planet_az[2];
  3886. document.planets.ra3.value = planet_ra[3];
  3887. document.planets.dec3.value = planet_dec[3];
  3888. document.planets.dist3.value = planet_mag[3];
  3889. document.planets.size3.value = planet_size[3];
  3890. document.planets.phase3.value = planet_phase[3];
  3891. document.planets.alt3.value = planet_alt[3];
  3892. document.planets.az3.value = planet_az[3];
  3893. document.planets.ra3_2.value = planet_ra[3];
  3894. document.planets.dec3_2.value = planet_dec[3];
  3895. document.planets.dist3_2.value = planet_mag[3];
  3896. document.planets.size3_2.value = planet_size[3];
  3897. document.planets.phase3_2.value = planet_phase[3];
  3898. document.planets.alt3_2.value = planet_alt[3];
  3899. document.planets.az3_2.value = planet_az[3];
  3900. document.planets.ra4.value = planet_ra[4];
  3901. document.planets.dec4.value = planet_dec[4];
  3902. document.planets.dist4.value = planet_mag[4];
  3903. document.planets.size4.value = planet_size[4];
  3904. // document.planets.phase4.value = planet_phase[4];
  3905. document.planets.alt4.value = planet_alt[4];
  3906. document.planets.az4.value = planet_az[4];
  3907. document.planets.ra4_2.value = planet_ra[4];
  3908. document.planets.dec4_2.value = planet_dec[4];
  3909. document.planets.dist4_2.value = planet_mag[4];
  3910. document.planets.size4_2.value = planet_size[4];
  3911. // document.planets.phase4_2.value = planet_phase[4];
  3912. document.planets.alt4_2.value = planet_alt[4];
  3913. document.planets.az4_2.value = planet_az[4];
  3914. document.planets.ra5.value = planet_ra[5];
  3915. document.planets.dec5.value = planet_dec[5];
  3916. document.planets.dist5.value = planet_mag[5];
  3917. document.planets.size5.value = planet_size[5];
  3918. // document.planets.phase5.value = planet_phase[5];
  3919. document.planets.alt5.value = planet_alt[5];
  3920. document.planets.az5.value = planet_az[5];
  3921. document.planets.ra5_2.value = planet_ra[5];
  3922. document.planets.dec5_2.value = planet_dec[5];
  3923. document.planets.dist5_2.value = planet_mag[5];
  3924. document.planets.size5_2.value = planet_size[5];
  3925. // document.planets.phase5_2.value = planet_phase[5];
  3926. document.planets.alt5_2.value = planet_alt[5];
  3927. document.planets.az5_2.value = planet_az[5];
  3928. document.planets.dist6.value = planet_dist[6];
  3929. document.planets.size6.value = sunrise_set;
  3930. document.planets.phase6.value = phenomena;
  3931. document.planets.dawn.value = dawn_planets;
  3932. document.planets.dusk.value = dusk_planets;
  3933. document.planets.size7.value = moonrise_set;
  3934. document.planets.phase7.value = twilight_begin_end;
  3935. document.planets.ra8.value = planet_ra[8];
  3936. document.planets.dec8.value = planet_dec[8];
  3937. document.planets.dist8.value = planet_mag[0];
  3938. document.planets.size8.value = planet_size[8];
  3939. document.planets.alt8.value = planet_alt[8];
  3940. document.planets.az8.value = planet_az[8];
  3941. document.planets.ra8_2.value = planet_ra[8];
  3942. document.planets.dec8_2.value = planet_dec[8];
  3943. document.planets.dist8_2.value = planet_mag[0];
  3944. document.planets.size8_2.value = planet_size[8];
  3945. document.planets.alt8_2.value = planet_alt[8];
  3946. document.planets.az8_2.value = planet_az[8];
  3947. document.planets.ra9.value = planet_ra[9];
  3948. document.planets.dec9.value = planet_dec[9];
  3949. document.planets.dist9.value = planet_mag[6];
  3950. document.planets.size9.value = planet_size[9];
  3951. document.planets.phase9.value = planet_phase[9];
  3952. document.planets.alt9.value = planet_alt[9];
  3953. document.planets.az9.value = planet_az[9];
  3954. document.planets.ra9_2.value = planet_ra[9];
  3955. document.planets.dec9_2.value = planet_dec[9];
  3956. document.planets.dist9_2.value = planet_mag[6];
  3957. document.planets.size9_2.value = planet_size[9];
  3958. document.planets.phase9_2.value = planet_phase[9];
  3959. document.planets.alt9_2.value = planet_alt[9];
  3960. document.planets.az9_2.value = planet_az[9];
  3961. }
  3962. }
  3963. /*
  3964. Calculate time for moonrise/moonset
  3965. */
  3966. function moon_rise_set(latitude,longitude,tzone)
  3967. {
  3968. with (Math) {
  3969. var r_a = new Array(3);
  3970. var dec = new Array(3);
  3971. var dist = new Array(3);
  3972. var i, c0, p1, p2, r1, RAD, k1, b5, l5, h, z0, t, t0;
  3973. var s, l, m, f, d, n, g, v, u, w, a5, d5, r5, z1, c, z, m8, w8;
  3974. var a0, d0, p, f0, f1, f2, a, b, a2, d2, l0, l2, h0, h2, d1;
  3975. var v0=0, v1=0, v2=0, e, t3, rise_str = "", set_str = "";
  3976. p1 = PI;
  3977. p2 = 2 * p1;
  3978. r1 = PI / 180;
  3979. RAD = 1 / r1;
  3980. k1 = 15 * r1 * 1.002738;
  3981. b5 = latitude * RAD;
  3982. l5 = longitude * RAD;
  3983. h = tzone;
  3984. l5 = -l5 / 360;
  3985. z0 = -h / 24;
  3986. t = (julian_date_zoned() - 2451545.0);
  3987. t0 = t / 36525;
  3988. s = (24110.5 + 8640184.813 * t0 + 86636.6 * z0 + 86400 * l5) / 86400;
  3989. s = s - floor(s);
  3990. t0 = s * 360 * r1;
  3991. t = t + z0;
  3992. for (i=1; i<4; i++)
  3993. {
  3994. l = 0.606434 + 0.036601 * t;
  3995. m = 0.374897 + 0.036292 * t;
  3996. f = 0.259091 + 0.036748 * t;
  3997. d = 0.827362 + 0.033863 * t;
  3998. n = 0.347343 - 1.470939e-04 * t;
  3999. g = 0.993126 + 2.737778e-03 * t;
  4000. l = (l - floor(l)) * p2;
  4001. m = (m - floor(m)) * p2;
  4002. f = (f - floor(f)) * p2;
  4003. d = (d - floor(d)) * p2;
  4004. n = (n - floor(n)) * p2;
  4005. g = (g - floor(g)) * p2;
  4006. v = 0.39558*sin(f+n) + 0.082*sin(f) + 0.03257*sin(m-f-n) + 0.01092*sin(m+f+n) + 6.66e-03*sin(m-f) - 6.44e-03*sin(m+f-2*d+n) - 3.31e-03*sin(f-2*d+n) - 3.04e-03*sin(f-2*d) - 2.4e-03*sin(m-f-2*d-n) + 2.26e-03*sin(m+f) - 1.08e-03*sin(m+f-2*d) - 7.9e-04*sin(f-n) + 7.8e-04*sin(f+2*d+n);
  4007. u = 1 - 0.10828*cos(m) - 0.0188*cos(m-2*d) - 0.01479*cos(2*d) + 1.81e-03*cos(2*m-2*d) - 1.47e-03*cos(2*m) - 1.05e-03*cos(2*d-g) - 7.5e-04*cos(m-2*d+g);
  4008. w = 0.10478*sin(m) - 0.04105*sin(2*f+2*n) - 0.0213*sin(m-2*d) - 0.01779*sin(2*f+n) + 0.01774*sin(n) + 9.87e-03*sin(2*d) - 3.38e-03*sin(m-2*f-2*n) - 3.09e-03*sin(g) - 1.9e-03*sin(2*f) - 1.44e-03*sin(m+n) - 1.44e-03*sin(m-2*f-n) - 1.13e-03*sin(m+2*f+2*n) - 9.4e-04*sin(m-2*d+g) - 9.2e-04*sin(2*m-2*d);
  4009. s = w / sqrt(u-v*v);
  4010. a5 = l + atan(s / sqrt(1-s*s));
  4011. s = v / sqrt(u);
  4012. d5 = atan(s / sqrt(1-s*s));
  4013. r5 = 60.40974 * sqrt(u);
  4014. r_a[i] = a5;
  4015. dec[i] = d5;
  4016. dist[i] = r5;
  4017. t += 0.5;
  4018. }
  4019. if (r_a[2] < r_a[1]) r_a[2] += p2;
  4020. if (r_a[3] < r_a[2]) r_a[3] += p2;
  4021. z1 = r1 * (90.567 - 41.685 / dist[2]);
  4022. s = sin(b5*r1);
  4023. c = cos(b5*r1);
  4024. z = cos(z1);
  4025. m8 = 0;
  4026. w8 = 0;
  4027. a0 = r_a[1];
  4028. d0 = dec[1];
  4029. for (c0=0; c0<24; c0++)
  4030. {
  4031. p = (c0 + 1) / 24;
  4032. f0 = r_a[1];
  4033. f1 = r_a[2];
  4034. f2 = r_a[3];
  4035. a = f1 - f0;
  4036. b = f2 - f1 - a;
  4037. f = f0 + p * (2 * a + b * (2 * p - 1));
  4038. a2 = f;
  4039. f0 = dec[1];
  4040. f1 = dec[2];
  4041. f2 = dec[3];
  4042. a = f1 - f0;
  4043. b = f2 - f1 - a;
  4044. f = f0 + p * (2 * a + b * (2 * p - 1));
  4045. d2 = f;
  4046. l0 = t0 + c0 * k1;
  4047. l2 = l0 + k1;
  4048. if (a2 < a0) a2 += p2;
  4049. h0 = l0 - a0;
  4050. h2 = l2 - a2;
  4051. h1 = (h2 + h0) / 2;
  4052. d1 = (d2 + d0) / 2;
  4053. if (c0 < 1) v0 = s * sin(d0) + c * cos(d0) * cos(h0) - z;
  4054. v2 = s * sin(d2) + c * cos(d2) * cos(h2) - z;
  4055. if (sign_of(v0) != sign_of(v2))
  4056. {
  4057. v1 = s * sin(d1) + c * cos(d1) * cos(h1) - z;
  4058. a = 2 * v2 - 4 * v1 + 2 * v0;
  4059. b = 4 * v1 - 3 * v0 - v2;
  4060. d = b * b - 4 * a * v0;
  4061. if (d >= 0)
  4062. {
  4063. d = sqrt(d);
  4064. e = (-b + d) / (2 * a);
  4065. if (e > 1 || e < 0) e = (-b - d) / (2 * a);
  4066. t3 = am_pm(c0 + e);
  4067. if (v0 < 0 && v2 > 0)
  4068. {
  4069. m8 = 1;
  4070. rise_str = t3;
  4071. }
  4072. if (v0 > 0 && v2 < 0)
  4073. {
  4074. w8 = 1;
  4075. set_str = t3;
  4076. }
  4077. }
  4078. }
  4079. a0 = a2;
  4080. d0 = d2;
  4081. v0 = v2;
  4082. }
  4083. if (m8 == 0 && w8 == 0)
  4084. {
  4085. if (v2 < 0)
  4086. {
  4087. rise_str = "down 24h";
  4088. set_str = "down 24h";
  4089. }
  4090. if (v2 > 0)
  4091. {
  4092. rise_str = " up 24h ";
  4093. set_str = " up 24h ";
  4094. }
  4095. }
  4096. else
  4097. {
  4098. if (m8 == 0) rise_str = " ------ ";
  4099. if (w8 == 0) set_str = " ------ ";
  4100. }
  4101. result = rise_str + " / " + set_str;
  4102. return result;
  4103. }
  4104. }
  4105. /*
  4106. Calculate time for sunrise/sunset
  4107. */
  4108. function sun_rise_set(latitude,longitude,tzone)
  4109. {
  4110. with (Math) {
  4111. var r_a = new Array(2);
  4112. var dec = new Array(2);
  4113. var p1 = PI;
  4114. var p2 = 2 * p1;
  4115. var dr = p1 / 180;
  4116. var RAD = 1 / dr;
  4117. var k1 = 15 * dr * 1.0027379;
  4118. var b5, l5, h, z0, t, tt, t0, s, l, g, v, u, w;
  4119. var a5, d5, z1, c, z, m8, w8, a0, d0, da, dd;
  4120. var c0, p, a2, d2, l0, l2, h0, h1, h2, d1;
  4121. var v0=0, v1=0, v2=0, a, b, d, e, t3;
  4122. var rise_str = "", set_str = "";
  4123. b5 = latitude * RAD;
  4124. l5 = longitude * RAD;
  4125. h = tzone;
  4126. l5 = -l5 / 360;
  4127. z0 = -h / 24;
  4128. t = (julian_date_zoned() - 2451545.0);
  4129. tt = t / 36525 + 1;
  4130. t0 = t / 36525;
  4131. s = (24110.5 + 8640184.813 * t0 + 86636.6 * z0 + 86400 * l5) / 86400;
  4132. s = s - floor(s);
  4133. t0 = s * 360 * dr;
  4134. t = t + z0;
  4135. l = .779072+.00273790931*t;
  4136. g = .993126+.0027377785*t;
  4137. l = (l-floor(l))*p2;
  4138. g = (g-floor(g))*p2;
  4139. v = .39785*sin(l)-.01000*sin(l-g)+.00333*sin(l+g)-.00021*tt*sin(l);
  4140. u = 1-.03349*cos(g)-.00014*cos(2*l)+.00008*cos(l);
  4141. w = -.00010-.04129*sin(2*l)+.03211*sin(g)+.00104*sin(2*l-g)-.00035*sin(2*l+g)-.00008*tt*sin(g);
  4142. s = w/sqrt(u-v*v);
  4143. a5 = l+atan(s/sqrt(1-s*s));
  4144. s = v/sqrt(u);
  4145. d5 = atan(s/sqrt(1-s*s));
  4146. r_a[1] = a5;
  4147. dec[1] = d5;
  4148. t = t + 1;
  4149. l = .779072+.00273790931*t;
  4150. g = .993126+.0027377785*t;
  4151. l = (l-floor(l))*p2;
  4152. g = (g-floor(g))*p2;
  4153. v = .39785*sin(l)-.01000*sin(l-g)+.00333*sin(l+g)-.00021*tt*sin(l);
  4154. u = 1-.03349*cos(g)-.00014*cos(2*l)+.00008*cos(l);
  4155. w = -.00010-.04129*sin(2*l)+.03211*sin(g)+.00104*sin(2*l-g)-.00035*sin(2*l+g)-.00008*tt*sin(g);
  4156. s = w/sqrt(u-v*v);
  4157. a5 = l+atan(s/sqrt(1-s*s));
  4158. s = v/sqrt(u);
  4159. d5 = atan(s/sqrt(1-s*s));
  4160. r_a[2] = a5;
  4161. dec[2] = d5;
  4162. if (r_a[2] < r_a[1]) r_a[2] += p2;
  4163. z1 = dr * 90.833;
  4164. s = sin(b5 * dr);
  4165. c = cos(b5 * dr);
  4166. z = cos(z1);
  4167. m8 = 0;
  4168. w8 = 0;
  4169. a0 = r_a[1];
  4170. d0 = dec[1];
  4171. da = r_a[2] - r_a[1];
  4172. dd = dec[2] - dec[1];
  4173. for (c0=0; c0<24; c0++)
  4174. {
  4175. p = (c0 + 1) / 24;
  4176. a2 = r_a[1] + p * da;
  4177. d2 = dec[1] + p * dd;
  4178. l0 = t0 + c0 * k1;
  4179. l2 = l0 + k1;
  4180. h0 = l0 - a0;
  4181. h2 = l2 - a2;
  4182. h1 = (h2 + h0) / 2;
  4183. d1 = (d2 + d0) / 2;
  4184. if (c0 < 1) v0 = s * sin(d0) + c * cos(d0) * cos(h0) - z;
  4185. v2 = s * sin(d2) + c * cos(d2) * cos(h2) - z;
  4186. if (sign_of(v0) != sign_of(v2))
  4187. {
  4188. v1 = s * sin(d1) + c * cos(d1) * cos(h1) - z;
  4189. a = 2 * v2 - 4 * v1 + 2 * v0;
  4190. b = 4 * v1 - 3 * v0 - v2;
  4191. d = b * b - 4 * a * v0;
  4192. if (d >= 0)
  4193. {
  4194. d = sqrt(d);
  4195. e = (-b + d) / (2 * a);
  4196. if (e > 1 || e < 0) e = (-b - d) / (2 * a);
  4197. t3 = am_pm(c0 + e);
  4198. if (v0 < 0 && v2 > 0)
  4199. {
  4200. m8 = 1;
  4201. rise_str = t3;
  4202. }
  4203. if (v0 > 0 && v2 < 0)
  4204. {
  4205. w8 = 1;
  4206. set_str = t3;
  4207. }
  4208. }
  4209. }
  4210. a0 = a2;
  4211. d0 = d2;
  4212. v0 = v2;
  4213. }
  4214. if (m8 == 0 && w8 == 0)
  4215. {
  4216. if (v2 < 0)
  4217. {
  4218. rise_str = "down 24h";
  4219. set_str = "down 24h";
  4220. }
  4221. if (v2 > 0)
  4222. {
  4223. rise_str = " up 24h ";
  4224. set_str = " up 24h ";
  4225. }
  4226. }
  4227. else
  4228. {
  4229. if (m8 == 0) rise_str = " ------ ";
  4230. if (w8 == 0) set_str = " ------ ";
  4231. }
  4232. result = rise_str + " / " + set_str;
  4233. return result;
  4234. }
  4235. }
  4236. /*
  4237. Get cookie data for loading location
  4238. */
  4239. function getCookie( name )
  4240. {
  4241. var start = document.cookie.indexOf( name + "=" );
  4242. var len = start + name.length + 1;
  4243. if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
  4244. return null;
  4245. }
  4246. if ( start == -1 ) return null;
  4247. var end = document.cookie.indexOf( ";", len );
  4248. if ( end == -1 ) end = document.cookie.length;
  4249. return decodeURI( document.cookie.substring( len, end ) );
  4250. }
  4251. /*
  4252. Set cookie data for loading location
  4253. */
  4254. function setCookie( name, value, expires, path, domain, secure )
  4255. {
  4256. var today = new Date();
  4257. today.setTime( today.getTime() );
  4258. if ( expires ) {
  4259. expires = expires * 1000 * 60 * 60 * 24;
  4260. }
  4261. var expires_date = new Date( today.getTime() + (expires) );
  4262. document.cookie = name+"="+ encodeURI( value ) +
  4263. ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
  4264. ( ( path ) ? ";path=" + path : "" ) +
  4265. ( ( domain ) ? ";domain=" + domain : "" ) +
  4266. ( ( secure ) ? ";secure" : "" );
  4267. }
  4268. /*
  4269. Delete cookies for new location
  4270. */
  4271. function deleteCookie( name, path, domain )
  4272. {
  4273. if ( getCookie( name ) ) document.cookie = name + "=" +
  4274. ( ( path ) ? ";path=" + path : "") +
  4275. ( ( domain ) ? ";domain=" + domain : "" ) +
  4276. ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  4277. }
  4278. /*
  4279. Save current location
  4280. */
  4281. function save_loc()
  4282. {
  4283. deleteCookie('almanac2latdeg','','');
  4284. deleteCookie('almanac2longdeg','','');
  4285. deleteCookie('almanac2tzonehours','','');
  4286. setCookie('almanac2latdeg',round_1000(latitude),365,'','','');
  4287. setCookie('almanac2longdeg',round_1000(longitude),365,'','','');
  4288. setCookie('almanac2tzonehours',t_zone,365,'','','');
  4289. alert("The current location has been saved.");
  4290. }
  4291. /*
  4292. Load saved location and reload window
  4293. */
  4294. function load_loc()
  4295. {
  4296. var full_custom_URL = "/wp-content/plugins/observing-tools/almanac/almanac.html?";
  4297. var display_saved_almanac;
  4298. var lat_deg = getCookie('almanac2latdeg');
  4299. var lng_deg = getCookie('almanac2longdeg');
  4300. var time_zone_hours = getCookie('almanac2tzonehours');
  4301. if (lat_deg == null && lng_deg == null)
  4302. {
  4303. alert ("Sorry, but you haven't saved a previous latitude and longitude. If you want the Almanac to remember the currently displayed location, please click the 'Save this?' link. Alternatively, enter a new latitude and longitude by clicking the 'New?' link.")
  4304. }
  4305. else
  4306. {
  4307. full_custom_URL += "latitude=" + lat_deg + "&";
  4308. full_custom_URL += "longitude=" + lng_deg + "&";
  4309. full_custom_URL += "tzone=" + time_zone_hours + "&";
  4310. full_custom_URL += "UTdate=" + document.planets.date_txt.value + "&";
  4311. full_custom_URL += "UTtime=" + document.planets.ut_h_m.value;
  4312. display_saved_almanac = window.open(full_custom_URL,'chooser');
  4313. }
  4314. }