<?php include('livedata.php');?>
<style>
/* home weather station earthquake notification 4th August 2016 */
.eqnotification{position:fixed;top:70px;right:25px;max-width:400px;width:100%;border-radius:4px;padding:15px;margin:10px auto;z-index:99999}.eqnotification .eqnotification-close{position:absolute;top:10px;right:10px;cursor:pointer;font-size:18px;border-radius:50px;width:28px;height:28px;line-height:22px;text-align:center;color:#fff}.eqnotification .eqnotification-close :after{content:"X";color:#fff}.eqnotification .eqnotification-title,.eqnotification .eqnotification-message{color:#fff;font-family:'Helvetica',arial,sans-serif}.eqnotification .eqnotification-title{position:relative;margin-top:-10px;font-size:22px;font-weight:600}.eqnotification .eqnotification-message{position:relative;margin-top:-5px;font-weight:normal;font-size:13px;font-weight:600;line-height:15px;width:300px}.eqnotification .eqnotification-distance{position:relative;margin-top:-5px;font-weight:normal;font-size:13px;font-weight:600;line-height:15px;width:300px;color:#fff}.eqnotification .eqnotification-credit{position:absolute;font-weight:normal;font-size:10px;font-weight:600;line-height:20px;color:#fff;padding-left:5px;margin-top:-10px;float:right}.eqnotification a{font-weight:normal;font-size:10px;font-weight:normal;line-height:20px;color:#fff}.eqpopup{background:#f26c4f}.eqpopup .eqnotification-close{border:1px solid #fff;color:#fff}eqnoti{position:absolute;margin-top:15px;margin-left:5px;font-size:14px;font-weight:normal;color:#878a8d;font-family:Helvetica,arial}eqnoti color{font-size:1em;font-weight:600;color:#f26c4f;font-family:Helvetica,arial}eqnoti magn{font-size:0.8em;font-weight:normal;color:#bbb;font-family:Helvetica,arial}magalert{position:absolute;margin-top:5px;margin-left:-15px;font-size:20px;font-weight:600;color:#f26c4f;font-family:Helvetica,arial}eqalert{position:absolute;margin-left:5px;margin-top:17px;font-size:9px;font-weight:600;font-family:Helvetica,arial;width:225px;line-height:10px}eqtime{position:absolute;margin-top:20px;font-size:10px;margin-left:5px;font-weight:normal;font-family:Helvetica,arial}dist{font-size:10px;font-weight:600;color:#f26c4f;font-family:Helvetica,arial}
	</style>
    
    
<?php //current eq
date_default_timezone_set($TZ);
//$json_string=file_get_contents('http://earthquake-report.com/feeds/recent-eq?json');
$json_string=file_get_contents('jsondata/eqnotification.json');
$parsed_json=json_decode($json_string,true);
$magnitude=$parsed_json{0}{'magnitude'};
$title=$parsed_json{0}['title'];
$eqtitle=$parsed_json{0}['location'];
$depth=$parsed_json{0}['depth'];
$time1=$parsed_json{0}['date_time'];
$lati=$parsed_json{0}['latitude'];
$longi=$parsed_json{0}['longitude'];
$eventime=date( "d-m-Y H:i", strtotime("$time1") );
$shorttime=date( "H:i", strtotime("$time1") );
$magnitude1=$parsed_json{1}{'magnitude'};
$eqtitle1=$parsed_json{1}['location'];
$depth1=$parsed_json{1}['depth'];
$time2=$parsed_json{1}['date_time'];
$eventime1=date( "d-m-Y H:i", strtotime("$time2") );
?>
<?php                                                                       
// CALCULATE THE DISTANCE OF LATEST EARTHQUAKE //
// FROM LOCATION OF HOMEWEATHER STATION //
// Brian Underdown July 28th 2016 //
  function distance($lat, $lon, $lati, $longi) {
  $difflon = $lon - $longi;
  $dist = sin(deg2rad($lat)) * sin(deg2rad($lati)) +  cos(deg2rad($lat)) * cos(deg2rad($lati)) * cos(deg2rad($difflon));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.60934;
  $units="km";  
  return round ($miles,1) ; }
  $eqdist= distance($lat, $lon, $lati, $longi) ."km";
  ?>
    
  
<body><div class="updatedtimealert"><span>
<?php echo "${cumulus[0]}";?></span><br /><?php echo "${cumulus[1]}";?></div> 
<div class="info"></div>
      <?php echo " ";
// 15th June 2016 homeweather station notifications alerts and cautions you can set the value to your preferred setting  //
// or what you term as an alert by increasing or decreasing the numbers below >45 etc..// 
 //windgust 
 if($cumulus[6] >45 ) {echo "<div class='homeweathernotify'>
 
  <br> 
  <img src='img/windgust.png' width='35px'></img> Wind Gusts at <hv> ${cumulus[6]} </hv><span>${windunits} <i class='fa fa-exclamation-triangle' aria-hidden='true'></i></span><br>
  ";}  
   
   
  //home weather station regional earthquake notification if less than 600km from location you can change it suit your preference
 else  if($eqdist < 500) {echo "<div class='homeweathernotify'>
   
  <eqnoti>Earthquake <color>${magnitude}</color><magn> magnitude</magn></eqnoti><br>
  <eqalert>$title </eqalert><br><eqtime> <i class='fa fa-clock-o'></i> $eventime <dist>$eqdist</dist> from <i class='fa fa-map-marker1'></i> $stationlocation</eqtime>
  ";} 
  
 //home weather station worldwide earthquake notification of greater than 6
 else  if($magnitude > $minmag) {echo "<div class='homeweathernotify'>
   
 <eqnoti>Earthquake <color>${magnitude}</color><magn> magnitude</magn></eqnoti><br>
  <eqalert>$title </eqalert><br><eqtime> <i class='fa fa-clock-o'></i> $eventime <dist>$eqdist</dist> from <i class='fa fa-map-marker1'></i> $stationlocation</eqtime>
  ";} 
  
   //heatindex >30c or >90f
 else  if($cumulus[41]>30) {echo "<div class='homeweathernotify'>
   
  <br> 
  <img src='img/heatindex.png' width='35px'></img><hv>${cumulus[41]}</hv>&deg; <span> HeatIndex Caution  <i class='fa fa-exclamation-triangle' aria-hidden='true'></i></span><br>
  ";} 
  
  
  //windchill <10c or <40 
 else  if($cumulus[24]<10) {echo "<div class='homeweathernotify'>
   
  <br> 
  <img src='img/windchill.png' width='35px'></img><hvcold>${cumulus[24]}</hvcold>&deg;<span> Windchill Caution <i class='fa fa-exclamation-triangle' aria-hidden='true'></i></span><br>
  ";} 
  
  
   
  //rainrate
 else  if($cumulus[8]>10 ) {echo "<div class='homeweathernotify'>
   
  <br> 
  <img src='img/rain.png' width='35px'></img><hv>${cumulus[8]}</hv> per/hr<span> Rainfall  <i class='fa fa-exclamation-triangle' aria-hidden='true'></i></span><br>
  ";} 
  
  //no cautions
 else  {
    echo "<div class='homeweathernotify'>
	<br>
	<hvempty> No Current Alerts </hvempty> \n";
}
 
  ?>
</div>

<?php // earthquake notifications script for homeweather station 4th Aug 2016 

echo '';
	   if ($eqdist < 500){echo "<div class='eqnotification eqpopup'>
    <span class='eqnotification-close'>X</span>
    <h3 class='eqnotification-title'><img src='img/eqalert.png'/></img>Regional Earthquake $magnitude </h3>
    <p class='eqnotification-message'> $title $shorttime  </p>
	<p class='eqnotification-distance'> $eqdist from $stationlocation  </p>
	<p class='eqnotification-credit'> <a href='http://earthquake-report.com' title='data provided by earthquake-report.com ' target='_blank'>data provided by earthquake-report.com <a href='http://weather34.com' title='weather34.com ' target='_blank'> | script by weather34.com</a></a></p>
	
  </div>";}  
  // earthquake notifications script brian underdown august 2016 
  
  else if ($magnitude > $minmag ){echo "<div class='eqnotification eqpopup'>
    <span class='eqnotification-close'>X</span>
    <h3 class='eqnotification-title'><img src='img/eqalert.png'/></img>Strong Earthquake $magnitude </h3>
    <p class='eqnotification-message'> $title $shorttime  </p>
	<p class='eqnotification-distance'> $eqdist from $stationlocation  </p>
	<p class='eqnotification-credit'> <a href='http://earthquake-report.com' title='data provided by earthquake-report.com ' target='_blank'>data provided by earthquake-report.com </a><a href='http://weather34.com' title='weather34.com ' target='_blank'> | script by weather34.com</a></p>
	
  </div>";}        
	   
	   ?>     
        
  
  <script> // simple earthquake notification script jquery only for homeweather station brian underdown //
  $('.eqnotification-close').delay(7000).fadeOut('slow', eqnotificationClose);
  function eqnotificationClose() {
  $(this)
  .parent('.eqnotification')
  .hide();
};</script>    

