<?
include("./functions.php");
$db db_connect();

$q1 mysql_query("SELECT * FROM weather ORDER BY time_recieved DESC LIMIT 1",$db);
$cur_wx = @mysql_fetch_array($q1);

require(
"./includes/head.html");
?>
<H1><CENTER>Current Weather at <? echo ucwords($cur_wx[station_id]); ?></CENTER></H1>
<HR>
<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=0 ALIGN=CENTER>
<TR BGCOLOR=d0d0d0><TD>
<TABLE BGCOLOR=WHITE BORDER=0 CELLSPACING=1 CELLPADDING=1>
<TR BGCOLOR=d0d0d0>
    <TD COLSPAN=3 ALIGN='center'>
        <B><FONT COLOR="#006633"><? echo ucwords($cur_wx[station_id]); ?></FONT></B>
    </TD>
</TR>

<TR>
    <TD ALIGN="right">Outside Temperature&nbsp;</TD>
<? 
printf
("\t<TD ALIGN=\"right\">%s</TD>\n"pad(temperature(2,$cur_wx[temp_outside]),1,1));
printf("\t<TD ALIGN=\"right\">%s</TD>\n"pad(temperature(1,$cur_wx[temp_outside]),1,1));    
?>
</TR>

<TR>
    <TD ALIGN="right">Inside Temperature&nbsp;</TD>
<? 
printf
("\t<TD ALIGN=\"right\">%s</TD>\n"pad(temperature(2,$cur_wx[temp_inside]),1,1));
printf("\t<TD ALIGN=\"right\">%s</TD>\n"pad(temperature(1,$cur_wx[temp_inside]),1,1));
?>
</TR>

<TR>
    <TD ALIGN="right">&nbsp;Atmospheric Pressure&nbsp;</TD>
<? 
printf
("\t<TD ALIGN=\"right\">&nbsp;</TD>\n");
printf("\t<TD ALIGN=\"right\">%s millibars</TD>\n"pad($cur_wx[pressure],1,1));
?>
</TR>

<TR>
    <TD ALIGN="right">Battery Voltage&nbsp;</TD>
<?
printf
("\t<TD COLSPAN=2 ALIGN='center'>%s</TD>\n"pad($cur_wx[batt_volts] . " volts " batt_percent($cur_wx[batt_volts]) . " Charge",1,1));
?>
</TR>

<TR>
    <TD ALIGN="right">Wind Direction&nbsp;</TD>
<?
printf
("\t<TD COLSPAN=2 ALIGN='center'>%s</TD>\n"pad($cur_wx[wind_dir] . "° " degrees_cardinal($cur_wx[wind_dir]),1,1));
?>
</TR>

<TR>
    <TD ALIGN="right">Wind Gust&nbsp;</TD>
<? 
printf
("\t<TD ALIGN='right'>%s</TD>\n"pad(speed_convert(1,$cur_wx[wind_gust]),1,1));
printf("\t<TD ALIGN='right'>%s</TD>\n"pad(speed_convert(2,$cur_wx[wind_gust]),1,1));
?>
</TR>

<TR>
    <TD ALIGN="right">Wind Speed&nbsp;</TD>
<? 
printf
("\t<TD ALIGN=\"right\">%s</TD>\n"pad(speed_convert(1,$cur_wx[wind_speed]),1,1));
printf("\t<TD ALIGN=\"right\">%s</TD>\n"pad(speed_convert(2,$cur_wx[wind_speed]),1,1));
?>
</TR>

<TR>
    <TD ALIGN="right">Wind Chill&nbsp;</TD>
<?
$wind_speed_mph 
speed_convert(1,$cur_wx[wind_speed]);
$wind_chill_f 91.4 - (0.474677 0.020425 $wind_speed_mph 0.303107 sqrt($wind_speed_mph) ) * (91.4 temperature(2,$cur_wx[temp_outside]));

printf("\t<TD COLSPAN=2 ALIGN=\"right\">%s</TD>\n",pad(round($wind_chill_f),1,1));
?>
</TR>

<TR>
    <TD ALIGN="right">Rain Fall&nbsp;</TD>
<? 
printf
("\t<TD ALIGN=\"right\">%s</TD>\n"pad(rain_in_24(1,$cur_wx[rain],1),1,1));
printf("\t<TD ALIGN=\"right\">%s</TD>\n"pad(rain_in_24(2,$cur_wx[rain],1),1,1));

?>
</TR>

<TR>
    <TD ALIGN="right">Relative Humidity&nbsp;</TD>
<?
printf
("\t<TD COLSPAN=2 ALIGN=\"right\">%s</TD>\n"pad($cur_wx[humidity_1],1,1));
?>
</TR>

<TR>
<TD ALIGN="right">Time of Measurement&nbsp;</TD>
<?
printf
("\t<TD COLSPAN=2 ALIGN=\"right\">%s</TD>\n"pad(datetime_to_string($cur_wx[time_recieved]),1,1));
?>
</TR>
</TABLE>
</TD></TR>
</TABLE>
<? require("news"); ?>
<? 
require("./includes/end.html"); ?>