<?php 
	if(isset($_GET['homesdestroyed'])){
		$homesdestroyed = $_GET['homesdestroyed'];
	}
	if(isset($_GET['roadsdestroyed'])){
		$roadsdestroyed = $_GET['roadsdestroyed'];
	}
	if(isset($_GET['so2'])){
		$so2 = $_GET['so2'];
	}

	if(isset($_GET['lavaarea'])){
		$lavaarea = $_GET['lavaarea'];
	}
	if(isset($_GET['height'])){
		$height = $_GET['height'];
	}
	

?>
<html>
        <head>
				<style>
						.animated {
							overflow: hidden;
							width: 820px;
							white-space: nowrap;
							display: inline-block;
							float: left;
						}
						.animated > * {
							display: inline-block;
							position: relative;
							animation: 13s linear 0s infinite alternate move;
						}
						.small_div{
							width: 605px !important;
						}
						.small_div > * {
							animation: 6s linear 0s infinite alternate move !important;
						}
						@keyframes move {
							0%,
							25% {
								transform: translateX(0%);
								left: 0%;
							}
							75%,
							100% {
								transform: translateX(-100%);
								left: 100%;
							}
						}
						html {
								-webkit-text-stroke: 0.25px;
						}
						* {
								box-sizing: border-box;
						}
						.container {
								position: relative;
								height: 100%;
						}
						.image {
								display: block;
								height: 100%;
								margin-left:-15px;
						}
						.overlay {
								position: absolute; 
								top: 0px; 
								left:0px;
								
								background-colo: #000000;
								background-size: 287px;
								width: 3840px;
								height:56px;

								font-family: 'Open Sans', sans-serif;
								font-weight: ;

								font-size:200%; 
						}    
						.container .overlay {
								opacity: 1;
						}	
						.footertext {
								font-face:Inconsolata;
								font-weight:300;
								font-size:150%;
								line-height:40px;
								color:#000000;
						}
						.date {
								color:#eceaea;
						}
						.location {
								color:#000000;
						}      
                </style>

                <link rel="preconnect" href="https://fonts.gstatic.com">
                <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;1,300;1,400;1,600&display=swap" rel="stylesheet">
    
                <meta http-equiv=“Pragma” content=”no-cache”>
                <meta http-equiv=“Expires” content=”-1″>
                <meta http-equiv=“CACHE-CONTROL” content=”NO-CACHE”>
                <meta http-equiv="refresh" content="3600">

                <script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script> 
                <!-- <script src="scripts/toolbar_Canary_Islands_new.js"></script>/iceland/ -->
    
                <title>Toolbar Madikwe Game Reserve</title>

        </head>
    
        <body style="margin:0px;padding:0px;background-color:#eceaea;">
    
				<div class="container " id="universalbar-container" style="width:3840px;min-height:80px;overflow:hidden;" >
					
						<div class="overlay" style="width:3840px;">
   
                                <div style="float:left;background-color:#931a24;  padding: 20px 40px;" class="footertext date" style="height:82px;">
                                       <span  id="daycount"></span> <b>&middot;</b>  <span   id="date"></span> <span   id="time"></span>
                                </div>
        
                                <div style="float:left;background-color:#eceaea;  padding: 10px 0px 10px 20px;width:100px;" class="footertext location">
                                       <img src="/images/icons/weather/02d17cb-rain_heavy.svg" id="weather" alt="weather" style="height:68px;">
                                </div>
                                <div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 30px 18px 10px;height: 80px;line-height: 38px;width:134px;text-align: left;" id="temperature" class="footertext location" >
                                </div>   

                                <div style="float:left;background-color:#eceaea;  padding: 10px 20px 10px 20px;width:80px;" class="footertext location">
                                       <img src="/images/icons/icon_wind.png" style="height:64px;">
                                </div>
                                <div style="float:left;background-color:#eceaea;  padding: 10px 0px 10px 10px;width:80px" class="footertext location">
                                       <img src='/images/icons/arrow.png' id='winddirection' alt='winddirection' style="height:56px;margin:2px;">
                                </div>                                
                                <div id="windSpeed" style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 18px 18px 0px;height: 80px;line-height: 60px;text-align: left;" class="footertext location" >
                                </div>  
        
                                <div style="float:left;background-color:#eceaea;  padding: 10px 10px 10px 20px;" class="footertext location" >
                                        <img src="/images/icons/icon_humidity.png" style="height:60px">
                                </div>    
                                <div style="float:left;background-color:#eceaea; border-right:1px solid #666666; padding: 8px 20px 18px 0px;height: 80px;line-height: 60px;text-align: left;" class="footertext location" >  
                                    	<span id="humidity"></span>%   
                                </div>  

                                <div style="float:left;background-color:#eceaea;  padding: 10px 10px 10px 20px;" class="footertext location" >
                                        <img src="/images/icons/icon_visibility.png" style="height:60px">
                                </div>    
                                <div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 20px 18px 0px;height: 80px;line-height: 60px;text-align: left;" class="footertext location" >  
                                         <span id="visibility"></span>km   
                                </div>       
                                <div style="float:left;background-color:#eceaea;  padding: 10px 10px 10px 20px;" class="footertext location sunrisediv" >
                                        <img src="/images/icons/icon_sunrise.png" style="height:60px">
                                </div>    
                                <div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 20px 18px 0px;height: 80px;line-height: 60px;text-align: left;" class="footertext location sunrisediv" id="sunrise">                                          
                                </div> 

                                <div style="float:left;background-color:#eceaea;  padding: 10px 10px 10px 20px;" class="footertext location sunsetdiv" >
                                        <img src="/images/icons/icon_sunset.png" style="height:60px">
                                </div>    
                                <div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 20px 18px 0px;height: 80px;line-height: 60px;text-align: left;" class="footertext location sunsetdiv" id="sunset">                                          
                                </div>           
                                <div style="float:left;background-color:#eceaea;  padding: 10px 10px 10px 20px;" class="footertext location" >
                                        <img src="/images/icons/icon_bar_graph.png" style="height:56px">
                                </div>   
                                <div style="float:left;background-color:#eceaea; border-right:0px solid #666666; padding: 8px 20px 18px 4px;height: 80px;line-height: 60px;text-align: left;" class="footertext location" >  
                                         Species Today:  
                                </div>                                 

								<div style="float:left;background-color:#eceaea;  padding: 10px 0px 10px 20px;" class="footertext location" >
										<img src=/images/icons/icon_mammal.png style="height:60px">
								</div>
								<div style="float:left;background-color:#eceaea; border-right:0px solid #666666; padding: 8px 0px 18px 20px;height: 80px;line-height: 60px;text-align: left;" class="footertext location" id="mammalas_count"> 
								</div> 
								<div style="float:left;background-color:#eceaea; border-right:0px solid #666666; padding: 20px 20px 18px 5px;height: 80px;line-height:24px;text-align: center;font-size:90% !important;" class="footertext location" id="mammalas_count_difference"></div>
								<div style="float:left;background-color:#eceaea;  padding: 10px 0px 10px 20px;" class="footertext location" >
										<img src=/images/icons/icon_bird.png style="height:56px">
								</div>
								<div style="float:left;background-color:#eceaea; border-right:0px solid #666666; padding: 8px 0px 18px 20px;height: 80px;line-height: 60px;text-align: left;" class="footertext location" id="bird_count"> 
								</div>   
								<div style="float:left;background-color:#eceaea; border-right:0px solid #666666; padding: 20px 20px 18px 5px;height: 80px;line-height:24px;text-align: center;font-size:90% !important;" class="footertext location" id="bird_count_difference"></div>
								<div style="float:left;background-color:#eceaea;  padding: 10px 0px 10px 20px;" class="footertext location" >
										<img src=/images/icons/icon_reptile.png style="height:56px">
								</div>        
								<div style="float:left;background-color:#eceaea; border-right:0px solid #666666; padding: 8px 0px 18px 20px;height: 80px;line-height: 60px;text-align: left;" class="footertext location" id="reptiles_count"> 
								</div>
								<div style="float:left;background-color:#eceaea; border-right:0px solid #666666; padding: 20px 0px 18px 5px;height: 80px;line-height:24px;text-align: center;font-size:75% !important;" class="footertext location" id="reptiles_count_difference"></div>
                                <div style="float: left;height: 80px;line-height: 60px;text-align: left;border-left:2px solid #666666;margin-left:20px;display: none;" class="footertext location" id="right_now_div">
                                    <div style="float:left;padding: 10px 10px 10px 20px;"  >
                                        <img src="/images/icons/icon_binoculars.png" style="height:60px">
                                    </div>                                
          						    <div style="float:left;border-right:0px solid #666666; padding: 8px 0px 18px 0px;height: 80px;line-height: 60px;text-align: left;" ><!--width:185px;-->
                                        <span id="right_now_title" style="float: left;margin-right: 5px;">Now: </span><span id="right_now_species" ></span>
                                    </div>
                                </div>
                                <div style="float: left;height: 80px;line-height: 60px;text-align: left;border-left:2px solid #666666;margin-left:20px;display: none;" class="footertext location" id="right_now_marquee_div">
                                    <div style="float:left;  padding: 10px 10px 10px 20px;"  >
                                        <img src="/images/icons/icon_binoculars.png" style="height:60px">
                                    </div>                                
          						    <div style="float:left; border-right:0px solid #666666; padding: 8px 0px 18px 0px;height: 80px;line-height: 60px;text-align: left;"  ><!--width:185px;-->
                                        <span id="right_now_marquee_title" style="float: left;margin-right: 5px;">Now: </span>
                                        <span class="animated" id="animated_marquee" >
                                            <span id="right_now_marquee_species"></span>
                                        </span>
                                    </div>
                                </div> 
                                <div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 20px 18px 20px;display:none;" class="footertext location" ><!--width:125px;-->
                                        <span id="surfaceArea"></span> km<sup>2</sup>   
                                </div>  
                                <div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 20px 18px 20px;display:none;" class="footertext location" ><!--width:125px;-->
                                        <span id="surfaceArea"></span> km<sup>2</sup>   
                                </div>         
								<div style="float:left;background-color:#eceaea;  padding: 10px 10px 10px 20px;display:none;" class="footertext location" >
                                    	<img src="/images/icons/icon_aqi.png" style="height:60px">
                                </div>    
                                <div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 20px 18px 0px;height: 80px;line-height: 60px;text-align: left;display:none;" class="footertext location">
										<span id="epaIndex"> </span> (<span id="epaHealthConcern"></span>)                                
                                </div>
								<div style="float:left;background-color:#eceaea; border-right:2px solid #666666; padding: 8px 20px 18px 20px;width:fit-content;min-width:350px;display:none;" class="footertext location" ><!--width:185px;-->
										<span id="lava"></span> m<sup>3</sup>   
								</div>  
                        </div>
                
						<script>
							//window.onload = setInterval(wheather,1000*60*2);//every 2 minute
							// window.onload = setInterval(wheather,1000*60*60*6);//every 6 hours
							window.onload = setInterval(wheather,600000);//every 10 minutes
							window.onload = setInterval(sunsetsunrise,1000 * 60 * 60 * 12);//every 12 hours //--added to get latest sunsetsunrise data every 12 hours 
							var response;
							var temperature;
							var weatherCode;
							var windSpeed;	
							var windDirection=0;
							var sunrise;
							var sunset;
							var currentDateTime;//-- added to get latest sunsetsunrise based on currentdatetime 
							var sunrisetimestamp;//-- added to get latest sunrise 
							var sunsetimestamp;//-- added to get latest sunset 
							var humidity;
							var visibility;
							var epaIndex;
							var epaHealthConcern;
							var epaHealthConcernstr ;
							$(document).ready(function(){
									// document.getElementById("universalbar-container").style.display = "none";
									sunsetsunrise();
									wheather();
									if(temperature != undefined ){
										document.getElementById("temperature").innerHtml = temperature + "<sup>&#176;</sup>";   
									}
									if(windSpeed != undefined ){
										document.getElementById("windSpeed").innerHtml = windSpeed + "km/h";  
									}   

									var imgsrc;
									switch (weatherCode) {
										case 1000: imgsrc = "icons/0b10b61-clear_day.svg"; break;
										case 1001: imgsrc = "icons/285ec93-cloudy.svg"; break;
										case 1100: imgsrc = "icons/9289e75-mostly_clear_night.svg"; break;
										case 1101: imgsrc = "icons/4bf020b-partly_cloudy_day.svg"; break;
										case 1102: imgsrc = "icons/27f7337-mostly_cloudy.svg"; break;
										case 2000: imgsrc = "icons/034add7-fog.svg"; break;
										case 2100: imgsrc = "icons/88d5a3f-fog_light.svg"; break;
										case 4000: imgsrc = "icons/85056eb-drizzle.svg"; break;
										case 4001: imgsrc = "icons/7fa1cb9-rain.svg"; break;
										case 4200: imgsrc = "icons/5707826-rain_light.svg"; break;
										case 4201: imgsrc = "icons/02d17cb-rain_heavy.svg"; break;
										case 5000: imgsrc = "icons/3971192-snow.svg"; break;
										case 5001: imgsrc = "icons/23a7e68-flurries.svg"; break;
										case 5100: imgsrc = "icons/2152ead-snow_light.svg"; break;
										case 5101: imgsrc = "icons/3669298-snow_heavy.svg"; break;
										case 6000: imgsrc = "icons/aad2371-freezing_rain_drizzle.svg"; break;
										case 6001: imgsrc = "icons/c84d163-freezing_rain.svg"; break;
										case 6002: imgsrc = "icons/0b23066-freezing_rain_light.svg"; break;
										case 6201: imgsrc = "icons/83a2b1b-freezing_rain_heavy.svg"; break;
										case 7000: imgsrc = "icons/d76e6fa-ice_pellets.svg"; break;
										case 7101: imgsrc = "icons/0c21c74-ice_pellets_heavy.svg"; break;
										case 7102: imgsrc = "icons/c9aa88a-ice_pellets_light.svg"; break;
										case 8000: imgsrc = "icons/58e635d-tstorm.svg"; break;
									}
									$("#weather").attr("src", imgsrc);
									$("#winddirection").css("transform","rotate("+windDirection+"deg)");
	
							});
							function sunsetsunrise(){
								var dt = convertTZ(new Date(), "Africa/Asmera");// get date n time in Iceland timezone
								console.log("in sunsetsunrise function " + dt.getTime() + " dt:" + dt);

								$.ajax({
									url: "includes/tomorrow_Canary_IslandsSunrise_sunset.php",
									type:"POST",
									contentType: "application/json",
									dataType: "json",
									cache: false,
									success: function(html){
										if(html !== undefined){
											if(html.code === undefined){
												sunsetsunriseresponse=html;
												console.log(sunsetsunriseresponse);
												// sunrise = sunsetsunriseresponse.data.timelines[0].intervals[0].values.sunriseTime.substring(11, 16);
												// sunset = sunsetsunriseresponse.data.timelines[0].intervals[0].values.sunsetTime.substring(11, 16);		

												//-- added to make sunset sunrise +1 hour to match with https://www.tomorrow.io/weather/ES/CN/El_Paso/034004/ 
												sunriseTime=sunsetsunriseresponse.data.timelines[0].intervals[0].values.sunriseTime.substring(11, 16);
												// sunrise = sunriseTime;
												sunrise = sunriseTime.split(":"); 
												sunrise = ("0" + (parseInt(sunrise[0])+2)).slice(-2)+":"+sunrise[1];//-- commented to show actual response to match with https://www.tomorrow.io/weather/ES/CN/El_Paso/034004/

												sunsetTime=sunsetsunriseresponse.data.timelines[0].intervals[0].values.sunsetTime.substring(11, 16);
												// sunset = sunsetTime;
												sunset = sunsetTime.split(":"); 
												sunset = ("0" + (parseInt(sunset[0])+2)).slice(-2)+":"+sunset[1];//-- commented to show actual response to match with https://www.tomorrow.io/weather/ES/CN/El_Paso/034004/
												console.log("sunrise:"+sunrise+" sunset:"+sunset);
												//-- added to get latest sunsetsunrise based on currentdatetime 
												currentDateTime=new Date(sunsetsunriseresponse.data.timelines[0].startTime.replace("T"," ").replace("Z",""));

												//--added to show either sunset or sunrise
												sunrisetimestamp=new Date(sunsetsunriseresponse.data.timelines[0].intervals[0].values.sunriseTime.replace("T"," ").replace("Z",""));
												sunrisetimestamp.setHours(sunrisetimestamp.getHours()+2);//-- to resolve sunrisesunset time 

												sunsetimestamp=new Date(sunsetsunriseresponse.data.timelines[0].intervals[0].values.sunsetTime.replace("T"," ").replace("Z",""));
												sunsetimestamp.setHours(sunsetimestamp.getHours()+2);//-- to resolve sunrisesunset time 

												console.log("sunrisetimestamp: "+new Date(sunrisetimestamp).getTime() +" sunsetimestamp: "+new Date(sunsetimestamp).getTime()+" current: "+new Date().getTime()); 	 
											}
										}
									},
									error: function(data){
										console.log("php fail "+JSON.stringify(data));
									}
								}); 
							}
							function wheather(){
								var dt = convertTZ(new Date(), "Africa/Asmera");// get date n time in Iceland timezone
								console.log("in weather function " + dt.getTime() + " dt:" + dt);

								$.ajax({
									url: "includes/tomorrow_Canary_Islands.php",
									type:"POST",
									contentType: "application/json",
									dataType: "json",
									cache: false,
									success: function(html){
										if(html !== undefined){
											if(html.code === undefined){
												response=html;
												console.log(response);
												temperature=Math.ceil(response.data.timelines[0].intervals[0].values.temperature);
												weatherCode=response.data.timelines[0].intervals[0].values.weatherCode;
												windSpeed = response.data.timelines[0].intervals[0].values.windSpeed;
												
												//temperature = ((9 * temperature)+(32*5))/5;
												windSpeed=Math.round(windSpeed*3.6);
												windDirection = response.data.timelines[0].intervals[0].values.windDirection;

												humidity = parseInt(Math.round(response.data.timelines[0].intervals[0].values.humidity));
												visibility = parseInt(Math.round(response.data.timelines[0].intervals[0].values.visibility));

												//--added to get AQI statistics
												epaIndex = response.data.timelines[0].intervals[0].values.epaIndex;
												epaHealthConcern = response.data.timelines[0].intervals[0].values.epaHealthConcern;
											}
										
										}
										console.log("temperature"+temperature+" weatherCode"+weatherCode+" windSpeed"+windSpeed+" windDirection"+windDirection);
										
									},
									error: function(data){
										console.log("php fail "+JSON.stringify(data));
									}
								});  
								
							}
							var no_sighting=true;
							var length_minus=0;
							var width_minus=0;
							function get_wildlife_data(){
								$.ajax({
									url: "wildlife_database/get_wildlife_data.php",
									type:"POST",
									contentType: "application/json",
									dataType: "json",
									cache: false,
									success: function(html){			
										length_minus = 0;	
										width_minus = 0;										
										if(html.bird_count!=undefined){											
											document.getElementById("bird_count").innerHTML = html.bird_count
											var bird_count_difference = html.bird_count - html.yesterdays_bird_count  ;
											if(bird_count_difference>0){//if species increased											 
												document.getElementById("bird_count_difference").innerHTML = '<img src="/images/arrow_up.png" style="width: 26px;padding:2px;"><br/>'+bird_count_difference;
												document.getElementById("bird_count_difference").style.display="inline-block";
												length_minus +=2;
												width_minus+=25;
											}else if(bird_count_difference<0){//if species decreased
												document.getElementById("bird_count_difference").innerHTML = '<img src="/images/arrow_down.png" style="width: 26px;padding:2px;"><br/>'+Math.abs(bird_count_difference);
												document.getElementById("bird_count_difference").style.display="inline-block";
												length_minus +=2;
												width_minus+=25;
											}else{//if secies count is same
												document.getElementById("bird_count_difference").innerHTML = 0;
												document.getElementById("bird_count_difference").style.display="none";
											}
										}
										if(html.reptiles_count!=undefined){
											document.getElementById("reptiles_count").innerHTML = html.reptiles_count;
											var reptiles_count_difference = html.reptiles_count - html.yesterdays_reptiles_count  ;
											if(reptiles_count_difference>0){//if species increased										 
												document.getElementById("reptiles_count_difference").innerHTML = '<img src="/images/arrow_up.png" style="width: 26px;padding:2px;"><br/>'+reptiles_count_difference;
												document.getElementById("reptiles_count_difference").style.display="inline-block";
												length_minus +=2;
												width_minus+=25;
											}else if(reptiles_count_difference<0){//if species decreased
												document.getElementById("reptiles_count_difference").innerHTML = '<img src="/images/arrow_down.png" style="width: 26px;padding:2px;"><br/>'+Math.abs(reptiles_count_difference);
												document.getElementById("reptiles_count_difference").style.display="inline-block";
												length_minus +=2;
												width_minus+=25;
											}else{//if secies count is same
												document.getElementById("reptiles_count_difference").innerHTML = 0;
												document.getElementById("reptiles_count_difference").style.display="none";
											}
										}
										if(html.mammalas_count!=undefined){
											document.getElementById("mammalas_count").innerHTML = html.mammalas_count;
											var mammalas_count_difference = html.mammalas_count - html.yesterdays_mammalas_count  ;
											if(mammalas_count_difference>0){//if species increased										 
												document.getElementById("mammalas_count_difference").innerHTML = '<img src="/images/arrow_up.png" style="width: 26px;padding:2px;"><br/>'+mammalas_count_difference;
												document.getElementById("mammalas_count_difference").style.display="inline-block";
												length_minus +=2;
												width_minus+=25;
											}else if(mammalas_count_difference<0){//if species decreased
												document.getElementById("mammalas_count_difference").innerHTML = '<img src="/images/arrow_down.png" style="width: 26px;padding:2px;"><br/>'+Math.abs(mammalas_count_difference);
												document.getElementById("mammalas_count_difference").style.display="inline-block";
												length_minus +=2;
												width_minus+=25;
											}else{//if secies count is same
												document.getElementById("mammalas_count_difference").innerHTML = 0;
												document.getElementById("mammalas_count_difference").style.display="none";
											}
										}
										// console.log("length"+html.right_now.length+" last-length"+html.last_seen.length);

										if(html.right_now != undefined){
											if(html.right_now !=""){
												no_sighting=false;
												console.log("right now : length=>"+html.right_now.length+" > "+(27-length_minus)+" , width=>"+width_minus);
												$('#animated_marquee').removeClass('small_div');
												if(html.right_now.length>(27-length_minus)){
													document.getElementById("rigth_now_")
													document.getElementById("right_now_marquee_div").style.display="inline-block";
													document.getElementById("right_now_div").style.display="none";
													document.getElementById("right_now_marquee_title").innerHTML="Now: ";
													document.getElementById("right_now_marquee_species").innerHTML=html.right_now;
												}else{
													document.getElementById("right_now_div").style.display="inline-block";
													document.getElementById("right_now_marquee_div").style.display="none";
													document.getElementById("right_now_title").innerHTML="Now: ";
													document.getElementById("right_now_species").innerHTML=html.right_now;
												}											
											}else{
												no_sighting=true;
												$('#animated_marquee').addClass('small_div');											
											}
										}else{
											console.log("last: length=>"+html.right_now.length+" > "+(27-length_minus)+" , width=>"+width_minus);
										}
										var elements=document.getElementsByClassName("small_div");
										for (var i = 0; i < elements.length; i++) {
											console.log("small_div new_width=>"+parseInt(625-width_minus)+"px !important");
											elements[i].style.width=parseInt(635-width_minus)+"px !important";
										}
										var elements=document.getElementsByClassName("animated");
										for (var i = 0; i < elements.length; i++) {
											console.log("animated new_width=>"+parseInt(790-width_minus)+"px");
											elements[i].style.width=parseInt(790-width_minus)+"px";
										}
									},
									error: function(data){
										console.log("php fail "+JSON.stringify(data));
									}
								}); 
							}
							window.onload = setInterval(clock,1000);
							window.onload = setInterval(get_wildlife_data,1000);

							var last_seen_arr=new Array();
							function getlast_seen_data(){
								$.ajax({
									url: "wildlife_database/get_wildlife_data.php?last_seen=1",
									type:"GET",
									// data:{"last_seen":1},
									contentType: "application/json",
									dataType: "json",
									cache: false,
									success: function(html){
										last_seen_arr=html.last_seen;
										if(last_seen_arr==undefined || last_seen_arr.length == 0){
											show_text=last_seen_arr.pop();	
											// console.log("lastseen: lenght=>"+show_text.length+" > "+(28-length_minus)+", width=>"+width_minus);
											if(show_text.length>(28-length_minus)){	
												document.getElementById("right_now_marquee_div").style.display="inline-block";	
												document.getElementById("right_now_div").style.display="none";	
												document.getElementById("right_now_marquee_title").innerHTML="Last sightings: ";	
												document.getElementById("right_now_marquee_species").innerHTML=show_text;	
											}else{	
												document.getElementById("right_now_div").style.display="inline-block";	
												document.getElementById("right_now_marquee_div").style.display="none";	
												document.getElementById("right_now_title").innerHTML="Last sightings: ";	
												document.getElementById("right_now_species").innerHTML=show_text;	
											}
										}else{	
												document.getElementById("right_now_div").style.display="inline-block";	
												document.getElementById("right_now_marquee_div").style.display="none";	
												document.getElementById("right_now_title").innerHTML="Last sightings: ";	
												document.getElementById("right_now_species").innerHTML=show_text;	
											}
									}
								});
							}
							function last_seen_data(){
								if(no_sighting){
									console.log("last_seen_arr.length"+last_seen_arr.length);
									if(last_seen_arr==undefined || last_seen_arr.length == 0){
										getlast_seen_data();                       
									}
									else{        
										show_text=last_seen_arr.pop();	
										// console.log("lastseen: lenght=>"+show_text.length+" > "+(28-length_minus)+", width=>"+width_minus);
										if(show_text.length>(28-length_minus)){	
											document.getElementById("right_now_marquee_div").style.display="inline-block";	
											document.getElementById("right_now_div").style.display="none";	
											document.getElementById("right_now_marquee_title").innerHTML="Last sightings: ";	
											document.getElementById("right_now_marquee_species").innerHTML=show_text;	
										}else{	
											document.getElementById("right_now_div").style.display="inline-block";	
											document.getElementById("right_now_marquee_div").style.display="none";	
											document.getElementById("right_now_title").innerHTML="Last sightings: ";	
											document.getElementById("right_now_species").innerHTML=show_text;	
										}     
										                  
									}
								}
							}
							window.onload = setInterval(last_seen_data,5000);

							function convertTZ(date, tzString) {// function to set timezone
								return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));   
							} 
							function clock()
							{
								var d = convertTZ(new Date(), "Africa/Asmera");// get date n time in Iceland timezone
								//console.log(" in clock "+d.getTime());
								var date = d.getDate();
								date = ("0" + date).slice(-2);
								
								var month = d.getMonth();
								var montharr =["Jan","Feb","Mar","April","May","June","July","Aug","Sep","Oct","Nov","Dec"];
								month=montharr[month];
								
								var year = d.getFullYear();

								var date1 = new Date("11/18/2021");
								var monthdigit=d.getMonth()+1;
								var date2 = new Date(monthdigit+"/"+date+"/"+year); 
								var Difference_In_Time = date2.getTime() - date1.getTime();
								var Difference_In_Days = parseInt(Math.round( Difference_In_Time / (1000 * 3600 * 24) ));
									
								var day = d.getDay();
								var dayarr =["Sun","Mon","Tues","Wed","Thurs","Fri","Sat"];
								day=dayarr[day];
								
								var hour =d.getHours();
								var hourminusone = hour;
								if(hourminusone > 0){
								hourminusone = hourminusone-1;
								}
								hour = ("0" + hour).slice(-2);
								hourminusone = ("0" + hourminusone).slice(-2);
								var min = d.getMinutes();	  
								min = ("0" + min).slice(-2);
								var sec = d.getSeconds();
								sec = ("0" + sec).slice(-2);
								var currentmonth = d.getMonth()+1;
								
								currentmonth=("0" + currentmonth).slice(-2);
								var time=year+"-"+currentmonth+"-"+date+"T"+hourminusone+":"+min+":"+sec+"Z";//"2021-06-12T06:52:00Z";
								if(response !== undefined){
									for (var i = 0; i < response.data.timelines[0].intervals.length; i++) {
										if (response.data.timelines[0].intervals[i].startTime === time) {
											//console.log(response.data.timelines.intervals[i].values);
										
											temperature = Math.ceil(response.data.timelines[0].intervals[i].values.temperature);
											//temperature = ((9 * temperature) + (32 * 5)) / 5;
											weatherCode=response.data.timelines[0].intervals[i].values.weatherCode;
											windSpeed=response.data.timelines[0].intervals[i].values.windSpeed;	
											windSpeed=Math.round(windSpeed*3.6);
											windDirection=response.data.timelines[0].intervals[i].values.windDirection;				  
											//console.log("temperature"+temperature+" weatherCode"+weatherCode+" windSpeed"+windSpeed);

											humidity = parseInt(Math.round(response.data.timelines[0].intervals[i].values.humidity));
											visibility = parseInt(Math.round(response.data.timelines[0].intervals[i].values.visibility));

											//--added to get AQI statistics
											epaIndex = response.data.timelines[0].intervals[i].values.epaIndex;
											epaHealthConcern = response.data.timelines[0].intervals[i].values.epaHealthConcern;
											
										}else{
											//console.log(time);
											
										}
									}
								}
								
								var startdate = new Date("10/03/2021 07:14:00");
								var currentdate = new Date(monthdigit+"/"+date+"/"+year+" "+hour+":"+min+":"+sec); 
								var Difference_In_seconds = (currentdate.getTime() - startdate.getTime()) / 1000;	
								var lavapersecond=66;
								var volume = 80000000;
								var estimatedlava = volume + (lavapersecond*Difference_In_seconds);
								estimatedlava = parseInt(estimatedlava/100);
								estimatedlava = estimatedlava*100;
								
								estimatedlava=estimatedlava.toLocaleString('en-US', {maximumFractionDigits:2}) 
								
								
								var areapersecond=0.000000000;
								var base = <?php  echo isset($lavaarea)?$lavaarea:2.37;  ?>;
								var surfaceArea = base + (areapersecond*Difference_In_seconds);
								surfaceArea=surfaceArea.toLocaleString('en-US', {maximumFractionDigits:2}) ;

								//-- added to get latest sunsetsunrise based on currentdatetime 
								if(currentdate > currentDateTime){
									// console.log(currentdate+" is past date as "+currentDateTime);
									sunsetsunriseresponse.data.timelines[0].intervals.forEach(function(sunrisesunsetdata){
										// console.log(sunrisesunsetdata);
										var starttime = sunrisesunsetdata.startTime.split("T");
										var newstarttime=starttime[0]+"T00:00:00Z";
										if(newstarttime == year+"-"+monthdigit+"-"+date+"T00:00:00Z" ){
											//-- added to make sunset sunrise +1 hour to match with https://www.tomorrow.io/weather/ES/CN/El_Paso/034004/ 
											sunriseTime=sunrisesunsetdata.values.sunriseTime.substring(11, 16);
											// sunrise = sunriseTime;
											sunrise = sunriseTime.split(":"); 
											sunrise = ("0" + (parseInt(sunrise[0])+2)).slice(-2)+":"+sunrise[1];//-- commented to show actual response to match with https://www.tomorrow.io/weather/ES/CN/El_Paso/034004/


											sunsetTime=sunrisesunsetdata.values.sunsetTime.substring(11, 16);
											// sunset = sunsetTime;
											sunset = sunsetTime.split(":"); 
											sunset = ("0" + (parseInt(sunset[0])+2)).slice(-2)+":"+sunset[1];	//-- commented to show actual response to match with https://www.tomorrow.io/weather/ES/CN/El_Paso/034004/
											console.log("another sunrise:"+sunrise+" sunset:"+sunset);
											currentDateTime=new Date(sunrisesunsetdata.startTime.replace("T"," ").replace("Z",""));
											// console.log("date found",sunrisesunsetdata.startTime,sunrisesunsetdata.values,"newdate",currentDateTime);

											//--added to show either sunset or sunrise	
											sunrisetimestamp=new Date(sunrisesunsetdata.values.sunriseTime.replace("T"," ").replace("Z",""));												
											sunrisetimestamp.setHours(sunrisetimestamp.getHours()+2);//-- to resolve sunrisesunset time 

											sunsetimestamp=new Date(sunrisesunsetdata.values.sunsetTime.replace("T"," ").replace("Z",""));
											sunsetimestamp.setHours(sunsetimestamp.getHours()+2);//-- to resolve sunrisesunset time 
	
											// console.log("another sunrisetimestamp: "+new Date(sunrisetimestamp).getTime() +" sunsetimestamp: "+new Date(sunsetimestamp).getTime()+" current: "+new Date().getTime()); 	 

										}else{
											// console.log(newstarttime+" not found "+ year+"-"+monthdigit+"-"+date+"T00:00:00Z");
										}
									});
									
								}else{
									// console.log(currentdate+" is current date as "+currentDateTime);
								}
								
								document.getElementById("date").innerHTML=month+" "+date+", ";
								document.getElementById("time").innerHTML=hour+":"+min+":"+sec;
								document.getElementById("daycount").innerHTML="Day "+Difference_In_Days+"";    
								if(document.getElementById('lava') !== null){
									document.getElementById("lava").innerHTML = estimatedlava;	
								}
								if(surfaceArea != undefined ){
									document.getElementById("surfaceArea").innerHTML = surfaceArea;
								} 
								if(windSpeed != undefined ){
									document.getElementById("windSpeed").innerHTML = windSpeed + "km/h";
								}
								if(temperature != undefined ){
									document.getElementById("temperature").innerHTML = temperature + "<sup>&#176;</sup>C";    
								}
								var imgsrc;
								switch(weatherCode){
									case 1000: imgsrc="/images/icons/weather/0b10b61-clear_day.svg"; break;
									case 1001: imgsrc="/images/icons/weather/285ec93-cloudy.svg"; break;
									case 1100: imgsrc="/images/icons/weather/9289e75-mostly_clear_night.svg"; break;
									case 1101: imgsrc="/images/icons/weather/4bf020b-partly_cloudy_day.svg"; break;
									case 1102: imgsrc="/images/icons/weather/27f7337-mostly_cloudy.svg"; break;
									case 2000: imgsrc="/images/icons/weather/034add7-fog.svg"; break;
									case 2100: imgsrc="/images/icons/weather/88d5a3f-fog_light.svg"; break;
									case 4000: imgsrc="/images/icons/weather/85056eb-drizzle.svg"; break;
									case 4001: imgsrc="/images/icons/weather/7fa1cb9-rain.svg"; break;
									case 4200: imgsrc="/images/icons/weather/5707826-rain_light.svg"; break;
									case 4201: imgsrc="/images/icons/weather/02d17cb-rain_heavy.svg"; break;
									case 5000: imgsrc="/images/icons/weather/3971192-snow.svg"; break;
									case 5001: imgsrc="/images/icons/weather/23a7e68-flurries.svg"; break;
									case 5100: imgsrc="/images/icons/weather/2152ead-snow_light.svg"; break;
									case 5101: imgsrc="/images/icons/weather/3669298-snow_heavy.svg"; break;
									case 6000: imgsrc="/images/icons/weather/aad2371-freezing_rain_drizzle.svg"; break;
									case 6001: imgsrc="/images/icons/weather/c84d163-freezing_rain.svg"; break;	 
									case 6002: imgsrc="/images/icons/weather/0b23066-freezing_rain_light.svg"; break; 
									case 6201: imgsrc="/images/icons/weather/83a2b1b-freezing_rain_heavy.svg"; break;
									case 7000: imgsrc="/images/icons/weather/d76e6fa-ice_pellets.svg"; break;
									case 7101: imgsrc="/images/icons/weather/0c21c74-ice_pellets_heavy.svg"; break;		  
									case 7102: imgsrc="/images/icons/weather/c9aa88a-ice_pellets_light.svg"; break;
									case 8000: imgsrc="/images/icons/weather/58e635d-tstorm.svg"; break;
								}
								$("#weather").attr("src",imgsrc);
								$("#winddirection").css("transform","rotate("+windDirection+"deg)");
								if(humidity != undefined ){
									document.getElementById("humidity").innerHTML = humidity; 
								}
								if(visibility != undefined ){
									document.getElementById("visibility").innerHTML = visibility; 
								}
								if(sunrise != undefined ){
									document.getElementById("sunrise").innerHTML = sunrise; 
								}
								if(sunset != undefined ){
									document.getElementById("sunset").innerHTML = sunset; 
								}

								//--added to show either sunset or sunrise
								// console.log("currentdate:"+currentdate+" , sunrisetimestamp:"+sunrisetimestamp+" , sunsetimestamp:"+sunsetimestamp);	
								if(sunrisetimestamp < currentdate && currentdate < sunsetimestamp){	
									var sunsetdiv = document.getElementsByClassName("sunsetdiv")	
									for (var i = 0; i < sunsetdiv.length; i++){	
										sunsetdiv[i].style.display = "block";	
									}	
									var sunrisediv = document.getElementsByClassName("sunrisediv")	
									for (var i = 0; i < sunrisediv.length; i++){	
										sunrisediv[i].style.display = "none";	
									}	
									// console.log("sunrise < current < sunset then show sunset ");	
								}else{	
									var sunrisediv = document.getElementsByClassName("sunrisediv")	
									for (var i = 0; i < sunrisediv.length; i++){	
										sunrisediv[i].style.display = "block";	
									}	
									var sunsetdiv = document.getElementsByClassName("sunsetdiv")	
									for (var i = 0; i < sunsetdiv.length; i++){	
										sunsetdiv[i].style.display = "none";	
									}	
									// console.log("sunrise < sunset < current OR current < sunrise < sunset then show sunrise ");	
								}
								/*if(currentdate < sunrisetimestamp){
									var sunrisediv = document.getElementsByClassName("sunrisediv")
									for (var i = 0; i < sunrisediv.length; i++){
										sunrisediv[i].style.display = "block";
									}

									var sunsetdiv = document.getElementsByClassName("sunsetdiv")
									for (var i = 0; i < sunsetdiv.length; i++){
										sunsetdiv[i].style.display = "none";
									}
								}else{
									var sunsetdiv = document.getElementsByClassName("sunsetdiv")
									for (var i = 0; i < sunsetdiv.length; i++){
										sunsetdiv[i].style.display = "block";
									}

									var sunrisediv = document.getElementsByClassName("sunrisediv")
									for (var i = 0; i < sunrisediv.length; i++){
										sunrisediv[i].style.display = "none";
									}
								}*/

								if(epaIndex != undefined ){
									document.getElementById("epaIndex").innerHTML  = epaIndex;
								}
								
								switch(epaHealthConcern){
									case 0: epaHealthConcernstr="Good";break;
									case 1:	epaHealthConcernstr="Moderate";break;
									case 2:	epaHealthConcernstr="Unhealthy for Sensitive Groups";break;
									case 3:	epaHealthConcernstr="Unhealthy";break;
									case 4:	epaHealthConcernstr="Very Unhealthy";break;
									case 5:	epaHealthConcernstr="Hazardous";break;
								}
								document.getElementById("epaHealthConcern").innerHTML  = epaHealthConcernstr;

								document.getElementById("universalbar-container").style.display = "block";
							}
						</script>
            
				</div>

		</body>
</html>
     