<?xml version="1.0" encoding="iso-8859-1"?>
<Module>
	<ModulePrefs 
    title="Daylight, Sunrise &amp; Sunset Map"
		title_url="http://www.catfood.net/products/desktate/download.asp"
		description="Shows the extent of day and night around the world using NASA Blue Marble images. Updates automatically so you can see the extent of sunlight and darkness throughout the day and the changing seasons over the course of the year. Optionally shows local sunrise and sunset times when you add your location."
		author="Catfood Software"
		author_email="support@catfood.net"
    author_link="http://www.catfood.net/"
		author_affiliation="Catfood Software"
		author_location="San Francisco, CA"
    author_photo="http://www.catfood.net/images/glogo.png"
    author_aboutme="Catfood Software is the home of connected tools, screen savers and other software from Robert Ellison."
		height="275"
		screenshot="http://www.catfood.net/deskss.png"
		thumbnail="http://www.catfood.net/desktn.png"
		render_inline="never"
		singleton="false"/>
	<UserPref name="showss" 
       display_name="Show sunset/sunrise:"
       datatype="bool"
       default_value="false"/>
	<UserPref name="lat" 
       display_name="Latitude:"
       default_value="37.75401"/>
    <UserPref name="long" 
       display_name="Longitude:"
       default_value="-122.4359"/>	
	<Content type="html">
<![CDATA[ 

<style type="text/css">
body 
{
	font-family: Verdana, Arial, Helvetica, sans-serif; 
	font-size: 8pt; 
	margin: 0px;
} 
td
{
	font-family: Verdana, Arial, Helvetica, sans-serif; 
	font-size: 8pt; 
} 
</style>
<table cellpadding="0" cellspacing="0" border="0" id="mapTable">
<tr><td align="left" colspan="2"><a href="http://www.catfood.net/products/desktate/download.asp" target="_top"><img id="cmap" src="http://www.catfood.net/images/loading.jpg" width="320" height="240" border="0" onLoad="ImageSize()" onError="UpdateMap()" alt="Desktate" /></a></td></tr>
<tr><td align="left">
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="srn"></td><td id="srv"></td></tr>
<tr><td id="ssn"></td><td id="ssv"></td></tr>
</table>
</td><td align="right" valign="top"><a href="http://www.catfood.net/products/desktate/download.asp" target="_top">Desktop Wallpaper</a></td></tr>
</table>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
_uacct = "UA-245433-1";
urchinTracker();

_IG_RegisterOnloadHandler(StartDesk());

var gDate = 0;
var gShowSS = false;
var gLat = 0.0;
var gLong = 0.0;
var gDST = 0;

function IsDst()
{
	var minOff = 1000;
	var maxOff = -1000;
	var dayTest = new Date();
	dayTest.setDate(1);
	for (var i = 0; i <= 11; i++)
	{
		dayTest.setMonth(i);
		offsetTest = dayTest.getTimezoneOffset();
		if (offsetTest > maxOff) maxOff = offsetTest;
		if (offsetTest < minOff) minOff = offsetTest;
	}
	var dayToday = new Date();
	var retVal = false;
	if (dayToday.getTimezoneOffset() == maxOff)
	{
		retVal = false;
	}
	else
	{
		retVal = true;
	}
	return retVal;
}

function ImageSize()
{
	var frameWidth = 320;
	var frameHeight = 240;
	
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
	}
	else return;
	
	if (frameWidth > 320)
	{
		frameWidth = 320;
	}
	
	var hScale = 240 * (frameWidth / 320);
	frameHeight = Math.round(hScale);

	document.getElementById("cmap").width = frameWidth;
	document.getElementById("cmap").height = frameHeight;
}

function StartSS()
{
	var now = new Date();
	var q = "http://www.earthtools.org/sun/";
	q += gLat;
	q += "/";
	q += gLong;
	q += "/";
	q += now.getDate();
	q += "/";
	q += (now.getMonth() + 1);
	q += "/99/";
	q += gDST;
	_IG_FetchXmlContent(q, EndSS);
}

function EndSS(xml)
{
	var sunrise = "";
	var sunset = "";
	
	sunrise = xml.getElementsByTagName("sunrise").item(0).firstChild.nodeValue;
	sunset = xml.getElementsByTagName("sunset").item(0).firstChild.nodeValue;
	
	if (8 != sunrise.length) return;
	if (8 != sunset.length) return;
	
	sunrise = "&nbsp;&nbsp;" + sunrise.substr(0, 5);
	sunset = "&nbsp;&nbsp;" + sunset.substr(0, 5);
	
	document.getElementById("srn").innerHTML = "Sunrise:";
	document.getElementById("ssn").innerHTML = "Sunset:";
	document.getElementById("srv").innerHTML = sunrise;
	document.getElementById("ssv").innerHTML = sunset;
}

function StartDesk()
{
	var now = new Date();
	gDate = now.getDate();
	
	if (true == IsDst())
	{
		gDST = 1;
	}
	else
	{
		gDST = 0;
	}
	
	var prefs = new _IG_Prefs(__MODULE_ID__);
	gShowSS = prefs.getBool("showss");
	if (true == gShowSS)
	{
		gLat = parseFloat(prefs.getString("lat"));
		gLong = parseFloat(prefs.getString("long"));
		
		if (NaN == gLat) gLat = 0.0;
		if (gLat > 90.0) gLat = 90.0;
		if (gLat < -90.0) gLat = -90.0;
		
		if (NaN == gLong) gLong = 0.0;
		if (gLong > 180.0) gLong = 180.0;
		if (gLong < -180.0) gLong = -180.0;
		
		StartSS();
	}
	
	UpdateMap();
	setInterval("UpdateMap()", 1800000);
}

function UpdateMap()
{
	var now = new Date();
	
	if (gDate != now.getDate())
	{
		gDate = now.getDate();
		if (true == gShowSS)
		{
			StartSS();
		}
	}
	
	var hourOfYear = 1;
	if (now.getUTCMonth() > 0) hourOfYear += (30 * 24); // Jan
	if (now.getUTCMonth() > 1) hourOfYear += (28 * 24); // Feb
	if (now.getUTCMonth() > 2) hourOfYear += (31 * 24); // Mar
	if (now.getUTCMonth() > 3) hourOfYear += (30 * 24); // Apr
	if (now.getUTCMonth() > 4) hourOfYear += (31 * 24); // May
	if (now.getUTCMonth() > 5) hourOfYear += (30 * 24); // Jun
	if (now.getUTCMonth() > 6) hourOfYear += (31 * 24); // Jul
	if (now.getUTCMonth() > 7) hourOfYear += (31 * 24); // Aug
	if (now.getUTCMonth() > 8) hourOfYear += (30 * 24); // Sep
	if (now.getUTCMonth() > 9) hourOfYear += (31 * 24); // Oct
	if (now.getUTCMonth() > 10) hourOfYear += (30 * 24); // Nov
	hourOfYear += (now.getUTCDate() * 24);
	hourOfYear += now.getUTCHours();
	if (hourOfYear > 8760)
	{
		hourOfYear = 1;
	}
	var imgPath = "" + hourOfYear + ".jpg";
	if (imgPath.length == 5) imgPath = "0000000" + imgPath;
	if (imgPath.length == 6) imgPath = "000000" + imgPath;
	if (imgPath.length == 7) imgPath = "00000" + imgPath;
	if (imgPath.length == 8) imgPath = "0000" + imgPath;
	imgPath = "http://www.catfood.net.nyud.net:8080/di/" + imgPath;
	document.getElementById("cmap").src = imgPath;
}

-->
</script>


]]>
  </Content>
</Module>