/*
    Sun/Moon Calculator
    Version 4.2  28 December 2009
    Copyright 1998-2009 Jeff Conrad
*/
var
J2000=2451545.0,
EARTH_RADIUS=6378.137,
K_REFR=0.175,
F_CIRCUMPOLAR=9999,
F_SET_NO_EVENT=999,
F_TEST_NO_EVENT=99,
TIMES=0,
POSITIONS=1;
var
INVALID=0,
EXTENDED=1,
VALID=2;
var
HM_FORMAT_MSG="HM value (hh[:mm] [a|p[m]] or hh.nn [a|p[m]]) required",
UT_FORMAT_MSG="HM value (hh[:mm]) required for UT",
DMS_LAT_FORMAT_MSG="DMS value ([d]d[:mm[:ss]][N|S], [d]dmmss[.ss][N|S], or [d]d[.dd...][N|S]) required",
DMS_LON_FORMAT_MSG="DMS value ([dd]d[:mm[:ss]][E|W], [dd]dmmss[.ss][E|W], or [dd]d[.dd...][E|W]) required",
NUMERIC_FORMAT_MSG="Numeric value required";
var
VSPACE='<br><br>',
SP='&nbsp;',
SP2=SP+SP,
SP4=SP2+SP2,
PAD4='    ',
PAD8=PAD4+PAD4,
PAD12=PAD8+PAD4,
BR='<br>',
EM='<em>',
EME='</em>',
HT='\t',
LF='\n',
BODY_COLOR='#000040',
BG_COLOR='#ffffff',
STUB_COLOR='#ffffff',
STD_COLOR='#ffffff',
SUN_COLOR='#f4f4f4',
MOON_COLOR='#ffffff',
BORDER_LT='1px',
BORDER_MED='1px',
BORDER_BLD='2px',
H_PADDING='0.25em',
V_PADDING='0.3ex',
RS_CENTER='*',
DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"' + LF
+ '"http://www.w3.org/TR/html4/loose.dtd">',
CONTENT='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">',
SCRIPT='<script language="JavaScript" type="text/javascript">'+LF
+'var flags=new Object();'+LF
+'flags.use_popups=false;'+LF
+'function reformat(type)'+LF
+'{'+LF
+'    if(!opener||opener.closed){'+LF
+'        if(type=="places")'+LF
+'            alert('+LF
+'                  "Cannot reformat: the data no longer are valid"+"\\n"'+LF
+'+"Close this window and repeat the List Locations"+"\\n"'+LF
+'+"You may need to restart the Sun/Moon Calculator"'+LF
+'            );'+LF
+'        else '+LF
+'            alert('+LF
+'                  "Cannot reformat: the data no longer are valid"+"\\n"'+LF
+'+"Close this window and recalculate"+"\\n"'+LF
+'+"You may need to restart the Sun/Moon Calculator"'+LF
+'            );'+LF
+'}'+LF
+'    else{'+LF
+'        if(type=="places")'+LF
+'            opener.list_places("reformat")'+LF
+'        else'+LF
+'            opener.reformat_results(type)'+LF
+'        window.focus();'+LF
+'}'+LF
+'}'+LF
+'function set_calc_date(date)'+LF
+'{'+LF
+'    if(!opener||opener.closed)'+LF
+'        alert('+LF
+'              "Cannot set calculation date: the data no longer are valid"+"\\n"'+LF
+'+"Close this window and recalculate"+"\\n"'+LF
+'+"You may need to restart the Sun/Moon Calculator"'+LF
+'        );'+LF
+'    else{'+LF
+'        opener.set_calc_date(date);'+LF
+'        opener.focus();'+LF
+'}'+LF
+'}'+LF
+'function set_place(ndx)'+LF
+'{'+LF
+'    if(!opener||opener.closed)'+LF
+'        alert('+LF
+'              "Cannot set location: the data no longer are valid"+"\\n"'+LF
+'+"Close this window and repeat the List Locations"+"\\n"'+LF
+'+"You may need to restart the Sun/Moon Calculator"'+LF
+'        );'+LF
+'    else{'+LF
+'        opener.set_place(ndx);'+LF
+'        opener.clearSearchPattern();'+LF
+'        opener.setStdLocation();'+LF
+'        opener.focus();'+LF
+'}'+LF
+'}'+LF
+'function help(topic)'+LF
+'{'+LF
+'   var'+LF
+'       HelpWindow,'+LF
+'       url="SunMoonCalcHelp.htm",'+LF
+'       title="Help",'+LF
+'       wid=0.9*screen.availWidth,'+LF
+'       ht=0.87*screen.availHeight,'+LF
+'       xpos=0.02*screen.availWidth,'+LF
+'       ypos=0.005*screen.availHeight,'+LF
+'       win_size,'+LF
+'       win_attribs,'+LF
+'       win_features;'+LF
+'    if(topic)'+LF
+'        url+="#"+topic;'+LF
+'    if(flags.use_popups===true){'+LF
+'        win_size="height="+ht+",width="+wid;'+LF
+'        win_pos="left="+xpos+","+"top="+ypos;'+LF
+'        win_attribs="resizable=1,menubar=1,toolbar=1,status=1,scrollbars=1";'+LF
+'        win_features=win_size+","+win_pos+","+win_attribs;'+LF
+'        HelpWindow=window.open(url, title, win_features);'+LF
+'}'+LF
+'    else'+LF
+'        HelpWindow=window.open(url, title);'+LF
+'    HelpWindow.focus();'+LF
+'    return true;'+LF
+'}'+LF
+'</script>'+LF,
STYLE='<style type="text/css">'+LF
+'<!--'+LF
+PAD4+'body{'+LF
+PAD8+'margin-left: 2%;'+LF
+PAD8+'margin-right: 2%;'+LF
+PAD8+'color: '+BODY_COLOR+';'+LF
+PAD8+'background-color: '+BG_COLOR+';'+LF
+PAD4+'}'+LF
+PAD4+'a.help, a.dateTag, a.placeTag{cursor: pointer;}'+LF
+PAD4+'a.help:link, a.help:visited{text-decoration: none; color: '+BODY_COLOR+';}'+LF
+PAD4+'a.dateTag:link, a.dateTag:visited{text-decoration: none; color: #000040;}'+LF
+PAD4+'a.dateTag:hover{text-decoration: none; color: white; background: navy;}'+LF
+PAD4+'a.dateTag:active{text-decoration: none; font-style: italic; color: white; background: navy;}'+LF
+PAD4+'a.placeTag:link, a.placeTag:visited{text-decoration: none; color: #000040;}'+LF
+PAD4+'a.placeTag:hover{text-decoration: none; color: white; background: navy;}'+LF
+PAD4+'a.placeTag:active{text-decoration: none; font-style: italic; color: white; background: navy;}'+LF
+PAD4+'h2{color: navy;}'+LF
+PAD4+'h3{margin-top: 0; margin-bottom: 0.8ex; white-space: nowrap; color: navy;}'+LF
+PAD4+'h4{margin-top: 1.5ex; margin-bottom: 0.2ex; color: navy;}'+LF
+PAD4+'table{border: '+BORDER_BLD+' solid black; border-collapse: collapse;}'+LF
+PAD4+'thead{border-bottom: '+BORDER_MED+' solid black;}'+LF
+PAD4+'th{'+LF
+PAD8+'border: '+BORDER_MED+' solid black;'+LF
+PAD8+'padding-left: '+H_PADDING+';'+LF
+PAD8+'padding-right: '+H_PADDING+';'+LF
+PAD8+'padding-top: '+V_PADDING+';'+LF
+PAD8+'padding-bottom: '+V_PADDING+';'+LF
+PAD4+'}'+LF
+PAD4+'td{'+LF
+PAD8+'border-right: '+BORDER_MED+' solid black;'+LF
+PAD8+'border-bottom: '+BORDER_LT+' solid #bbb;'+LF
+PAD8+'padding-left: '+H_PADDING+';'+LF
+PAD8+'padding-right: '+H_PADDING+';'+LF
+PAD8+'padding-top: '+V_PADDING+';'+LF
+PAD8+'padding-bottom: '+V_PADDING+';'+LF
+PAD8+'white-space: nowrap;'+LF
+PAD4+'}'+LF
+PAD4+'colgroup{border-right: '+BORDER_BLD+' solid black;}'+LF
+PAD4+'colgroup.StubColumn{background-color: '+STUB_COLOR+';}'+LF
+PAD4+'colgroup.SunColumn{background-color: '+SUN_COLOR+';}'+LF
+PAD4+'colgroup.MoonColumn{background-color: '+MOON_COLOR+';}'+LF
+PAD4+'colgroup.StdColumn{background-color: '+STD_COLOR+';}'+LF
+'-->'+LF
+'</style>'+LF,
TIMES_TABLE1='<table>'+LF,
TIMES_TABLE_COLSPEC1='<colgroup span=2 class="StubColumn">'+LF
+PAD4+'<col align=left>'+LF
+PAD4+'<col align=left>'+LF
+'<colgroup span=9 class="SunColumn">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+'<colgroup span=8 class="MoonColumn">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="left">'+LF
+PAD4+'<col align="left">'+LF,
TIMES_TABLE2='<table>'+LF,
TIMES_TABLE_COLSPEC2='<colgroup span=2 class="StubColumn">'+LF
+PAD4+'<col align=left>'+LF
+PAD4+'<col align=left>'+LF
+'<colgroup span=9 class="SunColumn">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+'<colgroup span=9 class="MoonColumn">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="left">'+LF
+PAD4+'<col align="left">'+LF,
POS_TABLE='<table>'+LF,
POS_TABLE_COLSPEC='<colgroup span=1 class="StubColumn">'+LF
+PAD4+'<col align="right">'+LF
+'<colgroup span=4 class="SunColumn">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+'<colgroup span=5 class="MoonColumn">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF
+PAD4+'<col align="right">'+LF,
PLACES_TABLE='<table>'+LF,
PLACES_TABLE_COLSPEC1='<colgroup span=1 class="StubColumn">'+LF
+PAD4+'<col align=left>'+LF
+'<colgroup span=5 class="StdColumn">'+LF
+PAD4+'<col align=center>'+LF
+PAD4+'<col align=center>'+LF
+PAD4+'<col align=center>'+LF
+PAD4+'<col align=center>'+LF
+PAD4+'<col align=left>'+LF,
PLACES_TABLE_COLSPEC2='<colgroup span=2 class="StdColumn">'+LF
+PAD4+'<col align=left>'+LF
+PAD4+'<col align=left>'+LF,
TABLE_START='<table>',
TABLE_END='</table>',
THD='<thead>',
THDE='</thead>',
TBD='<tbody>',
TBDE='</tbody>',
TR=PAD4+'<tr>',
TR_R=PAD4+'<tr align="right">',
TRE=PAD4+'</tr>',
TH11=PAD8+"<th align=center>",
TH21=PAD8+'<th align=center rowspan=2>',
TH31=PAD8+'<th align=center rowspan=3>',
TH12=PAD8+'<th align=center colspan=2>',
TH13=PAD8+'<th align=center colspan=3>',
TH14=PAD8+'<th align=center colspan=4>',
TH15=PAD8+'<th align=center colspan=5>',
TH17=PAD8+'<th align=center colspan=7>',
TH18=PAD8+'<th align=center colspan=8>',
TH19=PAD8+'<th align=center colspan=9>',
THE='</th>',
TD=PAD8+'<td align="right">',
TD12=PAD8+'<td colspan=2 align="center">',
TD14=PAD8+'<td colspan=4 align="center">',
TD_C=PAD8+'<td align="center">',
TD_L=PAD8+'<td align="left">',
TD_R=PAD8+'<td align="right">',
TDE='</td>';
var
DEG='&deg;',
MDASH='&mdash;',
NDASH='&ndash;',
MINUS='&minus;',
PLUS='+';
var
Today,
copyright,
flags,
form,
debug_window=null,
mag_model,
PRINT_STYLE,
times_results,
positions_results,
place_list,
SaveState,
std_TZ_offset;
Date.J1970=2440587.50;
Date.prototype.setZeroHours=function()
{this.setHours(0);
this.setMinutes(0);
this.setSeconds(0);
this.setMilliseconds(0);
};
function getDecimalYear(time)
{var
date=new Date(time.DayToMsec()),
year=date.getFullYear(),
start=Date.UTC(year, 0, 1),
end=Date.UTC(year+1, 0, 1),
today=date.getTime();
return year+(today-start)/(end-start);
}
Date.prototype.setDateDecimalTime=function(year, month, day, time)
{var
hours,
minutes,
seconds;
hours=Math.floor(time);
minutes=(time-hours)*60;
seconds=Math.round((minutes-Math.floor(minutes))*60);
minutes=Math.floor(minutes);
this.setTime(Date.UTC(year, month, day, hours, minutes, seconds));
};
Date.prototype.getJulian=function()
{var
jday=this.getTime().MsecToDay();
jday+=Date.J1970;
return Math.floor(jday-0.5)+0.5;
};
Date.prototype.setJDTime=function(jday)
{this.setTime((jday-Date.J1970).DayToMsec());
};
Date.prototype.getLocDayName=function(loc)
{var
day,
save_time;
save_time=this.getTime();
this.setTime(this.getTime()+(12).HtoMsec());
day=day_of_week[this.getUTCDay()];
this.setTime(save_time);
return day;
};
Date.prototype.toLocDateStr=function(pad)
{var
day,
dateStr,
save_time;
save_time=this.getTime();
this.setTime(this.getTime()+(12).HtoMsec());
day=this.getUTCDate();
if(pad>0)
dateStr=(day<10 ? SP+" " : "")+day;
else
dateStr=day;
dateStr+=" "+months[this.getUTCMonth()]
+" "+this.getUTCFullYear();
this.setTime(save_time);
return dateStr;
};
Date.prototype.getDayDST=function(loc)
{var
is_dst,
save_time;
if(loc.uses_dst===false||flags.show_dst===false)
return false;
save_time=this.getTime();
this.setTime(this.getTime()+(12).HtoMsec());
if(loc.isDST(this)>0)
is_dst=true;
else
is_dst=false;
this.setTime(save_time);
return is_dst;
};
Date.prototype.checkTimeAdjustDST=function(loc)
{
if(loc.dst_start===null||loc.dst_end===null)
return false;
if(loc.latitude<0){if(this.getTime()<loc.dst_end+(1).HtoMsec()||
this.getTime()>=loc.dst_start+(1).HtoMsec()){return true;
}
}
else{if(this.getTime()>=loc.dst_start+(1).HtoMsec()&&
this.getTime()<loc.dst_end+(1).HtoMsec()){return true;
}
}
return false;
};
var day_of_week=[ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ];
var months=[ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
var monthdays=[
[ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ],
[ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
];
function isleap(year)
{if((year) % 4===0&&(year) % 100!==0||(year) % 400===0)
return 1;
else
return 0;
}
function prog_time(program_start)
{var
program_end=new Date(),
time;
time=program_end.getTime()-program_start.getTime();
if(time<1000)
return "("+time+" msec)";
else
return "("+time/1000+" sec)";
}
function write_db()
{if(! arguments.length)
return;
if(debug_window===null||debug_window.closed){debug_window=window.open(
"", "Debug",
"width=600,height=300,resizable,scrollbars=1"
);
debug_window.document.open("text/plain");
}
var 
doc=debug_window.document;
for(var i=0; i<arguments.length; i++)
doc.writeln(arguments[i]);
}
function showElement(id, status)
{var elem;
elem=document.getElementById(id);
if(elem){if(status===true)
elem.style.display="";
else
elem.style.display="none";
}
else
alert("Element "+id+" not found");
}
function showCopy()
{var copy_dates=[
"calcTimesCopyPositionsDate",
"calcTimesCopyStartDate",
"calcPosCopyStartDate"
];
var ndx, elem, id;
for(ndx=0; ndx<copy_dates.length; ndx++){id=copy_dates[ndx];
elem=document.getElementById(id);
if(elem){if(flags.show_copy_dates===true)
elem.style.visibility="visible";
else
elem.style.visibility="hidden";
}
else
alert("Element "+id+" not found");
}
}
Number.prototype.testEvent=function()
{if(this<=-F_CIRCUMPOLAR)
return false;
else if(this>=F_CIRCUMPOLAR)
return false;
else if(this>F_TEST_NO_EVENT)
return false;
else
return true;
};
function calcDeclLimits(loc, limits)
{var
alt_min, alt_max,
az_min, az_max,
decl, decl_min, decl_max;
sin_lat=loc.sin_lat;
cos_lat=loc.cos_lat;
alt_min=limits.alt_min;
alt_max=limits.alt_max;
az_min=limits.az_min;
az_max=limits.az_max;
decl_min=Math.PI/2.0;
decl_max=-Math.PI/2.0;
decl=calcDeclination(alt_min, az_min, loc);
if(decl<decl_min)
decl_min=decl;
if(decl>limits.decl_max)
decl_max=decl;
decl=calcDeclination(alt_max, az_min, loc);
if(decl<decl_min)
decl_min=decl;
if(decl>decl_max)
decl_max=decl;
decl=calcDeclination(alt_min, az_max, loc);
if(decl<decl_min)
decl_min=decl;
if(decl>decl_max)
decl_max=decl;
decl=calcDeclination(alt_max, az_max, loc);
if(decl<decl_min)
decl_min=decl;
if(decl>decl_max)
decl_max=decl;
limits.decl_min=decl_min;
limits.decl_max=decl_max;
return 0;
}
function fix_name(field)
{field.value=field.value.trim();
}
function check_latitude(form, field)
{var
angle,
msg,
rtn_val,
latitude,
value,
MAX_VAL=90;
value=field.value.trim();
angle=value.getHemisphere("lat");
if(angle.isPackedDMS("lat")===true)
angle=angle.packedDMSto();
latitude=angle.DMSto();
msg="Invalid latitude ("+field.value+")"+LF;
if(isNaN(latitude)){fixField(field, msg+DMS_LAT_FORMAT_MSG);
rtn_val=false;
}
else if(Math.abs(latitude)>MAX_VAL){msg+="Range is "+-MAX_VAL+" to "+MAX_VAL;
fixField(field, msg);
rtn_val=false;
}
else{
if(latitude<0){latitude=-latitude;
set_hemisphere(form, field, "-");
}
else if(value.search(/N\s*$/i)>=0)
set_hemisphere(form, field, "+");
else if(value.search(/^\s*N/i)>=0)
set_hemisphere(form, field, "+");
if(value.search(/^\s*$/)!=-1)
field.value=0;
else if(angle.search(/[:\s\u00b0]/)<0)
field.value=latitude.toString();
else
field.value=latitude.toDMS(2);
rtn_val=true;
}
return rtn_val;
}
function check_longitude(form, field)
{var
angle,
msg,
rtn_val,
longitude,
value,
MAX_VAL=180;
value=field.value.trim();
angle=value.getHemisphere("lon");
if(angle.isPackedDMS("lon")===true)
angle=angle.packedDMSto();
longitude=angle.DMSto();
msg="Invalid longitude ("+field.value+")"+LF;
if(isNaN(longitude)){fixField(field, msg+DMS_LON_FORMAT_MSG);
rtn_val=false;
}
else if(Math.abs(longitude)>MAX_VAL){msg+="Range is "+-MAX_VAL+" to "+MAX_VAL;
fixField(field, msg);
rtn_val=false;
}
else{
if(longitude<0){longitude=-longitude;
set_hemisphere(form, field, "-");
}
else if(value.search(/E\s*$/i)>=0)
set_hemisphere(form, field, "+");
else if(value.search(/^\s*E/i)>=0)
set_hemisphere(form, field, "+");
if(value.search(/^\s*$/)!=-1)
field.value=0;
else if(angle.search(/[:\s\u00b0]/)<0)
field.value=longitude.toString();
else
field.value=longitude.toDMS(2);
rtn_val=true;
}
return rtn_val;
}
function set_hemisphere(form, field, value)
{var type;
switch(field.name){case "latitude":
type=form.lat_sign;
break;
case "longitude":
type=form.long_sign;
break;
default:
alert("Wrong field ("+field.name+") for function");
return false;
}
if(value=="-")
type.selectedIndex=1;
else
type.selectedIndex=0;
return true;
}
function check_elevation(field)
{var
msg,
rtn_val,
elevation=field.value,
elev_unit="m",
MIN_VAL=-400,
MAX_VAL=8850;
if(flags.elevation_in_feet===true){MIN_VAL=MIN_VAL.MtoFT().toFixed(0);
MAX_VAL=MAX_VAL.MtoFT().toFixed(0);
elev_unit="ft";
}
elevation=Number(rmCommas(elevation));
msg="Invalid elevation ("+field.value+" "+elev_unit+")"+LF;
if(isNaN(elevation)){fixField(field, msg+NUMERIC_FORMAT_MSG);
rtn_val=false;
}
else if(elevation<MIN_VAL||elevation>MAX_VAL){msg+="Range is "+MIN_VAL+" to "+addCommas(MAX_VAL)+" "+elev_unit;
fixField(field, msg);
rtn_val=false;
}
else{
field.value=addCommas(elevation);
rtn_val=true;
}
return rtn_val;
}
function get_elevation(form)
{var elevation;
if(form.loc_type[0].checked===true)
elevation=(places[form.place.selectedIndex][ELEV]);
else
elevation=Number(rmCommas(form.elevation.value));
return elevation;
}
function check_height(form, field)
{var
msg,
rtn_val,
MIN_VAL=0,
max_val,
elevation,
height,
height_unit="m";
elevation=get_elevation(form);
height=Number(rmCommas(field.value));
max_val=Math.max(elevation, 0);
if(flags.elevation_in_feet===true){MIN_VAL=MIN_VAL.MtoFT().toFixed(0);
max_val=max_val.MtoFT().toFixed(0);
height_unit="ft";
}
msg="Invalid height ("+field.value+" "+height_unit+")"+LF;
if(isNaN(height)){fixField(field, msg+NUMERIC_FORMAT_MSG);
rtn_val=false;
}
else if(height<MIN_VAL||height>max_val){msg+="Range is "+MIN_VAL+" to "+addCommas(max_val)+" "+height_unit;
fixField(field, msg);
rtn_val=false;
}
else{
field.value=addCommas(height);
rtn_val=true;
}
return rtn_val;
}
function check_year(field, tag)
{var
MIN_YEAR=1582,
msg,
rtn_val,
Today=new Date(),
thisyear,
year=field.value;
if(arguments.length>1)
msg="Invalid year ("+year+") for "+tag+" date"+LF;
else
msg="Invalid year ("+year+")"+LF;
if(year.search(/^\s*$/)!=-1){thisyear=Today.getFullYear();
field.value=thisyear;
}
else if(isNaN(year)||year!=Math.ipart(year)){msg+="Integer value (yyyy) required";
fixField(field, msg);
rtn_val=false;
}
else if(Number(year)<MIN_YEAR){msg+="Earliest is "+MIN_YEAR;
fixField(field, msg);
rtn_val=false;
}
else{field.value=Number(year).toString();
rtn_val=true;
}
return rtn_val;
}
function check_start_date(form)
{if(check_year(form.StartYear, "start")===false)
return false;
var
day=form.StartDay.selectedIndex+1,
ndx=form.StartMonth.selectedIndex,
year=form.StartYear.value,
maxdays=monthdays[isleap(year)][ndx];
if(day>maxdays)
form.StartDay.selectedIndex=maxdays-1;
check_dates(form, "start");
if(flags.show_mag_north===true)
check_mag_model(form, "Start Date", year, ndx, day);
return true;
}
function check_end_date(form, priority)
{if(check_year(form.EndYear, "end")===false)
return false;
var
day=form.EndDay.selectedIndex+1,
ndx=form.EndMonth.selectedIndex,
year=form.EndYear.value,
maxdays=monthdays[isleap(year)][ndx];
if(day>maxdays)
form.EndDay.selectedIndex=maxdays-1;
check_dates(form, priority);
if(flags.show_mag_north===true)
check_mag_model(form, "End Date", year, ndx, day);
return true;
}
function check_date_offset(form)
{var
day=form.StartDay.selectedIndex+1,
month=form.StartMonth.selectedIndex,
year=form.StartYear.value,
field=form.DateOffset,
date_offset=field.value-0,
ndx=form.DateOffsetUnits.selectedIndex,
units=form.DateOffsetUnits.options[ndx].value-0,
day_offset=date_offset*units,
EndDate=new Date(Date.UTC(year, month, day)+day_offset.DayToMsec());
if(field.value.search(/^\s*$/)!=-1)
field.value=1;
else if(check_nonnegative(field, "date offset")===false)
return false;
if(units==1)
field.value=Math.round(field.value);
if(flags.show_mag_north===false)
return true;
year=EndDate.getUTCFullYear();
month=EndDate.getUTCMonth();
day=EndDate.getUTCDate();
check_mag_model(form, "Date Offset", year, month, day);
return true;
}
function check_dates(form, priority)
{var
msg,
rtn_val,
StartDate,
EndDate,
year,
month,
day;
if(form.end_date[0].checked===true){year=form.StartYear.value;
month=form.StartMonth.selectedIndex;
day=form.StartDay.selectedIndex+1;
StartDate=new Date();
StartDate.setTime(Date.UTC(year, month, day));
start_date=StartDate.getTime().MsecToDay();
year=form.EndYear.value;
month=form.EndMonth.selectedIndex;
day=form.EndDay.selectedIndex+1;
EndDate=new Date();
EndDate.setTime(Date.UTC(year, month, day));
end_date=EndDate.getTime().MsecToDay();
if(end_date<start_date){if(priority=="start"){
form.EndYear.value=form.StartYear.value;
form.EndMonth.selectedIndex=form.StartMonth.selectedIndex;
form.EndDay.selectedIndex=form.StartDay.selectedIndex;
}
else{form.StartYear.value=form.EndYear.value;
form.StartMonth.selectedIndex=form.EndMonth.selectedIndex;
form.StartDay.selectedIndex=form.EndDay.selectedIndex;
}
rtn_val=false;
}
else
rtn_val=true;
}
else
rtn_val=true;
return rtn_val;
}
function check_calc_date(form)
{if(check_year(form.CalcYear, "positions")===false)
return false;
var
day=form.CalcDay.selectedIndex+1,
ndx=form.CalcMonth.selectedIndex,
year=form.CalcYear.value,
maxdays=monthdays[isleap(year)][ndx];
if(day>maxdays)
form.CalcDay.selectedIndex=maxdays-1;
if(flags.show_mag_north===true)
check_mag_model(form, "Date for positions", year, ndx, day);
return true;
}
function check_start_event(form)
{;
}
function check_start_time(field)
{var
msg,
rtn_val,
MIN=0,
MAX=24,
start=field.value.DMSto();
start=field.value.parseTime("start");
msg="Invalid start time"+LF;
if(start===null){fixField(field);
rtn_val=false;
}
else if(isNaN(start)){fixField(field, msg+HM_FORMAT_MSG);
rtn_val=false;
}
else if(start<MIN||start>MAX){msg+="Range is "+MIN+" to "+MAX;
fixField(field, msg);
rtn_val=false;
}
else{field.value=start.formatTime("F");
rtn_val=true;
}
return rtn_val;
}
function check_event_time_offset(field, tag)
{var
msg="",
rtn_val,
MIN=-480,
MAX=-MIN,
offset=Number(field.value);
if(arguments.length>1&&tag!==null&&tag!=="")
msg="Invalid time ("+field.value+") before or after "+tag+" event"+LF;
if(isNaN(offset)){fixField(field, msg+NUMERIC_FORMAT_MSG);
rtn_val=false;
}
else if(offset<MIN||offset>MAX){msg+="Range is "+MIN+" to "+MAX;
fixField(field, msg);
rtn_val=false;
}
else{if(offset<0){
field.value=-offset;
toggle_offset_sign(form, field);
}
field.value=Math.round(field.value);
rtn_val=true;
}
return rtn_val;
}
function toggle_offset_sign(form, field)
{var sign;
switch(field.name){case "StartEventOffset":
sign=form.StartEventOffsetSign;
break;
case "EndEventOffset":
sign=form.EndEventOffsetSign;
break;
default:
alert("Wrong field ("+field.name+") for function");
return false;
}
if(sign.selectedIndex===0)
sign.selectedIndex=1;
else
sign.selectedIndex=0;
return true;
}
function check_end_event(form)
{;
}
function check_end_time(field)
{var
msg,
rtn_val,
MIN=0,
MAX=24,
end=field.value.DMSto();
end=field.value.parseTime("end");
msg="Invalid end time"+LF;
if(end===null){fixField(field);
rtn_val=false;
}
else if(isNaN(end)){fixField(field, msg+NUMERIC_FORMAT_MSG);
rtn_val=false;
}
else if(end<MIN||end>MAX){msg+="Range is "+MIN+" to "+MAX;
fixField(field, msg);
rtn_val=false;
}
else{if(end===0)
end=24;
field.value=end.formatTime("F");
rtn_val=true;
}
return rtn_val;
}
function check_time_offset(form)
{var
msg,
rtn_val,
field=form.TimeOffset,
t_offset=field.value,
ndx=form.TimeOffsetUnits.selectedIndex;
multiplier=form.TimeOffsetUnits.options[ndx].value;
t_offset/=multiplier;
msg="Invalid time offset ("+field.value+")"+LF;
if(isNaN(t_offset)){fixField(field, msg+"Nonnegative number required");
rtn_val=false;
}
else if(t_offset<0||t_offset>48){if(ndx===0)
msg+="Range is 0 to 48 hours";
else
msg+="Range is 0 to 2880 minutes";
fixField(field, msg);
rtn_val=false;
}
else{if(field.value.search(/^\s*$/)!=-1){
t_offset=1;
form.TimeOffsetUnits.selectedIndex=0;
}
else if(ndx==1)
t_offset=Math.round(field.value);
field.value=t_offset.toString();
rtn_val=true;
}
return rtn_val;
}
function check_mag_date(date)
{
if(date>mag_model.start_date-MagModel.GRACE&&
date<mag_model.end_date+MagModel.GRACE)
return true;
else
return false;
}
function check_mag_dec_date(date)
{var YEAR=365;
if(date>mag_model.start_date-MagModel.GRACE&&
date<mag_model.end_date+MagModel.GRACE)
return VALID;
else if(date<mag_model.start_date-YEAR||date>mag_model.end_date+YEAR)
return INVALID;
else
return EXTENDED;
}
function check_mag_model(form, tag, year, month, day)
{var date=Date.UTC(year, month, day).MsecToDay();
if(date<mag_model.start_date-MagModel.GRACE||
date>mag_model.end_date+MagModel.GRACE){alert("Caution: "+tag+" is outside magnetic model range of "
+mag_model.valid_range_str2
);
return false;
}
else
return true;
}
function check_nonnegative(field, tag)
{var
value=field.value,
msg="";
if(isNaN(value)||value<0){if(arguments.length>1&&tag!==null&&tag!=="")
msg="Invalid "+tag+" ("+value+")"+LF;
msg+="Nonnegative number required";
fixField(field, msg);
return false;
}
field.value=Number(value).toString();
return true;
}
function check_value_positive(field, tag)
{var
value=field.value,
msg="";
if(isNaN(value)||value<=0){if(arguments.length>1&&tag!==null&&tag!=="")
msg="Invalid "+tag+" ("+value+")"+LF;
msg+="Positive number required";
fixField(field, msg);
return false;
}
field.value=Number(value).toString();
return true;
}
function check_date_step(field, units)
{var
msg,
ndx=units.selectedIndex,
value=field.value;
msg="Invalid date interval ("+value+")"+LF;
msg+="Positive number required";
if(value.search(/^\s*$/)!=-1)
value=1;
else if(isNaN(value)||value<=0){fixField(field, msg);
return false;
}
else if(units.options[ndx].value==1)
value=Math.round(value);
field.value=Number(value).toString();
return true;
}
function check_rs_alts(opts, loc)
{var
dip,
errors,
errmsg,
minstr,
rangestr,
rs_alt;
dip=loc.dip;
rs_alt=loc.rs_alt;
minstr=' minimum altitude is '+-dip.toFixed(3);
rangestr=' altitudes '+rs_alt.toFixed(3)+' to '+-dip.toFixed(3)
+' do not occur';
errors=0;
errmsg="";
if(opts.alt_sr>rs_alt&&opts.alt_sr<-dip){errmsg+='Sunrise alt (';
if(opts.alt_sr_range)
errmsg+=opts.alt_sr_min+' to '+opts.alt_sr_max;
else
errmsg+=opts.alt_sr;
errmsg+='):'+rangestr;
errors++;
}
if(opts.alt_ss>rs_alt&&opts.alt_ss<-dip){if(errmsg)
errmsg+='\n';
errmsg+='Sunset alt (';
if(opts.alt_ss_range)
errmsg+=opts.alt_ss_min+' to '+opts.alt_ss_max;
else
errmsg+=opts.alt_ss;
errmsg+='):'+rangestr;
errors++;
}
if(opts.alt_mr_min<-dip){if(errmsg)
errmsg+='\n';
errmsg+='Moonrise alt (';
if(opts.alt_mr_range)
errmsg+=opts.alt_mr_min+' to '+opts.alt_mr_max;
else
errmsg+=opts.alt_mr;
errmsg+='):'+minstr;
errors++;
}
if(opts.alt_ms_min<-dip){if(errmsg)
errmsg+='\n';
errmsg+='Moonset alt (';
if(opts.alt_ms_range)
errmsg+=opts.alt_ms_min+' to '+opts.alt_ms_max;
else
errmsg+=opts.alt_ms;
errmsg+='):'+minstr;
errors++;
}
if(errors){alert(errmsg);
return false;
}
else
return true;
}
function initialize_form()
{var load_state=0;
form=document.SunMoonCalc;
Today=new Date();
flags=new Flag();
copyright="SunMoonCalc &copy; "+Today.getFullYear()+" Jeff Conrad";
mag_model=new MagModel;
times_results=new Result("times");
positions_results=new Result("positions");
place_list=new PlaceList();
SaveState=new CalcState();
flags.isMozilla=false;
if(navigator.appName.indexOf("Netscape")!=-1){if(navigator.appCodeName=="Mozilla"&&navigator.product=="Gecko"&&
navigator.userAgent.indexOf("Mozilla")!=-1)
flags.isMozilla=true;
}
if(form.loaded!==true){reset_date(form);
load_state=SaveState.read(form);
}
initialize_preferences();
form.search_pattern.onkeypress=searchKeyFilter;
form.search_pattern.onkeyup=searchKeyFilter;
HTTP.initialize_buttons();
if(load_state==-2)
SaveState.write(form);
}
function initialize_preferences()
{flags.initFlags(form);
set_input_sizes();
setLocTypeAttrib();
setCalcTypeAttrib();
showElement("CheckPlaces", flags.show_check_places);
showElement("PlaceSearch", flags.show_search);
showCopy();
initialize_times(form);
initialize_units(form);
}
function initialize_times(form)
{var start_time, end_time;
if((start_time=form.StartTime.value.parseTime("start", "init"))===null)
start_time=0;
form.StartTime.value=start_time.formatTime("F");
if((end_time=form.EndTime.value.parseTime("end", "init"))===null)
end_time=24;
if(end_time===0)
end_time=24;
form.EndTime.value=end_time.formatTime("F");
}
function initialize_units(form)
{var elev_u, height_u;
elev_u=document.getElementById("ElevUnits");
height_u=document.getElementById("HeightUnits");
time_tag1=document.getElementById("TimeTag1");
time_tag2=document.getElementById("TimeTag2");
if(flags.elevation_in_feet===true){elev_u.innerHTML="ft";
height_u.innerHTML="ft";
}
else{elev_u.innerHTML="m";
height_u.innerHTML="m";
}
if(flags.show_ut===true){time_tag1.innerHTML="UT";
time_tag2.innerHTML="UT";
}
else{time_tag1.innerHTML="local time";
time_tag2.innerHTML="local time";
}
}
function convert_elev_ht(form, flag)
{var
elevation=form.elevation,
height=form.height;
function cvt_elev_value(value, flag)
{value=Number(rmCommas(value));
if(flag=="ft")
value=value.MtoFT();
else
value=value.FTtoM();
return addCommas(value.toFixed(0));
}
elevation.value=cvt_elev_value(elevation.value, flag);
height.value=cvt_elev_value(height.value, flag);
}
function open_url(url, title)
{var LookupWindow;
if(arguments.length<2)
title="LookupWindow";
LookupWindow=window.open(url, title);
LookupWindow.focus();
}
function get_tz_ndx(timezone)
{
var timezones=[
-12,-11,-10,-9,-8,-7,-6,-5,-4,-3.5,
-3,-2,-1,  0,   1,  2,  3, 3.5,   4,  4.5,
5, 5.5, 5.75,  6, 6.5,  7,  8,   9, 9.5,   10,
11,  12, 13 
];
var tz_ndx;
for(tz_ndx=0; tz_ndx<timezones.length; tz_ndx++){if(timezone==timezones[tz_ndx])
break;
}
if(tz_ndx==timezones.length)
tz_ndx=-1;
return tz_ndx;
}
function set_input_sizes()
{if(flags.show_am_pm_time===true){
form.StartTime.style.width="4.4em";
form.EndTime.style.width="4.4em";
}
else{form.StartTime.style.width="3em";
form.EndTime.style.width="3em";
}
}
function clearSearchPattern()
{form.search_pattern.value="";
}
function set_calc_date(date)
{var
calc_date=new Date(date.DayToMsec()),
year=calc_date.getUTCFullYear(),
month=calc_date.getUTCMonth(),
day=calc_date.getUTCDate();
form.CalcDay.selectedIndex=day-1;
form.CalcMonth.selectedIndex=month;
form.CalcYear.value=year;
form.calc_type[1].checked=true;
setCalcTypeAttrib();
SaveState.write(form);
}
function set_place(ndx)
{form.place.selectedIndex=ndx;
SaveState.write(form);
}
var stdLocTxt=[
[ "stdLocTxt0",  0, 0 ],
[ "stdLocTxt00", 0, 0 ],
[ "stdLocTxt01", 0, 0 ],
[ "stdLocTxt02", 1, 0 ],
[ "stdLocTxt03", 0, 0 ],
[ "stdLocTxt04", 0, 0 ],
[ "stdLocTxt05", 0, 0 ]
];
var cstmLocTxt=[
[ "cstmLocTxt0",  0, 0 ],
[ "cstmLocTxt00", 0, 0 ],
[ "cstmLocTxt01", 1, 0 ],
[ "cstmLocTxt02", 0, 0 ],
[ "cstmLocTxt1",  0, 0 ],
[ "cstmLocTxt10", 0, 0 ],
[ "cstmLocTxt11", 0, 0 ],
[ "cstmLocTxt12", 0, 0 ],
[ "cstmLocTxt13", 0, 0 ],
[ "cstmLocTxt14", 0, 0 ]
];
var calcTimesTxt=[
[ "calcTimesTab", 0, 0 ]
];
var calcPosTxt=[
[ "calcPosTab", 0, 0 ]
];
var stdLocElems=[
[ "stdLocType",          1, 0, 3, 0 ],
[ "stdLocPlace",         0, 2, 0, 0 ],
[ "stdLocListPlaces",    0, 0, 3, 0 ],
[ "CheckPlaces",         0, 0, 3, 0 ],
[ "stdLocSearchPattern", 0, 2, 0, 0 ],
[ "stdLocSearchPlaces",  0, 0, 0, 0 ],
[ "stdLocNextPlace",     0, 0, 0, 4 ]
];
var cstmLocElems=[
[ "cstmLocType",        1, 0, 3, 0 ],
[ "cstmLocLookup",      0, 2, 0, 0 ],
[ "cstmLocLookupGo",    0, 0, 0, 0 ],
[ "cstmLocPlaceName",   0, 2, 0, 0 ],
[ "cstmLocCopyPlace",   0, 0, 0, 0 ],
[ "cstmLocClearCustom", 0, 0, 0, 0 ],
[ "cstmLocLatitude",    0, 2, 0, 0 ],
[ "cstmLocLatSign",     0, 2, 0, 0 ],
[ "cstmLocTimeZone",    0, 2, 0, 0 ],
[ "cstmLocLongitude",   0, 2, 0, 0 ],
[ "cstmLocLongSign",    0, 2, 0, 0 ],
[ "cstmLocUsesDST",     0, 2, 0, 0 ],
[ "cstmLocElevation",   0, 2, 0, 0 ]
];
var calcTimesElems=[
[ "calcTimesHeading",           1, 0, 3, 0 ],
[ "calcTimesCalcType",          0, 0, 3, 0 ],
[ "calcTimesStartDay",          0, 2, 0, 0 ],
[ "calcTimesStartMonth",        0, 2, 0, 0 ],
[ "calcTimesStartYear",         0, 2, 0, 0 ],
[ "calcTimesCopyPositionsDate", 0, 0, 0, 0 ],
[ "calcTimesEndTypeDate",       0, 0, 0, 0 ],
[ "calcTimesEndDay",            0, 2, 0, 0 ],
[ "calcTimesEndMonth",          0, 2, 0, 0 ],
[ "calcTimesEndYear",           0, 2, 0, 0 ],
[ "calcTimesCopyStartDate",     0, 0, 0, 0 ],
[ "calcTimesEndTypeOffset",     0, 0, 0, 0 ],
[ "calcTimesDateOffset",        0, 2, 0, 0 ],
[ "calcTimesDateOffsetUnits",   0, 2, 0, 0 ],
[ "calcTimesDateInverval",      0, 2, 0, 0 ],
[ "calcTimesDateInvervalUnits", 0, 2, 0, 0 ],
[ "calcTimesRiseSetCriteria",   0, 0, 0, 0 ]
];
var calcPosElems=[
[ "calcPosHeading",              1, 0, 3, 0 ],
[ "calcPosCalcType",             0, 0, 3, 0 ],
[ "calcPosCalcDay",              0, 2, 0, 0 ],
[ "calcPosCalcMonth",            0, 2, 0, 0 ],
[ "calcPosCalcYear",             0, 2, 0, 0 ],
[ "calcPosDayDecrement",         0, 0, 0, 0 ],
[ "calcPosDayIncrement",         0, 0, 0, 0 ],
[ "calcPosCopyStartDate",        0, 0, 0, 0 ],
[ "calcPosStartTypeEvent",       0, 0, 0, 0 ],
[ "calcPosStartEventOffset",     0, 2, 0, 0 ],
[ "calcPosStartEventOffsetSign", 0, 2, 0, 0 ],
[ "calcPosStartEvent",           0, 2, 0, 0 ],
[ "calcPosStartTypeTime",        0, 0, 0, 0 ],
[ "calcPosStartTime",            0, 2, 0, 0 ],
[ "calcPosEndTypeEnd",           0, 0, 0, 0 ],
[ "calcPosEndTimeEvent",         0, 0, 0, 0 ],
[ "calcPosEndEventOffset",       0, 2, 0, 0 ],
[ "calcPosEndEventOffsetSign",   0, 2, 0, 0 ],
[ "calcPosEndEvent",             0, 2, 0, 0 ],
[ "calcPosEndTimeTime",          0, 0, 0, 0 ],
[ "calcPosEndTime",              0, 2, 0, 0 ],
[ "calcPosEndTypeOffset",        0, 0, 0, 0 ],
[ "calcPosTimeOffset",           0, 2, 0, 0 ],
[ "calcPosTimeOffsetUnits",      0, 2, 0, 0 ],
[ "calcPosTimeInterval",         0, 2, 0, 0 ]
];
function toggleAttrib(elmnts, elemType)
{var
elem,
elmnt,
ndx,
min=0,
max;
max=elmnts.group1.length;
for(ndx=min; ndx<max; ndx++){elmnt=elmnts.group1[ndx];
elem=document.getElementById(elmnt[0]);
if(elem){elem.style.color=elemType.active_color;
elem.style.fontWeight=elemType.active_weight;
elem.style.fontStyle=elemType.active_style;
elem.style.backgroundColor=elemType.active_bgcolor;
if(elmnt[4]===0)
elem.disabled=false;
}
else
alert("Element "+elmnt[0]+" not found");
}
if(elmnts.box1){max=elmnts.box1.length;
for(ndx=min; ndx<max; ndx++){elmnt=elmnts.box1[ndx];
elem=document.getElementById(elmnt[0]);
if(elem){if(elmnt[1]!==0){
elem.style.color=elemType.active_color1;
elem.style.fontWeight=elemType.active_weight1;
elem.style.fontStyle=elemType.active_style1;
}
else{elem.style.color=elemType.active_color;
elem.style.fontWeight=elemType.active_weight;
}
elem.style.borderColor=elemType.active_border_color;
elem.style.borderStyle=elemType.active_border_style;
elem.style.borderWidth=elemType.active_border_width;
elem.style.backgroundColor=elemType.active_bgcolor;
elem.disabled=false;
}
else
alert("Element "+elmnt[0]+" not found");
}
}
max=elmnts.group2.length;
for(ndx=min; ndx<max; ndx++){elmnt=elmnts.group2[ndx];
elem=document.getElementById(elmnt[0]);
if(elem){
if(elmnt[1]!==0){elem.style.color=elemType.inactive_color1;
elem.style.fontWeight=elemType.inactive_weight1;
elem.style.fontStyle=elemType.inactive_style1;
}
if(elmnt[2]!==0)
elem.style.backgroundColor=elemType.inactive_input_bgcolor;
if(elmnt[3]===0)
elem.disabled=true;
}
else
alert("Element "+elmnt[0]+" not found");
}
if(elmnts.box2){max=elmnts.box2.length;
for(ndx=min; ndx<max; ndx++){elmnt=elmnts.box2[ndx];
elem=document.getElementById(elmnt[0]);
if(elem){if(elmnt[1]!==0){
elem.style.color=elemType.inactive_color1;
elem.style.fontWeight=elemType.inactive_weight1;
elem.style.fontStyle=elemType.inactive_style1;
}
else{elem.style.color=elemType.inactive_color;
elem.style.fontWeight=elemType.inactive_weight;
}
if(elmnt[2]!==0)
elem.style.border="none";
else{elem.style.borderColor=elemType.inactive_border_color;
elem.style.borderStyle=elemType.inactive_border_style;
elem.style.borderWidth=elemType.inactive_border_width;
}
elem.style.backgroundColor=elemType.inactive_bgcolor;
}
else
alert("Element "+elmnt[0]+" not found");
}
}
}
function setLocTypeAttrib()
{var elem, min, max, ndx;
var
locType=new Object(),
elmnts=new Object();
elmnts.min=0;
elmnts.max=14;
locType.active_color1="navy";
locType.active_weight1="bold";
locType.active_style1="";
locType.active_color="";
locType.active_weight="";
locType.active_style="";
locType.inactive_color1="#aaa";
locType.inactive_weight1="bold";
locType.inactive_style1="";
locType.inactive_color="#999";
locType.inactive_weight="";
locType.inactive_style1="";
locType.inactive_style="";
locType.active_border_color="";
locType.active_border_style="";
locType.active_border_width="";
locType.active_bgcolor="";
locType.active_visibility="visible";
locType.inactive_border_color="";
locType.inactive_border_style="";
locType.inactive_border_width="";
locType.inactive_bgcolor="";
locType.inactive_bgcolor=SUN_COLOR;
locType.inactive_input_bgcolor="#f7f7f7";
locType.inactive_visibility="visible";
switch(form.loc_type[0].checked){case true:
elmnts.group1=stdLocElems;
elmnts.box1=stdLocTxt;
elmnts.group2=cstmLocElems;
elmnts.box2=cstmLocTxt;
break;
case false:
elmnts.group1=cstmLocElems;
elmnts.box1=cstmLocTxt;
elmnts.group2=stdLocElems;
elmnts.box2=stdLocTxt;
break;
default:
break;
}
toggleAttrib(elmnts, locType);
}
function setCalcTypeAttrib()
{var elem, min, max, ndx;
var
calcType=new Object(),
elmnts=new Object();
elmnts.min=0;
elmnts.max=24;
calcType.active_color="";
calcType.active_weight="";
calcType.active_style="";
calcType.inactive_color1="gray";
calcType.inactive_weight1="normal";
calcType.inactive_style1="";
calcType.inactive_color="#999";
calcType.inactive_weight="";
calcType.inactive_style1="";
calcType.inactive_style="";
calcType.active_border_color="";
calcType.active_border_style="";
calcType.active_border_width="";
calcType.active_bgcolor="";
calcType.active_visibility="visible";
calcType.inactive_border_width="1px";
calcType.inactive_border_color="#aaa";
calcType.inactive_border_style="dotted";
calcType.inactive_bgcolor=SUN_COLOR;
calcType.inactive_input_color="gray";
calcType.inactive_input_bgcolor="#f7f7f7";
calcType.inactive_visibility="visible";
switch(form.calc_type[0].checked){case true:
elmnts.group1=calcTimesElems;
elmnts.box1=calcTimesTxt;
elmnts.group2=calcPosElems;
elmnts.box2=calcPosTxt;
break;
case false:
elmnts.group1=calcPosElems;
elmnts.box1=calcPosTxt;
elmnts.group2=calcTimesElems;
elmnts.box2=calcTimesTxt;
break;
default:
break;
}
toggleAttrib(elmnts, calcType);
enable_inputs();
}
function enable_inputs()
{if(form.calc_type[0].checked===true)
enable_input(form.end_date[0]);
else{enable_input(form.time_start_type[0]);
enable_input(form.end_time[0]);
}
}
function enable_input(button)
{var
group1, group2, enable, disable, check,
elmts, elem, max, ndx,
inactive_input_color="gray",
inactive_input_bgcolor="#f7f7f7";
check=null;
switch (button.name){case "end_date":
group1=[ "EndDay", "EndMonth", "EndYear" ];
group2=[ "DateOffset", "DateOffsetUnits" ];
if(form.end_date[0].checked===true){enable=group1;
disable=group2;
}
else{enable=group2;
disable=group1;
}
break;
case "time_start_type":
group1=[ "StartEventOffset", "StartEventOffsetSign", "StartEvent" ];
group2=[ "StartTime" ];
if(form.time_start_type[0].checked===true){enable=group1;
disable=group2;
}
else{enable=group2;
disable=group1;
}
break;
case "end_time":
group1=[
"EndEventOffset", "EndEventOffsetSign",
"EndEvent", "EndTime", "time_end_type"
];
group2=[ "TimeOffset", "TimeOffsetUnits" ];
if(form.end_time[0].checked===true){enable=group1;
disable=group2;
check=form.time_end_type[0];
}
else{enable=group2;
disable=group1;
}
break;
case "time_end_type":
group1=[ "EndEventOffset", "EndEventOffsetSign", "EndEvent" ];
group2=[ "EndTime" ];
if(form.time_end_type[0].checked===true){enable=group1;
disable=group2;
}
else{enable=group2;
disable=group1;
}
break;
default:
break;
}
max=enable.length;
for(ndx=0; ndx<max; ndx++){elmts=document.getElementsByName(enable[ndx]);
if(elmts){for(ndx2=0; ndx2<elmts.length; ndx2++){
elem=elmts[ndx2];
elem.style.backgroundColor="";
elem.style.color="";
elem.disabled=false;
}
}
else
alert("Element "+elmts+" not found");
}
max=disable.length;
for(ndx=0; ndx<max; ndx++){elmts=document.getElementsByName(disable[ndx]);
if(elmts){for(ndx2=0; ndx2<elmts.length; ndx2++){
elem=elmts[ndx2];
elem.style.color=inactive_input_color;
elem.style.backgroundColor=inactive_input_bgcolor;
if(flags.enable_inactive_inputs===false)
elem.disabled=true;
}
}
else
alert("Element "+elmts+" not found");
}
if(check)
arguments.callee(check);
}
function CalcState(weeks)
{var msec;
if(weeks)
msec=weeks*24*7*3600e3;
else
msec=13*24*7*3600e3;
this.SMCalc_tag="SMCalc_state";
this.version="4.2";
this.vStr="v"+this.version;
this.expiration=new Date((new Date()).getTime()+msec);
this.saved_data=[
"loc_type",
"calc_type",
"place",
"place_name",
"latitude",
"longitude",
"elevation",
"lat_sign",
"long_sign",
"timezone",
"uses_dst",
"height",
"LocationLookup",
"WeatherLookup",
"UseSepWindows",
"UsePopups",
"UseAllTabs",
"ShowSearch",
"UseREs",
"ShowMagDec",
"ShowDSTRules",
"ShowDSTDates",
"ShowAMPMTime",
"ShowDST",
"ShowUT",
"ShowMagNorth",
"ElevationInFeet",
"InterpolateRSPositions",
"EnableInactiveInputs",
"ShowCheckPlaces",
"ShowCopyDates",
"ShowAzAdjust",
"TimeProgram",
"UseFontSize",
"FontSize"
];
}
CalcState.prototype.write=function(form)
{var
cookie, ndx, prop, prop_val, value;
cookie=this.SMCalc_tag+"=";
cookie+=this.vStr;
prop=this.saved_data;
for(ndx=0; ndx<prop.length; ndx++){
if(ndx<2){if(form[prop[ndx]][0].checked===true)
prop_val=0;
else
prop_val=1;
cookie+=":"+prop_val;
}
else{switch (form[prop[ndx]].type){
case "hidden":
case "text":
value=form[prop[ndx]].value;
if(value=="true")
prop_val="t";
else if(value=="false")
prop_val="f";
else
prop_val=value;
cookie+=":"+escape(prop_val);
break;
case "select-one":
cookie+=":"+escape(form[prop[ndx]].selectedIndex);
break;
default:
break;
}
}
}
cookie+="; expires="+this.expiration.toUTCString();
document.cookie=cookie;
};
CalcState.prototype.read=function(form)
{var
cookie=document.cookie,
a, prop, prop_val, value,
start, end;
if(! cookie)
return-1;
start=cookie.indexOf(this.SMCalc_tag+"=");
if(start==-1)
return-1;
start+=this.SMCalc_tag.length+1;
if(cookie.substring(start, start+this.vStr.length)!=this.vStr){alert("Could not load saved data (wrong version); using default values");
return-2;
}
start+=this.vStr.length+1;
end=cookie.indexOf(";", start);
if(end==-1)
end=cookie.length;
cookie=cookie.substring(start, end);
a=cookie.split(":");
prop=this.saved_data;
if(a.length!=prop.length){alert("Could not load saved data; using default values");
return-2;
}
for(var ndx=0; ndx<a.length; ndx++){
if(ndx<2){prop_val=a[ndx];
if(prop_val=="0")
form[prop[ndx]][0].checked=true;
else
form[prop[ndx]][1].checked=true;
}
else{
switch (form[prop[ndx]].type){case "hidden":
case "text":
prop_val=unescape(a[ndx]);
if(prop_val=="t")
value="true";
else if(prop_val=="f")
value="false";
else
value=prop_val;
form[prop[ndx]].value=value;
break;
case "select-one":
value=unescape(a[ndx]);
form[prop[ndx]].selectedIndex=value;
break;
default:
break;
}
}
}
return 0;
};
function list_places(type)
{flags.initFlags(form);
if(flags.show_dst_rules===true||flags.show_dst_dates===true)
flags.show_dst=true;
if(type=="reformat"){flags.print=true;
if(flags.use_font_size===true)
set_font_size();
}
place_list.build_doc_head();
if(type!="reformat"){flags.print=false;
if(flags.time_program===true)
var program_start=new Date();
var
year,
month, day,
mag_dec_date;
if(form.calc_type[0].checked===true){if(check_year(form.StartYear, "start")===false)
return false;
year=form.StartYear.value;
month=form.StartMonth.selectedIndex;
day=form.StartDay.selectedIndex+1;
}
else{if(check_year(form.CalcYear, "positions")===false)
return false;
year=form.CalcYear.value;
month=form.CalcMonth.selectedIndex;
day=form.CalcDay.selectedIndex+1;
}
if(flags.show_mag_dec===true)
mag_dec_date=Date.UTC(year, month, day).MsecToDay();
else
mag_dec_date=null;
place_list.build_places_header(year, mag_dec_date);
place_list.build_place_list(year, mag_dec_date);
place_list.copyright=copyright;
if(flags.time_program===true)
place_list.prog_time=prog_time(program_start);
}
place_list.add_buttons();
place_list.output();
flags.print=false;
return true;
}
function check_places()
{var field, tag, year;
flags.show_dst=true;
if(form.calc_type[0].checked===true){field=form.StartYear;
tag="start";
}
else{field=form.CalcYear;
tag="positions";
}
if(check_year(field, tag)===false)
return false;
else
year=field.value;
checkPlaces();
checkDSTRules(year);
debug_window.document.close();
debug_window.focus();
debug_window=null;
return true;
}
function search_places(type)
{var i, icase=true, ndx, n_places;
var form, pattern, pattern0, place;
form=document.SunMoonCalc;
if(this.searchIndex===undefined)
this.searchIndex=0;
switch (type){case "backspace":
case "new":
this.searchIndex=0;
form.NextPlace.disabled=true;
break;
default:
break;
}
pattern=form.search_pattern.value;
pattern0=pattern;
n_places=places.length;
if(pattern.search(/[A-Z]/)!=-1)
icase=false;
else
pattern=pattern.toLowerCase();
ndx=this.searchIndex;
for(i=ndx; i<n_places; i++){place=places[i][0];
if(icase===true)
place=place.toLowerCase();
found=false;
if(flags.use_REs===true&&place.search(pattern)!=-1)
found=true;
else if(flags.use_REs===false&&place.indexOf(pattern)>=0)
found=true;
if(found===true){set_place(i);
this.searchIndex=i+1;
form.NextPlace.disabled=false;
break;
}
}
if(type=="backspace")
return;
if(i>=n_places){if(ndx>0){
form.NextPlace.disabled=true;
alert("No other location matches '"+pattern0+"'");
}
else{alert("No location matches '"+pattern0+"'");
form.search_pattern.value=pattern0.replace(/.$/, "");
}
}
}
function location_lookup(ndx, name)
{var location, state, url;
switch (ndx){case 0:
url = "http://geonames.usgs.gov/pls/gnispublic/";
break;
case 1:
url = "http://earth-info.nga.mil/gns/html/index.html";
break;
case 2:
url = "http://www.getty.edu/research/conducting_research/vocabularies/tgn/";
break;
case 3:
url = "http://www.timeanddate.com/worldclock/search.html";
break;
case 4:
if(name.trim().length===0)
url = "http://www.geonames.org/";
else{
GeoNames.query("search", name.trim());
return;
}
break;
case 5:
var coords={lat: 0, lon: 0};
url = "http://www.maps.google.com/";
if(form.latitude.value!=0||form.longitude.value!=0){if(get_lat_lon(coords)===false)
return;
else
url+="?ll="+coords.lat+","+coords.lon+"&spn=0.08,0.08&t=p";
}
else if(name.trim().length>0)
url+="?q="+encodeURIComponent(name.trim())+"&t=p";
else
url+="?t=p";
break;
default:
break;
}
open_url(url);
}
function copy_place(form)
{var
latitude,
longitude,
ndx,
timezone,
tz_ndx;
ndx=form.place.selectedIndex;
if(form.place.options[ndx].text!=places[ndx][NAME]){alert(
"Location lookup error:"
+"\n"+form.place.options[ndx].text
+"\n          vs."
+"\n"+places[ndx][NAME]
);
return false;
}
timezone=places[ndx][TZ];
if((tz_ndx=get_tz_ndx(timezone))<0){alert("Invalid time zone: "+timezone);
return false;
}
form.place_name.value=form.place.options[ndx].text;
if((latitude=places[ndx][LAT].DMSto()) < 0) {	if(places[ndx][LAT].match(/:/g).length == 1)
form.latitude.value=(-latitude).toDMS(-1);
else
form.latitude.value=(-latitude).toDMS(0);
form.lat_sign.selectedIndex=1;
}
else{if(places[ndx][LAT].match(/:/g).length==1)
form.latitude.value=latitude.toDMS(-1);
else
form.latitude.value=latitude.toDMS(0);
form.lat_sign.selectedIndex=0;
}
if((longitude=places[ndx][LONG].DMSto()) < 0) {	if(places[ndx][LONG].match(/:/g).length == 1)
form.longitude.value=(-longitude).toDMS(-1);
else
form.longitude.value=(-longitude).toDMS(0);
form.long_sign.selectedIndex=1;
}
else{if(places[ndx][LONG].match(/:/g).length==1)
form.longitude.value=longitude.toDMS(-1);
else
form.longitude.value=longitude.toDMS(0);
form.long_sign.selectedIndex=0;
}
form.timezone.selectedIndex=tz_ndx+1;
if(places[ndx][DST]==1)
form.uses_dst.selectedIndex=1;
else
form.uses_dst.selectedIndex=0;
if(flags.elevation_in_feet===true)
form.elevation.value=addCommas(places[ndx][ELEV].MtoFT().toFixed(0));
else
form.elevation.value=addCommas(places[ndx][ELEV]);
SaveState.write(form);
return true;
}
function clear_custom_location(form)
{form.place_name.value="";
form.latitude.value=0;
form.lat_sign.selectedIndex=0;
form.longitude.value=0;
form.long_sign.selectedIndex=1;
form.timezone.selectedIndex=0;
form.uses_dst.selectedIndex=0;
form.elevation.value=0;
SaveState.write(form);
return true;
}
function weather_lookup(ndx)
{var place_name, url;
if(form.loc_type[0].checked===true){var place_ndx=form.place.options.selectedIndex;
place_name=form.place[place_ndx].text;
}
else
place_name=form.place_name.value;
switch (ndx){case 0:
url = "http://www.srh.noaa.gov/";
if(place_name!=="")
url+="zipcity.php?inputstring="+escape(place_name);
break;
case 1:
url = "http://www.wunderground.com/";
if(place_name!=="")
url+="cgi-bin/findweather/getForecast?query="+escape(place_name);
break;
case 2:
url = "http://www.bbc.co.uk/";
if(place_name!=="")
url+="cgi-perl/weather/search/new_search.pl?search_query="
+escape(place_name.replace(/,.*/, ""));
break;
default:
break;
}
open_url(url);
}
function copy_positions_date(form)
{form.StartDay.selectedIndex=form.CalcDay.selectedIndex;
form.StartYear.value=form.CalcYear.value;
form.StartMonth.selectedIndex=form.CalcMonth.selectedIndex;
check_dates(form, "start");
}
function copy_start_date_to_end(form)
{form.EndDay.selectedIndex=form.StartDay.selectedIndex;
form.EndYear.value=form.StartYear.value;
form.EndMonth.selectedIndex=form.StartMonth.selectedIndex;
}
function get_rs_criteria()
{var
OptionsWindow,
url="SMCalcRSCriteria.htm",
title="Options",
scale=screen.height/768,
wid=920*scale,
ht=360*scale,
xpos=20,
ypos=100;
if(screen.availWidth<1.1*wid)
xpos=0;
if(flags.use_all_tabs===false){var
win_size="height="+ht+",width="+wid,
win_pos="left="+xpos+","+"top="+ypos,
win_attribs="resizable=1,menubar=0,toolbar=0,status=0,scrollbars=0",
win_features=win_size+","+win_pos+","+win_attribs;
OptionsWindow=window.open(url, title, win_features);
}
else
OptionsWindow=window.open(url, title);
OptionsWindow.focus();
}
function increment_calc_date(form, increment)
{var
CalcDate=new Date(),
calc_date,
year=form.CalcYear.value,
month=form.CalcMonth.selectedIndex,
day=form.CalcDay.selectedIndex+1;
calc_date=Date.UTC(year, month, day);
CalcDate.setTime(calc_date+increment.DayToMsec());
form.CalcDay.selectedIndex=CalcDate.getUTCDate()-1;
form.CalcYear.value=CalcDate.getUTCFullYear();
form.CalcMonth.selectedIndex=CalcDate.getUTCMonth();
}
function copy_start_date(form)
{form.CalcDay.selectedIndex=form.StartDay.selectedIndex;
form.CalcYear.value=form.StartYear.value;
form.CalcMonth.selectedIndex=form.StartMonth.selectedIndex;
}
function reset_form(form)
{if(form.loaded===true){
if(confirm('Reset all values to defaults?')===false)
return;
}
flags.initFlags(form);
form.reset();
form.NextPlace.disabled=true;
setLocTypeAttrib();
setCalcTypeAttrib();
reset_date(form);
initialize_times(form);
SaveState.write(form);
}
function reset_date(form)
{var Today=new Date();
Today.setZeroHours();
form.StartDay.selectedIndex=Today.getDate()-1;
form.StartYear.value=Today.getFullYear();
form.StartMonth.selectedIndex=Today.getMonth();
form.EndDay.selectedIndex=form.StartDay.selectedIndex;
form.EndMonth.selectedIndex=form.StartMonth.selectedIndex;
form.EndYear.value=form.StartYear.value;
form.CalcDay.selectedIndex=Today.getDate()-1;
form.CalcYear.value=Today.getFullYear();
form.CalcMonth.selectedIndex=Today.getMonth();
form.end_date[0].checked=true;
form.loaded=true;
}
function get_preferences()
{var
PreferencesWindow,
url="SMCalcPreferences.htm",
title="Preferences",
scale=screen.height/768,
wid=575,
ht=625*scale,
xpos=15,
ypos=25;
if(screen.availWidth<1.1*wid)
xpos=0;
if(screen.availHeight<1.1*ht)
ypos=0;
if(flags.use_all_tabs===false){var
win_size="height="+ht+",width="+wid,
win_pos="left="+xpos+","+"top="+ypos,
win_attribs="resizable=1,menubar=0,toolbar=0,status=0,scrollbars=1",
win_features=win_size+","+win_pos+","+win_attribs;
PreferencesWindow=window.open(url, title, win_features);
}
else
PreferencesWindow=window.open(url, title);
PreferencesWindow.focus();
}
function help(topic)
{var
HelpWindow,
url="SunMoonCalcHelp.htm",
title="Help",
wid=0.9*screen.availWidth,
ht=0.87*screen.availHeight,
xpos=0.02*screen.availWidth,
ypos=0.005*screen.availHeight;
if(topic)
url+="#"+topic;
if(flags.use_popups===true){var
win_size="height="+ht+",width="+wid,
win_pos="left="+xpos+","+"top="+ypos,
win_attribs="resizable=1,menubar=1,toolbar=1,status=1,scrollbars=1",
win_features=win_size+","+win_pos+","+win_attribs;
HelpWindow=window.open(url, title, win_features);
}
else
HelpWindow=window.open(url, title);
HelpWindow.focus();
return true;
}
function open_tutorial()
{var
TutorialWindow,
url="SMCalcTutorial.htm",
title="TutorialWindow";
if(flags.use_popups===true){var
wid=0.9*screen.availWidth,
ht=0.87*screen.availHeight,
xpos=0.02*screen.availWidth,
ypos=0.005*screen.availHeight,
win_size="height="+ht+",width="+wid,
win_pos="left="+xpos+","+"top="+ypos,
win_attribs="resizable=1,menubar=1,toolbar=1,status=1,scrollbars=1",
win_features=win_size+","+win_pos+","+win_attribs;
TutorialWindow=window.open(url, title, win_features);
}
else
TutorialWindow=window.open(url, title);
}
function calculate(output_type)
{var
calc_params=new CalcParams(),
doc_title,
sun=new Object(),
moon=new Object(),
loc=new Place(),
results,
rs_opts=new RSCriteria(form),
time_zone;
if(loc.setLocation(form)===false)
return;
if(rs_opts.rs_alts===true){if(check_rs_alts(rs_opts, loc)===false)
return;
}
flags.initFlags(form);
if(flags.use_popups===true)
SCRIPT=SCRIPT.replace(/flags.use_popups *= *false/, "flags.use_popups=true");
if(output_type=="print"){flags.print=true;
if(flags.use_font_size===true)
set_font_size();
}
else
flags.print=false;
if(calc_params.getCalcParams(form, loc)===false)
return;
loc.mag_dec_mean=mag_model.calcMagDec(loc, loc.mag_dec_date);
if(calc_params.calc_type==POSITIONS){flags.interpolate_rs_positions=false;
loc.mag_dec=loc.mag_dec_mean;
results=positions_results;
}
else
results=times_results;
if(flags.time_program===true)
var program_start=new Date();
results.calculate_times(calc_params, sun, moon, rs_opts, loc);
results.build_times_header(rs_opts);
if(calc_params.calc_type==POSITIONS){
calc_params.getCalcTimes(sun, moon, loc);
if(calc_params.events_occur===true&&calc_params.start_time<=calc_params.ut_24h){results.calculate_positions(calc_params, sun, moon, loc);
results.build_positions_header();
}
else if(calc_params.checkSunNoPhenom(sun)===true){var msg=calc_params.eventMessage();
calc_params.setCalcTimes24h(sun, moon, loc);
results.calculate_positions(calc_params, sun, moon, loc);
results.build_positions_header(calc_params.SunNoPhenomMessage(sun));
}
else{results.positions.length=0;
results.positions_header=calc_params.eventMessage();
}
results.rs_criteria=null;
}
else
results.add_rs_criteria(calc_params, rs_opts);
if(flags.use_sep_windows===true&&calc_params.calc_type==POSITIONS)
results.name="Positions";
else
results.name="Results";
if(calc_params.calc_type==POSITIONS)
doc_title="Positions";
else
doc_title="Times";
results.build_doc_head(doc_title);
results.build_page_top(calc_params, rs_opts, loc);
results.copyright=copyright;
results.add_buttons();
if(flags.time_program===true)
results.prog_time=prog_time(program_start);
else
results.prog_time=null;
results.output();
flags.print=false;
}
function RSCriteria(form)
{this.rs_alts=false;
this.selections=false;
this.mr_check=false;
this.ms_check=false;
this.phase_check=false;
this.show_phase="transit";
if(form.SunriseAltRange.value=="true"){this.alt_sr_check=true;
this.alt_sr_min=form.SunriseAltMin.value.DMSto();
this.alt_sr_max=form.SunriseAltMax.value.DMSto();
if(this.alt_sr_min!=this.alt_sr_max)
this.alt_sr_range=true;
this.alt_sr_type=form.SunriseAltType.value;
}
else{this.alt_sr_check=false;
this.alt_sr_min=this.alt_sr_max=0;
this.alt_sr_type="top";
}
this.alt_sr=(this.alt_sr_min+this.alt_sr_max)/2;
if(form.SunsetAltRange.value=="true"){this.alt_ss_check=true;
this.alt_ss_min=form.SunsetAltMin.value.DMSto();
this.alt_ss_max=form.SunsetAltMax.value.DMSto();
if(this.alt_ss_min!=this.alt_ss_max)
this.alt_ss_range=true;
this.alt_ss_type=form.SunsetAltType.value;
}
else{this.alt_ss_check=false;
this.alt_ss_min=this.alt_ss_max=0;
this.alt_ss_type="top";
}
this.alt_ss=(this.alt_ss_min+this.alt_ss_max)/2;
if(form.MoonriseAltRange.value=="true"){this.alt_mr_check=true;
this.alt_mr_min=form.MoonriseAltMin.value.DMSto();
this.alt_mr_max=form.MoonriseAltMax.value.DMSto();
if(this.alt_mr_min!=this.alt_mr_max)
this.alt_mr_range=true;
this.alt_mr_type=form.MoonriseAltType.value;
}
else{this.alt_mr_check=false;
this.alt_mr_min=this.alt_mr_max=0;
this.alt_mr_type="top";
}
this.alt_mr=(this.alt_mr_min+this.alt_mr_max)/2;
if(form.MoonsetAltRange.value=="true"){this.alt_ms_check=true;
this.alt_ms_min=form.MoonsetAltMin.value.DMSto();
this.alt_ms_max=form.MoonsetAltMax.value.DMSto();
if(this.alt_ms_min!=this.alt_ms_max)
this.alt_ms_range=true;
this.alt_ms_type=form.MoonsetAltType.value;
}
else{this.alt_ms_check=false;
this.alt_ms_min=this.alt_ms_max=0;
this.alt_ms_type="top";
}
this.alt_ms=(this.alt_ms_min+this.alt_ms_max)/2;
if(form.SunriseAzRange.value=="true")
this.az_sr_check=true;
else
this.az_sr_check=false;
this.az_sr_min=form.SunriseAzMin.value.DMSto();
this.az_sr_max=form.SunriseAzMax.value.DMSto();
if(form.SunsetAzRange.value=="true")
this.az_ss_check=true;
else
this.az_ss_check=false;
this.az_ss_min=form.SunsetAzMin.value.DMSto();
this.az_ss_max=form.SunsetAzMax.value.DMSto();
if(form.MoonriseAzRange.value=="true")
this.az_mr_check=true;
else
this.az_mr_check=false;
this.az_mr_min=form.MoonriseAzMin.value.DMSto();
this.az_mr_max=form.MoonriseAzMax.value.DMSto();
if(form.MoonrisePhaseRange.value=="true")
this.phase_mr_check=true;
else
this.phase_mr_check=false;
this.phase_mr_min=Number(form.MoonrisePhaseMin.value);
this.phase_mr_max=Number(form.MoonrisePhaseMax.value);
if(form.MoonriseTdiff.value=="true")
this.tdiff_mr_check=true;
else
this.tdiff_mr_check=false;
this.tdiff_mr_min=form.MoonriseTdiffMin.value;
this.tdiff_mr_max=form.MoonriseTdiffMax.value;
this.tdiff_mr_type=form.MoonriseTdiffType.value;
if(form.MoonsetAzRange.value=="true")
this.az_ms_check=true;
else
this.az_ms_check=false;
this.az_ms_min=form.MoonsetAzMin.value.DMSto();
this.az_ms_max=form.MoonsetAzMax.value.DMSto();
if(form.MoonsetPhaseRange.value=="true")
this.phase_ms_check=true;
else
this.phase_ms_check=false;
this.phase_ms_min=Number(form.MoonsetPhaseMin.value);
this.phase_ms_max=Number(form.MoonsetPhaseMax.value);
if(form.MoonsetTdiff.value=="true")
this.tdiff_ms_check=true;
else
this.tdiff_ms_check=false;
this.tdiff_ms_min=Number(form.MoonsetTdiffMin.value);
this.tdiff_ms_max=Number(form.MoonsetTdiffMax.value);
this.tdiff_ms_type=form.MoonsetTdiffType.value;
if(this.alt_sr_check===true){if(this.alt_sr!==0||this.alt_sr_type=="center")
this.rs_alts=true;
}
if(this.alt_ss_check===true){if(this.alt_ss!==0||this.alt_ss_type=="center")
this.rs_alts=true;
}
if(this.alt_mr_check===true){if(this.alt_mr!==0||this.alt_mr_type=="center")
this.rs_alts=true;
}
if(this.alt_ms_check===true){if(this.alt_ms!==0||this.alt_ms_type=="center")
this.rs_alts=true;
}
if(this.az_sr_check===true)
this.decl_sr_check=true;
if(this.az_ss_check===true)
this.decl_ss_check=true;
if(this.az_mr_check===true)
this.decl_mr_check=true;
if(this.az_ms_check===true)
this.decl_ms_check=true;
if(this.tdiff_mr_check===true&&this.tdiff_ms_check===false)
this.show_tdiff_mr=true;
else if(this.tdiff_mr_check===false&&this.tdiff_ms_check===true)
this.show_tdiff_ms=true;
else{this.show_tdiff_mr=false;
this.show_tdiff_ms=false;
}
if(this.phase_mr_check===true||this.phase_ms_check===true)
this.phase_check=true;
if(this.decl_mr_check===true||this.phase_mr_check===true||
this.tdiff_mr_check===true)
this.mr_check=true;
if(this.decl_ms_check===true||this.phase_ms_check===true||
this.tdiff_ms_check===true)
this.ms_check=true;
if(this.mr_check===true&&this.ms_check===false)
this.show_phase="rise";
else if(this.mr_check===false&&this.ms_check===true)
this.show_phase="set";
if(this.decl_sr_check===true||this.decl_ss_check===true)
this.selections=true;
if(this.mr_check===true||this.ms_check===true)
this.selections=true;
if(this.tdiff_mr_check===true||this.tdiff_ms_check===true)
this.selections=true;
}
RSCriteria.prototype.getDeclLimits=function(type, loc)
{var limits=new Object();
switch (type){case "sunrise":
limits.alt_min=this.alt_sr_min;
limits.alt_max=this.alt_sr_max;
limits.az_min=this.az_sr_min;
limits.az_max=this.az_sr_max;
break;
case "sunset":
limits.alt_min=this.alt_ss_min;
limits.alt_max=this.alt_ss_max;
limits.az_min=this.az_ss_min;
limits.az_max=this.az_ss_max;
break;
case "moonrise":
limits.alt_min=this.alt_mr_min;
limits.alt_max=this.alt_mr_max;
limits.az_min=this.az_mr_min;
limits.az_max=this.az_mr_max;
break;
case "moonset":
limits.alt_min=this.alt_ms_min;
limits.alt_max=this.alt_ms_max;
limits.az_min=this.az_ms_min;
limits.az_max=this.az_ms_max;
break;
default:
break;
}
if(flags.show_mag_north===true){limits.az_min+=loc.mag_dec_mean;
limits.az_max+=loc.mag_dec_mean;
}
limits.alt_min=appAltToTrueAlt(limits.alt_min, loc);
limits.alt_max=appAltToTrueAlt(limits.alt_max, loc);
calcDeclLimits(loc, limits);
switch (type){case "sunrise":
this.decl_sr_min=limits.decl_min;
this.decl_sr_max=limits.decl_max;
break;
case "sunset":
this.decl_ss_min=limits.decl_min;
this.decl_ss_max=limits.decl_max;
break;
case "moonrise":
this.decl_mr_min=limits.decl_min;
this.decl_mr_max=limits.decl_max;
break;
case "moonset":
this.decl_ms_min=limits.decl_min;
this.decl_ms_max=limits.decl_max;
break;
default:
break;
}
return 0;
};
RSCriteria.prototype.expandTimeDiff=function(body, alt_tol, cos_lat, azimuth)
{var d_GHA, d_t;
if(body=="Sun")
d_GHA=15;
else
d_GHA=14.493;
d_t=alt_tol*60/(cos_lat*Math.sin(azimuth.DtoR())*d_GHA);
return Math.abs(d_t);
};
RSCriteria.prototype.select=function(sun, moon, loc)
{var
alt_tol,
dt,
tdiff_mr, tdiff_ms,
tdiff_min, tdiff_max;
var cos_lat=loc.cos_lat;
if(this.selections===false)
return true;
if(this.decl_sr_check===true){if(sun.az_rise===null)
return false;
else if(sun.decl_rise<this.decl_sr_min||sun.decl_rise>this.decl_sr_max)
return false;
}
if(this.decl_ss_check===true){if(sun.az_set===null)
return false;
else if(sun.decl_set<this.decl_ss_min||sun.decl_set>this.decl_ss_max)
return false;
}
if(this.mr_check===true){if(moon.az_rise===null)
return false;
if(this.decl_mr_check===true){if(moon.decl_rise<this.decl_mr_min||moon.decl_rise>this.decl_mr_max)
return false;
}
if(this.phase_mr_check===true){if(moon.phase_r<this.phase_mr_min||moon.phase_r>this.phase_mr_max)
return false;
}
if(this.tdiff_mr_check===true){tdiff_min=this.tdiff_mr_min-0;
tdiff_max=this.tdiff_mr_max-0;
if(this.tdiff_mr_type=="sunset"){if(sun.az_set===null)
return false;
else
tdiff_mr=(moon.rise-sun.set)*60;
if((alt_tol=(this.alt_ss_max-this.alt_ss_min)/2)!==0){dt=this.expandTimeDiff("Sun", alt_tol, cos_lat, sun.az_set);
tdiff_min-=dt;
tdiff_max+=dt;
}
}
else{if(sun.az_rise===null)
return false;
else
tdiff_mr=(moon.rise-sun.rise)*60;
if((alt_tol=(this.alt_sr_max-this.alt_sr_min)/2)!==0){dt=this.expandTimeDiff("Sun", alt_tol, cos_lat, sun.az_rise);
tdiff_min-=dt;
tdiff_max+=dt;
}
}
if((alt_tol=(this.alt_mr_max-this.alt_mr_min)/2)!==0){dt=this.expandTimeDiff("Moon", alt_tol, cos_lat, moon.az_rise)+0;
tdiff_min-=dt;
tdiff_max+=dt;
}
if(tdiff_mr<tdiff_min||tdiff_mr>tdiff_max)
return false;
}
}
if(this.ms_check===true){if(moon.az_set===null)
return false;
if(this.decl_ms_check===true){if(moon.decl_set<this.decl_ms_min||moon.decl_set>this.decl_ms_max)
return false;
}
if(this.phase_ms_check===true){if(moon.phase_s<this.phase_ms_min||moon.phase_s>this.phase_ms_max)
return false;
}
if(this.tdiff_ms_check===true){tdiff_min=this.tdiff_ms_min-0;
tdiff_max=this.tdiff_ms_max-0;
if(this.tdiff_ms_type=="sunset"){if(sun.az_set===null)
return false;
else
tdiff_ms=(moon.set-sun.set)*60;
if((alt_tol=(this.alt_ss_max-this.alt_ss_min)/2)!==0){dt=this.expandTimeDiff("Sun", alt_tol, cos_lat, sun.az_set);
tdiff_min-=dt;
tdiff_max+=dt;
}
}
else{if(sun.az_rise===null)
return false;
else
tdiff_ms=(moon.set-sun.rise)*60;
if((alt_tol=(this.alt_sr_max-this.alt_sr_min)/2)!==0){dt=this.expandTimeDiff("Sun", alt_tol, cos_lat, sun.az_rise);
tdiff_min-=dt;
tdiff_max+=dt;
}
}
if((alt_tol=(this.alt_ms_max-this.alt_ms_min)/2)!==0){dt=this.expandTimeDiff("Moon", alt_tol, cos_lat, moon.az_set);
tdiff_min-=dt;
tdiff_max+=dt;
}
if(tdiff_ms<tdiff_min||tdiff_ms>tdiff_max)
return false;
}
}
return true;
};
function initFlags(form)
{var ndx;
this.next_day=false;
if(form.UseSepWindows.value=="true")
this.use_sep_windows=true;
else
this.use_sep_windows=false;
if(form.UsePopups.value=="true")
this.use_popups=true;
else
this.use_popups=false;
if(form.UseAllTabs.value=="true")
this.use_all_tabs=true;
else
this.use_all_tabs=false;
if(form.ShowSearch.value=="true")
this.show_search=true;
else
this.show_search=false;
if(form.UseREs.value=="true")
this.use_REs=true;
else
this.use_REs=false;
if(form.ShowMagDec.value=="true")
this.show_mag_dec=true;
else
this.show_mag_dec=false;
if(form.ShowDSTRules.value=="true")
this.show_dst_rules=true;
else
this.show_dst_rules=false;
if(form.ShowDSTDates.value=="true")
this.show_dst_dates=true;
else
this.show_dst_dates=false;
if(form.ShowAMPMTime.value=="true")
this.show_am_pm_time=true;
else
this.show_am_pm_time=false;
if(form.ShowDST.value=="true")
this.show_dst=true;
else
this.show_dst=false;
if(form.ShowUT.value=="true")
this.show_ut=true;
else
this.show_ut=false;
if(form.ShowMagNorth.value=="true")
this.show_mag_north=true;
else
this.show_mag_north=false;
if(form.ElevationInFeet.value=="true")
this.elevation_in_feet=true;
else
this.elevation_in_feet=false;
if(form.InterpolateRSPositions.value=="true")
this.interpolate_rs_positions=true;
else
this.interpolate_rs_positions=false;
if(form.EnableInactiveInputs.value=="true")
this.enable_inactive_inputs=true;
else
this.enable_inactive_inputs=false;
if(form.ShowCopyDates.value=="true")
this.show_copy_dates=true;
else
this.show_copy_dates=false;
if(form.ShowCheckPlaces.value=="true")
this.show_check_places=true;
else
this.show_check_places=false;
if(form.ShowAzAdjust.value=="true")
this.show_az_adjust=true;
else
this.show_az_adjust=false;
if(form.TimeProgram.value=="true")
this.time_program=true;
else
this.time_program=false;
if(form.UseFontSize.value=="true")
this.use_font_size=true;
else
this.use_font_size=false;
this.font_size=form.FontSize.value;
}
function Flag()
{;
}
Flag.prototype.initFlags=initFlags;
function CalcParams()
{
this.MAX_DAY_CALC=7320;
this.start_date=-999999;
this.end_date=-999999;
this.date_step=1;
this.time_start_type=-99;
this.time_end_type=-99;
this.start_time=-99;
this.end_time=-99;
this.time_step=1;
}
CalcParams.prototype.getCalcParams=getCalcParams;
CalcParams.prototype.getEvent=function(type, sun, moon)
{var event;
switch(type){case 1:
event=sun.dawn;
break;
case 2:
event=sun.rise;
break;
case 3:
event=sun.transit;
break;
case 4:
event=sun.set;
break;
case 5:
event=sun.dusk;
break;
case 6:
event=moon.rise;
break;
case 7:
event=moon.transit;
break;
case 8:
event=moon.set;
break;
default:
break;
}
return event;
};
CalcParams.prototype.getCalcTimes=function(sun, moon, loc)
{var
CalcDate=new Date(),
event_time,
offset,
start_date=this.start_date,
ut_offset,
time_step=this.time_step;
if(this.time_start_type>0){event_time=this.getEvent(this.time_start_type, sun, moon);
if(Math.abs(event_time)>F_TEST_NO_EVENT)
this.start_time=null;
else{offset=this.start_event_offset;
this.start_time=event_time+offset;
this.start_time+=loc.ut_offset;
if(time_step>1/60||offset===0)
this.start_time=Math.floor(this.start_time/time_step)*time_step;
else
this.start_time=Math.round(this.start_time/time_step)*time_step;
this.start_time-=loc.ut_offset;
}
}
if(this.time_end_type==-1)
this.end_time=this.start_time+this.t_offset;
else if(this.time_end_type>0){event_time=this.getEvent(this.time_end_type, sun, moon);
if(Math.abs(event_time)>F_TEST_NO_EVENT)
this.end_time=null;
else if(event_time>this.ut_24h)
this.end_time=this.ut_24h;
else{offset=this.end_event_offset;
this.end_time=event_time+offset;
this.end_time+=loc.ut_offset;
if(time_step>1/60||offset===0)
this.end_time=Math.ceil(this.end_time/time_step)*time_step;
else
this.end_time=Math.round(this.end_time/time_step)*time_step;
this.end_time-=loc.ut_offset;
}
}
if(this.start_time===null||this.end_time===null)
this.events_occur=false;
else{this.events_occur=true;
if(this.start_time>this.end_time)
this.end_time+=24;
}
CalcDate.setTime((start_date+(-loc.timezone-12)/24).DayToMsec());
ut_offset=loc.getTimeOffset(CalcDate);
if(this.start_time+ut_offset<-12)
this.start_time=-ut_offset-12;
CalcDate.setTime((start_date+(-loc.timezone+48)/24).DayToMsec());
ut_offset=loc.getTimeOffset(CalcDate);
if(this.end_time+ut_offset>48)
this.end_time=-ut_offset+48;
if(this.end_time+loc.ut_offset>=24)
flags.next_day=true;
};
CalcParams.prototype.setCalcTimes24h=function(sun, moon, loc)
{var
CalcDate=new Date(),
ut_offset;
this.time_start_type=0;
this.start_time=0;
this.start_time-=loc.timezone;
CalcDate.setTime((this.start_date+this.start_time/24).DayToMsec());
if(CalcDate.checkTimeAdjustDST(loc)===true)
this.start_time-=1;
this.ut_24h=24-loc.timezone;
CalcDate.setTime((this.start_date+1-loc.timezone/24).DayToMsec());
ut_offset=loc.getTimeOffset(CalcDate);
if(ut_offset!=loc.timezone)
this.ut_24h=24-ut_offset;
this.time_end_type=0;
this.end_time=24;
this.end_time-=loc.timezone;
CalcDate.setTime((this.start_date+this.end_time/24).DayToMsec());
if(CalcDate.checkTimeAdjustDST(loc)===true)
this.end_time-=1;
this.time_step=1;
};
CalcParams.prototype.checkSunNoPhenom=function(sun)
{
if(this.time_start_type==2&&this.time_end_type==4&&
Math.abs(sun.rise)>=F_CIRCUMPOLAR&&Math.abs(sun.set)>=F_CIRCUMPOLAR)
return true;
else
return false;
};
CalcParams.prototype.SunNoPhenomMessage=function(sun)
{var msg="";
if(sun.rise<=-F_CIRCUMPOLAR&&sun.set<=-F_CIRCUMPOLAR)
msg='****'+SP+'Sun never rises'+SP+'****';
else if(sun.rise>=F_CIRCUMPOLAR&&sun.set>=F_CIRCUMPOLAR)
msg='****'+SP+'Sun never sets'+SP+'****';
if(msg)
msg=BR+SP2+msg.big().bold()+BR+BR+LF;
return msg;
};
CalcParams.prototype.eventMessage=function()
{var names=[
"dawn",
"sunrise",
"Sun transit",
"sunset",
"dusk",
"moonrise",
"Moon transit",
"moonset"
];
var msg="";
if(this.start_time===null)
msg='****'+SP+'No '+names[this.time_start_type-1];
if(this.time_end_type!=this.time_start_type&&this.end_time===null){if(! msg)
msg='****'+SP+'No ';
else
msg+=' or ';
msg+=names[this.time_end_type-1];
}
if(msg)
msg=BR+SP2+(msg+SP+'****').big().bold()+BR+LF;
return msg;
};
function getCalcParams(form, loc)
{var
year, month, day,
StartDate, EndDate,
n_calcs,
ndx,
start_date, end_date, date_offset, date_step,
start_time, end_time, time_offset, multiplier, time_step,
ut_offset,
mag_date=new Date();
if(form.calc_type[0].checked===true){
this.calc_type=TIMES;
year=form.StartYear.value;
month=form.StartMonth.selectedIndex;
day=form.StartDay.selectedIndex+1;
if(check_year(form.StartYear, "start")===false)
return false;
StartDate=new Date();
StartDate.setTime(Date.UTC(year, month, day));
if(StartDate.getJulian()<2299160.5){alert("Earliest date is 15 October 1582");
if(flags.isMozilla===false)
form.StartDay.focus();
return false;
}
if(loc.getDSTLimits(StartDate.getUTCFullYear())===false)
return false;
start_date=StartDate.getTime().MsecToDay();
if(form.end_date[1].checked===true){if(check_nonnegative(form.DateOffset, "date offset")===false)
return false;
else{date_offset=form.DateOffset.value-0;
ndx=form.DateOffsetUnits.selectedIndex;
end_date=start_date+date_offset*form.DateOffsetUnits.options[ndx].value;
}
}
else{if(check_year(form.EndYear, "end")===false)
return false;
year=form.EndYear.value;
month=form.EndMonth.selectedIndex;
day=form.EndDay.selectedIndex+1;
EndDate=new Date();
EndDate.setTime(Date.UTC(year, month, day));
end_date=EndDate.getTime().MsecToDay();
date_offset=Math.round(end_date-start_date);
end_date=start_date+date_offset;
}
if(check_dates(form, "start")===false){EndDate=new Date(form.EndYear.value,
form.EndMonth.selectedIndex,
form.EndDay.selectedIndex+1);
end_date=EndDate.getTime().MsecToDay();
}
ndx=form.DateIntervalUnits.selectedIndex;
if(check_date_step(form.DateStep, form.DateIntervalUnits)===false)
return false;
else
date_step=form.DateStep.value-0;
date_step*=form.DateIntervalUnits.options[ndx].value;
if(date_step<1){date_step=1;
if(form.DateIntervalUnits.options[ndx].value==1)
form.DateStep.value=1;
}
n_calcs=Math.round((end_date-start_date)/date_step);
if(n_calcs>this.MAX_DAY_CALC){alert("Too many calculations ("+n_calcs+")--maximum is "
+this.MAX_DAY_CALC);
return false;
}
this.start_date=start_date;
this.end_date=end_date;
this.date_step=date_step;
this.date_step_units_ndx=form.DateIntervalUnits.selectedIndex;
this.date_step_units_value=form.DateIntervalUnits.options[ndx].value;
EndDate=new Date();
EndDate.setTime(end_date.DayToMsec());
var
start_mag_valid=check_mag_date(this.start_date),
end_mag_valid=check_mag_date(this.end_date);
if(start_mag_valid===true&&end_mag_valid===true)
loc.mag_dec_valid=true;
else
loc.mag_dec_valid=false;
loc.mag_dec_date=(this.start_date+this.end_date)/2;
}
else{
this.calc_type=POSITIONS;
year=form.CalcYear.value;
month=form.CalcMonth.selectedIndex;
day=form.CalcDay.selectedIndex+1;
if(check_year(form.CalcYear, "positions")===false)
return false;
this.start_date=Date.UTC(year, month, day);
StartDate=new Date();
StartDate.setTime(this.start_date);
if(StartDate.getJulian()<2299160.5){alert("Earliest date is 15 October 1582");
form.CalcDay.focus();
return false;
}
if(loc.getDSTLimits(StartDate.getUTCFullYear())===false)
return false;
this.start_date=this.start_date.MsecToDay();
this.end_date=this.start_date;
ndx=form.TimeStep.selectedIndex;
time_step=form.TimeStep.options[ndx].value;
if(form.time_start_type[0].checked===true){this.time_start_type=form.StartEvent.selectedIndex+1;
if(check_event_time_offset(form.StartEventOffset, "start")===false)
return false;
else{this.start_event_offset=Number(form.StartEventOffset.value)/60;
if(form.StartEventOffsetSign.selectedIndex===0)
this.start_event_offset*=-1;
}
}
else{this.time_start_type=0;
if((this.start_time=form.StartTime.value.parseTime("start"))===null)
return false;
if(flags.show_ut===false){this.start_time-=loc.timezone;
StartDate.setDateDecimalTime(year, month, day, this.start_time);
if(StartDate.checkTimeAdjustDST(loc)===true)
this.start_time-=1;
}
}
this.ut_24h=24-loc.timezone;
StartDate.setTime(Date.UTC(year, month, day+1,-loc.timezone));
ut_offset=loc.getTimeOffset(StartDate);
if(ut_offset!=loc.timezone)
this.ut_24h=24-ut_offset;
if(form.end_time[0].checked===true){if(form.time_end_type[0].checked===true)
this.time_end_type=form.EndEvent.selectedIndex+1;
else{this.time_end_type=0;
if((this.end_time=form.EndTime.value.parseTime("end"))===null)
return false;
if(this.end_time===0)
this.end_time=24;
if(flags.show_ut===false){this.end_time-=loc.timezone;
StartDate.setDateDecimalTime(year, month, day, this.end_time);
if(StartDate.checkTimeAdjustDST(loc)===true)
this.end_time-=1;
}
}
if(check_event_time_offset(form.EndEventOffset, "end")===false)
return false;
else{this.end_event_offset=Number(form.EndEventOffset.value)/60;
if(form.EndEventOffsetSign.selectedIndex===0)
this.end_event_offset*=-1;
}
}
else{if(check_time_offset(form)===false)
return false;
else{time_offset=form.TimeOffset.value-0;
ndx=form.TimeOffsetUnits.selectedIndex;
multiplier=form.TimeOffsetUnits.options[ndx].value;
}
this.time_end_type=-1;
this.t_offset=time_offset/multiplier;
}
this.time_step=time_step/60;
StartDate.setTime(Date.UTC(year, month, day));
loc.mag_dec_date=this.start_date;
loc.mag_dec_valid=check_mag_date(loc.mag_dec_date);
}
mag_date.setTime(loc.mag_dec_date.DayToMsec());
loc.mag_date_str=mag_date.toLocDateStr(0);
loc.mag_dec_date_valid=check_mag_dec_date(loc.mag_dec_date);
return true;
}
var
NAME=0,
LAT=1,
LONG=2,
TZ=3,
DST=4,
ELEV=5,
HEIGHT=6;
var places=[
[ "Anchorage, AK", "61:13:05", "-149:54:00",-9, 1, 31 ],
[ "Barrow, AK", "71:17:26", "-156:47:20",-9, 1, 0 ],
[ "Bethel, AK", "60:47:32", "-161:45:22",-9, 1, 0 ],
[ "Cordova, AK", "60:32:34", "-145:45:29",-9, 1, 0 ],
[ "Craig, AK", "55:28:35", "-133:08:53",-9, 1, 1014 ],
[ "Dillingham, AK", "59:02:23", "-158:27:29",-9, 1, 26 ],
[ "Diomede, AK", "65:44:13", "-168:56:31",-9, 1, 0 ],
[ "Fairbanks, AK", "64:50:16", "-147:42:58",-9, 1, 134 ],
[ "Homer, AK", "59:38:33", "-151:32:53",-9, 1, 0 ],
[ "Hooper Bay, AK", "61:31:52", "-166:05:49",-9, 1, 11 ],
[ "Juneau, AK", "58:18:07", "-134:25:12",-9, 1, 0 ],
[ "Ketchikan, AK", "55:20:32", "-131:38:46",-9, 1, 0 ],
[ "Kodiak, AK", "57:47:24", "-152:24:25",-9, 1, 0 ],
[ "Navy Town, AK", "52:50:27", "173:10:32",-10, 1, 0 ],
[ "Nome, AK", "64:30:04", "-165:24:22",-9, 1, 0 ],
[ "Seward, AK", "60:06:15", "-149:26:31",-9, 1, 17 ],
[ "Sitka, AK", "57:03:11", "-135:19:48",-9, 1, 0 ],
[ "Skagway, AK", "59:27:30", "-135:18:50",-9, 1, 7 ],
[ "Unalaska, AK", "53:51:40", "-166:31:40",-9, 1, 0 ],
[ "Wrangell, AK", "56:28:15", "-132:22:37",-9, 1, 0 ],
[ "Auburn, AL", "32:36:35", "-85:28:51",-6, 1, 216 ],
[ "Birmingham, AL", "33:31:14", "-86:48:09",-6, 1, 183 ],
[ "Dothan, AL", "31:13:23", "-85:23:26",-6, 1, 99 ],
[ "Gadsden, AL", "34:00:51", "-86:00:24",-6, 1, 169 ],
[ "Huntsville, AL", "34:43:49", "-86:35:10",-6, 1, 195 ],
[ "Livingston, AL", "32:35:03", "-88:11:14",-6, 1, 45 ],
[ "Mobile, AL", "30:41:39", "-88:02:35",-6, 1, 5 ],
[ "Montgomery, AL", "32:22:00", "-86:18:00",-6, 1, 76 ],
[ "Selma, AL", "32:24:26", "-87:01:16",-6, 1, 42 ],
[ "Tuscaloosa, AL", "33:12:35", "-87:34:09",-6, 1, 69 ],
[ "Blytheville, AR", "35:55:38", "-89:55:08",-6, 1, 79 ],
[ "Brinkley, AR", "34:53:16", "-91:11:40",-6, 1, 63 ],
[ "Clinton, AR", "35:35:29", "-92:27:37",-6, 1, 0 ],
[ "El Dorado, AR", "33:12:27", "-92:39:58",-6, 1, 76 ],
[ "Fayetteville, AR", "36:03:45", "-94:09:26",-6, 1, 427 ],
[ "Fort Smith, AR", "35:23:09", "-94:23:54",-6, 1, 136 ],
[ "Jonesboro, AR", "35:50:32", "-90:42:15",-6, 1, 101 ],
[ "Little Rock, AR", "34:44:47", "-92:17:22",-6, 1, 107 ],
[ "Mountain Home, AR", "36:20:07", "-92:23:06",-6, 1, 250 ],
[ "Russellville, AR", "35:16:42", "-93:08:01",-6, 1, 108 ],
[ "Texarkana, AR", "33:26:30", "-94:02:15",-6, 1, 102 ],
[ "Pago Pago, AS", "14:16:41", "-170:42:09",-11, 0, 2 ],
[ "Ajo, AZ", "32:22:18", "-112:51:36",-7, 0, 0 ],
[ "Flagstaff, AZ", "35:11:53", "-111:39:04",-7, 0, 0 ],
[ "Holbrook, AZ", "34:54:08", "-110:09:29",-7, 0, 1549 ],
[ "Kayenta, AZ", "36:43:40", "-110:15:14",-7, 1, 1719 ],
[ "Kingman, AZ", "35:11:22", "-114:03:07",-7, 0, 1018 ],
[ "Nogales, AZ", "31:20:25", "-110:56:02",-7, 0, 0 ],
[ "Page, AZ", "36:54:31", "-111:28:23",-7, 0, 1311 ],
[ "Phoenix, AZ", "33:26:54", "-112:04:23",-7, 0, 329 ],
[ "Sedona, AZ", "34:52:11", "-111:45:36",-7, 0, 1294 ],
[ "Springerville, AZ", "34:08:00", "-109:17:06",-7, 0, 2124 ],
[ "Tucson, AZ", "32:13:18", "-110:55:34",-7, 0, 731 ],
[ "Willcox, AZ", "32:15:10", "-109:49:52",-7, 0, 1270 ],
[ "Yuma, AZ", "32:43:31", "-114:37:26",-7, 0, 0 ],
[ "Alturas, CA", "41:29:14", "-120:32:28",-8, 1, 1331 ],
[ "Baker, CA", "35:15:54", "-116:04:25",-8, 1, 281 ],
[ "Bakersfield, CA", "35:22:24", "-119:01:05",-8, 1, 124 ],
[ "Barstow, CA", "34:53:55", "-117:01:19",-8, 1, 642 ],
[ "Bishop, CA", "37:21:49", "-118:23:38",-8, 1, 1264 ],
[ "Blythe, CA", "33:36:37", "-114:35:46",-8, 1, 81 ],
[ "Borrego Springs, CA", "33:15:21", "-116:22:27",-8, 1, 180 ],
[ "Crescent City, CA", "41:45:22", "-124:12:04",-8, 1, 13 ],
[ "Eureka, CA", "40:48:08", "-124:09:47",-8, 1, 13 ],
[ "Fort Bragg, CA", "39:26:45", "-123:48:14",-8, 1, 30 ],
[ "Fresno, CA", "36:44:52", "-119:46:16",-8, 1, 90 ],
[ "Gorman, CA", "34:47:46", "-118:51:06",-8, 1, 1162 ],
[ "Lee Vining, CA", "37:57:27", "-119:07:15",-8, 1, 2067 ],
[ "Lone Pine, CA", "36:36:22", "-118:03:43",-8, 1, 1138 ],
[ "Los Angeles, CA", "34:03:08", "-118:14:35",-8, 1, 101 ],
[ "Los Osos, CA", "35:18:40", "-120:49:53",-8, 1, 38 ],
[ "Mojave, CA", "35:03:09", "-118:10:23",-8, 1, 840 ],
[ "Monterey, CA", "36:36:01", "-121:53:38",-8, 1, 18 ],
[ "Mount Shasta, CA", "41:18:36", "-122:18:34",-8, 1, 1083 ],
[ "Needles, CA", "34:50:53", "-114:36:47",-8, 1, 149 ],
[ "Nevada City, CA", "39:15:42", "-121:00:54",-8, 1, 770 ],
[ "Orick, CA", "41:17:13", "-124:03:31",-8, 1, 10 ],
[ "Quincy, CA", "39:56:13", "-120:56:46",-8, 1, 1046 ],
[ "Redding, CA", "40:35:12", "-122:23:28",-8, 1, 170 ],
[ "Sacramento, CA", "38:34:54", "-121:29:35",-8, 1, 6 ],
[ "San Diego, CA", "32:42:55", "-117:09:22",-8, 1, 12 ],
[ "San Francisco, CA", "37:46:30", "-122:25:05",-8, 1, 19 ],
[ "San Luis Obispo, CA", "35:16:58", "-120:39:32",-8, 1, 71 ],
[ "Santa Barbara, CA", "34:25:15", "-119:41:49",-8, 1, 15 ],
[ "Santa Rosa, CA", "38:26:26", "-122:42:47",-8, 1, 49 ],
[ "Susanville, CA", "40:24:59", "-120:39:07",-8, 1, 1298 ],
[ "Truckee, CA", "39:19:41", "-120:10:55",-8, 1, 1780 ],
[ "Twentynine Palms, CA", "34:08:08", "-116:03:11",-8, 1, 610 ],
[ "Yreka, CA", "41:44:08", "-122:37:59",-8, 1, 800 ],
[ "Aspen, CO", "39:11:28", "-106:49:01",-7, 1, 2410 ],
[ "Burlington, CO", "39:18:22", "-102:16:08",-7, 1, 1270 ],
[ "Colorado Springs, CO", "38:50:02", "-104:49:16",-7, 1, 1831 ],
[ "Craig, CO", "40:30:55", "-107:32:46",-7, 1, 1885 ],
[ "Denver, CO", "39:44:21", "-104:59:02",-7, 1, 1603 ],
[ "Durango, CO", "37:16:31", "-107:52:44",-7, 1, 1988 ],
[ "Fort Collins, CO", "40:35:07", "-105:05:02",-7, 1, 1525 ],
[ "Grand Junction, CO", "39:03:50", "-108:33:00",-7, 1, 1401 ],
[ "Lamar, CO", "38:05:14", "-102:37:12",-7, 1, 1104 ],
[ "Pueblo, CO", "38:15:16", "-104:36:32",-7, 1, 1421 ],
[ "Rifle, CO", "39:32:05", "-107:46:59",-7, 1, 1629 ],
[ "Steamboat Springs, CO", "40:29:06", "-106:49:52",-7, 1, 2051 ],
[ "Telluride, CO", "37:56:15", "-107:48:42",-7, 1, 2774 ],
[ "Trinidad, CO", "37:10:10", "-104:30:00",-7, 1, 1835 ],
[ "Bridgeport, CT", "41:10:01", "-73:12:19",-5, 1, 12 ],
[ "Danbury, CT", "41:23:41", "-73:27:16",-5, 1, 115 ],
[ "Hartford, CT", "41:45:49", "-72:41:08",-5, 1, 38 ],
[ "New Haven, CT", "41:18:29", "-72:55:43",-5, 1, 0 ],
[ "New London, CT", "41:21:20", "-72:06:00",-5, 1, 0 ],
[ "Norwich, CT", "41:31:27", "-72:04:35",-5, 1, 0 ],
[ "Putnam, CT", "41:54:54", "-71:54:34",-5, 1, 0 ],
[ "Salisbury, CT", "41:59:00", "-73:25:18",-5, 1, 0 ],
[ "Stamford, CT", "41:03:12", "-73:32:21",-5, 1, 0 ],
[ "Waterbury, CT", "41:33:29", "-73:03:07",-5, 1, 0 ],
[ "Washington, DC", "38:53:42", "-77:02:12",-5, 1, 18 ],
[ "Bethany Beach, DE", "38:32:22", "-75:03:20",-5, 1, 3 ],
[ "Dover, DE", "39:09:29", "-75:31:29",-5, 1, 11 ],
[ "Laurel, DE", "38:33:23", "-75:34:18",-5, 1, 9 ],
[ "Wilmington, DE", "39:44:45", "-75:32:49",-5, 1, 30 ],
[ "Cape Coral, FL", "26:33:45", "-81:56:59",-5, 1, 2 ],
[ "Daytona Beach, FL", "29:12:38", "-81:01:23",-5, 1, 3 ],
[ "Fort Pierce, FL", "27:26:47", "-80:19:33",-5, 1, 2 ],
[ "Gainesville, FL", "29:39:05", "-82:19:30",-5, 1, 56 ],
[ "Jacksonville, FL", "30:19:55", "-81:39:21",-5, 1, 4 ],
[ "Key West, FL", "24:33:19", "-81:46:58",-5, 1, 2 ],
[ "Melbourne, FL", "28:05:00", "-80:36:30",-5, 1, 6 ],
[ "Miami, FL", "25:46:26", "-80:11:38",-5, 1, 3 ],
[ "Orlando, FL", "28:32:17", "-81:22:46",-5, 1, 32 ],
[ "Pensacola, FL", "30:25:16", "-87:13:01",-6, 1, 10 ],
[ "Tallahassee, FL", "30:26:17", "-84:16:51",-5, 1, 57 ],
[ "Tampa, FL", "27:56:50", "-82:27:31",-5, 1, 15 ],
[ "Athens, GA", "33:57:39", "-83:22:41",-5, 1, 231 ],
[ "Atlanta, GA", "33:44:56", "-84:23:17",-5, 1, 320 ],
[ "Bainbridge, GA", "30:54:13", "-84:34:32",-5, 1, 41 ],
[ "Brunswick, GA", "31:08:59", "-81:29:30",-5, 1, 3 ],
[ "Carrollton, GA", "33:34:48", "-85:04:36",-5, 1, 338 ],
[ "Columbus, GA", "32:27:39", "-84:59:16",-5, 1, 91 ],
[ "Dalton, GA", "34:46:11", "-84:58:13",-5, 1, 231 ],
[ "Macon, GA", "32:50:26", "-83:37:57",-5, 1, 122 ],
[ "Savannah, GA", "32:05:00", "-81:06:00",-5, 1, 13 ],
[ "Valdosta, GA", "30:49:57", "-83:16:43",-5, 1, 70 ],
[ "Hilo, HI", "19:43:47", "-155:05:24",-10, 0, 12 ],
[ "Honolulu, HI", "21:18:25", "-157:51:29",-10, 0, 5 ],
[ "Kahului, HI", "20:53:41", "-156:28:12",-10, 0, 0 ],
[ "Kaunakakai, HI", "21:05:36", "-157:01:26",-10, 0, 2 ],
[ "Lanai City, HI", "20:49:50", "-156:55:19",-10, 0, 495 ],
[ "Burlington, IA", "40:48:27", "-91:06:46",-6, 1, 0 ],
[ "Cedar Rapids, IA", "42:00:30", "-91:38:38",-6, 1, 0 ],
[ "Davenport, IA", "41:31:25", "-90:34:39",-6, 1, 210 ],
[ "Des Moines, IA", "41:36:02", "-93:36:32",-6, 1, 247 ],
[ "Dubuque, IA", "42:30:02", "-90:39:52",-6, 1, 0 ],
[ "Fort Dodge, IA", "42:29:51", "-94:10:04",-6, 1, 0 ],
[ "Mason City, IA", "43:09:13", "-93:12:03",-6, 1, 0 ],
[ "Sioux City, IA", "42:30:00", "-96:24:00",-6, 1, 340 ],
[ "Spencer, IA", "43:08:29", "-95:08:39",-6, 1, 403 ],
[ "Waterloo, IA", "42:29:34", "-92:20:34",-6, 1, 0 ],
[ "Boise, ID", "43:36:49", "-116:12:11",-7, 1, 832 ],
[ "Bonners Ferry, ID", "48:41:29", "-116:18:54",-8, 1, 588 ],
[ "Coeur d'Alene, ID", "47:40:40", "-116:46:44",-8, 1, 667 ],
[ "Dubois, ID", "44:10:35", "-112:13:48",-7, 1, 1568 ],
[ "Montpelier, ID", "42:19:20", "-111:17:49",-7, 1, 1818 ],
[ "Moscow, ID", "46:43:57", "-116:59:56",-8, 1, 787 ],
[ "Mullan, ID", "47:28:13", "-115:48:04",-8, 1, 999 ],
[ "New Meadows, ID", "44:58:17", "-116:16:59",-7, 1, 1179 ],
[ "Pocatello, ID", "42:52:17", "-112:26:42",-7, 1, 1361 ],
[ "Salmon, ID", "45:10:33", "-113:53:42",-7, 1, 1204 ],
[ "Sandpoint, ID", "48:16:36", "-116:33:07",-8, 1, 636 ],
[ "Twin Falls, ID", "42:33:47", "-114:27:36",-7, 1, 1137 ],
[ "Carbondale, IL", "37:43:38", "-89:13:00",-6, 1, 126 ],
[ "Champaign, IL", "40:06:59", "-88:14:36",-6, 1, 229 ],
[ "Chicago, IL", "41:51:00", "-87:39:00",-6, 1, 182 ],
[ "De Kalb, IL", "41:55:46", "-88:45:01",-6, 1, 268 ],
[ "Decatur, IL", "39:50:25", "-88:57:17",-6, 1, 204 ],
[ "Effingham, IL", "39:07:12", "-88:32:36",-6, 1, 180 ],
[ "Galesburg, IL", "40:56:52", "-90:22:16",-6, 1, 236 ],
[ "Peoria, IL", "40:41:37", "-89:35:20",-6, 1, 183 ],
[ "Quincy, IL", "39:56:08", "-91:24:35",-6, 1, 183 ],
[ "Rockford, IL", "42:16:16", "-89:05:38",-6, 1, 226 ],
[ "Springfield, IL", "39:48:06", "-89:38:37",-6, 1, 183 ],
[ "Evansville, IN", "37:58:29", "-87:33:21",-6, 1, 118 ],
[ "Fort Wayne, IN", "41:07:50", "-85:07:44",-5, 1, 238 ],
[ "Gary, IN", "41:35:36", "-87:20:47",-5, 1, 183 ],
[ "Indianapolis, IN", "39:46:06", "-86:09:29",-5, 1, 219 ],
[ "Kokomo, IN", "40:29:11", "-86:08:01",-5, 1, 247 ],
[ "Lafayette, IN", "40:25:00", "-86:52:31",-5, 1, 173 ],
[ "Muncie, IN", "40:11:36", "-85:23:11",-5, 1, 290 ],
[ "Richmond, IN", "39:49:44", "-84:53:25",-5, 1, 294 ],
[ "South Bend, IN", "41:41:00", "-86:15:00",-5, 1, 221 ],
[ "Terre Haute, IN", "39:28:00", "-87:24:50",-5, 1, 153 ],
[ "Belleville, KS", "39:49:28", "-97:37:56",-6, 1, 472 ],
[ "Chanute, KS", "37:40:45", "-95:27:25",-6, 1, 290 ],
[ "Dodge City, KS", "37:45:10", "-100:01:01",-6, 1, 777 ],
[ "Emporia, KS", "38:24:14", "-96:10:53",-6, 1, 351 ],
[ "Goodland, KS", "39:21:03", "-101:42:36",-7, 1, 1123 ],
[ "Hays, KS", "38:52:45", "-99:19:35",-6, 1, 613 ],
[ "Hiawatha, KS", "39:51:09", "-95:32:08",-6, 1, 346 ],
[ "Liberal, KS", "37:02:35", "-100:55:16",-6, 1, 864 ],
[ "Manhattan, KS", "39:11:01", "-96:34:17",-6, 1, 311 ],
[ "Oswego, KS", "37:10:03", "-95:06:35",-6, 1, 274 ],
[ "Salina, KS", "38:50:25", "-97:36:40",-6, 1, 373 ],
[ "Topeka, KS", "39:02:54", "-95:40:40",-6, 1, 305 ],
[ "Wichita, KS", "37:41:32", "-97:20:14",-6, 1, 398 ],
[ "Ashland, KY", "38:28:42", "-82:38:17",-5, 1, 170 ],
[ "Bowling Green, KY", "36:59:25", "-86:26:37",-6, 1, 0 ],
[ "Elizabethtown, KY", "37:41:38", "-85:51:33",-5, 1, 223 ],
[ "Frankfort, KY", "38:12:03", "-84:52:24",-5, 1, 155 ],
[ "Lexington, KY", "37:59:19", "-84:28:40",-5, 1, 0 ],
[ "Louisville, KY", "38:15:15", "-85:45:34",-5, 1, 141 ],
[ "Owensboro, KY", "37:46:27", "-87:06:48",-6, 1, 0 ],
[ "Paducah, KY", "37:05:00", "-88:36:00",-6, 1, 0 ],
[ "Pikeville, KY", "37:28:45", "-82:31:08",-5, 1, 0 ],
[ "Richmond, KY", "37:44:52", "-84:17:41",-5, 1, 297 ],
[ "Williamsburg, KY", "36:44:36", "-84:09:35",-5, 1, 290 ],
[ "Alexandria, LA", "31:18:40", "-92:26:42",-6, 1, 25 ],
[ "Baton Rouge, LA", "30:27:02", "-91:09:16",-6, 1, 16 ],
[ "Lafayette, LA", "30:13:26", "-92:01:11",-6, 1, 12 ],
[ "Lake Charles, LA", "30:13:35", "-93:13:02",-6, 1, 6 ],
[ "Monroe, LA", "32:30:33", "-92:07:09",-6, 1, 23 ],
[ "New Orleans, LA", "29:57:16", "-90:04:30",-6, 1, 3 ],
[ "Opelousas, LA", "30:32:00", "-92:04:53",-6, 1, 21 ],
[ "Ruston, LA", "32:31:23", "-92:38:16",-6, 1, 97 ],
[ "Shreveport, LA", "32:31:30", "-93:45:00",-6, 1, 64 ],
[ "Tallulah, LA", "32:24:30", "-91:11:12",-6, 1, 27 ],
[ "Amherst, MA", "42:22:49", "-72:31:25",-5, 1, 90 ],
[ "Barnstable, MA", "41:42:00", "-70:18:00",-5, 1, 11 ],
[ "Boston, MA", "42:21:30", "-71:03:37",-5, 1, 6 ],
[ "Falmouth, MA", "41:33:05", "-70:36:55",-5, 1, 3 ],
[ "Gardner, MA", "42:34:30", "-71:59:55",-5, 1, 335 ],
[ "Gloucester, MA", "42:36:57", "-70:39:45",-5, 1, 15 ],
[ "Haverhill, MA", "42:46:34", "-71:04:40",-5, 1, 8 ],
[ "Lowell, MA", "42:38:00", "-71:19:00",-5, 1, 31 ],
[ "Nantucket, MA", "41:17:00", "-70:06:00",-5, 1, 9 ],
[ "New Bedford, MA", "41:38:10", "-70:56:05",-5, 1, 15 ],
[ "Pittsfield, MA", "42:27:00", "-73:14:45",-5, 1, 317 ],
[ "Plymouth, MA", "41:57:30", "-70:40:04",-5, 1, 15 ],
[ "Provincetown, MA", "42:03:30", "-70:10:45",-5, 1, 12 ],
[ "Springfield, MA", "42:06:05", "-72:35:25",-5, 1, 21 ],
[ "Williamstown, MA", "42:42:43", "-73:12:15",-5, 1, 194 ],
[ "Worcester, MA", "42:15:45", "-71:48:10",-5, 1, 146 ],
[ "Annapolis, MD", "38:58:42", "-76:29:33",-5, 1, 12 ],
[ "Baltimore, MD", "39:17:25", "-76:36:45",-5, 1, 30 ],
[ "Cumberland, MD", "39:39:10", "-78:45:46",-5, 1, 210 ],
[ "Frederick, MD", "39:24:51", "-77:24:39",-5, 1, 88 ],
[ "Hagerstown, MD", "39:38:30", "-77:43:13",-5, 1, 168 ],
[ "Ridge, MD", "38:07:09", "-76:22:27",-5, 1, 18 ],
[ "Salisbury, MD", "38:21:38", "-75:35:59",-5, 1, 9 ],
[ "Augusta, ME", "44:18:38", "-69:46:48",-5, 1, 23 ],
[ "Bangor, ME", "44:48:04", "-68:46:42",-5, 1, 48 ],
[ "Bar Harbor, ME", "44:23:15", "-68:12:16",-5, 1, 0 ],
[ "Caribou, ME", "46:51:38", "-68:00:45",-5, 1, 135 ],
[ "Dennistown, ME", "45:40:37", "-70:17:01",-5, 1, 417 ],
[ "Dickey, ME", "47:06:34", "-69:05:13",-5, 1, 192 ],
[ "Farmington, ME", "44:40:14", "-70:09:06",-5, 1, 130 ],
[ "Houlton, ME", "46:07:34", "-67:50:27",-5, 1, 112 ],
[ "Lewiston, ME", "44:06:01", "-70:12:55",-5, 1, 37 ],
[ "Pembroke, ME", "44:57:13", "-67:09:45",-5, 1, 6 ],
[ "Portland, ME", "43:39:41", "-70:15:21",-5, 1, 10 ],
[ "Alpena, MI", "45:03:42", "-83:25:58",-5, 1, 0 ],
[ "Detroit, MI", "42:19:53", "-83:02:45",-5, 1, 183 ],
[ "Escanaba, MI", "45:44:43", "-87:03:52",-5, 1, 182 ],
[ "Flint, MI", "43:00:45", "-83:41:15",-5, 1, 0 ],
[ "Grand Rapids, MI", "42:57:48", "-85:40:05",-5, 1, 201 ],
[ "Houghton, MI", "47:07:19", "-88:34:08",-5, 1, 185 ],
[ "Jackson, MI", "42:14:45", "-84:24:05",-5, 1, 0 ],
[ "Kalamazoo, MI", "42:17:30", "-85:35:14",-5, 1, 0 ],
[ "Lansing, MI", "42:43:57", "-84:33:20",-5, 1, 0 ],
[ "Mackinaw City, MI", "45:47:02", "-84:43:40",-5, 1, 0 ],
[ "Manistee, MI", "44:14:40", "-86:19:27",-5, 1, 0 ],
[ "Marquette, MI", "46:32:37", "-87:23:43",-5, 1, 191 ],
[ "Menominee, MI", "45:06:28", "-87:36:51",-6, 1, 0 ],
[ "Midland, MI", "43:36:56", "-84:14:50",-5, 1, 192 ],
[ "Sault Ste. Marie, MI", "46:29:43", "-84:20:43",-5, 1, 187 ],
[ "Traverse City, MI", "44:45:47", "-85:37:14",-5, 1, 183 ],
[ "Alexandria, MN", "45:53:07", "-95:22:38",-6, 1, 0 ],
[ "Austin, MN", "43:40:00", "-92:58:28",-6, 1, 0 ],
[ "Bagley, MN", "47:31:18", "-95:23:53",-6, 1, 439 ],
[ "Brainerd, MN", "46:21:29", "-94:12:02",-6, 1, 0 ],
[ "Chisholm, MN", "47:29:21", "-92:53:01",-6, 1, 481 ],
[ "Duluth, MN", "46:47:00", "-92:06:23",-6, 1, 183 ],
[ "Grand Marais, MN", "47:45:02", "-90:20:03",-6, 1, 210 ],
[ "Hallock, MN", "48:46:28", "-96:56:46",-6, 1, 249 ],
[ "Marshall, MN", "44:26:49", "-95:47:17",-6, 1, 0 ],
[ "Minneapolis, MN", "44:58:48", "-93:15:49",-6, 1, 246 ],
[ "Rochester, MN", "44:01:18", "-92:28:11",-6, 1, 0 ],
[ "Saint Cloud, MN", "45:33:39", "-94:09:44",-6, 1, 0 ],
[ "Winona, MN", "44:03:00", "-91:38:21",-6, 1, 0 ],
[ "Bethany, MO", "40:16:06", "-94:01:41",-6, 1, 276 ],
[ "Cape Girardeau, MO", "37:18:21", "-89:31:05",-6, 1, 0 ],
[ "Columbia, MO", "38:57:06", "-92:20:02",-6, 1, 231 ],
[ "Hannibal, MO", "39:42:30", "-91:21:30",-6, 1, 150 ],
[ "Jefferson City, MO", "38:34:36", "-92:10:24",-6, 1, 214 ],
[ "Joplin, MO", "37:05:03", "-94:30:47",-6, 1, 0 ],
[ "Kansas City, MO", "39:05:59", "-94:34:42",-6, 1, 268 ],
[ "Kirksville, MO", "40:11:41", "-92:34:59",-6, 1, 0 ],
[ "Saint Louis, MO", "38:37:38", "-90:11:52",-6, 1, 135 ],
[ "Sedalia, MO", "38:42:16", "-93:13:41",-6, 1, 280 ],
[ "Sikeston, MO", "36:52:36", "-89:35:16",-6, 1, 0 ],
[ "Springfield, MO", "37:12:55", "-93:17:53",-6, 1, 0 ],
[ "Biloxi, MS", "30:23:45", "-88:53:07",-6, 1, 8 ],
[ "Clarksdale, MS", "34:12:00", "-90:34:15",-6, 1, 55 ],
[ "Columbus, MS", "33:29:44", "-88:25:38",-6, 1, 61 ],
[ "Greenville, MS", "33:24:36", "-91:03:42",-6, 1, 38 ],
[ "Hattiesburg, MS", "31:19:37", "-89:17:25",-6, 1, 49 ],
[ "Jackson, MS", "32:17:55", "-90:11:05",-6, 1, 90 ],
[ "Meridian, MS", "32:21:51", "-88:42:13",-6, 1, 104 ],
[ "Olive Branch, MS", "34:57:42", "-89:49:46",-6, 1, 105 ],
[ "Tupelo, MS", "34:15:27", "-88:42:12",-6, 1, 88 ],
[ "Vicksburg, MS", "32:21:09", "-90:52:40",-6, 1, 61 ],
[ "Billings, MT", "45:47:00", "-108:30:00",-7, 1, 952 ],
[ "Bozeman, MT", "45:40:47", "-111:02:17",-7, 1, 1466 ],
[ "Butte, MT", "46:00:14", "-112:32:02",-7, 1, 1691 ],
[ "Dillon, MT", "45:12:59", "-112:38:13",-7, 1, 1553 ],
[ "Glasgow, MT", "48:11:49", "-106:38:10",-7, 1, 637 ],
[ "Glendive, MT", "47:06:19", "-104:42:43",-7, 1, 633 ],
[ "Great Falls, MT", "47:30:01", "-111:18:00",-7, 1, 1016 ],
[ "Havre, MT", "48:33:00", "-109:40:59",-7, 1, 760 ],
[ "Helena, MT", "46:35:34", "-112:02:06",-7, 1, 1247 ],
[ "Kalispell, MT", "48:11:45", "-114:18:43",-7, 1, 900 ],
[ "Lewistown, MT", "47:03:45", "-109:25:41",-7, 1, 1208 ],
[ "Missoula, MT", "46:52:20", "-113:59:35",-7, 1, 975 ],
[ "Plentywood, MT", "48:46:29", "-104:33:43",-7, 1, 624 ],
[ "Shelby, MT", "48:30:19", "-111:51:22",-7, 1, 1002 ],
[ "Asheville, NC", "35:36:03", "-82:33:15",-5, 1, 650 ],
[ "Charlotte, NC", "35:13:37", "-80:50:36",-5, 1, 259 ],
[ "Fayetteville, NC", "35:03:09", "-78:52:43",-5, 1, 73 ],
[ "Greensboro, NC", "36:04:21", "-79:47:32",-5, 1, 235 ],
[ "Havelock, NC", "34:52:44", "-76:54:06",-5, 1, 8 ],
[ "Lumberton, NC", "34:37:05", "-79:00:32",-5, 1, 42 ],
[ "Manteo, NC", "35:54:29", "-75:40:34",-5, 1, 2 ],
[ "Raleigh, NC", "35:46:19", "-78:38:20",-5, 1, 107 ],
[ "Rocky Mount, NC", "35:56:17", "-77:47:27",-5, 1, 30 ],
[ "Wilmington, NC", "34:13:32", "-77:56:42",-5, 1, 15 ],
[ "Winston-Salem, NC", "36:05:59", "-80:14:40",-5, 1, 278 ],
[ "Bismarck, ND", "46:48:30", "-100:46:59",-6, 1, 518 ],
[ "Bottineau, ND", "48:49:38", "-100:26:42",-6, 1, 498 ],
[ "Bowman, ND", "46:10:59", "-103:23:38",-7, 1, 902 ],
[ "Cavalier, ND", "48:47:38", "-97:37:19",-6, 1, 272 ],
[ "Dickinson, ND", "46:52:45", "-102:47:20",-7, 1, 737 ],
[ "Fargo, ND", "46:52:38", "-96:47:22",-6, 1, 274 ],
[ "Grand Forks, ND", "47:55:31", "-97:01:57",-6, 1, 254 ],
[ "Jamestown, ND", "46:54:38", "-98:42:29",-6, 1, 431 ],
[ "Linton, ND", "46:16:00", "-100:13:59",-6, 1, 521 ],
[ "Lisbon, ND", "46:26:30", "-97:40:51",-6, 1, 333 ],
[ "Minot, ND", "48:13:57", "-101:17:46",-6, 1, 474 ],
[ "Rugby, ND", "48:22:08", "-99:59:45",-6, 1, 472 ],
[ "Stanley, ND", "48:19:02", "-102:23:24",-6, 1, 686 ],
[ "Valley City, ND", "46:55:24", "-98:00:10",-6, 1, 372 ],
[ "Williston, ND", "48:08:00", "-103:37:59",-6, 1, 574 ],
[ "Alliance, NE", "42:06:06", "-102:52:19",-6, 1, 1207 ],
[ "Broken Bow, NE", "41:24:07", "-99:38:20",-6, 1, 754 ],
[ "Chadron, NE", "42:49:46", "-102:59:56",-6, 1, 0 ],
[ "Columbus, NE", "41:25:47", "-97:22:05",-6, 1, 0 ],
[ "Grand Island, NE", "40:55:30", "-98:20:30",-6, 1, 0 ],
[ "Kearney, NE", "40:41:58", "-99:04:52",-6, 1, 656 ],
[ "Lincoln, NE", "40:48:00", "-96:40:00",-6, 1, 0 ],
[ "McCook, NE", "40:12:07", "-100:37:30",-6, 1, 784 ],
[ "Norfolk, NE", "42:01:42", "-97:25:00",-6, 1, 465 ],
[ "North Platte, NE", "41:07:26", "-100:45:54",-6, 1, 0 ],
[ "O'Neill, NE", "42:27:28", "-98:38:50",-6, 1, 0 ],
[ "Omaha, NE", "41:15:31", "-95:56:15",-6, 1, 320 ],
[ "Scottsbluff, NE", "41:52:00", "-103:40:01",-6, 1, 0 ],
[ "Tecumseh, NE", "40:22:00", "-96:11:45",-6, 1, 0 ],
[ "Valentine, NE", "42:52:22", "-100:33:04",-7, 1, 0 ],
[ "Berlin, NH", "44:28:07", "-71:11:08",-5, 1, 308 ],
[ "Concord, NH", "43:12:29", "-71:32:17",-5, 1, 88 ],
[ "Keene, NH", "42:56:01", "-72:16:43",-5, 1, 148 ],
[ "Littleton, NH", "44:18:22", "-71:46:14",-5, 1, 251 ],
[ "Manchester, NH", "42:59:44", "-71:27:19",-5, 1, 85 ],
[ "Nashua, NH", "42:45:55", "-71:28:05",-5, 1, 52 ],
[ "Pittsburg, NH", "45:03:04", "-71:23:31",-5, 1, 406 ],
[ "Portsmouth, NH", "43:04:18", "-70:45:47",-5, 1, 6 ],
[ "Rochester, NH", "43:18:16", "-70:58:34",-5, 1, 71 ],
[ "Atlantic City, NJ", "39:21:51", "-74:25:24",-5, 1, 2 ],
[ "Bridgeton, NJ", "39:25:38", "-75:14:04",-5, 1, 12 ],
[ "Cherry Hill, NJ", "39:56:05", "-75:01:52",-5, 1, 12 ],
[ "New Brunswick, NJ", "40:29:10", "-74:27:08",-5, 1, 24 ],
[ "Newark, NJ", "40:44:08", "-74:10:22",-5, 1, 29 ],
[ "Paterson, NJ", "40:55:00", "-74:10:20",-5, 1, 21 ],
[ "Toms River, NJ", "39:57:13", "-74:11:54",-5, 1, 12 ],
[ "Trenton, NJ", "40:13:01", "-74:44:36",-5, 1, 16 ],
[ "Alamogordo, NM", "32:53:58", "-105:57:36",-7, 1, 1321 ],
[ "Albuquerque, NM", "35:05:04", "-106:39:04",-7, 1, 1510 ],
[ "Bard, NM", "35:07:43", "-103:14:42",-7, 1, 1216 ],
[ "Carlsbad, NM", "32:25:14", "-104:13:41",-7, 1, 948 ],
[ "Clovis, NM", "34:24:17", "-103:12:18",-7, 1, 1300 ],
[ "Farmington, NM", "36:43:41", "-108:13:05",-7, 1, 1613 ],
[ "Gallup, NM", "35:31:41", "-108:44:31",-7, 1, 1984 ],
[ "Hernandez, NM", "36:03:27", "-106:07:02",-7, 1, 1738 ],
[ "Hobbs, NM", "32:42:09", "-103:08:10",-7, 1, 1104 ],
[ "Las Cruces, NM", "32:18:44", "-106:46:41",-7, 1, 1191 ],
[ "Lordsburg, NM", "32:21:01", "-108:42:29",-7, 1, 1298 ],
[ "Raton, NM", "36:54:12", "-104:26:20",-7, 1, 2036 ],
[ "Roswell, NM", "33:23:39", "-104:31:23",-7, 1, 1089 ],
[ "Austin, NV", "39:29:36", "-117:04:07",-8, 1, 1989 ],
[ "Beatty, NV", "36:54:31", "-116:45:30",-8, 1, 1008 ],
[ "Carson City, NV", "39:09:50", "-119:45:58",-8, 1, 1442 ],
[ "Elko, NV", "40:49:57", "-115:45:43",-8, 1, 1544 ],
[ "Ely, NV", "39:14:51", "-114:53:17",-8, 1, 1959 ],
[ "Hawthorne, NV", "38:31:29", "-118:37:26",-8, 1, 1320 ],
[ "Jackpot, NV", "41:59:00", "-114:40:26",-8, 1, 1597 ],
[ "Las Vegas, NV", "36:10:30", "-115:08:10",-8, 1, 610 ],
[ "Lovelock, NV", "40:10:46", "-118:28:23",-8, 1, 1212 ],
[ "McDermitt, NV", "41:59:51", "-117:43:01",-8, 1, 1348 ],
[ "Mesquite, NV", "36:48:20", "-114:03:58",-8, 1, 490 ],
[ "Pahrump, NV", "36:12:30", "-115:58:59",-8, 1, 820 ],
[ "Reno, NV", "39:31:47", "-119:48:47",-8, 1, 1371 ],
[ "Tonopah, NV", "38:04:02", "-117:13:44",-8, 1, 1838 ],
[ "Warm Springs, NV", "39:39:12", "-114:48:07",-8, 1, 1815 ],
[ "Winnemucca, NV", "40:58:23", "-117:44:06",-8, 1, 1310 ],
[ "Albany, NY", "42:39:09", "-73:45:24",-5, 1, 52 ],
[ "Binghamton, NY", "42:05:55", "-75:55:06",-5, 1, 0 ],
[ "Bridgehampton, NY", "40:56:16", "-72:18:05",-5, 1, 12 ],
[ "Buffalo, NY", "42:53:11", "-78:52:43",-5, 1, 181 ],
[ "Elizabethtown, NY", "42:57:58", "-75:04:46",-5, 1, 383 ],
[ "Garden City, NY", "40:43:36", "-73:38:05",-5, 1, 0 ],
[ "Glen Cove, NY", "40:51:44", "-73:38:03",-5, 1, 0 ],
[ "Jamestown, NY", "42:05:49", "-79:14:08",-5, 1, 0 ],
[ "Lake Placid, NY", "44:16:46", "-73:58:49",-5, 1, 0 ],
[ "Medford, NY", "40:49:03", "-73:00:02",-5, 1, 31 ],
[ "New York, NY", "40:42:51", "-74:00:23",-5, 1, 23 ],
[ "Rochester, NY", "43:09:17", "-77:36:57",-5, 1, 158 ],
[ "Syracuse, NY", "43:02:53", "-76:08:52",-5, 1, 120 ],
[ "Watertown, NY", "43:58:29", "-75:54:40",-5, 1, 146 ],
[ "Akron, OH", "41:04:53", "-81:31:09",-5, 1, 320 ],
[ "Canton, OH", "40:47:56", "-81:22:43",-5, 1, 335 ],
[ "Cincinnati, OH", "39:09:43", "-84:27:25",-5, 1, 208 ],
[ "Cleveland, OH", "41:29:58", "-81:41:44",-5, 1, 210 ],
[ "Columbus, OH", "39:57:40", "-82:59:56",-5, 1, 244 ],
[ "Dayton, OH", "39:45:32", "-84:11:30",-5, 1, 229 ],
[ "Mansfield, OH", "40:45:30", "-82:30:56",-5, 1, 381 ],
[ "Portsmouth, OH", "38:43:54", "-82:59:52",-5, 1, 165 ],
[ "Toledo, OH", "41:39:50", "-83:33:19",-5, 1, 187 ],
[ "Youngstown, OH", "41:05:59", "-80:38:59",-5, 1, 262 ],
[ "Zanesville, OH", "39:56:25", "-82:00:48",-5, 1, 216 ],
[ "Altus, OK", "34:38:17", "-99:20:01",-6, 1, 426 ],
[ "Ardmore, OK", "34:10:27", "-97:08:36",-6, 1, 0 ],
[ "Bartlesville, OK", "36:44:50", "-95:58:50",-6, 1, 0 ],
[ "Boise City, OK", "36:43:46", "-102:30:47",-6, 1, 1269 ],
[ "Elk City, OK", "35:24:43", "-99:24:14",-6, 1, 588 ],
[ "Enid, OK", "36:23:44", "-97:52:41",-6, 1, 380 ],
[ "Hugo, OK", "34:00:38", "-95:30:34",-6, 1, 0 ],
[ "Lawton, OK", "34:36:31", "-98:23:24",-6, 1, 0 ],
[ "Miami, OK", "36:52:28", "-94:52:38",-6, 1, 243 ],
[ "Norman, OK", "35:13:21", "-97:26:21",-6, 1, 0 ],
[ "Oklahoma City, OK", "35:28:03", "-97:30:58",-6, 1, 362 ],
[ "Stillwater, OK", "36:06:56", "-97:03:29",-6, 1, 0 ],
[ "Tulsa, OK", "36:09:14", "-95:59:33",-6, 1, 213 ],
[ "Astoria, OR", "46:11:17", "-123:49:48",-8, 1, 5 ],
[ "Baker City, OR", "44:46:30", "-117:49:59",-8, 1, 1049 ],
[ "Bend, OR", "44:03:30", "-121:18:50",-8, 1, 1106 ],
[ "Coos Bay, OR", "43:22:05", "-124:12:58",-8, 1, 3 ],
[ "Eugene, OR", "44:03:08", "-123:05:10",-8, 1, 128 ],
[ "Gold Beach, OR", "42:24:27", "-124:25:16",-8, 1, 16 ],
[ "Grants Pass, OR", "42:26:21", "-123:19:37",-8, 1, 289 ],
[ "Hood River, OR", "45:42:20", "-121:31:12",-8, 1, 122 ],
[ "Klamath Falls, OR", "42:13:30", "-121:46:52",-8, 1, 1323 ],
[ "Ontario, OR", "44:01:36", "-116:57:43",-7, 1, 657 ],
[ "Portland, OR", "45:31:25", "-122:40:30",-8, 1, 15 ],
[ "Allentown, PA", "40:36:30", "-75:29:26",-5, 1, 107 ],
[ "Altoona, PA", "40:31:07", "-78:23:42",-5, 1, 357 ],
[ "Bradford, PA", "41:57:21", "-78:38:39",-5, 1, 440 ],
[ "Clarion, PA", "41:12:53", "-79:23:08",-5, 1, 454 ],
[ "Erie, PA", "42:07:45", "-80:05:07",-5, 1, 198 ],
[ "Harrisburg, PA", "40:16:25", "-76:53:05",-5, 1, 98 ],
[ "Philadelphia, PA", "39:57:08", "-75:09:51",-5, 1, 12 ],
[ "Pittsburgh, PA", "40:26:26", "-79:59:46",-5, 1, 235 ],
[ "Reading, PA", "40:20:08", "-75:55:38",-5, 1, 81 ],
[ "Scranton, PA", "41:24:32", "-75:39:46",-5, 1, 230 ],
[ "Towanda, PA", "41:46:03", "-76:26:35",-5, 1, 225 ],
[ "Williamsport, PA", "41:14:28", "-77:00:05",-5, 1, 161 ],
[ "San Juan, PR", "18:28:06", "-66:06:22",-4, 0, 2 ],
[ "Newport, RI", "41:29:24", "-71:18:48",-5, 1, 29 ],
[ "Providence, RI", "41:49:26", "-71:24:48",-5, 1, 35 ],
[ "Westerly, RI", "41:22:39", "-71:49:40",-5, 1, 41 ],
[ "Woonsocket, RI", "42:00:10", "-71:30:55",-5, 1, 49 ],
[ "Charleston, SC", "32:46:35", "-79:55:52",-5, 1, 36 ],
[ "Columbia, SC", "34:00:02", "-81:02:06",-5, 1, 96 ],
[ "Florence, SC", "34:11:43", "-79:45:46",-5, 1, 45 ],
[ "Greenville, SC", "34:51:09", "-82:23:39",-5, 1, 294 ],
[ "Greenwood, SC", "34:11:43", "-82:09:43",-5, 1, 203 ],
[ "Myrtle Beach, SC", "33:41:20", "-78:53:13",-5, 1, 9 ],
[ "Rock Hill, SC", "34:55:29", "-81:01:31",-5, 1, 203 ],
[ "Spartanburg, SC", "34:56:58", "-81:55:56",-5, 1, 249 ],
[ "Summerville, SC", "33:01:06", "-80:10:33",-5, 1, 23 ],
[ "Sumter, SC", "33:55:13", "-80:20:30",-5, 1, 52 ],
[ "Aberdeen, SD", "45:27:53", "-98:29:10",-6, 1, 397 ],
[ "Brookings, SD", "44:18:41", "-96:47:53",-6, 1, 495 ],
[ "Chamberlain, SD", "43:48:39", "-99:19:49",-6, 1, 447 ],
[ "Hot Springs, SD", "43:25:54", "-103:28:26",-7, 1, 1056 ],
[ "Huron, SD", "44:21:48", "-98:12:50",-6, 1, 387 ],
[ "Milbank, SD", "45:13:09", "-96:38:07",-6, 1, 351 ],
[ "Mitchell, SD", "43:42:34", "-98:01:46",-6, 1, 396 ],
[ "Pierre, SD", "44:22:06", "-100:21:04",-6, 1, 452 ],
[ "Rapid City, SD", "44:04:50", "-103:13:52",-7, 1, 990 ],
[ "Redfield, SD", "44:52:33", "-98:31:06",-6, 1, 397 ],
[ "Sioux Falls, SD", "43:33:00", "-96:42:00",-6, 1, 440 ],
[ "Spearfish, SD", "44:29:27", "-103:51:32",-7, 1, 1110 ],
[ "Vermillion, SD", "42:46:46", "-96:55:44",-6, 1, 372 ],
[ "Watertown, SD", "44:53:58", "-97:06:53",-6, 1, 530 ],
[ "Chattanooga, TN", "35:02:44", "-85:18:35",-5, 1, 209 ],
[ "Clarksville, TN", "36:31:47", "-87:21:34",-6, 1, 150 ],
[ "Cookeville, TN", "36:09:46", "-85:30:06",-6, 1, 345 ],
[ "Jackson, TN", "35:36:52", "-88:48:50",-6, 1, 122 ],
[ "Johnson City, TN", "36:18:48", "-82:21:13",-5, 1, 498 ],
[ "Knoxville, TN", "35:57:38", "-83:55:15",-5, 1, 271 ],
[ "Lynchburg, TN", "35:16:59", "-86:22:27",-6, 1, 242 ],
[ "Memphis, TN", "35:08:58", "-90:02:56",-6, 1, 77 ],
[ "Nashville, TN", "36:09:57", "-86:47:04",-6, 1, 134 ],
[ "Abilene, TX", "32:26:55", "-99:43:58",-6, 1, 524 ],
[ "Amarillo, TX", "35:13:19", "-101:49:52",-6, 1, 1116 ],
[ "Austin, TX", "30:16:01", "-97:44:34",-6, 1, 153 ],
[ "Beaumont, TX", "30:05:09", "-94:06:06",-6, 1, 0 ],
[ "Brownsville, TX", "25:54:05", "-97:29:50",-6, 1, 0 ],
[ "Corpus Christi, TX", "27:48:01", "-97:23:46",-6, 1, 0 ],
[ "Dallas, TX", "32:47:00", "-96:48:00",-6, 1, 141 ],
[ "Del Rio, TX", "29:21:45", "-100:53:46",-6, 1, 0 ],
[ "Eagle Pass, TX", "28:42:32", "-100:29:56",-6, 1, 225 ],
[ "El Paso, TX", "31:45:31", "-106:29:10",-7, 1, 1158 ],
[ "Houston, TX", "29:45:47", "-95:21:47",-6, 1, 12 ],
[ "Huntsville, TX", "30:43:24", "-95:33:02",-6, 1, 112 ],
[ "Laredo, TX", "27:30:22", "-99:30:26",-6, 1, 126 ],
[ "Longview, TX", "32:30:02", "-94:44:25",-6, 1, 0 ],
[ "Lubbock, TX", "33:34:40", "-101:51:18",-6, 1, 975 ],
[ "Lufkin, TX", "31:20:17", "-94:43:44",-6, 1, 96 ],
[ "Midland, TX", "31:59:50", "-102:04:41",-6, 1, 865 ],
[ "New Boston, TX", "33:27:35", "-94:24:55",-6, 1, 0 ],
[ "Paris, TX", "33:39:39", "-95:33:19",-6, 1, 183 ],
[ "San Angelo, TX", "31:27:49", "-100:26:13",-6, 1, 563 ],
[ "San Antonio, TX", "29:25:26", "-98:29:36",-6, 1, 196 ],
[ "Tyler, TX", "32:21:04", "-95:18:03",-6, 1, 0 ],
[ "Waco, TX", "31:32:57", "-97:08:47",-6, 1, 0 ],
[ "Wichita Falls, TX", "33:54:49", "-98:29:35",-6, 1, 291 ],
[ "Cedar City, UT", "37:40:39", "-113:03:40",-7, 1, 1778 ],
[ "Kanab, UT", "37:02:51", "-112:31:34",-7, 1, 1496 ],
[ "Logan, UT", "41:44:08", "-111:50:02",-7, 1, 1382 ],
[ "Mexican Hat, UT", "37:09:07", "-109:51:58",-7, 1, 1294 ],
[ "Moab, UT", "38:34:24", "-109:32:56",-7, 1, 1227 ],
[ "Monticello, UT", "37:52:17", "-109:20:32",-7, 1, 2154 ],
[ "Price, UT", "39:35:58", "-110:48:36",-7, 1, 1697 ],
[ "Richfield, UT", "38:46:21", "-112:04:59",-7, 1, 1618 ],
[ "Saint George, UT", "37:06:15", "-113:34:59",-7, 1, 842 ],
[ "Salt Lake City, UT", "40:45:39", "-111:53:24",-7, 1, 1300 ],
[ "Vernal, UT", "40:27:20", "-109:31:41",-7, 1, 1622 ],
[ "Wendover, UT", "40:44:14", "-114:02:12",-7, 1, 1294 ],
[ "Blacksburg, VA", "37:13:46", "-80:24:51",-5, 1, 634 ],
[ "Charlottesville, VA", "38:01:45", "-78:28:37",-5, 1, 181 ],
[ "Fredericksburg, VA", "38:18:11", "-77:27:39",-5, 1, 18 ],
[ "Harrisonburg, VA", "38:26:58", "-78:52:09",-5, 1, 412 ],
[ "Lebanon, VA", "36:54:03", "-82:04:49",-5, 1, 622 ],
[ "Lynchburg, VA", "37:24:49", "-79:08:33",-5, 1, 249 ],
[ "Manassas, VA", "38:45:03", "-77:28:32",-5, 1, 94 ],
[ "Norfolk, VA", "36:50:48", "-76:17:08",-5, 1, 3 ],
[ "Richmond, VA", "37:33:13", "-77:27:38",-5, 1, 58 ],
[ "Roanoke, VA", "37:16:15", "-79:56:30",-5, 1, 287 ],
[ "Staunton, VA", "38:08:58", "-79:04:19",-5, 1, 427 ],
[ "Winchester, VA", "39:11:08", "-78:09:49",-5, 1, 219 ],
[ "Saint John, VI", "17:45:56", "-64:44:51",-4, 0, 0 ],
[ "Bennington, VT", "42:52:41", "-73:11:50",-5, 1, 208 ],
[ "Brattleboro, VT", "42:51:03", "-72:33:30",-5, 1, 73 ],
[ "Burlington, VT", "44:28:33", "-73:12:45",-5, 1, 34 ],
[ "Montpelier, VT", "44:15:36", "-72:34:33",-5, 1, 160 ],
[ "Newport, VT", "44:56:11", "-72:12:20",-5, 1, 220 ],
[ "Rutland, VT", "43:36:38", "-72:58:23",-5, 1, 198 ],
[ "Saint Albans, VT", "44:48:39", "-73:05:01",-5, 1, 131 ],
[ "Saint Johnsbury, VT", "44:25:09", "-72:00:56",-5, 1, 179 ],
[ "Swanton, VT", "44:55:05", "-73:07:29",-5, 1, 48 ],
[ "Bellingham, WA", "48:45:35", "-122:29:13",-8, 1, 30 ],
[ "Colville, WA", "48:32:48", "-117:54:14",-8, 1, 189 ],
[ "Hoquiam, WA", "46:58:52", "-123:53:17",-8, 1, 6 ],
[ "Mount Vernon, WA", "48:25:17", "-122:19:59",-8, 1, 55 ],
[ "Olympia, WA", "47:02:17", "-122:53:56",-8, 1, 40 ],
[ "Port Angeles, WA", "48:07:06", "-123:25:44",-8, 1, 10 ],
[ "Pullman, WA", "46:43:53", "-117:10:44",-8, 1, 732 ],
[ "Seattle, WA", "47:36:23", "-122:19:52",-8, 1, 107 ],
[ "Spokane, WA", "47:39:32", "-117:25:30",-8, 1, 610 ],
[ "Walla Walla, WA", "46:03:53", "-118:20:31",-8, 1, 305 ],
[ "Wenatchee, WA", "47:25:25", "-120:18:32",-8, 1, 238 ],
[ "Yakima, WA", "46:36:08", "-120:30:18",-8, 1, 325 ],
[ "Ashland, WI", "46:35:33", "-90:53:01",-6, 1, 205 ],
[ "Beloit, WI", "42:30:30", "-89:01:54",-6, 1, 238 ],
[ "Eau Claire, WI", "44:48:41", "-91:29:54",-6, 1, 259 ],
[ "Fond du Lac, WI", "43:46:23", "-88:26:49",-6, 1, 232 ],
[ "Green Bay, WI", "44:31:09", "-88:01:11",-6, 1, 181 ],
[ "Kenosha, WI", "42:35:05", "-87:49:16",-6, 1, 189 ],
[ "La Crosse, WI", "43:48:05", "-91:14:22",-6, 1, 204 ],
[ "Madison, WI", "43:04:23", "-89:24:04",-6, 1, 263 ],
[ "Milwaukee, WI", "43:02:20", "-87:54:23",-6, 1, 193 ],
[ "Oshkosh, WI", "44:01:29", "-88:32:33",-6, 1, 235 ],
[ "Sheboygan, WI", "43:45:03", "-87:42:52",-6, 1, 194 ],
[ "Stevens Point, WI", "44:31:25", "-89:34:28",-6, 1, 333 ],
[ "Sturgeon Bay, WI", "44:50:03", "-87:22:37",-6, 1, 179 ],
[ "Wausau, WI", "44:57:33", "-89:37:48",-6, 1, 369 ],
[ "Bluefield, WV", "37:16:11", "-81:13:21",-5, 1, 796 ],
[ "Charleston, WV", "38:20:59", "-81:37:58",-5, 1, 185 ],
[ "Huntington, WV", "38:25:09", "-82:26:43",-5, 1, 173 ],
[ "Parkersburg, WV", "39:16:00", "-81:33:42",-5, 1, 198 ],
[ "Romney, WV", "39:20:31", "-78:45:25",-5, 1, 250 ],
[ "Wheeling, WV", "40:03:50", "-80:43:16",-5, 1, 205 ],
[ "Williamson, WV", "37:40:27", "-82:16:39",-5, 1, 203 ],
[ "Casper, WY", "42:52:00", "-106:18:47",-7, 1, 1567 ],
[ "Cheyenne, WY", "41:08:24", "-104:49:12",-7, 1, 1849 ],
[ "Cody, WY", "44:31:35", "-109:03:22",-7, 1, 1551 ],
[ "Evanston, WY", "41:16:06", "-110:57:47",-7, 1, 2057 ],
[ "Gillette, WY", "44:17:28", "-105:30:07",-7, 1, 1387 ],
[ "Jackson, WY", "43:28:48", "-110:45:43",-7, 1, 1900 ],
[ "Laramie, WY", "41:18:41", "-105:35:28",-7, 1, 2183 ],
[ "Rawlins, WY", "41:47:28", "-107:14:17",-7, 1, 2063 ],
[ "Sheridan, WY", "44:47:50", "-106:57:22",-7, 1, 1141 ],
[ "Sundance, WY", "44:24:23", "-104:22:30",-7, 1, 1452 ],
[ "Denali NP, AK", "63:20:00", "-150:30:02",-9, 1, 0 ],
[ "Gates of the Arctic NP, AK", "67:45:02", "-153:15:02",-9, 1, 0 ],
[ "Glacier Bay NP, AK", "58:30:02", "-137:00:02",-9, 1, 0 ],
[ "Katmai NP, AK", "58:25:00", "-154:55:00",-9, 1, 0 ],
[ "Kenai Fjords NP, AK", "59:55:04", "-149:58:15",-9, 1, 1524 ],
[ "Kobuk Valley NP, AK", "67:20:00", "-159:10:00",-9, 1, 0 ],
[ "Lake Clark NP, AK", "60:35:00", "-153:15:02",-9, 1, 0 ],
[ "Wrangell-Saint Elias NP, AK", "60:45:02", "-142:00:02",-9, 1, 0 ],
[ "Hot Springs NP, AR", "34:31:05", "-93:03:15",-6, 1, 197 ],
[ "Canyon de Chelly NM, AZ", "36:09:19", "-109:30:30",-7, 1, 1676 ],
[ "Grand Canyon NP, AZ", "36:11:43", "-112:03:00",-7, 0, 2128 ],
[ "Petrified Forest NP, AZ", "34:59:54", "-109:48:05",-7, 0, 1656 ],
[ "Saguaro NP (East Unit), AZ", "32:11:23", "-110:43:03",-7, 0, 962 ],
[ "Saguaro NP (Tucson Mountain Unit), AZ", "32:16:45", "-111:10:59",-7, 0, 961 ],
[ "Carrizo Plain NM, CA", "35:11:25", "-119:51:49",-8, 1, 597 ],
[ "Channel Islands NP, CA", "34:00:38", "-119:46:17",-8, 1, 276 ],
[ "Death Valley NP (Eureka Valley), CA", "37:06:47", "-117:41:33",-8, 1, 875 ],
[ "Death Valley NP (Furnace Creek), CA", "36:27:26", "-116:51:55",-8, 1,-55 ],
[ "Death Valley NP (Stovepipe Wells), CA", "36:36:22", "-117:08:44",-8, 1, 2 ],
[ "Devil's Postpile NM, CA", "37:36:54", "-119:05:11",-8, 1, 2301 ],
[ "Joshua Tree NP, CA", "33:55:00", "-115:55:00",-8, 1, 792 ],
[ "Kings Canyon NP (Cedar Grove), CA", "36:47:27", "-118:40:10",-8, 1, 1402 ],
[ "Lassen Volcanic NP, CA", "40:28:48", "-121:26:34",-8, 1, 2229 ],
[ "Lava Beds NM, CA", "41:45:11", "-121:32:57",-8, 1, 1392 ],
[ "Pinnacles NM, CA", "36:28:02", "-121:10:25",-8, 1, 652 ],
[ "Point Reyes NS, CA", "38:03:25", "-122:58:25",-8, 1, 55 ],
[ "Redwood NP, CA", "41:15:00", "-124:01:37",-8, 1, 260 ],
[ "Yosemite NP, CA", "37:44:43", "-119:35:50",-8, 1, 1219 ],
[ "Black Canyon of the Gunnison NM, CO", "38:34:48", "-107:43:21",-7, 1, 2098 ],
[ "Dinosaur NM, CO", "39:03:40", "-108:42:02",-7, 1, 1867 ],
[ "Great Sand Dunes NM, CO", "37:45:17", "-105:33:30",-7, 1, 2555 ],
[ "Mesa Verde NP, CO", "37:13:58", "-108:28:48",-7, 1, 2305 ],
[ "Rocky Mountain NP, CO", "40:20:07", "-105:42:38",-7, 1, 3488 ],
[ "White Sands NM, CO", "32:46:00", "-106:19:56",-7, 1, 1208 ],
[ "Biscayne NP, FL", "25:28:39", "-80:11:38",-5, 1, 0 ],
[ "Dry Tortugas NP, FL", "24:37:39", "-82:52:20",-5, 1, 0 ],
[ "Everglades NP, FL", "25:32:43", "-80:59:12",-5, 1, 0 ],
[ "Haleakala NP, HI", "20:42:25", "-156:08:58",-10, 0, 0 ],
[ "Hawaii Volcanoes NP, HI", "19:24:00", "-155:18:00",-10, 0, 0 ],
[ "Prairie NP, KS", "39:14:59", "-96:40:10",-6, 1, 399 ],
[ "Mammoth Cave NP, KY", "37:11:13", "-86:05:56",-6, 1, 231 ],
[ "Fiske Hill NP, MA", "42:26:38", "-71:43:12",-5, 1, 127 ],
[ "Fort Washington NP, MD", "38:42:36", "-77:01:59",-5, 1, 1 ],
[ "Arcadia NP, ME", "44:19:35", "-68:16:33",-5, 1, 162 ],
[ "Isle Royale NP, MI", "48:00:01", "-88:50:01",-5, 1, 0 ],
[ "Voyageurs NP, MN", "48:30:06", "-92:49:57",-6, 1, 394 ],
[ "Glacier NP, MT", "48:41:10", "-113:48:35",-7, 1, 1477 ],
[ "Great Smoky Mountains NP, NC", "35:34:58", "-83:30:07",-5, 1, 1438 ],
[ "Wind Cave NP, ND", "43:41:38", "-103:25:20",-7, 1, 1373 ],
[ "Washington Headquarters NP, NJ", "40:47:45", "-74:27:55",-5, 1, 98 ],
[ "Great Basin NP, NV", "38:56:03", "-114:14:45",-8, 1, 2619 ],
[ "Crater Lake NP, OR", "42:54:30", "-122:06:01",-8, 1, 1884 ],
[ "Badlands NP, SD", "43:37:19", "-102:51:58",-7, 1, 893 ],
[ "Big Bend NP, TX", "29:15:07", "-103:15:00",-6, 1, 1505 ],
[ "Guadalupe Mountains NP, TX", "31:53:56", "-104:52:05",-6, 1, 2315 ],
[ "Arches NP, UT", "38:42:33", "-109:33:54",-7, 1, 1499 ],
[ "Bryce Canyon NP, UT", "37:36:25", "-112:12:11",-7, 1, 2423 ],
[ "Canyonlands NP (Islands in the Sky), UT", "38:23:14", "-109:52:13",-7, 1, 1867 ],
[ "Canyonlands NP (Needles), UT", "38:10:25", "-109:48:44",-7, 1, 1522 ],
[ "Capitol Reef NP (Fruita), UT", "38:17:06", "-111:14:57",-7, 1, 1694 ],
[ "Cedar Breaks NM, UT", "37:38:33", "-112:50:53",-7, 1, 3048 ],
[ "Zion NP, UT", "37:14:55", "-113:01:13",-7, 1, 1611 ],
[ "Fort Hunt NP, VA", "38:42:59", "-77:03:16",-5, 1, 2 ],
[ "Shenandoah NP, VA", "38:30:02", "-78:26:58",-5, 1, 989 ],
[ "Mount Ranier NP, WA", "46:50:39", "-121:52:16",-8, 1, 1224 ],
[ "North Cascades NP, WA", "48:41:51", "-121:13:25",-8, 1, 418 ],
[ "Olympic NP, WA", "47:47:58", "-123:33:06",-8, 1, 917 ],
[ "Grand Teton NP, WY", "43:44:46", "-110:43:41",-7, 1, 2069 ],
[ "Yellowstone NP, WY", "44:43:01", "-110:29:54",-7, 1, 2351 ],
[ "Calgary, AB", "51:02:28", "-114:03:39",-7, 1, 1048 ],
[ "Edmonton, AB", "53:32:44", "-113:30:18",-7, 1, 665 ],
[ "Fort McMurray, AB", "56:44:02", "-111:25:35",-7, 1, 0 ],
[ "Dawson Creek, BC", "55:45:15", "-120:14:02",-7, 1, 655 ],
[ "Prince George, BC", "53:54:40", "-122:45:40",-8, 1, 569 ],
[ "Prince Rupert, BC", "54:19:05", "-130:18:12",-8, 1, 0 ],
[ "Vancouver, BC", "49:15:45", "-123:06:00",-8, 1, 0 ],
[ "Victoria, BC", "48:25:30", "-123:21:45",-8, 1, 0 ],
[ "Brandon, MB", "49:50:26", "-99:57:30",-6, 1, 0 ],
[ "Churchill, MB", "58:46:28", "-94:10:24",-6, 1, 0 ],
[ "Thompson, MB", "55:44:32", "-97:51:39",-6, 1, 0 ],
[ "Winnipeg, MB", "49:53:57", "-97:08:57",-6, 1, 229 ],
[ "Fredericton, NB", "45:57:30", "-66:39:11",-4, 1, 10 ],
[ "Saint John, NB", "45:16:50", "-66:03:58",-4, 1, 0 ],
[ "Happy Valley-Goose Bay, NL", "53:18:50", "-60:15:00",-4, 1, 0 ],
[ "Saint John's, NL", "47:34:24", "-52:42:56",-3.5, 1, 0 ],
[ "Halifax, NS", "44:39:52", "-63:36:30",-4, 1, 0 ],
[ "Inuvik, NT", "68:18", "-133:29",-7, 1, 0 ],
[ "Yellowknife, NT", "62:27:14", "-114:20:57",-7, 1, 0 ],
[ "Aujuittuq (Grise Fiord), NU", "76:25:29", "-82:57:23",-5, 1, 0 ],
[ "Iqaluit, NU", "63:44", "-68:32",-5, 1, 0 ],
[ "Qausuittuq (Resolute Bay), NU", "74:41:13", "-94:54:38",-6, 1, 0 ],
[ "London, ON", "42:59:12", "-81:13:46",-5, 1, 0 ],
[ "Ottawa, ON", "45:25:34", "-75:42:04",-5, 1, 65 ],
[ "Sault Ste. Marie, ON", "46:31:23", "-84:19:42",-5, 1, 0 ],
[ "Sudbury, ON", "46:28:33", "-80:59:46",-5, 1, 0 ],
[ "Thunder Bay, ON", "48:24:10", "-89:15:38",-5, 1, 214 ],
[ "Toronto, ON", "43:39:51", "-79:21:26",-5, 1, 77 ],
[ "Windsor, ON", "42:18:03", "-83:02:09",-5, 1, 177 ],
[ "Charlottetown, PE", "46:14:20", "-63:07:49",-4, 1, 0 ],
[ "Montreal, QC", "45:31:22", "-73:34:00",-5, 1, 8 ],
[ "Quebec, QC", "46:48:54", "-71:12:38",-5, 1, 93 ],
[ "Rimouski, QC", "48:26:32", "-68:32:22",-5, 1, 0 ],
[ "Regina, SK", "50:26:54", "-104:36:38",-6, 0, 577 ],
[ "Saskatoon, SK", "52:08:32", "-106:38:41",-6, 0, 486 ],
[ "Dawson, YT", "64:04:03", "-139:25:08",-8, 1, 0 ],
[ "Whitehorse, YT", "60:23:40", "-135:02:46",-8, 1, 0 ],
[ "Banff NP, AB", "51:43:52", "-116:21:18",-7, 1, 0 ],
[ "Elk Island NP, AB", "53:36:57", "-112:51:54",-7, 1, 0 ],
[ "Jasper NP, AB", "52:52:54", "-118:05:04",-7, 1, 0 ],
[ "Waterton Lakes NP, AB", "49:04:06", "-113:54:57",-7, 1, 0 ],
[ "Wood Buffalo NP, AB", "59:35:00", "-112:54:58",-7, 1, 0 ],
[ "Yoho NP, AB", "51:23:37", "-116:30:41",-7, 1, 0 ],
[ "Glacier NP, BC", "51:17:08", "-117:32:33",-8, 1, 0 ],
[ "Gwaii Haanas NP, BC", "52:30:33", "-131:37:37",-8, 1, 0 ],
[ "Kootenay NP, BC", "50:59:40", "-115:59:04",-8, 1, 0 ],
[ "Mount RevelStoke NP, BC", "51:05:50", "-118:02:42",-8, 1, 0 ],
[ "Pacific Rim NP, BC", "49:04:45", "-125:41:18",-8, 1, 0 ],
[ "Riding Mountain NP, MB", "50:51:21", "-100:17:29",-6, 1, 0 ],
[ "Wapusk NP, MB", "58:34:27", "-93:32:11",-6, 1, 0 ],
[ "Fundy NP, NB", "45:37:20", "-65:02:27",-4, 1, 0 ],
[ "Kouchibouguac NP, NB", "46:50:15", "-64:57:41",-4, 1, 0 ],
[ "Gros Morne NP, NL", "49:39:15", "-57:43:38",-3.5, 1, 0 ],
[ "Terra Nova NP, NL", "48:32:11", "-53:58:06",-3.5, 1, 0 ],
[ "Cape Breton Highlands NP, NS", "46:43:22", "-60:38:31",-4, 1, 0 ],
[ "Kejimkujik NP, NS", "44:22:25", "-65:18:25",-4, 1, 0 ],
[ "Aulavik NP, NT", "73:39:53", "-119:45:12",-7, 1, 0 ],
[ "Nahanni NP, NT", "61:00:00", "-125:41:56",-7, 1, 0 ],
[ "Tuktut Nogait NP, NT", "68:50:10", "-121:56:49",-7, 1, 0 ],
[ "Auyuittuk NP, NU", "67:24:55", "-66:09:26",-5, 1, 0 ],
[ "Quttinirpaaq NP, NU", "82:09:27", "-70:43:47",-5, 1, 0 ],
[ "Bruce Peninsula NP, ON", "45:11:09", "-81:30:33",-5, 1, 0 ],
[ "Downsview NP, ON", "43:44:41", "-79:28:46",-5, 1, 0 ],
[ "Georgian Bay Islands NP, ON", "44:52:21", "-79:52:07",-5, 1, 0 ],
[ "Point Pelee NP, ON", "41:58:14", "-82:31:03",-5, 1, 0 ],
[ "Pukaskwa NP, ON", "48:17:40", "-85:52:22",-5, 1, 0 ],
[ "Saint Lawrence Islands NP, ON", "44:13:26", "-75:51:45",-5, 1, 0 ],
[ "Prince Edward Island NP, PE", "46:26:03", "-63:13:28",-4, 1, 0 ],
[ "Fourillon NP, QC", "48:54:04", "-64:22:34",-5, 1, 0 ],
[ "La Mauricie NP, QC", "46:47:43", "-72:58:22",-5, 1, 0 ],
[ "Grasslands NP, SK", "49:06:10", "-107:26:36",-6, 0, 0 ],
[ "Prince Albert NP, SK", "53:58:49", "-106:23:59",-6, 0, 0 ],
[ "Ivvavik NP, YT", "69:04:36", "-139:48:21",-8, 1, 0 ],
[ "Kluane NP, YT", "60:44:19", "-139:23:23",-8, 1, 0 ],
[ "Vuntut NP, YT", "68:25:05", "-139:58:54",-8, 1, 0 ],
[ "Acapulco, Mexico", "16:51", "-99:55",-6, 1, 0 ],
[ "Aguascalientes, Mexico", "21:53", "-102:17",-6, 1, 1885 ],
[ "Cancun, Mexico", "21:10", "-86:50",-6, 1, 10 ],
[ "Chetumal, Mexico", "18:30", "-88:18",-6, 1, 10 ],
[ "Chihuahua, Mexico", "28:38", "-106:04",-6, 1, 1402 ],
[ "Ciudad Juarez, Mexico", "31:44", "-106:28",-6, 1, 1183 ],
[ "Culiacan, Mexico", "24:47", "-107:23",-7, 1, 40 ],
[ "Durango, Mexico", "24:01", "-104:39",-6, 1, 1856 ],
[ "Ensenada, Mexico", "31:52", "-116:37",-8, 1, 0 ],
[ "Guadalajara, Mexico", "20:40", "-103:21",-6, 1, 1567 ],
[ "Hermosillo, Mexico", "29:05", "-110:57",-7, 0, 210 ],
[ "La Paz, Mexico", "24:09", "-110:19",-7, 1, 18 ],
[ "Mazatlan, Mexico", "23:12", "-106:25",-7, 1, 0 ],
[ "Merida, Mexico", "20:59", "-89:37",-6, 1, 11 ],
[ "Mexico City, Mexico", "19:26", "-99:08",-6, 1, 2239 ],
[ "Monterrey, Mexico", "25:41", "-100:19",-6, 1, 512 ],
[ "Oaxaca, Mexico", "17:03", "-96:42",-6, 1, 1529 ],
[ "San Lucas, Mexico", "22:54", "-109:54",-7, 1, 0 ],
[ "Torreon, Mexico", "25:33", "-103:26",-6, 1, 1119 ],
[ "Villahermosa, Mexico", "17:58", "-92:55",-6, 1, 14 ],
[ "San Jose, Costa Rica", "9:56", "-84:05",-6, 0, 1170 ],
[ "San Salvador, El Salvador", "13:42", "-89:12",-6, 0, 683 ],
[ "Guatemala City, Guatemala", "14:38", "-90:32",-6, 0, 0 ],
[ "Tegucigalpa, Honduras", "14:06", "-87:12",-6, 1, 1006 ],
[ "Managua, Nicaragua", "12:09", "-86:16",-6, 0, 0 ],
[ "Panama City, Panama", "8:57", "-79:32",-5, 0, 0 ],
[ "Havana, Cuba", "23:08", "-82:24",-5, 0, 0 ],
[ "Nassau, Bahamas", "25:04", "-77:20",-5, 1, 0 ],
[ "Santo Domingo, Dominican Republic", "18:29", "-69:54",-4, 0, 0 ],
[ "Port-au-Prince, Haiti", "18:33", "-72:20",-5, 1, 0 ],
[ "Kingston, Jamaica", "18:00", "-76:48",-5, 0, 0 ],
[ "Buenos Aires, Argentina", "-34:37", "-58:22",-3, 1, 0 ],
[ "La Paz, Bolivia", "-16:30", "-68:09",-4, 0, 3658 ],
[ "Brasilia, Brazil", "-15:48", "-47:54",-3, 1, 1006 ],
[ "Manaus, Brazil", "-3:07", "-60:01",-4, 1, 0 ],
[ "Recife, Brazil", "-8:22", "-35:04",-3, 1, 0 ],
[ "Rio de Janeiro, Brazil", "-22:54", "-43:13",-3, 1, 9 ],
[ "Sao Paulo, Brazil", "-23:23", "-46:38",-3, 1, 823 ],
[ "Punta Arenas, Chile", "-53:09", "-70:56",-4, 1, 0 ],
[ "Santiago, Chile", "-33:28", "-70:39",-4, 1, 518 ],
[ "Bogota, Columbia", "4:37", "-74:04",-5, 0, 2610 ],
[ "Quito, Ecuador", "-0:11", "-78:30",-5, 0, 2850 ],
[ "Georgetown, Guyana", "6:48", "-58:09",-4, 0, 0 ],
[ "Panama City, Panama", "8:57", "-79:32",-5, 0, 0 ],
[ "Asuncion, Paraguay", "-25:18", "-57:38",-4, 1, 43 ],
[ "Lima, Peru", "-12:04", "-77:03",-5, 0, 152 ],
[ "Paramaribo, Suriname", "5:49", "-55:10",-3, 0, 0 ],
[ "Montevideo, Uruguay", "-34:54", "-56:10",-3, 1, 0 ],
[ "Caracas, Venezuela", "10:30", "-66:55",-4, 0, 0 ],
[ "Tirana, Albania", "41:19", "19:49", 1, 1, 90 ],
[ "Innsbruck, Austria", "47:16", "11:24", 1, 1, 579 ],
[ "Salzburg, Austria", "47:49", "13:02", 1, 1, 450 ],
[ "Vienna, Austria", "48:13", "16:21", 1, 1, 305 ],
[ "Minsk, Belarus", "53:54", "27:33", 2, 1, 280 ],
[ "Brussels, Belgium", "50:51", "4:22", 1, 1, 0 ],
[ "Sarajevo, Bosnia and Herzegovina", "43:51", "18:24", 1, 1, 500 ],
[ "Zagreb, Croatia", "45:49", "15:59", 1, 1, 158 ],
[ "Prague, Czech Republic", "50:05", "14:25", 1, 1, 183 ],
[ "Copenhagen, Denmark", "55:41", "12:34", 1, 1, 0 ],
[ "Helsinki, Finland", "60:10", "24:57", 2, 1, 0 ],
[ "Oulu, Finland", "65:01", "25:28", 2, 1, 12 ],
[ "Bordeaux, France", "44:51", "-0:34", 1, 1, 0 ],
[ "Brest, France", "48:23", "-4:29", 1, 1, 0 ],
[ "Dijon, France", "47:19", "5:02", 1, 1, 300 ],
[ "Le Havre, France", "49:29", "0:07", 1, 1, 0 ],
[ "Lyon, France", "45:44", "4:49", 1, 1, 238 ],
[ "Marseille, France", "43:17", "5:22", 1, 1, 0 ],
[ "Orleans, France", "47:54", "1:54", 1, 1, 125 ],
[ "Paris, France", "48:50", "2:20", 1, 1, 91 ],
[ "Berlin, Germany", "52:32", "13:25", 1, 1, 34 ],
[ "Cologne, Germany", "50:56", "6:56", 1, 1, 99 ],
[ "Dresden, Germany", "51:03", "13:44", 1, 1, 226 ],
[ "Frankfurt, Germany", "50:07", "8:40", 1, 1, 113 ],
[ "Hamburg, Germany", "53:33", "10:01", 1, 1, 15 ],
[ "Munich, Germany", "48:08", "11:34", 1, 1, 518 ],
[ "Stuttgart, Germany", "48:47", "9:11", 1, 1, 419 ],
[ "Athens, Greece", "37:58", "23:44", 2, 1, 91 ],
[ "Budapest, Hungary", "47:30", "19:03", 1, 1, 0 ],
[ "Reykjavik, Iceland", "64:08", "-21:54", 0, 0, 0 ],
[ "Cork, Ireland", "51:54", "-8:28", 0, 1, 162 ],
[ "Dublin, Ireland", "53:21", "-6:15", 0, 1, 0 ],
[ "Genoa, Italy", "44:25", "8:55", 1, 1, 0 ],
[ "Milan, Italy", "45:29", "9:11", 1, 1, 120 ],
[ "Naples, Italy", "40:50", "14:16", 1, 1, 0 ],
[ "Palermo, Italy", "38:07", "13:21", 1, 1, 0 ],
[ "Rome, Italy", "41:53", "12:30", 1, 1, 29 ],
[ "Turin, Italy", "45:04", "7:40", 1, 1, 287 ],
[ "Skopje, Macedonia", "42:00", "21:27", 1, 1, 240 ],
[ "Amsterdam, Netherlands", "52:23", "4:53", 1, 1, 0 ],
[ "Bergen, Norway", "60:23", "5:21", 1, 1, 37 ],
[ "Oslo, Norway", "59:55", "10:46", 1, 1, 0 ],
[ "Trondheim, Norway", "63:25", "10:25", 1, 1, 17 ],
[ "Gdansk, Poland", "54:21", "18:38", 1, 1, 0 ],
[ "Krakow, Poland", "50:03", "19:57", 1, 1, 238 ],
[ "Warsaw, Poland", "52:15", "21:00", 1, 1, 110 ],
[ "Wroclaw, Poland", "51:07", "17:02", 1, 1, 121 ],
[ "Lisbon, Portugal", "38:43", "-9:08", 0, 1, 0 ],
[ "Bucharest, Romania", "44:26", "26:07", 2, 1, 76 ],
[ "Moscow, Russia", "55:45", "37:42", 3, 1, 120 ],
[ "Murmansk, Russia", "68:58", "33:05", 3, 1, 51 ],
[ "Omsk, Russia", "54:59", "73:22", 6, 1, 123 ],
[ "St. Petersburg, Russia", "59:34", "30:08", 3, 1, 6 ],
[ "Vladivostok, Russia", "42:57", "131:48", 10, 1, 183 ],
[ "Yakutsk, Russia", "62:02", "129:44", 9, 1, 103 ],
[ "Yekaterinburg, Russia", "56:50", "60:35", 5, 1, 237 ],
[ "Belgrade, Serbia and Montenegro", "44:04", "20:33", 1, 1, 117 ],
[ "Ljubljana, Slovenia", "46:03", "14:30", 1, 1, 385 ],
[ "Bratislava, Slovakia", "48:09", "17:07", 1, 1, 152 ],
[ "Madrid, Spain", "40:26", "-3:43", 1, 1, 655 ],
[ "Malaga, Spain", "36:43", "-4:25", 1, 1, 0 ],
[ "Murcia, Spain", "37:58", "-1:07", 1, 1, 66 ],
[ "Oviedo, Spain", "43:22", "-5:50", 1, 1, 30 ],
[ "Seville, Spain", "37:23", "-5:59", 1, 1, 0 ],
[ "Valencia, Spain", "39:28", "-0:21", 1, 1, 62 ],
[ "Zaragoza, Spain", "41:39", "-0:53", 1, 1, 258 ],
[ "Longyearbyen, Svalbard", "78:13", "15:38", 1, 1, 0 ],
[ "Goteborg, Sweden", "57:42", "11:59", 1, 1, 0 ],
[ "Malmo, Sweden", "55:36", "13:00", 1, 1, 0 ],
[ "Stockholm, Sweden", "59:20", "18:02", 1, 1, 0 ],
[ "Umea, Sweden", "63:49", "20:14", 1, 1, 14 ],
[ "Bern, Switzerland", "46:57", "7:27", 1, 1, 542 ],
[ "Geneva, Switzerland", "46:12", "6:08", 1, 1, 416 ],
[ "Zurich, Switzerland", "47:22", "8:32", 1, 1, 475 ],
[ "Aberdeen, United Kingdom", "57:08", "-2:05", 0, 1, 0 ],
[ "Birmingham, United Kingdom", "52:28:59", "-1:53:37", 0, 1, 140 ],
[ "Bristol, United Kingdom", "51:27", "-2:35", 0, 1, 11 ],
[ "Cardiff, United Kingdom", "51:28", "-3:10", 0, 1, 0 ],
[ "Edinburgh, United Kingdom", "55:54", "-3:09", 0, 1, 0 ],
[ "Glasgow, United Kingdom", "55:52", "-4:16", 0, 1, 0 ],
[ "Inverness, United Kingdom", "57:29", "-4:13", 0, 1, 6 ],
[ "Liverpool, United Kingdom", "53:24", "-2:59", 0, 1, 0 ],
[ "London, United Kingdom", "51:30", "-0:06", 0, 1, 75 ],
[ "Manchester, United Kingdom", "53:28", "-2:14", 0, 1, 78 ],
[ "Newcastle upon Tyne, United Kingdom", "54:59", "-1:31", 0, 1, 0 ],
[ "Plymouth, United Kingdom", "50:22", "-4:08", 0, 1, 0 ],
[ "Kiev, Ukraine", "49:43", "30:12", 2, 1, 0 ],
[ "Kabul, Afghanistan", "34:32", "69:08", 4.5, 0, 1676 ],
[ "Dhaka, Bangladesh", "23:42", "90:25", 6, 0, 0 ],
[ "Yangon, Burma", "16:46:54", "96:09:08", 6.5, 0, 0 ],
[ "Phnom Penh, Cambodia", "11:15", "104:54", 7, 0, 0 ],
[ "Beijing, China", "39:54", "116:23", 8, 0, 183 ],
[ "Shanghai, China", "31:14", "121:28", 8, 0, 0 ],
[ "Chennai, India", "13:05", "80:16", 5.5, 0, 0 ],
[ "Darjiling, India", "27:03", "88:15", 5.5, 0, 2286 ],
[ "Kolkata, India", "22:34", "88:22", 5.5, 0, 0 ],
[ "Mumbai, India", "18:57", "72:50", 5.5, 0, 8 ],
[ "New Delhi, India", "28:38", "77:12", 5.5, 0, 235 ],
[ "Jakarta, Indonesia", "-6:11", "106:50", 7, 0, 8 ],
[ "Tehran, Iran", "35:42", "51:25", 3.5, 1, 1207 ],
[ "Baghdad, Iraq", "33:20", "44:25", 3, 1, 34 ],
[ "Jerusalem, Israel", "31:47", "35:13", 2, 1, 762 ],
[ "Sapporo, Japan", "43:03", "141:21", 9, 0, 0 ],
[ "Tokyo, Japan", "35:35", "139:45", 9, 0, 9 ],
[ "Amman, Jordan", "31:57", "35:56", 2, 1, 718 ],
[ "Seoul, Korea", "37:33", "127:02", 9, 0, 9 ],
[ "Beirut, Lebanon", "33:53", "35:30", 2, 1, 0 ],
[ "Kathmandu, Nepal", "27:42", "85:19", 5.75, 0, 1372 ],
[ "Islamabad, Pakistan", "33:43", "73:04", 5, 0, 533 ],
[ "Karachi, Pakistan", "24:51", "67:00", 5, 0, 0 ],
[ "Manila, Philippines", "14:35", "120:59", 8, 0, 0 ],
[ "Mecca, Saudi Arabia", "21:26", "39:49", 3, 0, 610 ],
[ "Singapore, Singapore", "1:18", "103:51", 8, 0, 0 ],
[ "Damascus, Syria", "33:31", "36:18", 2, 1, 600 ],
[ "Taipei, Taiwan", "25:02", "121:31", 8, 0, 0 ],
[ "Bangkok, Thailand", "13:45", "100:31", 7, 0, 0 ],
[ "Lhasa, Tibet", "29:39", "91:08", 8, 0, 3650 ],
[ "Istanbul, Turkey", "41:01", "28:57", 2, 1, 100 ],
[ "Nabulus, West Bank", "32:13", "35:16", 2, 1, 940 ],
[ "Hanoi, Vietnam", "21:22", "105:51", 7, 0, 0 ],
[ "Algiers, Algeria", "36:46", "3:03", 1, 0, 0 ],
[ "Luanda, Angola", "-8:49", "13:14", 1, 0, 0 ],
[ "Kinshasa, DRC", "-4:19", "15:18", 1, 0, 0 ],
[ "Cairo, Egypt", "30:02", "31:15", 2, 1, 116 ],
[ "Addis Ababa, Ethiopia", "9:01", "38:45", 3, 0, 2438 ],
[ "Nairobi, Kenya", "-1:17", "36:49", 3, 0, 1661 ],
[ "Monrovia, Liberia", "6:18", "-10:48", 0, 0, 0 ],
[ "Tripoli, Libya", "32:52", "13:11", 1, 0, 0 ],
[ "Antananarivo, Madagascar", "-18:55", "47:32", 3, 0, 1248 ],
[ "Casablanca, Morocco", "33:36", "7:37", 0, 0, 0 ],
[ "Windhoek, Namibia", "-22:34", "17:05", 2, 1, 1646 ],
[ "Lagos, Nigeria", "6:29", "3:22", 1, 0, 0 ],
[ "Dakar, Senegal", "14:40", "-17:26", 0, 0, 0 ],
[ "Mogadishu, Somalia", "2:03", "45:21", 3, 0, 0 ],
[ "Capetown, South Africa", "-33:55", "18:26", 2, 0, 0 ],
[ "Khartoum, Sudan", "15:35", "32:31", 2, 0, 0 ],
[ "Dar es Salaam, Tanzania", "-6:49", "39:17", 3, 0, 0 ],
[ "Tunis, Tunisia", "36:49", "10:10", 1, 0, 0 ],
[ "Kampala, Uganda", "0:04", "32:46", 3, 0, 0 ],
[ "Adelaide, Australia", "-34:56", "138:35", 9.5, 1, 4 ],
[ "Alice Springs, Australia", "-23:42", "133:52", 9.5, 0, 609 ],
[ "Brisbane, Australia", "-27:28", "153:02", 10, 0, 4 ],
[ "Canberra, Australia", "-35:20", "149:08", 10, 1, 575 ],
[ "Darwin, Australia", "-12:27", "130:51", 9.5, 0, 30 ],
[ "Hobart, Australia", "-43:49", "149:07", 10, 1, 3 ],
[ "Melbourne, Australia", "-37:48", "144:57", 10, 1, 132 ],
[ "Perth, Australia", "-31:57:09", "115:51:24", 8, 0, 11 ],
[ "Sydney, Australia", "-33:52:00", "151:12:00", 10, 1, 8 ],
[ "Townsville, Australia", "-19:16", "146:47", 10, 1, 0 ],
[ "Hamilton, Bermuda", "32:18", "-64:47",-4, 1, 0 ],
[ "Stanley, Falkland Islands", "-51:42", "-57:40",-4, 1, 73 ],
[ "Nuuk, Greenland", "64:10", "-51:43",-3, 1, 0 ],
[ "Auckland, New Zealand", "-36:50", "174:45", 12, 1, 0 ],
[ "Christchurch, New Zealand", "-43:31", "172:38", 12, 1, 34 ],
[ "Grytviken, South Georgia", "-54:16", "-36:31",-2, 0, 0 ],
[ "Papeete, Tahiti", "-17:32", "-149:34",-10, 0, 0 ]
];
function Place(place)
{if(arguments.length){
this.name=place[NAME];
if(this.getCountry()===false)
return false;
this.latitude=place[LAT].DMSto();
this.longitude=place[LONG].DMSto();
this.timezone=place[TZ].DMSto();
this.uses_dst=Number(place[DST]);
this.dst_offset=0;
this.elevation=Number(place[ELEV]);
if(place[HEIGHT])
this.height=Number(place[HEIGHT]);
else
this.height=0;
this.calcObserverCoord();
this.calcDensities();
this.calcRSAlt();
}
return true;
}
Place.prototype.Init=function(place)
{if(arguments.length){
this.name=place[NAME];
if(this.getCountry()===false)
return false;
this.latitude=place[LAT].DMSto();
this.longitude=place[LONG].DMSto();
this.timezone=place[TZ].DMSto();
this.uses_dst=Number(place[DST]);
this.dst_offset=0;
this.elevation=Number(place[ELEV]);
if(place[HEIGHT])
this.height=Number(place[HEIGHT]);
else
this.height=0;
this.sin_lat=Math.sin(this.latitude.DtoR());
this.cos_lat=Math.cos(this.latitude.DtoR());
this.calcObserverCoord();
this.calcDensities();
this.calcRSAlt();
}
return true;
};
Place.prototype.setLocation=function(form)
{var
errors=0,
ndx,
place=new Array(),
timezone;
if(form.loc_type[0].checked===true){ndx=form.place.selectedIndex;
if(form.place.options[ndx].text!=places[ndx][NAME]){alert(
"Location lookup error:"
+"\n"+form.place.options[ndx].text
+"\n          vs."
+"\n"+places[ndx][NAME]
);
errors++;
}
else
place=places[ndx];
}
else{
if(form.place_name.value)
place[NAME]=form.place_name.value;
else
place[NAME]="Unknown";
if(check_latitude(form, form.latitude)===false)
errors++;
else{place[LAT]=form.latitude.value.DMSto();
ndx=form.lat_sign.selectedIndex;
place[LAT]*=form.lat_sign.options[ndx].value;
}
if(check_longitude(form, form.longitude)===false)
errors++;
else{place[LONG]=form.longitude.value.DMSto();
ndx=form.long_sign.selectedIndex;
place[LONG]*=form.long_sign.options[ndx].value;
}
timezone=form.timezone.value;
if(timezone==="")
place[TZ]=Math.round(place[LONG]/15);
else if(isNaN((place[TZ]=timezone.DMSto()))){alert("Invalid time zone ("+timezone+")");
errors++;
}
else if(place[TZ]<-12){alert("Invalid time zone ("+timezone+")");
errors++;
}
else if(place[TZ]>13){alert("Invalid time zone ("+timezone+")");
errors++;
}
ndx=form.uses_dst.selectedIndex;
place[DST]=form.uses_dst.options[ndx].value;
if(check_elevation(form.elevation)===false)
errors++;
else{place[ELEV]=Number(rmCommas(form.elevation.value));
if(flags.elevation_in_feet===true)
place[ELEV]=place[ELEV].FTtoM();
}
}
if(check_height(form, form.height)===false)
errors++;
else{place[HEIGHT]=Number(rmCommas(form.height.value));
if(flags.elevation_in_feet===true)
place[HEIGHT]=place[HEIGHT].FTtoM();
}
if(errors>0)
return false;
this.Init(place);
return true;
};
Place.prototype.getCountry=function()
{    if((this.country=this.name.replace(/.*,\s*/, "")) == this.name)
this.country="Unknown";
if(this.country=="UK")
this.country="United Kingdom";
if(this.country=="England"||this.country=="Scotland")
this.country="United Kingdom";
else if(this.country=="Wales"||this.country=="Northern Ireland")
this.country="United Kingdom";
else if(this.country.length<3){var
provinces="AB|BC|MB|NB|NL|NS|NT|NU|ON|PE|QC|SK|YT",
states="AK|AL|AR|AS|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS";
states+="|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NC|ND|NE|NH|NJ|NM|NV|NY|OH";
states+="|OK|OR|PA|PR|RI|SC|SD|TN|TX|UT|VA|VI|VT|WA|WI|WV|WY";
var
province=new RegExp(provinces),
state=new RegExp(states);
if(province.test(this.country)===true)
this.country="Canada";
else if(state.test(this.country)===true)
this.country="United States";
else{alert('Unrecognized state or province: '+this.country);
return false;
}
}
return true;
};
Place.prototype.tzName=new Array();
Place.prototype.tzName[0]="GMT";
Place.prototype.tzName[6]="Greenland";
Place.prototype.tzName[7]="Newfoundland";
Place.prototype.tzName[8]="Atlantic";
Place.prototype.tzName[10]="Eastern";
Place.prototype.tzName[12]="Central";
Place.prototype.tzName[14]="Mountain";
Place.prototype.tzName[16]="Pacific";
Place.prototype.tzName[18]="Alaska";
Place.prototype.tzName[20]="Hawaii-Aleutian";
Place.prototype.tzName[22]="Samoa";
Place.prototype.getTimezone=function()
{var
tz_name,
tz_ndx=-2*this.timezone;
switch (this.country){case "Canada":
case "Greenland":
case "United States":
if(tz_ndx>22||! this.tzName[tz_ndx])
tz_name=null;
else
tz_name=this.tzName[tz_ndx];
break;
default:
if(tz_ndx===0)
tz_name=this.tzName[tz_ndx];
else
tz_name=null;
break;
}
return tz_name;
};
Place.prototype.isDST=function(date)
{var
dst_offset,
time=date.getTime();
if(this.uses_dst===false||flags.show_dst===false)
dst_offset=0;
else if(this.dst_start===null||this.dst_end===null)
dst_offset=0;
else if(this.latitude<0){if(time>=this.dst_start||time<this.dst_end)
dst_offset=1;
else
dst_offset=0;
}
else{if(time>=this.dst_start&&time<this.dst_end)
dst_offset=1;
else
dst_offset=0;
}
return dst_offset;
};
Place.prototype.getTimeOffset=function(date)
{var ut_offset=this.timezone;
if(this.uses_dst==1&&flags.show_dst===true)
ut_offset+=this.isDST(date);
this.ut_offset=ut_offset;
return (ut_offset*1);
};
Place.prototype.getDSTRule=function(year)
{
var
EUstates="Austria|Belgium|Cyprus|Czech Republic|Denmark|Estonia",
E_states="Albania|Andorra|Bosnia and Herzegovina|Gibraltar";
EUstates+="|Finland|France|Germany|Greece|Hungary|Ireland|Italy";
EUstates+="|Latvia|Lithuania|Luxembourg|Malta|Poland|Portugal";
EUstates+="|Slovakia|Slovenia|Spain|Sweden|Netherlands|United Kingdom";
E_states+="|Bulgaria|Croatia|Macedonia|Romania|Turkey";
E_states+="|Liechtenstein|Moldova|Monaco|Norway|San Marino";
E_states+="|Serbia and Montenegro|Switzerland|Vatican City";
var
Europe=new RegExp(E_states),
EUnion=new RegExp(EUstates);
if(EUnion.test(this.country)===true)
this.country="European Union";
else if(Europe.test(this.country)===true)
this.country="Europe";
year=Number(year);
switch (this.country){
case "Guatemala":
case "Haiti":
case "Mexico":
this.DSTStartStr="4:1:1:0:2:s";
this.DSTEndStr="10:31:5:0:1:s";
break;
case "Honduras":
this.DSTStartStr="5:1:1:0:2:s";
this.DSTEndStr="8:1:1:1:1:s";
break;
case "Bahamas":
case "Bermuda":
case "Canada":
case "PR":
case "VI":
case "United States":
if(year<2007){this.DSTStartStr="4:1:1:0:2:s";
this.DSTEndStr="10:31:5:0:1:s";
}
else{this.DSTStartStr="3:1:2:0:2:w";
this.DSTEndStr="11:1:1:0:2:w";
}
break;
case "European Union":
case "Europe":
case "Greenland":
case "Svalbard":
this.DSTStartStr="3:31:5:0:1:u";
this.DSTEndStr="10:31:5:0:1:u";
break;
case "Egypt":
this.DSTStartStr="4:1:4:4:0:s";
this.DSTEndStr="9:30:5:5:0:s";
break;
case "Mauritius":
this.DSTStartStr="0:31:5:0:2:s";
this.DSTEndStr="0:31:5:0:1:s";
break;
case "Namibia":
this.DSTStartStr="9:1:1:0:2:s";
this.DSTEndStr="4:1:1:0:1:s";
break;
case "Tunisia":
this.DSTStartStr="3:31:5:0:2:s";
this.DSTEndStr="10:31:5:0:2:s";
break;
case "Israel":
switch (year){case 2009:
this.DSTStartStr="3:31:5:5:2:w";
this.DSTEndStr="9:30:5:0:2:w";
break;
case 2010:
this.DSTStartStr="3:31:5:5:2:w";
this.DSTEndStr="9:1:2:0:2:w";
break;
case 2011:
this.DSTStartStr="4:1:1:5:2:w";
this.DSTEndStr="10:1:1:0:2:w";
break;
case 2012:
this.DSTStartStr="3:31:5:5:2:w";
this.DSTEndStr="9:1:4:0:2:w";
break;
case 2013:
this.DSTStartStr="3:31:5:5:2:w";
this.DSTEndStr="9:1:2:0:2:w";
break;
case 2014:
this.DSTStartStr="3:31:5:5:2:w";
this.DSTEndStr="9:1:4:0:2:w";
break;
case 2015:
this.DSTStartStr="3:31:5:5:2:w";
this.DSTEndStr="9:1:3:0:2:w";
break;
default:
this.DSTStartStr="3:31:5:5:2:w";
this.DSTEndStr="9:1:2:0:2:w";
break;
}
break;
case "Iran":
if(year<2009){this.DSTStartStr="0:1:3:0:0:s";
this.DSTEndStr="0:1:3:2:0:s";
}
else switch (year){case 2009:
this.DSTStartStr="3:21:0:0:24:w";
this.DSTEndStr="9:21:0:0:24:w";
break;
case 2010:
this.DSTStartStr="3:21:0:0:24:w";
this.DSTEndStr="9:21:0:0:24:w";
break;
case 2011:
this.DSTStartStr="3:21:0:0:24:w";
this.DSTEndStr="9:21:0:0:24:w";
break;
case 2012:
this.DSTStartStr="3:20:0:0:24:w";
this.DSTEndStr="9:20:0:0:24:w";
break;
case 2013:
break;
case 2014:
this.DSTStartStr="3:21:0:0:24:w";
this.DSTEndStr="9:21:0:0:24:w";
break;
case 2015:
this.DSTStartStr="3:21:0:0:24:w";
this.DSTEndStr="9:21:0:0:24:w";
break;
default:
this.DSTStartStr="3:21:0:0:24:w";
this.DSTEndStr="9:21:0:0:24:w";
break;
}
break;
case "Iraq":
this.DSTStartStr="0:1:0:0:2:s";
this.DSTEndStr="0:1:0:0:1:s";
break;
case "Syria":
this.DSTStartStr="3:31:5:5:0:s";
this.DSTEndStr="10:31:5:5:0:s";
break;
case "Jordan":
this.DSTStartStr="3:31:5:5:0:s";
this.DSTEndStr="10:31:5:5:0:s";
break;
case "Lebanon":
this.DSTStartStr="3:31:5:0:0:s";
this.DSTEndStr="10:31:5:0:1:s";
break;
case "Gaza":
case "West Bank":
case "Palestine":
this.DSTStartStr="3:31:5:5:2:s";
this.DSTEndStr="9:1:1:5:1:s";
break;
case "Armenia":
case "Azerbaijan":
case "Belarus":
case "Russia":
case "Ukraine":
this.DSTStartStr="3:31:5:0:2:s";
this.DSTEndStr="10:31:5:0:1:s";
break;
case "Pakistan":
this.DSTStartStr="4:1:2:3:0:s";
this.DSTEndStr="10:31:5:0:0:s";
break;
case "Afghanistan":
case "Berzerkistan":
case "Kazakhstan":
case "Kazakstan":
case "Kyrgyzstan":
case "Tajikistan":
case "Turkmenistan":
case "Uzbekistan":
this.DSTStartStr="0:31:5:0:0:s";
this.DSTEndStr="0:31:5:0:1:s";
break;
case "Australia":
var city=this.name.replace(/,.*/, "");
switch (city){case "Perth":
this.DSTStartStr="0:31:5:0:2:s";
this.DSTEndStr="0:31:5:0:1:s";
break;
default:
this.DSTStartStr="10:1:1:0:2:s";
this.DSTEndStr="4:1:1:0:1:s";
break;
}
break;
case "New Zealand":
this.DSTStartStr="9:30:5:0:2:s";
this.DSTEndStr="4:1:1:0:2:s";
break;
case "Tonga":
this.DSTStartStr="0:1:1:0:2:s";
this.DSTEndStr="0:31:5:0:1:s";
break;
case "Cuba":
this.DSTStartStr="4:15:0:0:2:s";
this.DSTEndStr="10:31:5:0:1:s";
break;
case "Argentina":
this.DSTStartStr="0:1:3:0:0:s";
this.DSTEndStr="0:1:2:0:0:s";
break;
case "Brazil":
switch (year){case 2009:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:15:1:0:0:s";
break;
case 2010:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:15:1:0:0:s";
break;
case 2011:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:15:1:0:0:s";
break;
case 2012:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:22:1:0:0:s";
break;
case 2013:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:15:1:0:0:s";
break;
case 2014:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:15:1:0:0:s";
break;
case 2015:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:22:1:0:0:s";
break;
default:
this.DSTStartStr="10:15:1:0:0:s";
this.DSTEndStr="2:15:1:0:0:s";
break;
}
break;
case "Chile":
this.DSTStartStr="10:1:2:0:0:s";
this.DSTEndStr="3:1:2:0:0:s";
break;
case "Falkland Islands":
this.DSTStartStr="9:8:1:0:2:s";
this.DSTEndStr="4:6:1:0:1:s";
break;
case "Paraguay":
this.DSTStartStr="9:1:1:0:2:s";
this.DSTEndStr="4:1:1:0:1:s";
break;
case "Uruguay":
this.DSTStartStr="10:1:1:0:2:s";
this.DSTEndStr="3:1:2:0:1:s";
break;
case "UseUSRule":
case "Unknown":
if(this.latitude<0){this.DSTStartStr="11:1:1:0:2:s";
this.DSTEndStr="3:1:2:0:1:s";
if(this.country=="Unknown")
alert('Country unknown: using inverse of US DST rules');
}
else{if(year<2007){
this.DSTStartStr="4:1:1:0:2:w";
this.DSTEndStr="10:31:5:0:2:w";
}
else{this.DSTStartStr="3:1:2:0:2:w";
this.DSTEndStr="11:1:1:0:2:w";
}
if(this.country=="Unknown")
alert('Country unknown: using US DST rules');
}
this.country="UseUSRule";
break;
default:
if(this.country=="NoRule")
alert('No DST rule for '+this.country);
this.country="NoRule";
return false;
}
return true;
};
function showDSTRule(changeStr)
{var
change=new Array(),
RuleStr;
change=changeStr.split(":");
var
change_month=(change[0]-0),
change_day=(change[1]-0),
change_week=(change[2]-0),
change_DoW=(change[3]-0);
if(change_week===0){RuleStr=change_day+' '+months[change_month-1];
return RuleStr;
}
switch (change_week){case 1:
RuleStr="1st";
break;
case 2:
RuleStr="2nd";
break;
case 3:
RuleStr="3rd";
break;
case 4:
RuleStr="4th";
break;
case 5:
RuleStr="Last";
break;
default:
break;
}
RuleStr+=' '+day_of_week[change_DoW];
if(change_week==5)
RuleStr+=' of '+months[change_month-1];
else if(change_day>1)
RuleStr+=' after '+change_day+' '+months[change_month-1];
else
RuleStr+=' of '+months[change_month-1];
return RuleStr;
}
function showDSTDate(changeStr, year)
{var
DateStr,
dayStr,
change=new Array();
change=changeStr.split(":");
var
change_month=(change[0]-0),
change_day=(change[1]-0),
change_week=(change[2]-0),
change_DoW=(change[3]-0);
if(change_week>0){change_day=getDSTChangeDate(year, changeStr);
dayStr=day_of_week[change_DoW];
}
else{var date;
date=new Date(Date.UTC(year, change_month-1, change_day, 12));
dayStr=day_of_week[date.getUTCDay()];
}
DateStr=dayStr+' '+change_day+' '+months[change_month-1];
return DateStr;
}
function getDSTChangeDate(year, changeStr)
{var
change=new Array();
change=changeStr.split(":");
var
change_month=(change[0]-0),
change_day=(change[1]-0),
change_week=(change[2]-0),
change_DoW=(change[3]-0),
change_time=(change[4]-0),
weekday,
day_adj=0;
var DST_change=new Date(Date.UTC(year, change_month-1, change_day, 12));
weekday=DST_change.getUTCDay();
if(change_week==5){
change_day=monthdays[isleap(year)][change_month-1];
if(weekday!=change_DoW){if((day_adj=weekday-change_DoW)<0)
day_adj+=7;
change_day-=day_adj;
}
}
else if(change_week>0){if(weekday!=change_DoW){
if((day_adj=change_DoW-weekday)<0)
day_adj+=7;
change_day+=day_adj;
}
change_day+=((change_week-1)*7);
}
return (change_day);
}
Place.prototype.getDSTLimits=function(year)
{if(this.uses_dst===0||flags.show_dst===false)
return true;
if(this.getDSTRule(year)===false)
return false;
var
start=this.DSTStartStr.split(":"),
end=this.DSTEndStr.split(":");
var
ut_offset,
start_month=(start[0]-0),
start_day=(start[1]-0),
start_week=(start[2]-0),
start_DoW=(start[3]-0),
start_time=(start[4]-0),
start_type=start[5],
end_month=(end[0]-0),
end_day=(end[1]-0),
end_week=(end[2]-0),
end_DoW=(end[3]-0),
end_time=(end[4]-0),
end_type=end[5];
if(start_month===0||end_month===0){this.dst_start=this.dst_end=null;
return true;
}
if(start_type=="u")
ut_offset=0;
else
ut_offset=this.timezone;
if(start_week>0)
start_day=getDSTChangeDate(year, this.DSTStartStr);
start_time-=ut_offset;
this.dst_start=Date.UTC(year, start_month-1, start_day,
Math.ipart(start_time), Math.fpart(start_time)*60);
if(end_type=="u")
ut_offset=0;
else if(end_type=="w")
ut_offset=this.timezone+1;
else
ut_offset=this.timezone;
if(end_week>0)
end_day=getDSTChangeDate(year, this.DSTEndStr);
end_time-=ut_offset;
this.dst_end=Date.UTC(year, end_month-1, end_day,
Math.ipart(end_time), Math.fpart(end_time)*60);
this.dst_start_date=(this.dst_start-start_time.HtoMsec()).MsecToDay();
this.dst_end_date=(this.dst_end-end_time.HtoMsec()).MsecToDay();
this.dst_start_date=Math.round(this.dst_start_date);
this.dst_end_date=Math.round(this.dst_end_date);
return true;
};
function checkPlaces()
{var
warnings=0,
errors=0,
loc=new Place(),
latitude, longitude, lon_val, timezone, dst_flag,
ndx;
var
from_database=form.loc_type[0].checked,
loc_ndx=form.place.selectedIndex;
if(form.place.length!=places.length){if(form.place.length>places.length)
write_db('More locations on form than in database:');
else
write_db('Fewer locations on form than in database:');
write_db('  '+form.place.length+' vs. '+places.length);
errors++;
}
form.loc_type[0].checked=true;
for(ndx=0; places[ndx]&&ndx<form.place.length; ndx++){form.place.selectedIndex=ndx;
if(form.place.options[ndx].text!=places[ndx][NAME]){write_db('Location lookup error:',
'  '+form.place.options[ndx].text
+' vs. '+places[ndx][NAME]);
errors++;
}
latitude=places[ndx][LAT];
if(Math.abs(latitude.DMSto())>90){write_db(places[ndx][NAME]+": invalid latitude ("+latitude+")");
errors++;
}
longitude=places[ndx][LONG];
if(Math.abs(lon_val=longitude.DMSto())>180){write_db(places[ndx][NAME]+": invalid longitude ("+longitude+")");
errors++;
}
timezone=places[ndx][TZ];
if(get_tz_ndx(timezone)<0){write_db(places[ndx][NAME]+": invalid time zone ("+timezone+")");
errors++;
}
else if(lon_val*timezone<0){write_db(places[ndx][NAME]+": warning: longitude-time zone mismatch ("
+longitude+" "+"<->"+" "+timezone+")");
warnings++;
}
dst_flag=places[ndx][DST];
if(dst_flag!==0&&dst_flag!=1){write_db(places[ndx][NAME]+": invalid DST flag ("+dst_flag+")");
errors++;
}
}
if(from_database===true)
form.loc_type[0].checked=true;
else
form.loc_type[1].checked=true;
form.place.selectedIndex=loc_ndx;
write_db(form.place.options.length+' locations');
if(warnings==1)
write_db(warnings+' location warning');
else if(warnings>1)
write_db(warnings+' location warnings');
if(errors==1)
write_db(errors+' location error');
else
write_db(errors+' location errors');
}
function checkDSTRules(year)
{var
errors=0,
loc,
ndx;
for(ndx=0; places[ndx]; ndx++){if(places[ndx][DST]==1){
loc=new Place(places[ndx]);
if(loc.checkDSTLimits(year)===false)
errors++;
}
}
if(errors==1)
write_db(errors+' DST rule error');
else
write_db(errors+' DST rule errors');
}
Place.prototype.checkDSTLimits=function(year)
{var errors=0;
if(this.uses_dst===0||flags.show_dst===false)
return true;
if(this.getDSTRule(year)===false){write_db('No DST rule for '+this.name);
return false;
}
if(this.checkDSTChangeDate(this.DSTStartStr, "start")===false)
errors++;
if(this.checkDSTChangeDate(this.DSTEndStr, "end")===false)
errors++;
if(this.getDSTLimits(year)===false){write_db(this.name+": cannot get DST start/end dates");
errors++;
}
if(this.dst_start!==null&&this.dst_end!==null){var dst_diff=this.dst_end-this.dst_start;
if(this.latitude/dst_diff<0){write_db(this.name+": DST start/end reversed?");
errors++;
}
}
if(errors>0)
return false;
else
return true;
};
Place.prototype.checkDSTChangeDate=function(changeStr, tag)
{var
errors=0,
change=changeStr.split(":");
var
change_month=(change[0]-0),
change_day=(change[1]-0),
change_week=(change[2]-0),
change_DoW=(change[3]-0),
change_time=(change[4]-0),
change_type=change[5];
if(change_month===0)
return true;
if(isNaN(change[0])||change_month<0||change_month>12){write_db(this.name+": invalid "+tag+" month ("+change[0]+")");
errors++;
}
if(isNaN(change[1])||change_day<1||
change_day>monthdays[1][change_month-1]){write_db(this.name+": invalid "+tag+" day ("+change[1]+" "
+months[change_month-1]+")");
errors++;
}
if(isNaN(change[2])||change_week<0||change_week>5){write_db(this.name+": invalid "+tag+" week ("+change[2]+")");
errors++;
}
if(isNaN(change[3])||change_DoW<0||change_DoW>6){write_db(this.name+": invalid "+tag+" DoW ("+change[3]+")");
errors++;
}
if(isNaN(change[4])||change_time<0||change_time>24){write_db(this.name+": invalid "+tag+" time ("+change[4]+")");
errors++;
}
if(change_type.search(/[suw]/)<0){write_db(this.name+": invalid "+tag+" time type ("+change_type+")");
errors++;
}
if(errors>0)
return false;
else
return true;
};
function searchKeyFilter(event)
{var
BACKSPACE=8,
RETURN=13,
e=window.event||event,
code=e.keyCode||e.charCode;
switch (e.type){case "keyup":
if(code==BACKSPACE)
search_places("backspace");
else if(code>=32)
search_places("new");
break;
case "keypress":
if(code==RETURN){search_places("next");
return false;
}
break;
default:
break;
}
return true;
}
// incoporates many ideas from http://www.geonames.org/export/ajax-postalcode-autocomplete.html
GeoNames={};
GeoNames.isProvince=function(str)
{var result;
result=str.match(/\b(AB|BC|MB|NB|NL|NS|NT|NU|NV|ON|PE|PQ|QC|SK|YT)\b/i);
if(result!==null)
return result[1];
else
return null;
};
GeoNames.provinces={"AB": "Alberta",
"BC": "British Columbia",
"MB": "Manitoba",
"NB": "New Brunswick",
"NL": "Newfoundland and Labrador",
"NS": "Nova Scotia",
"NT": "Northwest Territories",
"NU": "Nunavut",
"NV": "Nunavut",
"ON": "Ontario",
"PE": "Prince Edward Island",
"QC": "Quebec",
"PQ": "Quebec",
"SK": "Saskatchewan",
"YT": "Yukon"
};
GeoNames.closeSelectList=function()
{document.getElementById('selectListElement').innerHTML='';
document.getElementById('selectListElement').style.visibility='hidden';
};
GeoNames.selectListMouseOut=function(ndx)
{document.getElementById('locId'+ndx).className='selectListTR';
};
GeoNames.selectListMouseOver=function(ndx)
{document.getElementById('locId'+ndx).className='selectListMouseOver';
};
var geoData;
GeoNames.selectListMouseDown=function(ndx)
{GeoNames.closeSelectList();
GeoNames.setLocation(form, GeoNames.geoData[ndx]);
};
GeoNames.enableDisplayPrint=function(timer)
{clearTimeout(timer);
HTTP.Display.disabled=false;
HTTP.Print.disabled=false;
};
GeoNames.getLocation=function(data)
{var i, g;
if((GeoNames.geoData=data.geonames)===undefined){alert("Query failed");
return;
}
clearTimeout(HTTP.queryTimer);
HTTP.lookUpGoButton.disabled=false;
var
TH='<th align="center" class="selectListTD">',
TD='<td class="selectListTD">',
TD_L='<td align="left" class="selectListTD">',
TD_C='<td align="center" class="selectListTD">';
TD_R='<td align="right" class="selectListTD">';
var selectList;
var selectListHTML='';
switch (GeoNames.geoData.length){case 0:
alert("No matches");
break;
case 1:
GeoNames.setLocation(form, GeoNames.geoData[0]);
break;
default:
selectListHTML+="<table class='selectListTR'>";
selectListHTML+=TR+
TH+"Name"+THE+
TH+"Country"+THE+
TH+"State/Province"+THE+
TH+"County/Other"+THE+
TH+"Feat. Type"+THE+
TH+"Lat, &deg;"+THE+
TH+"Long, &deg;"+THE;
if(flags.elevation_in_feet===true)
selectListHTML+=TH+"Elev, ft"+THE;
else
selectListHTML+=TH+"Elev, m"+THE;
selectListHTML+=TRE;
for(i=0; i<GeoNames.geoData.length; i++){g=GeoNames.geoData[i];
selectListHTML+="<tr class='selectListTR' id=locId"+i+
" onmouseover='GeoNames.selectListMouseOver("+i+")'"+
" onmouseout='GeoNames.selectListMouseOut("+i+")'"+
" onmousedown='GeoNames.selectListMouseDown("+i+")'>"+
TD_L+g.name+TDE+
TD+g.countryName+TDE+
TD_L+g.adminName1+TDE+
TD_L+g.adminName2+TDE+
TD_L+g.fcodeName+TDE+
TD_R+g.lat.toDMS(0).replace(/^-/, MINUS)+TDE+
TD_R+g.lng.toDMS(0).replace(/^-/, MINUS)+TDE;
if(g.elevation===undefined)
selectListHTML+=TD_C+SP+TDE;
else if(flags.elevation_in_feet===true)
selectListHTML+=TD_R+g.elevation.MtoFT().toFixed(0)+TDE;
else
selectListHTML+=TD_R+g.elevation+TDE;
selectListHTML+=TRE;
}
selectListHTML+="</table>";
selectList=document.getElementById('selectListElement');
selectList.innerHTML=selectListHTML;
selectList.style.visibility='visible';
break;
}
};
GeoNames.setLocation=function(form, gdata)
{var admin_name;
var latitude, longitude, timezone;
var query, type;
if(gdata.elevation===undefined){query="lat="+gdata.lat+"&lng="+gdata.lng;
if(gdata.lat>=-56&&gdata.lat<=60)
type="srtm3";
else if(gdata.lat>=-65&&gdata.lat<=83)
type="astergdem";
else
type="gtopo30";
GeoNames.query(type, query);
}
else if(flags.elevation_in_feet===true)
form.elevation.value=addCommas(gdata.elevation.MtoFT().toFixed(0));
else
form.elevation.value=addCommas(gdata.elevation);
if(gdata.timezone.gmtOffset===undefined||
gdata.timezone.dstOffset===undefined){
query="lat="+gdata.lat+"&lng="+gdata.lng;
GeoNames.query("timezone", query);
}
else{
if(gdata.lat<0)
timezone=gdata.timezone.dstOffset;
else
timezone=gdata.timezone.gmtOffset;
if((tz_ndx=get_tz_ndx(timezone))<0){tz_ndx=-1;
alert("Invalid time zone: "+timezone);
}
form.timezone.selectedIndex=tz_ndx+1;
if(gdata.timezone.dstOffset!=gdata.timezone.gmtOffset)
form.uses_dst.selectedIndex=1;
else
form.uses_dst.selectedIndex=0;
}
switch (gdata.countryCode){case "US":
admin_name=gdata.adminCode1;
break;
case "CA":
for(var code in GeoNames.provinces){if(GeoNames.provinces[code]==gdata.adminName1){
admin_name=code;
break;
}
}
if(admin_name===undefined)
admin_name=gdata.adminName1;
break;
default:
admin_name=gdata.countryName;
break;
}
form.place_name.value=gdata.name+", "+admin_name;
if((latitude=gdata.lat)<0){form.latitude.value=(-latitude).toDMS(-1);
form.lat_sign.selectedIndex=1;
}
else{form.latitude.value=latitude.toDMS(-1);
form.lat_sign.selectedIndex=0;
}
if((longitude=gdata.lng)<0){form.longitude.value=(-longitude).toDMS(-1);
form.long_sign.selectedIndex=1;
}
else{form.longitude.value=longitude.toDMS(-1);
form.long_sign.selectedIndex=0;
}
SaveState.write(form);
return true;
};
GeoNames.setElevation=function(data, obj)
{if(data[obj]===undefined){
alert("Could not get elevation");
GeoNames.enableDisplayPrint(HTTP.elevationTimer);
return false;
}
else if(obj=="srtm3"&&data[obj]==-32768)
form.elevation.value=0;
else if(obj=="astergdem"&&data[obj]==-9999)
form.elevation.value=0;
else if(obj=="gtopo30"&&data[obj]==-9999)
form.elevation.value=0;
else if(flags.elevation_in_feet===true)
form.elevation.value=addCommas(data[obj].MtoFT().toFixed(0));
else
form.elevation.value=addCommas(data[obj]);
GeoNames.enableDisplayPrint(HTTP.elevationTimer);
SaveState.write(form);
return true;
};
GeoNames.setTimeZone=function(data)
{var timezone, tz_ndx;
if(data.gmtOffset===undefined||
data.dstOffset===undefined){
alert("Could not get time zone");
GeoNames.enableDisplayPrint(HTTP.timezoneTimer);
return false;
}
else{
if(data.lat<0)
timezone=data.dstOffset;
else
timezone=data.gmtOffset;
}
if((tz_ndx=get_tz_ndx(timezone))<0){tz_ndx=-1;
alert("Invalid time zone: "+timezone);
}
form.timezone.selectedIndex=tz_ndx+1;
if(data.dstOffset!=data.gmtOffset)
form.uses_dst.selectedIndex=1;
else
form.uses_dst.selectedIndex=0;
GeoNames.enableDisplayPrint(HTTP.timezoneTimer);
SaveState.write(form);
return true;
};
GeoNames.query=function(type, query)
{var url;
var callback, obj;
var name, name_param, rest, province;
var timer=null;
var buttons=[];
switch (type){case "search":
url = "http://ws.geonames.org/searchJSON?";
url+="style=FULL";
callback=GeoNames.getLocation;
obj=null;
if(query.indexOf("~")>=0){name_param="&name=";
query=query.replace(/\~/g, "");
}
else
name_param="&name_equals=";
if(query.indexOf(",") >= 0) {		name=query.replace(/,.*/, "");
rest=query.replace(/.*, */, "");
if((province=GeoNames.isProvince(rest))!==null)
rest=rest.replace(province, GeoNames.provinces[province.toUpperCase()]);
query=name_param+encodeURIComponent(name)+
"&q="+encodeURIComponent(rest);
}
else
query=name_param+encodeURIComponent(query);
buttons=[ "lookUpGoButton" ];
timer="queryTimer";
break;
case "srtm3":
url = "http://ws.geonames.org/srtm3JSON?";
callback=GeoNames.setElevation;
obj="srtm3";
buttons=[ "Display", "Print" ];
timer="elevationTimer";
break;
case "astergdem":
url = "http://ws.geonames.org/astergdemJSON?";
callback=GeoNames.setElevation;
obj="astergdem";
buttons=[ "Display", "Print" ];
timer="elevationTimer";
break;
case "gtopo30":
url = "http://ws.geonames.org/gtopo30JSON?";
callback=GeoNames.setElevation;
obj="gtopo30";
buttons=[ "Display", "Print" ];
timer="elevationTimer";
break;
case "timezone":
url = "http://ws.geonames.org/timezoneJSON?";
callback=GeoNames.setTimeZone;
obj=null;
buttons=[ "Display", "Print" ];
timer="timezoneTimer";
break;
default:
break;
}
HTTP.getJSON(url, query, callback, obj, timer, buttons);
};
var HTTP={};
HTTP.initialize_buttons=function()
{
HTTP.lookUpGoButton=document.getElementById("cstmLocLookupGo");
HTTP.Display=document.getElementsByName("Display")[0];
HTTP.Print=document.getElementsByName("Print")[0];
};
HTTP.getJSON=function(url, query, callback, obj, timer, buttons)
{var i;
var timeout=16000;
var script=document.createElement("script");
document.body.appendChild(script);
var funcname="func"+HTTP.getJSON.counter++;
HTTP.getJSON[funcname]=function(text)
{
callback(text, obj);
document.body.removeChild(script);
delete HTTP.getJSON[funcname];
};
HTTP[timer]=setTimeout(function()
{
document.body.removeChild(script);
delete HTTP.getJSON[funcname];
alert("Request timed out");
for(i=0; i<buttons.length; i++)
HTTP[buttons[i]].disabled=false;
}, timeout);
for(i=0; i<buttons.length; i++)
HTTP[buttons[i]].disabled=true;
script.src=url+query+"&callback="+
encodeURIComponent("HTTP.getJSON."+funcname);
};
HTTP.getJSON.counter=0;
function get_lat_lon(coords)
{if(check_latitude(form, form.latitude)===true){
coords.lat=form.latitude.value.DMSto();
if(form.lat_sign.selectedIndex==1)
coords.lat=-coords.lat;
}
else
return false;
if(check_longitude(form, form.longitude)===true){coords.lon=form.longitude.value.DMSto();
if(form.long_sign.selectedIndex==1)
coords.lon=-coords.lon;
}
else
return false;
return true;
}
Place.prototype.getEventUTLimits=function(calc_date)
{var
STD=0, DST_START=1, DST=2, DST_END=4,
status;
if(calc_date==this.dst_start_date)
status=DST_START;
else if(calc_date==this.dst_end_date)
status=DST_END;
else if(this.latitude>=0){if(calc_date>this.dst_start_date&&calc_date<this.dst_end_date)
status=DST;
else
status=STD;
}
else{if(calc_date>this.dst_end_date&&calc_date<this.dst_start_date)
status=STD;
else
status=DST;
}
switch (status){case STD:
this.ut_min=0-this.timezone;
this.ut_max=24-this.timezone;
break;
case DST_START:
this.ut_min=0-this.timezone;
this.ut_max=24-this.timezone-1;
break;
case DST:
this.ut_min=0-this.timezone-1;
this.ut_max=24-this.timezone-1;
break;
case DST_END:
this.ut_min=0-this.timezone-1;
this.ut_max=24-this.timezone;
break;
default:
break;
}
this.ut_offset_start=-this.ut_min;
};
function Array1D(rows)
{var a=new Array(rows);
for(var i=0; i<rows; i++)
a[i]=0;
return a;
}
function Array2D(rows)
{var a=new Array(rows);
var cols=rows;
for(var i=0; i<rows; i++){a[i]=new Array(cols);
for(var j=0; j<cols; j++)
a[i][j]=0;
}
return a;
}
MagModel.GRACE=120;
MagModel.EPS=1e-38;
MagModel.EQUAT_RAD=6378.137;
MagModel.POLAR_RAD=6356.7523142;
MagModel.MEAN_RAD=6371.2;
MagModel.MAXORD=12;
function MagModel()
{this.maxord=MagModel.MAXORD;
var n=this.maxord+1;
this.k=Array2D(n);
this.c_main=Array2D(n);
this.c_sec=Array2D(n);
this.c_time=Array2D(n);
this.p=Array2D(n);
this.dp=Array2D(n);
this.snorm=Array2D(n);
this.sin_p=Array1D(n);
this.cos_p=Array1D(n);
this.fn=Array1D(n);
this.fm=Array1D(n);
this.pp=Array1D(n);
this.a2=Math.square(MagModel.EQUAT_RAD);
this.b2=Math.square(MagModel.POLAR_RAD);
this.a4=Math.square(this.a2);
this.b4=Math.square(this.b2);
this.old_lat=null;
this.old_lon=null;
this.old_elev=null;
this.old_dyear=null;
this.Init();
}
MagModel.prototype.Init=function()
{
this.epoch=2010.0;
this.t_valid=5.0;
this.valid_range_str=this.epoch+NDASH+(this.epoch+this.t_valid-1);
this.valid_range_str2=this.epoch+"-"+(this.epoch+this.t_valid-1);
var mag_coeff=[
[  1,   0,-29496.6,      0.0,   11.6,    0.0 ],
[  1,   1,-1586.3,   4944.4,   16.5,-25.9 ],
[  2,   0,-2396.6,      0.0,-12.1,    0.0 ],
[  2,   1,    3026.1,-2707.7,-4.4,-22.5 ],
[  2,   2,    1668.6,-576.1,    1.9,-11.8 ],
[  3,   0,    1340.1,      0.0,    0.4,    0.0 ],
[  3,   1,-2326.2,-160.2,-4.1,    7.3 ],
[  3,   2,    1231.9,    251.9,-2.9,-3.9 ],
[  3,   3,     634.0,-536.6,-7.7,-2.6 ],
[  4,   0,     912.6,      0.0,-1.8,    0.0 ],
[  4,   1,     808.9,    286.4,    2.3,    1.1 ],
[  4,   2,     166.7,-211.2,-8.7,    2.7 ],
[  4,   3,-357.1,    164.3,    4.6,    3.9 ],
[  4,   4,      89.4,-309.1,-2.1,-0.8 ],
[  5,   0,-230.9,      0.0,-1.0,    0.0 ],
[  5,   1,     357.2,     44.6,    0.6,    0.4 ],
[  5,   2,     200.3,    188.9,-1.8,    1.8 ],
[  5,   3,-141.1,-118.2,-1.0,    1.2 ],
[  5,   4,-163.0,      0.0,    0.9,    4.0 ],
[  5,   5,-7.8,    100.9,    1.0,-0.6 ],
[  6,   0,      72.8,      0.0,-0.2,    0.0 ],
[  6,   1,      68.6,-20.8,-0.2,-0.2 ],
[  6,   2,      76.0,     44.1,-0.1,-2.1 ],
[  6,   3,-141.4,     61.5,    2.0,-0.4 ],
[  6,   4,-22.8,-66.3,-1.7,-0.6 ],
[  6,   5,      13.2,      3.1,-0.3,    0.5 ],
[  6,   6,-77.9,     55.0,    1.7,    0.9 ],
[  7,   0,      80.5,      0.0,    0.1,    0.0 ],
[  7,   1,-75.1,-57.9,-0.1,    0.7 ],
[  7,   2,-4.7,-21.1,-0.6,    0.3 ],
[  7,   3,      45.3,      6.5,    1.3,-0.1 ],
[  7,   4,      13.9,     24.9,    0.4,-0.1 ],
[  7,   5,      10.4,      7.0,    0.3,-0.8 ],
[  7,   6,       1.7,-27.7,-0.7,-0.3 ],
[  7,   7,       4.9,-3.3,    0.6,    0.3 ],
[  8,   0,      24.4,      0.0,-0.1,    0.0 ],
[  8,   1,       8.1,     11.0,    0.1,-0.1 ],
[  8,   2,-14.5,-20.0,-0.6,    0.2 ],
[  8,   3,-5.6,     11.9,    0.2,    0.4 ],
[  8,   4,-19.3,-17.4,-0.2,    0.4 ],
[  8,   5,      11.5,     16.7,    0.3,    0.1 ],
[  8,   6,      10.9,      7.0,    0.3,-0.1 ],
[  8,   7,-14.1,-10.8,-0.6,    0.4 ],
[  8,   8,-3.7,      1.7,    0.2,    0.3 ],
[  9,   0,       5.4,      0.0,-0.0,    0.0 ],
[  9,   1,       9.4,-20.5,-0.1,-0.0 ],
[  9,   2,       3.4,     11.5,    0.0,-0.2 ],
[  9,   3,-5.2,     12.8,    0.3,    0.0 ],
[  9,   4,       3.1,-7.2,-0.4,-0.1 ],
[  9,   5,-12.4,-7.4,-0.3,    0.1 ],
[  9,   6,-0.7,      8.0,    0.1,-0.0 ],
[  9,   7,       8.4,      2.1,-0.1,-0.2 ],
[  9,   8,-8.5,-6.1,-0.4,    0.3 ],
[  9,   9,-10.1,      7.0,-0.2,    0.2 ],
[ 10,   0,-2.0,      0.0,    0.0,    0.0 ],
[ 10,   1,-6.3,      2.8,-0.0,    0.1 ],
[ 10,   2,       0.9,-0.1,-0.1,-0.1 ],
[ 10,   3,-1.1,      4.7,    0.2,    0.0 ],
[ 10,   4,-0.2,      4.4,-0.0,-0.1 ],
[ 10,   5,       2.5,-7.2,-0.1,-0.1 ],
[ 10,   6,-0.3,-1.0,-0.2,-0.0 ],
[ 10,   7,       2.2,-3.9,    0.0,-0.1 ],
[ 10,   8,       3.1,-2.0,-0.1,-0.2 ],
[ 10,   9,-1.0,-2.0,-0.2,    0.0 ],
[ 10,  10,-2.8,-8.3,-0.2,-0.1 ],
[ 11,   0,       3.0,      0.0,    0.0,    0.0 ],
[ 11,   1,-1.5,      0.2,    0.0,-0.0 ],
[ 11,   2,-2.1,      1.7,-0.0,    0.1 ],
[ 11,   3,       1.7,-0.6,    0.1,    0.0 ],
[ 11,   4,-0.5,-1.8,-0.0,    0.1 ],
[ 11,   5,       0.5,      0.9,    0.0,    0.0 ],
[ 11,   6,-0.8,-0.4,-0.0,    0.1 ],
[ 11,   7,       0.4,-2.5,-0.0,    0.0 ],
[ 11,   8,       1.8,-1.3,-0.0,-0.1 ],
[ 11,   9,       0.1,-2.1,    0.0,-0.1 ],
[ 11,  10,       0.7,-1.9,-0.1,-0.0 ],
[ 11,  11,       3.8,-1.8,-0.0,-0.1 ],
[ 12,   0,-2.2,      0.0,-0.0,    0.0 ],
[ 12,   1,-0.2,-0.9,    0.0,-0.0 ],
[ 12,   2,       0.3,      0.3,    0.1,    0.0 ],
[ 12,   3,       1.0,      2.1,    0.1,-0.0 ],
[ 12,   4,-0.6,-2.5,-0.1,    0.0 ],
[ 12,   5,       0.9,      0.5,-0.0,-0.0 ],
[ 12,   6,-0.1,      0.6,    0.0,    0.1 ],
[ 12,   7,       0.5,-0.0,    0.0,    0.0 ],
[ 12,   8,-0.4,      0.1,-0.0,    0.0 ],
[ 12,   9,-0.4,      0.3,    0.0,-0.0 ],
[ 12,  10,       0.2,-0.9,    0.0,-0.0 ],
[ 12,  11,-0.8,-0.2,-0.1,    0.0 ],
[ 12,  12,       0.0,      0.9,    0.1,    0.0 ]
];
var j, m, n;
var
g_nm,
h_nm,
dg_nm,
dh_nm;
this.reset=true;
this.cos_p[0]=1;
this.p[0][0]=1;
this.pp[0]=1;
for(var line=0; line<mag_coeff.length; line++){n=mag_coeff[line][0];
m=mag_coeff[line][1];
g_nm=mag_coeff[line][2];
h_nm=mag_coeff[line][3];
dg_nm=mag_coeff[line][4];
dh_nm=mag_coeff[line][5];
if(m<=n){this.c_main[n][m]=g_nm;
this.c_sec[n][m]=dg_nm;
if(m!==0){this.c_main[m-1][n]=h_nm;
this.c_sec[m-1][n]=dh_nm;
}
}
}
this.snorm[0][0]=1;
for(n=1; n<=this.maxord; n++){this.snorm[n][0]=this.snorm[n-1][0]*(2*n-1)/n;
j=2;
for(m=0; m<=n; m++){this.k[n][m]=(Math.square(n-1)-Math.square(m) )
/((2*n-1)*(2*n-3));
if(m>0){this.snorm[n][m]=this.snorm[n][m-1]*Math.sqrt(((n-m+1)*j)/(n+m));
j=1;
this.c_main[m-1][n]=this.snorm[n][m]*this.c_main[m-1][n];
this.c_sec[m-1][n]=this.snorm[n][m]*this.c_sec[m-1][n];
}
this.c_main[n][m]=this.snorm[n][m]*this.c_main[n][m];
this.c_sec[n][m]=this.snorm[n][m]*this.c_sec[n][m];
}
this.fn[n]=n+1;
this.fm[n]=n;
}
for(n=0; n<=this.maxord; n++){for(m=0; m<=n; m++)
this.p[n][m]=this.snorm[n][m];
}
this.k[1][1]=0;
this.start_date=Date.UTC(this.epoch, 0, 0).MsecToDay();
this.end_date=Date.UTC(this.epoch+this.t_valid, 0, 0).MsecToDay();
return true;
};
MagModel.prototype.calcMagDec=function (loc, date)
{
var m, n;
var
dt,
aor,
ar,
br,
bt,
bp,
bpp,
par,
parp,
c2,
c4,
dyear,
rlon,
rlat,
sin_rlon,
sin_rlat,
cos_rlon,
cos_rlat,
sin_rlon2,
sin_rlat2,
cos_rlon2,
cos_rlat2,
temp1,
temp2,
t_long;
dyear=getDecimalYear(date);
var
glat=loc.latitude,
glon=loc.longitude,
elev=0;
dt=dyear-this.epoch;
rlon=glon.DtoR();
rlat=glat.DtoR();
sin_rlon=Math.sin(rlon);
sin_rlat=Math.sin(rlat);
cos_rlon=Math.cos(rlon);
cos_rlat=Math.cos(rlat);
sin_rlon2=Math.square(sin_rlon);
sin_rlat2=Math.square(sin_rlat);
cos_rlon2=Math.square(cos_rlon);
cos_rlat2=Math.square(cos_rlat);
this.sin_p[1]=sin_rlon;
this.cos_p[1]=cos_rlon;
c2=this.a2-this.b2;
c4=this.a4-this.b4;
if(elev!=this.old_elev||glat!=this.old_lat){this.q=Math.sqrt(this.a2-c2*sin_rlat2);
this.q1=elev*this.q;
this.q2=Math.square((this.q1+this.a2)/(this.q1+this.b2));
this.cos_t=sin_rlat/Math.sqrt(this.q2*cos_rlat2+sin_rlat2);
this.sin_t=Math.sqrt(1.0-Math.square(this.cos_t));
this.r2=Math.square(elev)+2.0*this.q1+(this.a4-c4*sin_rlat2)/Math.square(this.q);
this.r=Math.sqrt(this.r2);
this.d=Math.sqrt(this.a2*cos_rlat2+this.b2*sin_rlat2);
this.cos_a=(elev+this.d)/this.r;
this.sin_a=c2*cos_rlat*sin_rlat/(this.r*this.d);
}
if(this.reset===true||glon!=this.old_lon){for(m=2; m<=this.maxord; m++){
this.sin_p[m]=this.sin_p[1]*this.cos_p[m-1]+this.cos_p[1]*this.sin_p[m-1];
this.cos_p[m]=this.cos_p[1]*this.cos_p[m-1]-this.sin_p[1]*this.sin_p[m-1];
}
}
aor=MagModel.MEAN_RAD/this.r;
ar=Math.square(aor);
br=0;
bt=0;
bp=0;
bpp=0;
for(n=1; n<=this.maxord; n++){ar*=aor;
for(m=0; m<=n; m++){
if(this.reset===true||elev!=this.old_elev||glat!=this.old_lat){if(n==m){
this.p[n][m]=this.sin_t*this.p[n-1][m-1];
this.dp[n][m]=this.sin_t*this.dp[n-1][m-1]+this.cos_t*this.p[n-1][m-1];
}
else if(n==1&&m===0){this.p[n][m]=this.cos_t*this.p[n-1][m];
this.dp[n][m]=this.cos_t*this.dp[n-1][m]-this.sin_t*this.p[n-1][m];
}
else if(n>1&&n!=m){if(m>n-2){
this.p[n-2][m]=0.0;
this.dp[n-2][m]=0.0;
}
this.p[n][m]=this.cos_t*this.p[n-1][m]-this.k[n][m]*this.p[n-2][m];
this.dp[n][m]=this.cos_t*this.dp[n-1][m]-this.sin_t*this.p[n-1][m]
-this.k[n][m]*this.dp[n-2][m];
}
}
if(this.reset===true||dyear!=this.old_dyear){this.c_time[n][m]=this.c_main[n][m]+dt*this.c_sec[n][m];
if(m!==0)
this.c_time[m-1][n]=this.c_main[m-1][n]+dt*this.c_sec[m-1][n];
}
par=ar*this.p[n][m];
if(m===0){temp1=this.c_time[n][m]*this.cos_p[m];
temp2=this.c_time[n][m]*this.sin_p[m];
}
else{temp1=this.c_time[n][m]*this.cos_p[m]+this.c_time[m-1][n]*this.sin_p[m];
temp2=this.c_time[n][m]*this.sin_p[m]-this.c_time[m-1][n]*this.cos_p[m];
}
bt-=ar*temp1*this.dp[n][m];
bp+=this.fm[m]*temp2*par;
br+=this.fn[n]*temp1*par;
if(Math.abs(this.sin_t)<MagModel.EPS&&m==1){if(n==1)
this.pp[n]=this.pp[n-1];
else
this.pp[n]=this.cos_t*this.pp[n-1]-this.k[n][m]*this.pp[n-2];
parp=ar*this.pp[n];
bpp+=this.fm[m]*temp2*parp;
}
}
}
if(Math.abs(this.sin_t)<MagModel.EPS)
bp=bpp;
else
bp/=this.sin_t;
var
bx=-bt*this.cos_a-br*this.sin_a,
by=bp,
bz=bt*this.sin_a-br*this.cos_a;
this.old_dyear=dyear;
this.old_elev=elev;
this.old_lat=glat;
this.old_lon=glon;
this.reset=false;
return Math.atan2(by, bx).RtoD();
};
function calculate_times(calc_params, sun, moon, rs_opts, loc)
{var
CalcDate=new Date(),
start_date=calc_params.start_date,
end_date=calc_params.end_date,
calc_step=calc_params.date_step,
mag_dec_date=null;
var
found_one=false,
hours,
jday,
year,
last_year,
ndx=0,
spos=new SunPos(),
mpos=new MoonPos(),
sun_dist,
dst_offset,
opt=rs_opts,
t_offset;
CalcDate.setTime(start_date.DayToMsec());
last_year=CalcDate.getUTCFullYear();
this.times.length=0;
if(opt.decl_sr_check===true)
opt.getDeclLimits("sunrise", loc);
if(opt.decl_ss_check===true)
opt.getDeclLimits("sunset", loc);
if(opt.decl_mr_check===true)
opt.getDeclLimits("moonrise", loc);
if(opt.decl_ms_check===true)
opt.getDeclLimits("moonset", loc);
for(var calc_date=start_date; calc_date<=end_date+1.001/24; calc_date+=calc_step){
calc_date=Math.round(calc_date);
CalcDate.setTime((calc_date-loc.timezone/24+0.5).DayToMsec());
if((year=CalcDate.getUTCFullYear())!=last_year){if(loc.getDSTLimits(year)===false)
return false;
last_year=year;
}
loc.getEventUTLimits(calc_date);
CalcDate.setTime(calc_date.DayToMsec());
jday=CalcDate.getJulian();
calcObliquity(jday, spos, mpos);
calcNutation(jday, spos, mpos);
calcDeltaT(jday, spos, mpos);
if(flags.interpolate_rs_positions===true){spos.initPosArray(jday, loc);
mpos.initPosArray(jday, loc);
}
sun.dawn=spos.getEventTime(jday, loc, "M",-6, "");
sun.rise=spos.getEventTime(jday, loc, "R", opt.alt_sr, opt.alt_sr_type);
if(sun.rise.testEvent()===true){sun.az_rise=spos.getAzRS(loc, "R");
sun.decl_rise=spos.declination;
}
else
sun.az_rise=null;
sun.transit=spos.getEventTime(jday, loc, "T",-99, "");
sun.maxalt=spos.getMaxAlt(loc);
sun_dist=spos.dist;
sun.set=spos.getEventTime(jday, loc, "S", opt.alt_ss, opt.alt_ss_type);
if(sun.set.testEvent()===true){sun.az_set=spos.getAzRS(loc, "S");
sun.decl_set=spos.declination;
}
else
sun.az_set=null;
sun.dusk=spos.getEventTime(jday, loc, "E",-6, "");
sun.day=spos.getDayLen(sun.rise, sun.set);
moon.rise=mpos.getEventTime(jday, loc, "R", opt.alt_mr, opt.alt_mr_type);
if(moon.rise.testEvent()===true){moon.az_rise=mpos.getAzRS(loc, "R");
mpos.calcPhase(sun_dist, loc);
moon.phase_r=mpos.phase;
moon.waxing_r=mpos.waxing;
moon.sd_r=mpos.getTopoSD();
mpos.geoToTopo(loc);
moon.decl_rise=mpos.declination;
}
else
moon.az_rise=moon.phase_r=moon.sd_r=null;
moon.transit=mpos.getEventTime(jday, loc, "T",-99, "");
if(moon.transit.testEvent()===true){moon.maxalt=mpos.getMaxAlt(loc);
mpos.calcPhase(sun_dist, loc);
moon.phase_t=mpos.phase;
moon.waxing_t=mpos.waxing;
moon.sd_t=mpos.getTopoSD();
}
else
moon.phase_t=moon.sd_t=moon.maxalt=null;
moon.set=mpos.getEventTime(jday, loc, "S", opt.alt_ms, opt.alt_ms_type);
if(moon.set.testEvent()===true){moon.az_set=mpos.getAzRS(loc, "S");
mpos.calcPhase(sun_dist, loc);
moon.phase_s=mpos.phase;
moon.waxing_s=mpos.waxing;
moon.sd_s=mpos.getTopoSD();
mpos.geoToTopo(loc);
moon.decl_set=mpos.declination;
}
else
moon.az_set=moon.phase_s=moon.sd_s=null;
if(flags.show_mag_north===true){
if(mag_dec_date===null||calc_date-mag_dec_date>=30){loc.mag_dec=mag_model.calcMagDec(loc, calc_date);
mag_dec_date=calc_date;
}
if(sun.az_rise!==null)
sun.az_rise=(sun.az_rise-loc.mag_dec).setRange(360);
if(sun.az_set!==null)
sun.az_set=(sun.az_set-loc.mag_dec).setRange(360);
if(moon.az_rise!==null)
moon.az_rise=(moon.az_rise-loc.mag_dec).setRange(360);
if(moon.az_set!==null)
moon.az_set=(moon.az_set-loc.mag_dec).setRange(360);
}
if(rs_opts.select(sun, moon, loc)===true||calc_params.calc_type==POSITIONS){found_one=true;
this.times[ndx++]=format_times(CalcDate, calc_params.calc_type,
sun, moon, rs_opts, t_offset, loc);
}
}
rs_opts.matches=ndx;
return found_one;
}
function calculate_positions(calc_params, sun, moon, loc)
{var
altitude,
calc_time,
ndx=0,
path_angle,
places,
spos=new SunPos(),
mpos=new MoonPos(),
CalcDate=new Date(),
jday,
start_date=calc_params.start_date;
var
ncalcs,
start_time=calc_params.start_time,
end_time=calc_params.end_time,
time_step=calc_params.time_step;
end_time+=1e-4;
var line;
CalcDate.setTime(start_date.DayToMsec());
jday=CalcDate.getJulian();
calcObliquity(jday, spos, mpos);
calcNutation(jday, spos, mpos);
calcDeltaT(jday, spos, mpos);
this.positions.length=0;
ncalcs=0;
places=2;
for(calc_time=start_time; calc_time<=end_time; calc_time+=time_step){if(++ncalcs>2880)
break;
calc_time=Math.round(calc_time*60)/60;
spos.calcPos(jday, calc_time);
spos.geoToTopo(loc);
spos.calcAltAz(loc);
spos.addRefraction(loc);
spos.calcDecl(loc);
mpos.calcPos(jday, calc_time);
mpos.calcPhase(spos.dist, loc);
mpos.geoToTopo(loc);
mpos.calcAltAz(loc);
mpos.addRefraction(loc);
mpos.calcDecl(loc);
if(flags.show_mag_north===true){spos.azimuth=(spos.azimuth-loc.mag_dec).setRange(360);
mpos.azimuth=(mpos.azimuth-loc.mag_dec).setRange(360);
}
CalcDate.setTime((start_date+calc_time/24).DayToMsec());
line=TR+LF;
line+=TD;
if(time_step<0.5&&Math.rnd(calc_time+loc.ut_offset, 3) % 1===0)
line+=calc_time.showPosTime(CalcDate, loc).bold();
else
line+=calc_time.showPosTime(CalcDate, loc);
line+=TDE+LF;
line+=TD+spos.azimuth.toFixed(places)+SP2+TDE+LF;
if((altitude=spos.altitude)<0)
line+=TD+MINUS+(-altitude).toFixed(places);
else
line+=TD+altitude.toFixed(places);
line+=SP2+TDE+LF;
if((path_angle=spos.getPathAngle(loc))>90)
line+=TD+SP+(180-path_angle).toFixed(1)+MINUS+SP+TDE+LF;
else
line+=TD+SP+path_angle.toFixed(1)+SP2+TDE+LF;
if(altitude>0){var shadow_len=(1/Math.tan(altitude.DtoR() ));
if(shadow_len>100)
line+=TD_C+">"+" 100"+TDE+LF;
else
line+=TD+shadow_len.toFixed(2)+SP+TDE+LF;
}
else
line+=TD_C+MDASH+TDE+LF;
line+=TD+mpos.azimuth.toFixed(places)+SP2+TDE+LF;
if((altitude=mpos.altitude)<0)
line+=TD+MINUS+(-altitude).toFixed(places);
else
line+=TD+altitude.toFixed(places);
line+=SP2+TDE+LF;
if((path_angle=mpos.getPathAngle(loc))>90)
line+=TD+SP+(180-path_angle).toFixed(1)+MINUS+SP+TDE+LF;
else
line+=TD+SP+path_angle.toFixed(1)+SP2+TDE+LF;
line+=TD+mpos.phase.toFixed(3)+SP+TDE+LF;
line+=TD+SP+mpos.sd.toFixed(3)+SP+TDE+LF;
line+=TRE+LF;
this.positions[ndx++]=line;
}
return true;
}
Place.prototype.calcObserverCoord=function()
{var
earth_rad=EARTH_RADIUS*1e3,
elevation=this.elevation,
latitude=this.latitude.DtoR(),
ratio=0.99664719,
u;
u=Math.atan(ratio*Math.tan(latitude));
this.rhoSinPhi=ratio*Math.sin(u)+elevation/earth_rad*Math.sin(latitude);
this.rhoCosPhi=Math.cos(u)+elevation/earth_rad*Math.cos(latitude);
this.rho=Math.sqrt(Math.square(this.rhoSinPhi)+Math.square(this.rhoCosPhi));
};
Place.prototype.calcDensities=function()
{var
elevation=this.elevation,
height=this.height,
lapse_rate=6.5e-3,
ndx=4.256,
std_temp=273.15+10;
this.density=calcDensity(elevation);
this.density_gnd=calcDensity(elevation-height);
};
calcDensity=function(elevation)
{var
lapse_rate=6.5e-3,
ndx=4.256,
temp0=273.15+10;
return Math.pow(1-lapse_rate/temp0*elevation, ndx);
};
function calc_k(elevation)
{var
lapse_rate=6.5e-3,
ndx=3.256,
temp0=273.15+10;
return K_REFR*Math.pow(1.0-lapse_rate/temp0*elevation, ndx);
}
Place.prototype.calcRSAlt=function()
{var
refr_0h_gnd,
horizon_true;
refr_0h_gnd=this.refr_0h_elev=refraction_app(0, this);
this.refr_0h=this.refr_0h_elev/this.density;
if(this.height>0)
refr_0h_gnd*=this.density_gnd/this.density;
this.rs_alt=-refr_0h_gnd;
this.dip=0;
if(this.height>0){var
density,
k,
r_E;
density=this.density;
k=calc_k(this.elevation-2*this.height/3);
r_E=EARTH_RADIUS*1e3*this.rho;
this.dip=Math.sqrt(2*(1-k)*this.height/r_E).RtoD();
horizon_true=this.dip/(1-k);
this.rs_alt-=horizon_true;
}
};
function calcObliquity(jday, sun, moon)
{var
T, T2, T3,
obliquity;
T=(jday-J2000)/36525;
T2=T*T;
T3=T2*T;
obliquity=-46.8150*T
-0.00059*T2
+0.001813*T3;
obliquity/=3600.0;
obliquity+=23.43929111;
obliquity=obliquity.DtoR();
sun.obliquity=moon.obliquity=obliquity;
}
function calcNutation(jday, sun, moon)
{var
T,
T2,
L_s,
G_s,
L_m,
N_m,
nut_lon,
nut_obl,
eq_equinoxes;
T=(jday-J2000)/36525;
T2=T*T;
L_s=0.77907196+100.00213759*T+0.00000084*T2;
G_s=0.99312619+99.99735956*T-0.00000044*T2;
L_m=0.60643382+1336.85522267*T-0.00000313*T2;
N_m=0.34734264-5.37260713*T+0.00000579*T2;
L_s=L_s.setRange(1)*Math.PI2;
G_s=G_s.setRange(1)*Math.PI2;
L_m=L_m.setRange(1)*Math.PI2;
N_m=N_m.setRange(1)*Math.PI2;
nut_lon=-17.200*Math.sin(N_m)
-1.319*Math.sin(2*L_s)
-0.227*Math.sin(2*L_m)
+0.206*Math.sin(2*N_m)
+0.143*Math.sin(G_s);
nut_obl=9.203*Math.cos(N_m)
+0.574*Math.cos(2*L_s)
+0.098*Math.cos(2*L_m)
-0.090*Math.cos(2*N_m);
nut_lon=(nut_lon/3600).DtoR();
nut_obl=(nut_obl/3600).DtoR();
eq_equinoxes=nut_lon*Math.cos(sun.obliquity+nut_obl);
sun.nut_lon=moon.nut_lon=nut_lon;
sun.nut_obl=moon.nut_obl=nut_obl;
sun.eq_equinoxes=moon.eq_equinoxes=eq_equinoxes;
}
function calcDeltaT(jday, sun, moon)
{
var
deltaT,
T,
t,
u,
year;
T=(jday-J2000)/36525;
year=2000+100*T;
if(year>=2005){if(year<2050){
t=year-2000;
deltaT=62.92+0.32217*t+0.005589*Math.square(t);
}
else if(year<2150){t=(year-1820)/100;
deltaT=-20+32*Math.square(t)-0.5628*(2150-year);
}
else{u=(year-1820)/100;
deltaT=-20+32*Math.square(u);
}
}
else if(year>=1986){t=year-2000;
deltaT=63.86+0.3345*t-0.060374*Math.square(t)
+0.0017275*Math.pow(t, 3)+0.000651814*Math.pow(t, 4)
+0.00002373599*Math.pow(t, 5);
}
else if(year>=1961){t=year-1975;
deltaT=45.45+1.067*t-Math.square(t)/260-Math.pow(t, 3)/718;
}
else if(year>=1941){t=year-1950;
deltaT=29.07+0.407*t-Math.square(t)/233+Math.pow(t, 3)/2547;
}
else if(year>=1920){t=year-1920;
deltaT=21.20+0.84493*t-0.076100*Math.square(t)
+0.0020936*Math.pow(t, 3);
}
else if(year>=1900){t=year-1900;
deltaT=-2.79+1.494119*t-0.0598939*Math.square(t)
+0.0061966*Math.pow(t, 3)-0.000197*Math.pow(t, 4);
}
else if(year>=1860){t=year-1860;
deltaT=7.62+0.5737*t-0.251754*Math.square(t)
+0.01680668*Math.pow(t, 3)-0.0004473624*Math.pow(t, 4)
+Math.pow(t, 5)/233174;
}
else if(year>=1800){t=year-1800;
deltaT=13.72-0.332447*t+0.0068612*Math.square(t)
+0.0041116*Math.pow(t, 3)-0.00037436*Math.pow(t, 4) 
+0.0000121272*Math.pow(t, 5)-0.0000001699*Math.pow(t, 6)
+0.000000000875*Math.pow(t, 7);
}
else if(year>=1700){t=year-1700;
deltaT=8.83+0.1603*t-0.0059285*Math.square(t)
+0.00013336*Math.pow(t, 3)-Math.pow(t, 4)/1174000;
}
else if(year>=1600){t=year-1600;
deltaT=120-0.9808*t-0.01532*Math.square(t)+Math.pow(t, 3)/7129;
}
else{u=(year-1000)/100;
deltaT=1574.2-556.01*u+71.23472*Math.square(u)
+0.319781*Math.pow(u, 3)-0.8503463*Math.pow(u, 4)
-0.005050998*Math.pow(u, 5)+0.0083572073*Math.pow(u, 6);
}
sun.deltaT=moon.deltaT=deltaT/86400;
}
function GSTofUT(jday, ut)
{var
T,
T2, T3,
gst0,
gst;
T=(jday-J2000)/36525.0;
T2=T*T;
T3=T2*T;
gst0=6.697374558+2400.05133691*T+0.000025862*T2-1.72e-9*T3;
return (gst0+ut.UTtoST()).setRange(24);
}
function refraction_app(alt, loc)
{var refraction;
if(alt<-4.3425||alt>89.9225)
return 0;
refraction=1/Math.tan((alt+7.31/(alt+4.4)).DtoR());
refraction*=loc.density;
return refraction/60;
}
function refraction_true(alt, loc)
{var refr0, refr;
if(alt<-5.0016||alt>89.891)
refr=0;
else if(Math.abs(loc.elevation)>1e-6&&alt<=5){refr0=-1;
refr=0;
while(Math.abs(refr-refr0)>0.01){refr0=refr;
if(alt<-4.3425||alt>89.9225)
return 0;
refr=1/Math.tan((alt+refr+7.31/(alt+refr+4.4)).DtoR());
refr*=loc.density;
refr/=60;
}
}
else{refr=1.02/Math.tan((alt+10.3/(alt+5.11)).DtoR());
refr*=loc.density;
refr/=60;
}
return refr;
}
function parallax_geo(alt, sin_hp, loc)
{var num, denom;
num=loc.rho*sin_hp*Math.cos(alt.DtoR());
denom=1.0-loc.rho*sin_hp*Math.sin(alt.DtoR());
return Math.atan2(num, denom).RtoD();
}
function parallax_topo(alt, sin_hp, loc)
{return Math.asin(loc.rho*sin_hp*Math.cos(alt.DtoR())).RtoD();
}
function getTopoSD()
{return this.sd0*(1+Math.sin(this.altitude.DtoR())*this.sin_hp);
}
function getGeoAlt(alt, loc)
{var
rs_alt_app,
sin_hp=this.sin_hp;
alt=appAltToTrueAlt(alt, loc);
if(sin_hp>0)
alt+=parallax_topo(alt, sin_hp, loc);
return alt;
}
function getTopoAlt(loc)
{var
alt=this.altitude,
sin_hp=this.sin_hp;
var alt0=alt;
if(sin_hp>0)
alt-=parallax_geo(alt, sin_hp, loc);
return alt;
}
function getAppAlt(loc)
{var
alt=this.altitude,
refraction,
sin_hp=this.sin_hp;
if(sin_hp>0)
alt-=parallax_geo(alt, sin_hp, loc);
refraction=refraction_true(alt, loc);
if(alt+refraction>=0)
alt+=refraction;
return alt;
}
function getRefrAlt(loc)
{var
alt=this.altitude,
refraction;
refraction=refraction_true(alt, loc);
if(alt+refraction>=0)
alt+=refraction;
return alt;
}
addRefraction=function(loc)
{this.altitude=trueAltToAppAlt(this.altitude, loc);
};
function trueAltToAppAlt(altitude, loc)
{if(loc.height>0){
if(altitude>=loc.rs_alt&&altitude<=-loc.refr_0h_elev){var
alt,
density_vh,
elev_vh,
elevation,
k,
r_E,
y_diff;
elevation=loc.elevation;
r_E=(EARTH_RADIUS*1e3*loc.rho);
alt=altitude+loc.refr_0h*loc.density_gnd;
var alt0=-99;
elev_vh=loc.elevation-loc.height;
y_diff=loc.height;
while(Math.abs(alt-alt0)>0.01){alt0=alt;
k=calc_k(elev_vh+y_diff/3);
if(alt<0)
y_diff=(1-k)*r_E/2*Math.square(alt.DtoR());
else
y_diff=0;
elev_vh=elevation-y_diff;
density_vh=calcDensity(elev_vh);
alt=altitude+loc.refr_0h*density_vh;
}
altitude=alt;
if(altitude<0){
k=calc_k(elev_vh+y_diff/3);
altitude*=(1-k);
}
}
else if(altitude>-loc.refr_0h_elev)
altitude+=refraction_true(altitude, loc);
}
else{var refraction=refraction_true(altitude, loc);
if(altitude+refraction>=0)
altitude+=refraction;
}
return altitude;
}
function appAltToTrueAlt(alt_app, loc)
{var alt_true;
if(Math.abs(alt_app)<1e-9)
alt_true=loc.rs_alt;
else if(loc.height>0&&alt_app>=-loc.dip&&alt_app<0){
var
density_vh,
elev_vh,
elevation,
k,
r_E,
y_diff;
elevation=loc.elevation;
elev_vh=loc.elevation-loc.height;
r_E=EARTH_RADIUS*1e3*loc.rho;
y_diff=loc.height;
k=calc_k(elev_vh+y_diff/3);
y_diff=Math.square(alt_app.DtoR())*r_E/(2*(1-k));
alt_true=alt_app/(1-k);
elev_vh=elevation-y_diff;
density_vh=calcDensity(elev_vh);
alt_true-=loc.refr_0h*density_vh;
}
else if(alt_app>=0)
alt_true=alt_app-refraction_app(alt_app, loc);
else
alt_true=alt_app;
return alt_true;
}
function getPathAngle(loc)
{var
alt=this.altitude.DtoR(),
argument,
declination=this.declination;
argument=(loc.sin_lat-Math.sin(declination)*Math.sin(alt))
/(Math.cos(declination)*Math.cos(alt));
if(argument>1.0)
return 0;
else if(argument<-1)
return 180;
else
return Math.acos(argument).RtoD();
}
function calcDeclination(altitude, azimuth, loc)
{var alt, az, arg;
alt=altitude.DtoR();
az=azimuth.DtoR();
arg=Math.sin(alt)*loc.sin_lat+Math.cos(alt)*loc.cos_lat*Math.cos(az);
return Math.asin(arg);
}
function calcDecl(loc)
{this.declination=calcDeclination(this.altitude, this.azimuth, loc);
}
function eclipticToTopo(loc)
{var
num,
denom,
cos_obl,
sin_obl,
rhoCosPhi=loc.rhoCosPhi,
rhoSinPhi=loc.rhoSinPhi,
lambda_g=this.lambda,
beta_g=this.beta,
lambda_t,
beta_t,
cos_beta,
lst,
cos_lst,
sin_lst,
sin_hp=this.sin_hp;
lst=(this.gst+loc.longitude/15).setRange(24);
cos_obl=Math.cos(this.obliquity+this.nut_obl);
sin_obl=Math.sin(this.obliquity+this.nut_obl);
cos_beta=Math.cos(beta_g);
cos_lst=Math.cos(lst.HtoR());
sin_lst=Math.sin(lst.HtoR());
denom=Math.cos(lambda_g)*cos_beta-rhoCosPhi*sin_hp*cos_lst;
num=Math.sin(lambda_g)*cos_beta
-sin_hp*(rhoSinPhi*sin_obl+rhoCosPhi*cos_obl*sin_lst);
lambda_t=Math.atan2(num, denom);
if(lambda_t<0.0)
lambda_t+=Math.PI2;
num=Math.cos(lambda_t)*(Math.sin(beta_g)
-sin_hp*(rhoSinPhi*cos_obl-rhoCosPhi*sin_obl*sin_lst));
beta_t=Math.atan(num/denom);
this.lambda_t=lambda_t;
this.beta_t=beta_t;
}
function eclipticToEquat(obliquity)
{var 
sin_long,
cos_obl,
sin_obl;
sin_long=Math.sin(this.lambda);
sin_obl=Math.sin(obliquity);
cos_obl=Math.cos(obliquity);
this.ra=Math.atan2(sin_long*cos_obl
-Math.tan(this.beta)*sin_obl, Math.cos(this.lambda));
if(this.ra<0.0)
this.ra+=Math.PI2;
this.declination=Math.asin(Math.sin(this.beta)*cos_obl
+Math.cos(this.beta)*sin_obl*sin_long);
}
function geoToTopo(loc)
{var
lha=(this.gha+loc.longitude).DtoR(),
cos_dec=Math.cos(this.declination),
a=cos_dec*Math.sin(lha),
b=cos_dec*Math.cos(lha)-loc.rhoCosPhi*this.sin_hp,
c=Math.sin(this.declination)-loc.rhoSinPhi*this.sin_hp,
q=Math.sqrt(Math.square(a)+Math.square(b)+Math.square(c));
this.lha=Math.atan2(a, b);
this.ra=(this.gst.HtoR()+loc.longitude.DtoR())-this.lha;
this.declination=Math.asin(c/q);
this.sd=this.sd0/q;
}
function calcAltAz(loc)
{var
arg, num, denom,
lha=this.gst.HtoR()+loc.longitude.DtoR()-this.ra,
decl=this.declination,
sin_lat=loc.sin_lat,
cos_lat=loc.cos_lat;
num=Math.sin(lha);
denom=Math.cos(lha)*sin_lat-Math.tan(decl)*cos_lat;
this.azimuth=Math.atan2(num, denom).RtoD()+180;
arg=sin_lat*Math.sin(decl)+cos_lat*Math.cos(decl)*Math.cos(lha);
this.altitude=Math.asin(arg).RtoD();
this.zenith=90-this.altitude;
}
function getAzRS(loc, type)
{var
alt_rs=this.altitude.DtoR(),
azimuth,
cos_az,
declination=this.declination;
cos_az=
(Math.sin(declination)-loc.sin_lat*Math.sin(alt_rs))
/(loc.cos_lat*Math.cos(alt_rs));
if(cos_az>1.0)
azimuth=null;
else if(cos_az<-1.0)
azimuth=null;
else
azimuth=Math.acos(cos_az).RtoD();
if(azimuth===null)
return null;
else
return (type=="R" ? azimuth : 360-azimuth).setRange(360);
}
function getMaxAlt(loc)
{var
altitude;
altitude=90.0-Math.abs(this.declination.RtoD()-loc.latitude);
this.altitude=altitude;
return this.getAppAlt(loc);
}
function getEventTime(jday, loc, type, alt_rs, alt_rs_type)
{var
cos_H,
longitude=loc.longitude,
ntries,
sign,
sin_h,
lha0,
lha,
sd,
ut,
ut0=-1;
var
sin_lat=loc.sin_lat,
cos_lat=loc.cos_lat;
switch (type){case "M":
case "R":
sign=1;
break;
case "T":
sign=0;
break;
case "S":
case "E":
sign=-1;
break;
default:
break;
}
switch (type){case "M":
case "E":
sin_h=Math.sin(alt_rs.DtoR());
break;
case "T":
break;
default:
if(this.body=="Sun"){
this.altitude=this.getGeoAlt(alt_rs, loc);
if(alt_rs_type=="top")
this.altitude-=this.getTopoSD();
sin_h=Math.sin(this.altitude.DtoR());
}
break;
}
if(loc.timezone>0&&longitude<0)
longitude+=360;
else if(loc.timezone<0&&longitude>0)
longitude-=360;
ut=12-loc.longitude/15;
lha=0;
ut0=ut-12;
ntries=0;
while(Math.abs(ut-ut0)>0.005){if(++ntries>10)
break;
ut0=ut;
if(flags.interpolate_rs_positions===true)
this.interpPos(jday, ut, loc);
else
this.calcPos(jday, ut);
lha0=this.gha+longitude;
if(this.body=="Moon"){
this.altitude=this.getGeoAlt(alt_rs, loc);
if(alt_rs_type=="top")
this.altitude-=this.getTopoSD();
sin_h=Math.sin(this.altitude.DtoR());
}
if(type=="T")
cos_H=1;
else{cos_H=(sin_h-sin_lat*Math.sin(this.declination))/
(cos_lat*Math.cos(this.declination));
}
if(cos_H>1)
lha=0;
else if(cos_H<-1)
lha=180;
else
lha=Math.acos(cos_H).RtoD();
ut=ut0-(lha0+sign*lha)/15;
while(ut<loc.ut_min)
ut+=24;
while(ut>loc.ut_max)
ut-=24;
}
if(cos_H>1)
ut=Number.NEGATIVE_INFINITY;
else if(cos_H<-1)
ut=Number.POSITIVE_INFINITY;
else if(ntries>10)
ut=F_SET_NO_EVENT;
return (ut);
}
function Array2D2(rows, cols)
{var a=new Array(rows);
for(var i=0; i<rows; i++)
a[i]=new Array(cols);
return a;
}
function initPosArray(jday, loc)
{var max=7;
this.pos=Array2D2(max, 3);
for(i=0; i<=2; i++){
this.calcPos(jday, i*12-loc.ut_offset_start);
if(this.body=="Moon"){this.pos[i][0]=this.lambda;
this.pos[i][1]=this.beta;
this.pos[i][2]=this.lambda_s;
}
else{this.pos[i][0]=0;
this.pos[i][1]=0;
this.pos[i][2]=0;
}
this.pos[i][3]=this.sin_hp;
this.pos[i][4]=this.ra;
this.pos[i][5]=this.declination;
this.pos[i][6]=this.sd0;
if(i>0){if(this.pos[i][0]<=this.pos[i-1][0])
this.pos[i][0]+=Math.PI2;
if(this.pos[i][2]<=this.pos[i-1][2])
this.pos[i][2]+=Math.PI2;
if(this.pos[i][4]<=this.pos[i-1][4])
this.pos[i][4]+=Math.PI2;
}
}
}
function interpPos(jday, ut, loc)
{var n;
n=(ut+loc.ut_offset_start)/24;
if(this.body=="Moon"){
this.lambda=interpolate(this.pos[0][0], this.pos[1][0], this.pos[2][0], n);
this.beta=interpolate(this.pos[0][1], this.pos[1][1], this.pos[2][1], n);
this.lambda_s=interpolate(this.pos[0][2], this.pos[1][2], this.pos[2][2], n);
this.sin_hp=interpolate(this.pos[0][3], this.pos[1][3], this.pos[2][3], n);
this.sd0=interpolate(this.pos[0][6], this.pos[1][6], this.pos[2][6], n);
}
else{
this.sin_hp=this.pos[1][3];
this.sd0=this.pos[1][6];
}
this.ra=interpolate(this.pos[0][4], this.pos[1][4], this.pos[2][4], n);
this.declination=interpolate(this.pos[0][5], this.pos[1][5], this.pos[2][5], n);
this.gst=GSTofUT(jday, ut)+this.eq_equinoxes.RtoH();
this.gha=this.gst-this.ra.RtoH();
this.gha=this.gha.setRange(24)*15;
}
function interpolate(y1, y2, y3, p)
{var a, c;
a=y2-y1;
c=y3-y2-a;
return y1+p*(2*a+c*(2*p-1));
}
function SunPos()
{this.body="Sun";
this.HP0=(8.794/3600).DtoR();
this.SIN_HP0=Math.sin(this.HP0);
this.SD0=959.63/3600;
}
SunPos.prototype.eclipticToEquat=eclipticToEquat;
SunPos.prototype.geoToTopo=geoToTopo;
SunPos.prototype.getTopoSD=getTopoSD;
SunPos.prototype.calcAltAz=calcAltAz;
SunPos.prototype.getGeoAlt=getGeoAlt;
SunPos.prototype.getAppAlt=getAppAlt;
SunPos.prototype.addRefraction=addRefraction;
SunPos.prototype.getRefrAlt=getRefrAlt;
SunPos.prototype.calcDecl=calcDecl;
SunPos.prototype.getAzRS=getAzRS;
SunPos.prototype.getMaxAlt=getMaxAlt;
SunPos.prototype.getPathAngle=getPathAngle;
SunPos.prototype.getEventTime=getEventTime;
SunPos.prototype.initPosArray=initPosArray;
SunPos.prototype.interpPos=interpPos;
SunPos.prototype.calcPos=function(jday, ut)
{var
T,
T1900,
L_s,
G_s,
G_2,
G_4,
G_5,
L_m,
N_m,
lambda,
dist;
T=(jday+ut/24.0+this.deltaT-J2000)/36525.0;
T2=T*T;
T1900=T+1;
L_m=0.60643382+1336.85522267*T-0.00000313*T2;
N_m=0.34734264-5.37260713*T+0.00000579*T2;
L_s=0.77907196+100.00213759*T+0.00000084*T2;
G_s=0.99312619+99.99735956*T-0.00000044*T2;
G_2=0.140023+162.54946219*T;
G_4=0.053856+53.16627469*T;
G_5=0.056531+8.43029617*T;
L_m=L_m.setRange(1)*Math.PI2;
N_m=N_m.setRange(1)*Math.PI2;
L_s=L_s.setRange(1)*Math.PI2;
G_s=G_s.setRange(1)*Math.PI2;
G_2=G_2.setRange(1)*Math.PI2;
G_4=G_4.setRange(1)*Math.PI2;
G_5=G_5.setRange(1)*Math.PI2;
lambda=6910*Math.sin(G_s)
+72*Math.sin(2*G_s)
-17*T1900*Math.sin(G_s)
-7*Math.cos(G_s-G_5)
+6*Math.sin(L_m-L_s)
+5*Math.sin(4*G_s-8*G_4+3*G_5)
-5*Math.cos(2*G_s-2*G_2)
-4*Math.sin(G_s-G_2)
+4*Math.cos(4*G_s-8*G_4+3*G_5)
+3*Math.sin(2*G_s-2*G_2)
-3*Math.sin(G_5)
-3*Math.sin(2*G_s-2*G_5);
lambda-=20;
dist=1.00014
-0.01675*Math.cos(G_s)
-0.00014*Math.cos(2*G_s);
lambda*=(1).DtoR()/3600.0;
this.lambda=(L_s+lambda+this.nut_lon).setRange(Math.PI2);
this.beta=0;
this.dist=dist;
this.sin_hp=this.SIN_HP0/dist;
this.sd0=this.SD0/dist;
this.eclipticToEquat(this.obliquity+this.nut_obl);
this.gst=GSTofUT(jday, ut)+this.eq_equinoxes.RtoH();
this.gha=this.gst-this.ra.RtoH();
this.gha=this.gha.setRange(24)*15;
};
SunPos.prototype.getDayLen=function(rise, set)
{var
day,
rise_event=rise.testEvent(),
set_event=set.testEvent();
if(rise_event===true&&set_event===true){if(rise<set)
day=set-rise;
else
day=24-(rise-set);
}
else if(rise_event===false&&set_event===false){
if(rise>=F_CIRCUMPOLAR||set>=F_CIRCUMPOLAR){day=24;
}
else
day=0;
}
else if(rise_event===true&&set_event===false)
day=24-rise;
else if(rise_event===false&&set_event===true)
day=set;
return day;
};
function MoonPos()
{this.body="Moon";
this.RADIUS=1738;
}
MoonPos.prototype.eclipticToEquat=eclipticToEquat;
MoonPos.prototype.geoToTopo=geoToTopo;
MoonPos.prototype.getTopoSD=getTopoSD;
MoonPos.prototype.calcAltAz=calcAltAz;
MoonPos.prototype.getGeoAlt=getGeoAlt;
MoonPos.prototype.getTopoAlt=getTopoAlt;
MoonPos.prototype.getAppAlt=getAppAlt;
MoonPos.prototype.addRefraction=addRefraction;
MoonPos.prototype.getRefrAlt=getRefrAlt;
MoonPos.prototype.getAzRS=getAzRS;
MoonPos.prototype.getMaxAlt=getMaxAlt;
MoonPos.prototype.calcAltAz=calcAltAz;
MoonPos.prototype.calcDecl=calcDecl;
MoonPos.prototype.eclipticToTopo=eclipticToTopo;
MoonPos.prototype.getPathAngle=getPathAngle;
MoonPos.prototype.getEventTime=getEventTime;
MoonPos.prototype.initPosArray=initPosArray;
MoonPos.prototype.interpPos=interpPos;
MoonPos.prototype.calcPos=function(jday, ut)
{var
T,
T2,
T1900,
L_m,
G_m,
F_m,
N_m,
D_ms,
G_s,
L_s,
G_2,
d_lambda,
lambda,
lambda_s,
beta,
dist;
T=(jday+ut/24+this.deltaT-J2000)/36525.0;
T2=T*T;
T1900=T+1;
L_m=0.60643382+1336.85522467*T-0.00000313*T2;
G_m=0.37489701+1325.55240982*T+0.00002565*T2;
F_m=0.25909118+1342.22782980*T-0.00000892*T2;
D_ms=0.82736186+1236.85308708*T-0.00000397*T2;
N_m=0.34734264-5.37260513*T+0.00000579*T2;
L_s=0.77907196+100.00213759*T+0.00000084*T2;
G_s=0.99312619+99.99735956*T-0.00000044*T2;
L_2=0.50549945+162.55336953*T+8.628e-07*T2;
L_m=L_m.setRange(1)*Math.PI2;
G_m=G_m.setRange(1)*Math.PI2;
F_m=F_m.setRange(1)*Math.PI2;
D_ms=D_ms.setRange(1)*Math.PI2;
N_m=N_m.setRange(1)*Math.PI2;
L_s=L_s.setRange(1)*Math.PI2;
G_s=G_s.setRange(1)*Math.PI2;
L_2=L_2.setRange(1)*Math.PI2;
d_lambda=6910*Math.sin(G_s)
+72*Math.sin(2*G_s)
-17*T1900*Math.sin(G_s);
d_lambda-=20;
d_lambda*=(1).DtoR()/3600.0;
lambda_s=(L_s+d_lambda+this.nut_lon).setRange(Math.PI2);
d_lambda=22640*Math.sin(G_m)
-4586*Math.sin(G_m-2*D_ms)
+2370*Math.sin(2*D_ms)
+769*Math.sin(2*G_m)
-668*Math.sin(G_s)
-412*Math.sin(2*F_m)
-212*Math.sin(2*G_m-2*D_ms)
-206*Math.sin(G_m-2*D_ms+G_s)
+192*Math.sin(G_m+2*D_ms)
+165*Math.sin(2*D_ms-G_s)
+148*Math.sin(G_m-G_s)
-125*Math.sin(D_ms)
-110*Math.sin(G_m+G_s)
-55*Math.sin(2*F_m-2*D_ms)
-45*Math.sin(G_m+2*F_m)
+40*Math.sin(G_m-2*F_m)
-38*Math.sin(G_m-4*D_ms)
+36*Math.sin(3*G_m)
-31*Math.sin(2*G_m-4*D_ms)
+28*Math.sin(G_m-2*D_ms-G_s)
-24*Math.sin(2*D_ms+G_s)
+19*Math.sin(G_m-D_ms)
+18*Math.sin(D_ms+G_s)
+15*Math.sin(G_m+2*D_ms-G_s)
+14*Math.sin(2*G_m+2*D_ms)
+14*Math.sin(4*D_ms)
-13*Math.sin(3*G_m-2*D_ms)
-11*Math.sin(G_m+16*L_s-18*L_2)
+10*Math.sin(2*G_m-G_s)
+9*Math.sin(G_m-2*F_m-2*D_ms)
+9*Math.cos(G_m+16*L_s-18*L_2)
-9*Math.sin(2*G_m-2*D_ms+G_s)
-8*Math.sin(G_m+D_ms)
+8*Math.sin(2*D_ms-2*G_s)
-8*Math.sin(2*G_m+G_s)
-7*Math.sin(2*G_s)
-7*Math.sin(G_m-2*D_ms+2*G_s)
+7*Math.sin(N_m)
-6*Math.sin(G_m-2*F_m+2*D_ms)
-6*Math.sin(2*F_m+2*D_ms)
-4*Math.sin(G_m-4*D_ms+G_s)
+4*T1900*Math.cos(G_m+16*L_s-18*L_2)
-4*Math.sin(2*G_m+2*F_m)
+4*T1900*Math.sin(G_m+16*L_s-18*L_2)
+3*Math.sin(G_m-3*D_ms)
-3*Math.sin(G_m+2*D_ms+G_s)
-3*Math.sin(2*G_m-4*D_ms+G_s)
+3*Math.sin(G_m-2*G_s)
+3*Math.sin(G_m-2*D_ms-2*G_s)
-2*Math.sin(2*G_m-2*D_ms-G_s)
-2*Math.sin(2*F_m-2*D_ms+G_s)
+2*Math.sin(G_m+4*D_ms)
+2*Math.sin(4*G_m)
+2*Math.sin(4*D_ms-G_s)
+2*Math.sin(2*G_m-D_ms);
beta=18461*Math.sin(F_m)
+1010*Math.sin(G_m+F_m)
+1000*Math.sin(G_m-F_m)
-624*Math.sin(F_m-2*D_ms)
-199*Math.sin(G_m-F_m-2*D_ms)
-167*Math.sin(G_m+F_m-2*D_ms)
+117*Math.sin(F_m+2*D_ms)
+62*Math.sin(2*G_m+F_m)
+33*Math.sin(G_m-F_m+2*D_ms)
+32*Math.sin(2*G_m-F_m)
-30*Math.sin(F_m-2*D_ms+G_s)
-16*Math.sin(2*G_m+F_m-2*D_ms)
+15*Math.sin(G_m+F_m+2*D_ms)
+12*Math.sin(F_m-2*D_ms-G_s)
-9*Math.sin(G_m-F_m-2*D_ms+G_s)
-8*Math.sin(F_m+N_m)
+8*Math.sin(F_m+2*D_ms-G_s)
-7*Math.sin(G_m+F_m-2*D_ms+G_s)
+7*Math.sin(G_m+F_m-G_s)
-7*Math.sin(G_m+F_m-4*D_ms)
-6*Math.sin(F_m+G_s)
-6*Math.sin(3*F_m)
+6*Math.sin(G_m-F_m-G_s)
-5*Math.sin(F_m+D_ms)
-5*Math.sin(G_m+F_m+G_s)
-5*Math.sin(G_m-F_m+G_s)
+5*Math.sin(F_m-G_s)
+5*Math.sin(F_m-D_ms)
+4*Math.sin(3*G_m+F_m)
-4*Math.sin(F_m-4*D_ms)
-3*Math.sin(G_m-F_m-4*D_ms)
+3*Math.sin(G_m-3*F_m)
-2*Math.sin(2*G_m-F_m-4*D_ms)
-2*Math.sin(3*F_m-2*D_ms)
+2*Math.sin(2*G_m-F_m+2*D_ms)
+2*Math.sin(G_m-F_m+2*D_ms-G_s)
+2*Math.sin(2*G_m-F_m-2*D_ms)
+2*Math.sin(3*G_m-F_m);
dist=60.36298
-3.27746*Math.cos(G_m)
-0.57994*Math.cos(G_m-2*D_ms)
-0.46357*Math.cos(2*D_ms)
-0.08904*Math.cos(2*G_m)
+0.03865*Math.cos(2*G_m-2*D_ms)
-0.03237*Math.cos(2*D_ms-G_s)
-0.02688*Math.cos(G_m+2*D_ms)
-0.02358*Math.cos(G_m-2*D_ms+G_s)
-0.02030*Math.cos(G_m-G_s)
+0.01719*Math.cos(D_ms)
+0.01671*Math.cos(G_m+G_s)
+0.01247*Math.cos(G_m-2*F_m)
+0.00704*Math.cos(G_s)
+0.00529*Math.cos(2*D_ms+G_s)
-0.00524*Math.cos(G_m-4*D_ms)
+0.00398*Math.cos(G_m-2*D_ms-G_s)
-0.00366*Math.cos(3*G_m)
-0.00295*Math.cos(2*G_m-4*D_ms)
-0.00263*Math.cos(D_ms+G_s)
+0.00249*Math.cos(3*G_m-2*D_ms)
-0.00221*Math.cos(G_m+2*D_ms-G_s)
+0.00185*Math.cos(2*F_m-2*D_ms)
-0.00161*Math.cos(2*D_ms-2*G_s)
+0.00147*Math.cos(G_m+2*F_m-2*D_ms)
-0.00142*Math.cos(4*D_ms)
+0.00139*Math.cos(2*G_m-2*D_ms+G_s)
-0.00118*Math.cos(G_m-4*D_ms+G_s)
-0.00116*Math.cos(2*G_m+2*D_ms)
-0.00110*Math.cos(2*G_m-G_s);
this.dist=dist;
this.sin_hp=1/dist;
d_lambda*=(1).DtoR()/3600;
lambda=(L_m+d_lambda+this.nut_lon).setRange(Math.PI2);
beta*=(1).DtoR()/3600;
this.sd0=Math.asin(this.RADIUS/EARTH_RADIUS*this.sin_hp).RtoD();
this.lambda=lambda;
this.beta=beta;
this.lambda_s=lambda_s;
this.eclipticToEquat(this.obliquity+this.nut_obl);
this.gst=GSTofUT(jday, ut)+this.eq_equinoxes.RtoH();
this.gha=this.gst-this.ra.RtoH();
this.gha=this.gha.setRange(24)*15;
};
MoonPos.prototype.calcPhase=function(sun_dist, loc)
{var
lambda,
beta,
cos_elong,
elong,
phase_angle,
moon_dist;
sun_dist*=Math.AU;
moon_dist=this.dist*EARTH_RADIUS;
this.eclipticToTopo(loc);
lambda=this.lambda_t;
beta=this.beta_t;
cos_elong=Math.cos(beta)*Math.cos(lambda-this.lambda_s);
elong=Math.acos(cos_elong);
phase_angle=Math.atan2(sun_dist*Math.sin(elong),
moon_dist-sun_dist*cos_elong);
this.phase=(1+Math.cos(phase_angle))/2;
this.phase_angle=Math.abs(phase_angle.RtoD());
if(elong.setRange(Math.PI2)<Math.PI)
this.waxing=true;
else
this.waxing=false;
};
function set_font_size()
{var
FONT_SIZE=flags.font_size;
PRINT_STYLE='<style type="text/css">'+LF
+'<!--'+LF
+PAD4+'body{'+LF
+PAD8+'font-size: '+FONT_SIZE+'pt;'+LF
+PAD8+'margin-left: 0; margin-right: 0;'+LF
+PAD4+'}'+LF
+PAD4+'table{font-size: '+FONT_SIZE+'pt;}'+LF
+'-->'+LF
+'</style>'+LF;
}
function add_help(name, href)
{if(!href)
return name;
return "<a class=help onclick='blur(); help(\""+href+"\");'>"+name+"</a>";
}
function add_place_link(name, ndx)
{var
tag='<a class="placeTag" title="Set location to '+name+'"'
+LF+PAD12+'onclick="blur(); set_place('+ndx+');">'
+name+'</a>';
return tag;
}
function add_date_link(tipStr, dateStr, date)
{var
tag='<a class="dateTag" title="Set Sun and Moon Positions Date to '+tipStr+'"'
+LF+PAD12+'onclick="blur(); set_calc_date('+date+');">'
+dateStr+'</a>';
return tag;
}
function begin_document(title)
{var
d,
handle;
var
wid=0.98*screen.availWidth,
ht=0.86*screen.availHeight,
xpos=5,
ypos=0.005*screen.availHeight,
win_size,
win_attribs,
win_features;
if(flags.use_popups===true){win_size=",height="+ht+",width="+wid+","+win_attribs;
win_attribs="resizable=1,menubar=1,toolbar=0,status=1,scrollbars=1";
win_pos="left="+xpos+","+"top="+ypos;
win_features=win_size+","+win_pos+","+win_attribs;
handle=window.open("",title,win_features);
}
else
handle=window.open("",title);
handle.document.close();
handle.document.open("text/html");
return handle;
}
function add_buttons()
{var form;
if(flags.print!==true){form="<form name='Buttons' action='none'>"+LF;
form+="<center>"+LF;
form+="<input type='button' value='Close' onclick='window.close()'>"+LF;
form+=SP2+"<input type='button' value='Print' onclick='reformat(\""+this.type+"\")'>"+LF;
form+=SP2+"<input type='button' value='Help'  style='font-weight: bold;' onclick='help()'>"+LF;
form+="</center>"+LF;
form+="</form>"+LF;
this.buttons=form;
}
else
this.buttons=null;
}
function build_positions_header(hdr)
{var header;
if(arguments.length>0)
header=hdr;
else
header=BR+LF;
header+=POS_TABLE;
header+=POS_TABLE_COLSPEC;
header+=THD+LF;
header+=TR+LF;
header+=TH21+"Time";
if(flags.show_ut===true)
header+=BR+" (UT)";
header+=THE+LF;
header+=TH14+"Sun"+THE+LF;
header+=TH15+"Moon"+THE+LF;
header+=TRE+LF;
header+=TR+LF;
if(flags.show_mag_north===true)
header+=TH11+add_help("Azimuth*", "posAzimuth")+THE+LF;
else
header+=TH11+add_help("Azimuth", "posAzimuth")+THE+LF;
header+=TH11+add_help("Altitude", "posAltitude")+THE+LF;
header+=TH11+add_help("Path"+BR+"Angle", "posPathAngle")+THE+LF;
header+=TH11+add_help("Shadow"+BR+"Length", "posShadowLength")+THE+LF;
if(flags.show_mag_north===true)
header+=TH11+add_help("Azimuth*", "posAzimuth")+THE+LF;
else
header+=TH11+add_help("Azimuth", "posAzimuth")+THE+LF;
header+=TH11+add_help("Altitude", "posAltitude")+THE+LF;
header+=TH11+add_help("Path"+BR+"Angle", "posPathAngle")+THE+LF;
header+=TH11+add_help("Phase", "posPhase")+THE+LF;
header+=TH11+add_help("SD", "posSD")+THE+LF;
header+=TRE+LF;
header+=THDE+LF;
header+=TBD+LF;
this.positions_header=header;
}
function build_results_doc_head(title)
{var head;
head =  DOCTYPE + LF;
head+="<html>"+LF;
head+="<head>"+LF;
head+=CONTENT+LF;
head+="<title>Sun/Moon "+title+"</title>"+LF;
head+=SCRIPT;
head+=STYLE;
if(flags.print===true&&flags.use_font_size===true)
head+=PRINT_STYLE;
head+="</head>"+LF;
this.doc_head=head;
}
function output_results(type)
{var i,
handle=begin_document(this.name),
d=handle.document;
d.write(this.doc_head);
d.write(this.page_top);
if(this.rs_criteria)
d.write(this.rs_criteria);
d.write(this.times_header);
if(this.times.length>0){for(i=0; i<this.times.length; i++)
d.writeln(this.times[i]);
d.writeln(TBDE);
d.writeln(TABLE_END);
}
if(this.type=="positions"){d.write(this.positions_header);
if(this.positions.length>0){for(i=0; i<this.positions.length; i++)
d.writeln(this.positions[i]);
d.writeln(TBDE);
d.writeln(TABLE_END);
}
}
d.writeln(BR, SP2, this.copyright);
if(this.prog_time)
d.writeln(this.prog_time, BR);
if(this.buttons)
d.writeln(this.buttons);
d.writeln('</body>', LF, '</html>', LF);
d.close();
handle.focus();
if(handle.print&&flags.print===true)
handle.print();
}
function build_page_top(calc_params, rs_opts, loc)
{var header, title, time_zone, elev_units;
if(flags.elevation_in_feet===true)
elev_units="ft";
else
elev_units="m";
header="<body>"+LF;
title="Location: " + loc.name.replace(/'/g, "&rsquo;");
header+=SP+title.big().bold()+BR+LF;
if(loc.latitude<0)
title="Latitude: "+(-loc.latitude).toDMS(2)+" S";
else
title="Latitude: "+loc.latitude.toDMS(2)+" N";
header+=SP+title.bold()+",";
if(loc.longitude<0)
title="Longitude: "+(-loc.longitude).toDMS(2)+" W";
else
title="Longitude: "+loc.longitude.toDMS(2)+" E";
header+=SP+title.bold();
if(flags.elevation_in_feet===true)
loc.elevation=loc.elevation.MtoFT();
if(loc.elevation<0)
title="Elevation: "+MINUS+addCommas(Math.round(-loc.elevation));
else if(loc.elevation>0)
title="Elevation: "+addCommas(Math.round(loc.elevation));
title+=" "+elev_units;
if(loc.elevation!==0)
header+=","+SP+title.bold();
header+=BR+LF;
title="Time Zone: ";
if(Math.floor(loc.timezone)!=loc.timezone){if(loc.timezone<0)
title+="UTC"+MINUS+(-loc.timezone).toDMS();
else
title+="UTC+"+loc.timezone.toDMS();
}
else{if(loc.timezone<0)
title+="UTC"+MINUS+(-loc.timezone);
else
title+="UTC+"+loc.timezone;
}
if((time_zone=loc.getTimezone()))
title+=" ("+time_zone+")";
header+=SP+title.bold()+BR+LF;
if(loc.mag_dec_date_valid!=INVALID||
flags.show_mag_north===true||flags.show_az_adjust===true){title=add_help("Magnetic Declination: ", "magdec");
if(loc.mag_dec_mean<0)
title+=(-loc.mag_dec_mean).toFixed(1)+DEG+" W";
else
title+=loc.mag_dec_mean.toFixed(1)+DEG+" E";
title=title.bold();
if(calc_params.end_date-calc_params.start_date>180)
title+=" on "+loc.mag_date_str;
if(loc.mag_dec_date_valid!=VALID)
title+=SP2+"(Caution: outside magnetic model range of "
+mag_model.valid_range_str+")";
header+=SP+title+BR+LF;
}
title=(flags.show_mag_north===true ? "Magnetic" : "True")+" North";
title="Azimuths relative to "+title.bold();
if(flags.show_az_adjust===true&&Math.abs(loc.mag_dec_mean)>=0.05){var az_adjustment;
if(loc.mag_dec_mean<0){az_adjustment=(-loc.mag_dec_mean).toFixed(1);
if(flags.show_mag_north===true)
title+=" (subtract "+az_adjustment+DEG+" for True North)";
else
title+=" (add "+az_adjustment+DEG+" for Magnetic North)";
}
else{az_adjustment=loc.mag_dec_mean.toFixed(1);
if(flags.show_mag_north===true)
title+=" (add "+az_adjustment+DEG+" for True North)";
else
title+=" (subtract "+az_adjustment+DEG+" for Magnetic North)";
}
}
if(calc_params.calc_type==TIMES&&flags.show_mag_north===true&&
loc.mag_dec_valid===false){title+=SP2+"(Caution: ";
if(calc_params.start_date>mag_model.end_date+MagModel.GRACE||
calc_params.end_date<mag_model.start_date-MagModel.GRACE)
title+="all dates ";
else
title+="some dates ";
title+="outside magnetic model range of "
+mag_model.valid_range_str+")";
}
header+=SP+title+BR+LF;
if(loc.height>0){if(flags.elevation_in_feet===true)
loc.height=loc.height.MtoFT();
title=add_help("Height above Horizon:", "HeightAboveHorizon")
+SP+addCommas(loc.height.toFixed(0))+" "+elev_units
+SP+"(elevation at horizon:"
+SP+addCommas((loc.elevation-loc.height).toFixed(0))+" "+elev_units+")"
+BR+LF;
title+=SP+add_help("Dip of the horizon: ", "dip")+loc.dip.toFixed(2)+"&deg;";
header+=SP+title+BR+LF;
}
this.page_top=header;
}
function add_rs_criteria(calc_params, rs_opts)
{if(rs_opts.selections===false){
this.rs_criteria=null;
if(rs_opts.rs_alts===false)
return;
}
var
header="",
date_step_units=[ "days", "weeks", "months (30 day)", "months (1/12 year)", "years" ];
if(rs_opts.selections===true){var
StartDate=new Date(calc_params.start_date.DayToMsec()),
EndDate=new Date(calc_params.end_date.DayToMsec());
header=SP+'Dates: '+StartDate.toLocDateStr(0)
+' to '+EndDate.toLocDateStr(0)+BR+LF;
if(calc_params.date_step!=1)
header+=SP+'Date Interval: '
+(calc_params.date_step/calc_params.date_step_units_value)
+' '+date_step_units[calc_params.date_step_units_ndx]+BR+LF;
}
if(rs_opts.alt_sr_range===true){header+=SP+"Sunrise Altitude "
+(rs_opts.alt_sr_type=="center" ? "(center): " : "(upper limb): ");
if(rs_opts.alt_sr_min<0)
header+=MINUS+-Math.rnd(rs_opts.alt_sr_min, 2);
else
header+=Math.rnd(rs_opts.alt_sr_min, 2);
header+=DEG+" to ";
if(rs_opts.alt_sr_max<0)
header+=MINUS+-Math.rnd(rs_opts.alt_sr_max, 2);
else
header+=Math.rnd(rs_opts.alt_sr_max, 2);
header+=DEG+BR+LF;
}
else if(rs_opts.alt_sr!==0||rs_opts.alt_sr_type=="center"){header+=SP+"Sunrise Altitude: "
+(rs_opts.alt_sr_type=="center" ? "center at " : "upper limb at ");
if(rs_opts.alt_sr<0)
header+=MINUS+-Math.rnd(rs_opts.alt_sr, 2);
else
header+=Math.rnd(rs_opts.alt_sr, 2);
header+=DEG+BR+LF;
}
if(rs_opts.az_sr_check===true){header+=SP+"Sunrise Azimuth: "+Math.rnd(rs_opts.az_sr_min, 2)+DEG;
if(rs_opts.az_sr_max!=rs_opts.az_sr_min)
header+=" to "+Math.rnd(rs_opts.az_sr_max, 2)+DEG;
header+=BR+LF;
}
if(rs_opts.alt_ss_range===true){header+=SP+"Sunset Altitude "
+(rs_opts.alt_ss_type=="center" ? "(center): " : "(upper limb): ");
if(rs_opts.alt_ss_min<0)
header+=MINUS+-Math.rnd(rs_opts.alt_ss_min, 2);
else
header+=Math.rnd(rs_opts.alt_ss_min, 2);
header+=DEG+" to ";
if(rs_opts.alt_ss_max<0)
header+=MINUS+-Math.rnd(rs_opts.alt_ss_max, 2);
else
header+=Math.rnd(rs_opts.alt_ss_max, 2);
header+=DEG+BR+LF;
}
else if(rs_opts.alt_ss!==0||rs_opts.alt_ss_type=="center"){header+=SP+"Sunset Altitude: "
+(rs_opts.alt_ss_type=="center" ? "center at " : "upper limb at ");
if(rs_opts.alt_ss<0)
header+=MINUS+-Math.rnd(rs_opts.alt_ss, 2);
else
header+=Math.rnd(rs_opts.alt_ss, 2);
header+=DEG+BR+LF;
}
if(rs_opts.az_ss_check===true){header+=SP+"Sunset Azimuth: "+Math.rnd(rs_opts.az_ss_min, 2)+DEG;
if(rs_opts.az_ss_max!=rs_opts.az_ss_min)
header+=" to "+Math.rnd(rs_opts.az_ss_max, 2)+DEG;
header+=BR+LF;
}
if(rs_opts.alt_mr_range===true){header+=SP+"Moonrise Altitude "
+(rs_opts.alt_mr_type=="center" ? "(center): " : "(upper limb): ")
+Math.rnd(rs_opts.alt_mr_min, 2)+DEG
+" to "+Math.rnd(rs_opts.alt_mr_max, 2)+DEG+BR+LF;
}
else if(rs_opts.alt_mr!==0||rs_opts.alt_mr_type=="center"){header+=SP+"Moonrise Altitude:"+SP
+(rs_opts.alt_mr_type=="center" ? "center at " : "upper limb at ")
+Math.rnd(rs_opts.alt_mr, 2)+DEG+BR+LF;
}
if(rs_opts.az_mr_check===true){header+=SP+"Moonrise Azimuth: "+Math.rnd(rs_opts.az_mr_min, 2)+DEG;
if(rs_opts.az_mr_max!=rs_opts.az_mr_min)
header+=" to "+Math.rnd(rs_opts.az_mr_max, 2)+DEG;
header+=BR+LF;
}
if(rs_opts.alt_ms_range===true){header+=SP+"Moonset Altitude "
+(rs_opts.alt_ms_type=="center" ? "(center): " : "(upper limb): ")
+Math.rnd(rs_opts.alt_ms_min, 2)+DEG
+" to "+Math.rnd(rs_opts.alt_ms_max, 2)+DEG+BR+LF;
}
else if(rs_opts.alt_ms!==0||rs_opts.alt_ms_type=="center"){header+=SP+"Moonset Altitude: "
+(rs_opts.alt_ms_type=="center" ? "center at " : "upper limb at ")
+Math.rnd(rs_opts.alt_ms, 2)+DEG+BR+LF;
}
if(rs_opts.az_ms_check===true){header+=SP+"Moonset Azimuth: "+Math.rnd(rs_opts.az_ms_min, 2)+DEG;
if(rs_opts.az_ms_max!=rs_opts.az_ms_min)
header+=" to "+Math.rnd(rs_opts.az_ms_max, 2)+DEG;
header+=BR+LF;
}
if(rs_opts.phase_mr_check===true&&
(rs_opts.phase_mr_min>0||rs_opts.phase_mr_max<1)){header+=SP+"Moonrise Phase: "+Math.rnd(rs_opts.phase_mr_min, 3)
+" to "+Math.rnd(rs_opts.phase_mr_max, 3)+BR+LF;
}
if(rs_opts.phase_ms_check===true&&
(rs_opts.phase_ms_min>0||rs_opts.phase_ms_max<1)){header+=SP+"Moonset Phase: "+Math.rnd(rs_opts.phase_ms_min, 3)
+" to "+Math.rnd(rs_opts.phase_ms_max, 3)+BR+LF;
}
if(rs_opts.tdiff_mr_check===true){header+=SP+"Moonrise ";
if(rs_opts.tdiff_mr_min<0)
header+=-rs_opts.tdiff_mr_min+" min before "+rs_opts.tdiff_mr_type;
else
header+=rs_opts.tdiff_mr_min+" min after "+rs_opts.tdiff_mr_type;
header+=" to ";
if(rs_opts.tdiff_mr_max<0)
header+=-rs_opts.tdiff_mr_max+" min before "+rs_opts.tdiff_mr_type;
else
header+=rs_opts.tdiff_mr_max+" min after "+rs_opts.tdiff_mr_type;
header+=BR+LF;
}
if(rs_opts.tdiff_ms_check===true){header+=SP+"Moonset ";
if(rs_opts.tdiff_ms_min<0)
header+=-rs_opts.tdiff_ms_min+" min before "+rs_opts.tdiff_ms_type;
else
header+=rs_opts.tdiff_ms_min+" min after "+rs_opts.tdiff_ms_type;
header+=" to ";
if(rs_opts.tdiff_ms_max<0)
header+=-rs_opts.tdiff_ms_max+" min before "+rs_opts.tdiff_ms_type;
else
header+=rs_opts.tdiff_ms_max+" min after "+rs_opts.tdiff_ms_type;
header+=BR+LF;
}
if(flags.show_ut===true)
header+=SP+"Times in "+"UT".bold()+BR+LF;
if(rs_opts.selections===true){if(rs_opts.matches==1)
header+=BR+SP+rs_opts.matches+' date matches criteria:';
else if(rs_opts.matches>0)
header+=BR+SP+rs_opts.matches+' dates match criteria:';
header+=BR+LF;
}
this.rs_criteria=header;
}
function build_times_header(rs_opts)
{var header;
if(this.times.length===0){this.times_header=BR+SP2+"****No dates meet criteria****".big().bold()+BR;
return;
}
header=BR+LF;
if(rs_opts.show_tdiff_mr===true||rs_opts.show_tdiff_ms===true){header+=TIMES_TABLE2;
header+=TIMES_TABLE_COLSPEC2;
}
else{header+=TIMES_TABLE1;
header+=TIMES_TABLE_COLSPEC1;
}
header+=THD+LF;
header+=TR+LF;
header+=TH31+"Day"+THE+LF;
header+=TH31+"Date"+THE+LF;
header+=TH19+"Sun"+THE+LF;
if(rs_opts.show_tdiff_mr===true||rs_opts.show_tdiff_ms===true)
header+=TH19+"Moon"+THE+LF;
else
header+=TH18+"Moon"+THE+LF;
header+=TRE+LF;
header+=TR+LF;
header+=TH21+add_help("Dawn", "timeDawn")+THE+LF;
header+=TH21+add_help("Rise", "timeRise");
if(rs_opts.alt_sr_type=="center")
header+=RS_CENTER;
if(rs_opts.alt_sr!==0){header+=BR;
if(rs_opts.alt_sr<0)
header+=MINUS+-Math.rnd(rs_opts.alt_sr, 1)+DEG;
else
header+=Math.rnd(rs_opts.alt_sr, 1)+DEG;
}
header+=THE+LF;
header+=TH21+add_help("Transit", "timeTransit")+THE+LF;
header+=TH21+add_help("Set", "timeSet");
if(rs_opts.alt_ss_type=="center")
header+=RS_CENTER;
if(rs_opts.alt_ss!==0){header+=BR;
if(rs_opts.alt_ss<0)
header+=MINUS+-Math.rnd(rs_opts.alt_ss, 1)+DEG;
else
header+=Math.rnd(rs_opts.alt_ss, 1)+DEG;
}
header+=THE+LF;
header+=TH21+add_help("Dusk", "timeDusk")+THE+LF;
header+=TH21+add_help("Day"+BR+"Length", "dayLength")+THE+LF;
if(flags.show_mag_north===true)
header+=TH12+add_help("Azimuth*", "timeRiseAzimuth")+THE+LF;
else
header+=TH12+add_help("Azimuth", "timeRiseAzimuth")+THE+LF;
header+=TH21+add_help("Max"+BR+"Alt", "timeMaxAlt")+THE+LF;
header+=TH21+add_help("Rise", "timeRise");
if(rs_opts.alt_mr_type=="center")
header+=RS_CENTER;
if(rs_opts.alt_mr!==0){header+=BR;
header+=Math.rnd(rs_opts.alt_mr, 1)+DEG;
}
header+=THE+LF;
header+=TH21+add_help("Transit", "timeTransit")+THE+LF;
header+=TH21+add_help("Set", "timeSet");
if(rs_opts.alt_ms_type=="center")
header+=RS_CENTER;
if(rs_opts.alt_ms!==0){header+=BR;
header+=Math.rnd(rs_opts.alt_ms, 1)+DEG;
}
header+=THE+LF;
if(rs_opts.show_tdiff_mr===true||rs_opts.show_tdiff_ms===true)
header+=TH21+add_help("Time"+BR+"Diff", "timeTimeDiff")+THE+LF;
if(flags.show_mag_north===true)
header+=TH12+add_help("Azimuth*", "timeRiseAzimuth")+THE+LF;
else
header+=TH12+add_help("Azimuth", "timeRiseAzimuth")+THE+LF;
header+=TH21+add_help("Max"+BR+"Alt", "timeMaxAlt")+THE+LF;
switch(rs_opts.show_phase){case "rise":
header+=TH12+add_help("At Rise", "timePhase")+THE+LF;
break;
case "transit":
header+=TH12+add_help("At Transit", "timePhase")+THE+LF;
break;
case "set":
header+=TH12+add_help("At Set", "timePhase")+THE+LF;
break;
default:
break;
}
header+=TRE+LF;
header+=TR+LF;
header+=TH11+add_help("Rise", "timeRiseAzimuth")+THE+LF;
header+=TH11+add_help("Set", "timeSetAzimuth")+THE+LF;
header+=TH11+add_help("Rise", "timeRiseAzimuth")+THE+LF;
header+=TH11+add_help("Set", "timeSetAzimuth")+THE+LF;
header+=TH11+add_help("Phase", "timePhase")+THE+LF;
header+=TH11+add_help("SD", "timeSD")+THE+LF;
header+=TRE+LF;
header+=THDE+LF;
header+=TBD+LF;
this.times_header=header;
}
function format_times(cdate, ctype, s, m, rs_opts, t_offset, loc, d)
{var
cdate_time,
dateStr,
t_diff,
rpad_d,
rpad_t,
NO_EVENT=MDASH,
line="";
if(flags.show_am_pm_time===true&&flags.show_ut===false)
rpad_d=0;
else if(flags.show_ut===true){rpad_d=0;
rpad_t=0;
}
else{rpad_d=1;
rpad_t=1;
}
line+=TR_R+LF;
line+=TD_L+cdate.getLocDayName(loc)+TDE+LF;
if(ctype==TIMES)
line+=TD_L
+add_date_link(cdate.toLocDateStr(0), cdate.toLocDateStr(1),
cdate.getTime().MsecToDay());
else
line+=TD_L+cdate.toLocDateStr(1);
if(flags.show_ut===true)
line+=" (UT)";
else if(cdate.getDayDST(loc)===true)
line+="*";
line+=TDE+LF;
line+=s.dawn.showEventTime(cdate, loc, "T", rpad_d)+LF;
line+=s.rise.showEventTime(cdate, loc, "", 0)+LF;
line+=s.transit.showEventTime(cdate, loc, "", rpad_t)+LF;
line+=s.set.showEventTime(cdate, loc, "", 0)+LF;
line+=s.dusk.showEventTime(cdate, loc, "T", 0)+LF;
if(s.day.testEvent()===true)
line+=TD+(s.day).toDMS()+SP2+TDE+LF;
else
line+=TD_C+NO_EVENT+TDE+LF;
if(s.az_rise===null)
line+=TD_C+NO_EVENT+TDE+LF;
else
line+=TD+Math.round(s.az_rise)+SP+TDE+LF;
if(s.az_set===null)
line+=TD_C+NO_EVENT+TDE+LF;
else
line+=TD+Math.round(s.az_set)+TDE+LF;
if(s.transit.testEvent()===false)
line+=TD_C+NO_EVENT+TDE+LF;
else
line+=s.maxalt.showMaxAlt()+LF;
line+=m.rise.showEventTime(cdate, loc, "", 0)+LF;
line+=m.transit.showEventTime(cdate, loc, "", rpad_t)+LF;
line+=m.set.showEventTime(cdate, loc, "", 0)+LF;
if(rs_opts.show_tdiff_mr===true){if(m.az_rise===null)
line+=TD_C+NO_EVENT+TDE+LF;
else{if(rs_opts.tdiff_mr_type=="sunset")
t_diff=m.rise-s.set;
else
t_diff=m.rise-s.rise;
if(t_diff<0)
line+=TD+MINUS+(-t_diff).toDMS()+TDE+LF;
else
line+=TD+t_diff.toDMS()+TDE+LF;
}
}
else if(rs_opts.show_tdiff_ms===true){if(m.az_set===null)
line+=TD_C+NO_EVENT+TDE+LF;
else{if(rs_opts.tdiff_ms_type=="sunset")
t_diff=m.set-s.set;
else
t_diff=m.set-s.rise;
if(t_diff<0)
line+=TD+MINUS+(-t_diff).toDMS()+TDE+LF;
else
line+=TD+t_diff.toDMS()+TDE+LF;
}
}
if(m.az_rise===null)
line+=TD_C+NO_EVENT+TDE+LF;
else
line+=TD+Math.round(m.az_rise)+SP+TDE+LF;
if(m.az_set===null)
line+=TD_C+NO_EVENT+TDE+LF;
else
line+=TD+Math.round(m.az_set)+TDE+LF;
if(m.transit.testEvent()===false)
line+=TD_C+NO_EVENT+TDE+LF;
else
line+=m.maxalt.showMaxAlt()+LF;
switch(rs_opts.show_phase){case "rise":
if(m.az_rise===null){line+=TD_C+NO_EVENT+TDE+LF;
line+=TD_C+NO_EVENT+TDE+LF;
}
else{
line+=TD_L+m.phase_r.toFixed(3);
if(rs_opts.phase_check===true)
line+=(m.waxing_r===true ? PLUS : MINUS);
line+=TDE+LF;
line+=TD+m.sd_r.toFixed(3)+TDE+LF;
}
break;
case "transit":
if(m.transit.testEvent()===false){line+=TD_C+NO_EVENT+TDE+LF;
line+=TD_C+NO_EVENT+TDE+LF;
}
else{
line+=TD_L+m.phase_t.toFixed(3);
if(rs_opts.phase_check===true)
line+=(m.waxing_t===true ? PLUS : MINUS);
line+=TDE+LF;
line+=TD+m.sd_t.toFixed(3)+TDE+LF;
}
break;
case "set":
if(m.az_set===null){line+=TD_C+NO_EVENT+TDE+LF;
line+=TD_C+NO_EVENT+TDE+LF;
}
else{
line+=TD_L+m.phase_s.toFixed(3);
if(rs_opts.phase_check===true)
line+=(m.waxing_s===true ? PLUS : MINUS);
line+=TDE+LF;
line+=TD+m.sd_s.toFixed(3)+TDE+LF;
}
break;
default:
break;
}
line+=TRE+LF;
return line;
}
function build_places_doc_head()
{
var PLACES_STYLE='<style type="text/css">'+LF
+'<!--'+LF;
if(flags.show_mag_dec===true&&flags.show_dst_rules===true&&flags.show_dst_dates===true)
PLACES_STYLE+=PAD4+'body{margin-left: 1%; margin-right: 0;}'+LF;
PLACES_STYLE+=PAD4+'td.error{background-color: yellow;}'+LF
+'-->'+LF
+'</style>'+LF;
var header;
header = DOCTYPE + LF;
header+="<html>"+LF;
header+="<head>"+LF;
header+=CONTENT+LF;
header+="<title>Sun/Moon Calculator Locations</title>"+LF;
header+=SCRIPT;
header+=STYLE;
header+=PLACES_STYLE;
if(flags.print===true&&flags.use_font_size===true)
header+=PRINT_STYLE;
header+="</head>"+LF;
this.doc_head=header;
}
function build_places_header(year, date)
{var elev_units, header;
if(flags.elevation_in_feet===true)
elev_units="ft";
else
elev_units="m";
header="<body>"+LF;
header+="Sun/Moon Calculator Locations".big().bold()+VSPACE+LF;
if(flags.show_mag_dec===true){var mag_date=new Date();
mag_date.setTime(date.DayToMsec());
header+=SP+"Magnetic declinations on "+mag_date.toLocDateStr(0);
if(date<mag_model.start_date-MagModel.GRACE||
date>mag_model.end_date+MagModel.GRACE)
header+=SP2+"(Caution: outside magnetic model range of "
+mag_model.valid_range_str+")";
header+=VSPACE+LF;
}
this.page_top=header;
header=PLACES_TABLE;
header+=PLACES_TABLE_COLSPEC1;
if(flags.show_dst_rules===true)
header+=PLACES_TABLE_COLSPEC2;
if(flags.show_dst_dates===true)
header+=PLACES_TABLE_COLSPEC2;
header+=THD+LF;
header+=TR+LF;
if(flags.show_dst_rules===true||flags.show_dst_dates===true){header+=TH21+"Name"+THE+LF;
header+=TH21+"Latitude"+THE+LF;
header+=TH21+"Longitude"+THE+LF;
header+=TH21+"Elevation,"+BR+elev_units+THE+LF;
if(flags.show_mag_dec===true)
header+=TH21+"Magnetic"+BR+"Declination"+THE+LF;
}
else{header+=TH11+"Name"+THE+LF;
header+=TH11+"Latitude"+THE+LF;
header+=TH11+"Longitude"+THE+LF;
header+=TH11+"Elevation,"+BR+elev_units+THE+LF;
if(flags.show_mag_dec===true)
header+=TH11+"Magnetic"+BR+"Declination"+THE+LF;
}
if(flags.show_mag_dec===true&&flags.show_dst_rules===true&&flags.show_dst_dates===true)
header+=TH21+"Time"+BR+"Zone"+THE+LF;
else if(flags.show_dst_rules===true||flags.show_dst_dates===true)
header+=TH21+"Time Zone"+THE+LF;
else
header+=TH11+"Time Zone"+THE+LF;
if(flags.show_dst_rules===true)
header+=TH12+"DST Rule for "+year+THE+LF;
if(flags.show_dst_dates===true)
header+=TH12+"DST Dates for "+year+THE+LF;
if(flags.show_dst_rules===true||flags.show_dst_dates===true){header+=TRE+LF;
header+=TR+LF;
}
if(flags.show_dst_rules===true){header+=TH11+"Start"+THE+LF;
header+=TH11+"End"+THE+LF;
}
if(flags.show_dst_dates===true){header+=TH11+"Start"+THE+LF;
header+=TH11+"End"+THE+LF;
}
header+=TRE+LF;
header+=THDE+LF;
this.places_header=header;
}
function build_place_list(year, date)
{var
ERRMSG="***Missing DST rule***",
NO_DST_MSG="DST not observed",
TD_ERRMSG,
TD_L_ERR=PAD8+'<td class="error" align="left">',
TD_MSG,
TD_NAME;
var
errors=0,
line,
ndx,
i=0,
msg_wid=0;
var
loc=new Place();
if(flags.show_dst_rules===true)
msg_wid++;
if(flags.show_dst_dates===true)
msg_wid++;
switch (msg_wid){case 1:
TD_MSG=TD12;
TD_ERRMSG=PAD8+'<td class="error" colspan="2" align="center">';
break;
case 2:
TD_MSG=TD14;
TD_ERRMSG=PAD8+'<td class="error" colspan="4" align="center">';
break;
default:
break;
}
place_list.length=0;
for(ndx=0; places[ndx]; ndx++){loc.Init(places[ndx]);
TD_NAME=TD_L;
name=add_place_link(loc.name.replace(/'/g, "&rsquo;"), ndx);
line=TD_L+SP;
if(loc.latitude<0)
line+=(-loc.latitude).toDMSLeftPadded(2)+SP+'S';
else
line+=(loc.latitude).toDMSLeftPadded(2)+SP+'N';
line+=TDE+LF;
line+=TD_L+SP;
if(loc.longitude<0)
line+=(-loc.longitude).toDMSLeftPadded(3)+SP+'W';
else
line+=(loc.longitude).toDMSLeftPadded(3)+SP+'E';
line+=TDE+LF;
if(flags.elevation_in_feet===true)
loc.elevation=loc.elevation.MtoFT();
if(loc.elevation<0)
line+=TD_R+SP+MINUS+(-loc.elevation).toFixed(0)+SP;
else if(loc.elevation>0)
line+=TD_R+SP+(loc.elevation).toFixed(0)+SP;
else
line+=TD_R+MDASH+SP2;
line+=TDE+LF;
if(flags.show_mag_dec===true){line+=TD_L+SP2;
loc.mag_dec=mag_model.calcMagDec(loc, date);
if(loc.mag_dec<0)
line+=(-loc.mag_dec).toFixedLeftPadded(1, 3)+' W';
else
line+=loc.mag_dec.toFixedLeftPadded(1, 3)+' E';
line+=TDE+LF;
}
line+=TD_L+SP;
if(loc.timezone<0)
line+='UTC'+MINUS+(-loc.timezone);
else
line+='UTC'+PLUS+loc.timezone;
if(! (flags.show_dst_rules===true&&flags.show_dst_dates===true)){var time_zone;
if((time_zone=loc.getTimezone()))
line+=" ("+time_zone+")";
}
line+=TDE+LF;
if(flags.show_dst_rules===true||flags.show_dst_dates===true){if(loc.uses_dst==1){
var
start_month,
start_day,
start_week,
start_DoW,
end_month,
end_day,
end_week,
end_DoW;
if(loc.getDSTLimits(year)===false){name=name.bold();
TD_NAME=TD_L_ERR;
line+=TD_ERRMSG+ERRMSG.bold()+TDE+LF;
}
else if(loc.dst_start===null||loc.dst_end===null)
line+=TD_MSG+NO_DST_MSG+TDE+LF;
else{if(flags.show_dst_rules===true){
line+=TD_L+SP+showDSTRule(loc.DSTStartStr)+TDE+LF;
line+=TD_L+SP+showDSTRule(loc.DSTEndStr)+TDE+LF;
}
if(flags.show_dst_dates===true){line+=TD_L+SP+showDSTDate(loc.DSTStartStr, year)+TDE+LF;
line+=TD_L+SP+showDSTDate(loc.DSTEndStr, year)+TDE+LF;
}
}
}
else
line+=TD_MSG+NO_DST_MSG+TDE+LF;
}
name=TD_NAME+name+TDE+LF;
line=TR+LF+name+line+TRE+LF;
this.places[i++]=line;
}
}
function output_places()
{var
handle=begin_document("Places"),
d=handle.document;
d.writeln(this.doc_head);
d.writeln(this.page_top);
d.writeln(this.places_header);
d.writeln(this.places.join(LF), TABLE_END);
d.writeln(BR, SP2, this.copyright);
if(this.prog_time)
d.writeln(this.prog_time, BR);
if(this.buttons)
d.writeln(this.buttons);
d.writeln('</body>', LF, '</html>', LF);
d.close();
handle.focus();
if(handle.print&&flags.print===true)
handle.print();
}
function reformat_results(type)
{var title;
if(type=="positions")
title="Positions";
else
title="Times";
flags.print=true;
if(flags.use_font_size===true)
set_font_size();
if(type=="positions")
results=positions_results;
else
results=times_results;
if(flags.use_sep_windows===true&&type=="positions")
results.name="Positions";
else
results.name="Results";
results.build_doc_head(title);
results.add_buttons();
results.output();
flags.print=false;
}
function Result(type)
{this.type=type;
this.doc_head=null;
this.page_top=null;
this.times_header=null;
this.times=new Array();
this.positions_header=null;
this.positions=new Array();
}
Result.prototype.calculate_times=calculate_times;
Result.prototype.calculate_positions=calculate_positions;
Result.prototype.build_doc_head=build_results_doc_head;
Result.prototype.build_page_top=build_page_top;
Result.prototype.add_rs_criteria=add_rs_criteria;
Result.prototype.build_times_header=build_times_header;
Result.prototype.build_positions_header=build_positions_header;
Result.prototype.add_buttons=add_buttons;
Result.prototype.output=output_results;
function PlaceList()
{this.type="places";
this.doc_head=null;
this.page_top=null;
this.places_header=null;
this.places=new Array();
}
PlaceList.prototype.build_doc_head=build_places_doc_head;
PlaceList.prototype.build_places_header=build_places_header;
PlaceList.prototype.build_place_list=build_place_list;
PlaceList.prototype.add_buttons=add_buttons;
PlaceList.prototype.output=output_places;
Number.prototype.showEventTime=function(cdate, loc, type, r_pad)
{var
NO_EVENT=MDASH,
ABOVE="****",
BELOW="-----",
	LIGHT = "/////",
DARK="===";
var column=null;
if(type=="T"){if(this<=-F_CIRCUMPOLAR)
column=DARK;
else if(this>=F_CIRCUMPOLAR)
column=LIGHT;
else if(this>F_TEST_NO_EVENT)
column=NO_EVENT;
}
else{if(this<=-F_CIRCUMPOLAR)
column=BELOW;
else if(this>=F_CIRCUMPOLAR)
column=ABOVE;
else if(this>F_TEST_NO_EVENT)
column=NO_EVENT;
}
if(column)
return TD_C+column+TDE;
var
date=new Date(),
time=this,
ut_offset;
date.setTime(cdate.getTime()+time.HtoMsec());
ut_offset=loc.getTimeOffset(date);
if(flags.show_ut===false){time+=ut_offset;
if(time<0||time>24)
column=NO_EVENT;
}
if(column)
return TD_C+column+TDE;
if(time<0)
column=(time+24).formatTime("T")+MINUS;
else if(time>24)
column=(time-24).formatTime("T")+PLUS;
else{column=time.formatTime("T");
if(flags.show_ut===true)
column+=SP2;
}
while(r_pad-->0)
column+=SP;
return TD+column+TDE;
};
Number.prototype.showPosTime=function(date, loc)
{var
time=this,
timeStr, 
ut_offset=loc.getTimeOffset(date);
if(flags.show_ut===false)
time=this+ut_offset;
if(time<0)
timeStr=(time+24).formatTime("P")+MINUS;
else if(time>=24){while(time>=24)
time-=24;
timeStr=(time).formatTime("P")+PLUS;
}
else{timeStr=time.formatTime("P");
if(flags.show_ut===true||flags.next_day===true)
timeStr+=SP2;
}
return timeStr;
};
Number.prototype.showMaxAlt=function()
{var column;
if(this<-9.5)
column=MINUS+-Math.round(this);
else if(this<0)
column=MINUS+(-this).toFixed(1);
else if(this<9.5)
column=this.toFixed(1);
else
column=Math.round(this);
return TD+column+SP+TDE;
};
