Cut 'n' Paste the following:
Code: Select all
<script type="text/javascript">
<!--
/*
day / night decider / graphic 'switcher' by beteljuice Feb 09
put this code at the bottom of your Cumulus *****T.htm page just before the closing </body> tag
Where you want the graphic(s) on your page use:
<span id="day_night"></span> or you could use <div ..
*/
// user set variables
var day_graphic = "weather_graphics/big_sun.png"; // location of your day graphic
var day_text = "It's Day Time"; // mouseover text for day graphic
var night_graphic = "weather_graphics/night.png"; // location of your night graphic
var night_text = "It's Night Time"; // mouseover text for night graphic
// END user variables
var hour = "<#hour>";
var minutes = "<#minute>";
var day_start = "<#sunrise>";
var day_end = "<#sunset>";
var day_length = "<#daylength>";
day_start = day_start.replace(':', '') *1; // turn into a 'real' number
day_end = day_end.replace(':', '') *1; // turn into a 'real' number
obs_time = (hour + minutes) *1; // turn into a 'real' number
sun_check = day_length.substr(0, 2) *1; // get the hours part of day length a make numeric
if(!isNaN(day_start) && !isNaN(day_end) && !isNaN(obs_time)) { // make sure inputs are valid (numeric)
if(obs_time < day_start || obs_time > day_end) { // must be night
night = true;
} else {
night = false;
}
} else { // hmm ... might be ALL DAY or ALL NIGHT !
if(!isNan(sun_check)) { // if it really is a number
(sun_check < 1 ? night = true : night = false);
}
} // end numeric check
if(self.night != null) { // we've made some sort of decision
// day / night time graphic 'switch'
element = document.getElementById("day_night");
if(element) {
(!night ? element.innerHTML = "<img src=\"" + day_graphic + "\" alt=\"" + day_text + "\" title = \"" + day_text + "\" />" : element.innerHTML = "<img src=\"" + night_graphic + "\" alt=\"" + night_text + "\" title = \"" + night_text + "\" />");
}
// END graphic switch
} // end decision made
// END day / night
-->
</script>
This is a modified 'snippet' from:
https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=735