/* Copyright
   (c) 2010 bitSplit(tm) Enterprises
*/

var gOnLoadInterval				= 3600;
var	gOnLoadIntervalID			= 0;
var	gOnLoadCount 				= 0;
var	gDoReload 					= 0;

var gOrientationInterval		= 333;
var	gOrientationIntervalID		= 0;

var	gLast_left					= 0;
var	gLast_top					= 0;
var	gLast_rotAngle				= 0;
var	gLast_img1_left				= 0;
var	gLast_img1_top				= 0;
var	gLast_img2_left				= 0;
var	gLast_img2_top				= 0;

var	gPageHidden					= 0;
var	gPageAngle					= -1;

var gLastValidAngle				= 0;

//-----------------------------------------------------------------

var gGlobalVar1					= 0;
var gGlobalVar2					= 0;
var gGlobalVar3					= 0;
var gGlobalVar4					= 0;
var gGlobalVar5					= 0;

//-----------------------------------------------------------------
// Device Info
//-----------------------------------------------------------------

var gDevice_ScreenMinDim		= 320;
var gDevice_ScreenMaxDim		= 480;
var gDevice_Debug				= 0;

var gDevice_ScreenWidth			= gDevice_ScreenMinDim;
var gDevice_ScreenHeight		= gDevice_ScreenMaxDim;

var gDevice_PhoneNumber			= "";
var gDevice_Language			= "";
var gDevice_Name				= "";
var gDevice_SystemVersion		= "";

//-----------------------------------------------------------------
// Conditions
//-----------------------------------------------------------------

var	gCond_CurrentRealTime		= 0;
var	gCond_CurrentTimeScale		= 1;
var	gCond_CurrentTimeOffset		= 0;
	
var gCond_CurrentTime			= 0;
var gCond_CurrentHours24		= 0;
var gCond_CurrentHours12		= 0;
var gCond_CurrentMinutes		= 0;
var gCond_CurrentSeconds		= 0;
var gCond_CurrentWeekday		= 0;
var gCond_CurrentDay			= 0;
var gCond_CurrentMonth			= 0;
var gCond_CurrentYear			= 0;

var gCond_LastSecond			= -1;
var gCond_LastMinute			= -1;
var gCond_LastHour				= -1;
var gCond_LastDay				= -1;
var gCond_LastMonth				= -1;

var gCond_secondTransition		= 0;
var gCond_minuteTransition		= 0;
var gCond_hourTransition		= 0;
var gCond_dayTransition			= 0;
var gCond_monthTransition		= 0;

var gCond_DeviceAngle			= 0;
var gCond_Landscape				= 0;
var gCond_Portrait				= 1;

var gCond_BatteryLevel			= 0;
var gCond_BatteryDischarging 	= 0;
var gCond_BatteryCharging 		= 0;
var gCond_BatteryFull 			= 0;
var gCond_BatteryAngle			= 0;

var gCond_NumPhone				= 0;
var gCond_NumSMS				= 0;
var gCond_NumMail				= 0;
var gCond_SpaceUsed				= 0;

//-----------------------------------------------------------------
// Formats
//-----------------------------------------------------------------

var WeekdayNames 			= new Array();
var ShortWeekdayNames 		= new Array();
var MonthNames   			= new Array();
var ShortMonthNames   		= new Array();

WeekdayNames['0'] 			= new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
ShortWeekdayNames['0'] 		= new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
MonthNames['0']   			= new Array("January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December");
ShortMonthNames['0']   		= new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug","Sep", "Oct", "Nov", "Dec");

//-----------------------------------------------------------------
// Weather
//-----------------------------------------------------------------

var WeatherAppleIcons =
[
  "mini-sun.png",   	// 1  Sunny
  "mini-suncloud.png",	// 2  Mostly Sunny
  "mini-suncloud.png",	// 3  Partly Sunny
  "mini-suncloud.png",	// 4  Intermittent Clouds
  "mini-sunhaze.png",	// 5  Hazy Sunshine
  "mini-clouds.png",	// 6  Mostly Cloudy
  "mini-clouds.png",	// 7  Cloudy (am/pm)
  "mini-clouds.png",	// 8  Dreary (am/pm)
  "moon-1.png", 		// 9  retired
  "moon-1.png", 		// 10 retired
  "mini-fog.png", 		// 11 fog (am/pm)
  "mini-rain.png", 		// 12 showers (am/pm)
  "mini-cloudrain.png",	// 13 Mostly Cloudy with Showers
  "mini-sunrain.png",	// 14 Partly Sunny with Showers
  "mini-lightning.png",	// 15 Thunderstorms (am/pm)
  "mini-lightning.png",	// 16 Mostly Cloudy with Thunder Showers
  "mini-lightning.png",	// 17 Partly Sunnty with Thunder Showers
  "mini-rain.png",		// 18 Rain (am/pm)
  "mini-flurries.png",	// 19 Flurries (am/pm)
  "mini-flurries.png",	// 20 Mostly Cloudy with Flurries
  "mini-flurries.png",	// 21 Partly Sunny with Flurries
  "mini-snow.png",     	// 22 Snow (am/pm)
  "mini-snow.png",      // 23 Mostly Cloudy with Snow
  "mini-ice.png",      	// 24 Ice (am/pm)
  "mini-snowrain.png",	// 25 Sleet (am/pm)
  "mini-hail.png",  	// 26 Freezing Rain (am/pm)
  "moon-1.png",         // 27 retired
  "moon-1.png",         // 28 retired
  "mini-snowrain.png",	// 29 Rain and Snow Mixed (am/pm)
  "mini-sun.png",      	// 30 Hot (am/pm)
  "mini-sun.png",   	// 31 Cold (am/pm)
  "mini-wind.png",    	// 32 Windy (am/pm)
  
  // Night only Icons;
  "moon-18.png",   		// 33 Clear
  "moon-18.png", 		// 34 Mostly Clear
  "moon-18.png", 		// 35 Partly Cloudy
  "moon-18.png", 		// 36 Intermittent Clouds
  "moon-18.png", 		// 37 Hazy
  "moon-18.png",       	// 38 Mostly Cloudy
  "moon-18.png", 		// 39 Partly Cloudy with Showers
  "moon-18.png", 		// 40 Mostly Cloudy with Showers
  "moon-18.png", 		// 41 Partly Cloudy with Thunder Showers
  "moon-18.png", 		// 42 Mostly Cloudy with Thunder Showers
  "moon-18.png", 		// 43 Mostly Cloudy with Flurries
  "moon-18.png",  		// 44 Mostly Cloudy with Flurries
];

var WeatherIcons =
[
  "sunny.png",         	// 1  Sunny
  "cloudy1.png",      	// 2  Mostly Sunny
  "cloudy2.png",       	// 3  Partly Sunny
  "cloudy3.png",       	// 4  Intermittent Clouds
  "cloudy4.png",       	// 5  Hazy Sunshine
  "cloudy5.png",       	// 6  Mostly Cloudy
  "cloudy5.png",       	// 7  Cloudy (am/pm)
  "overcast.png",      	// 8  Dreary (am/pm)
  "dunno.png",         	// 9  retired
  "dunno.png",         	// 10 retired
  "fog.png",           	// 11 fog (am/pm)
  "shower1.png",       	// 12 showers (am/pm)
  "shower3.png",       	// 13 Mostly Cloudy with Showers
  "shower2.png",       	// 14 Partly Sunny with Showers
  "tstorm3.png",       	// 15 Thunderstorms (am/pm)
  "tstorm2.png",       	// 16 Mostly Cloudy with Thunder Showers
  "tstorm1.png",       	// 17 Partly Sunnty with Thunder Showers
  "light_rain.png",    	// 18 Rain (am/pm)
  "cloudy5.png",       	// 19 Flurries (am/pm)
  "cloudy4.png",       	// 20 Mostly Cloudy with Flurries
  "cloudy2.png",       	// 21 Partly Sunny with Flurries
  "snow5.png",         	// 22 Snow (am/pm)
  "snow3.png",         	// 23 Mostly Cloudy with Snow
  "hail.png",          	// 24 Ice (am/pm)
  "sleet.png",         	// 25 Sleet (am/pm)
  "hail.png",          	// 26 Freezing Rain (am/pm)
  "dunno.png",         	// 27 retired
  "dunno.png",         	// 28 retired
  "sleet.png",         	// 29 Rain and Snow Mixed (am/pm)
  "sunny.png",         	// 30 Hot (am/pm)
  "sunny_night.png",   	// 31 Cold (am/pm)
  "mist.png",          	// 32 Windy (am/pm)
  
  // Night only Icons;
  "sunny_night.png",   	// 33 Clear
  "cloudy1_night.png", 	// 34 Mostly Clear
  "cloudy2_night.png", 	// 35 Partly Cloudy
  "cloudy3_night.png", 	// 36 Intermittent Clouds
  "cloudy4_night.png", 	// 37 Hazy
  "cloudy5.png",       	// 38 Mostly Cloudy
  "shower2_night.png", 	// 39 Partly Cloudy with Showers
  "shower3_night.png", 	// 40 Mostly Cloudy with Showers
  "tstorm1_night.png", 	// 41 Partly Cloudy with Thunder Showers
  "tstorm2_night.png", 	// 42 Mostly Cloudy with Thunder Showers
  "cloudy4_night.png", 	// 43 Mostly Cloudy with Flurries
  "cloudy4_night.png", 	// 44 Mostly Cloudy with Flurries
];

//-----------------------------------------------------------------


	
	function DefaultBackgroundImageLoad(use)
	{
		if (use)
		{
			var CurrentTimestamp = new Date();
			var CurrentTime = CurrentTimestamp.getTime();

			delete CurrentTimestamp;
			
			document.getElementById("DefaultBackgroundImage").style.display = 'block';
			
			if (use == 2)	path = "/private/var/mobile/Library/HomeBackground.jpg?v=" + CurrentTime;
			else		path = "/private/var/mobile/Library/LockBackground.jpg?v=" + CurrentTime;
			
			document.getElementById("DefaultBackgroundImage").src = path;
		}
		else
		{
			document.getElementById("DefaultBackgroundImage").style.display = 'none';
		}
	}
	


	//-------------------------------------------------------------

	function W2010061616144808Click()
	{
		W2010061616144808Clicked = 1;
	}

	//-------------------------------------------------------------

	function W2010061616144808LoadWeather(sync)
	{
		var globalObj = W2010061616144808Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144808WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144808WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144808Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Stars

	var W2010061616144808Global = new widgetGlobalVars;
	
	var W2010061616144808ConditionsIntervalID	= 0;
	var W2010061616144808LastUpdate			= 0;
	var W2010061616144808LastCustomInterval	= 0;
	var	W2010061616144808Clicked				= 0;
	
	var W2010061616144808ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144808TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Stars
	
	function W2010061616144808CheckConditions()
	{
		var globalObj 		= W2010061616144808Global;
		var interval 		= 100;
		var	customInterval	= 300000;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144808LastUpdate;
		
		if (W2010061616144808ConditionsIntervalID)
		{
			clearInterval( W2010061616144808ConditionsIntervalID );
			W2010061616144808ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144808LastCustomInterval != customInterval)
				||(W2010061616144808Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144808UpdateConditions();
				W2010061616144808LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144808LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144808ConditionsIntervalID = setInterval(W2010061616144808CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Stars

	function W2010061616144808UpdateConditions()
	{
		var globalObj 			= W2010061616144808Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144808Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144808Image");
		var	theTextObj			= document.getElementById("W2010061616144808Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144808TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144808Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144808Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144808IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144808LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144808LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144808Clicked)
		{
			W2010061616144808Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Stars
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Stars
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Stars
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Stars
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Stars
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144808ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144808ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144808ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144808ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144808ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144808ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144808ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144808ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144808TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144808TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Stars
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144808TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC010/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144808TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144808ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC010/" + W2010061616144808ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC010/" + W2010061616144808ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC010/" + W2010061616144808ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC010/" + W2010061616144808ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144808ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC010/" + W2010061616144808ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Stars
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Stars
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Stars
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Stars
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144807LoadWeather(sync)
	{
		var globalObj = W2010061616144807Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144807WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144807WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144807Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Sky

	var W2010061616144807Global = new widgetGlobalVars;
	
	var W2010061616144807ConditionsIntervalID	= 0;
	var W2010061616144807LastUpdate			= 0;
	var W2010061616144807LastCustomInterval	= 0;
	var	W2010061616144807Clicked				= 0;
	
	var W2010061616144807ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144807TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Sky
	
	function W2010061616144807CheckConditions()
	{
		var globalObj 		= W2010061616144807Global;
		var interval 		= 100;
		var	customInterval	= 15000;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144807LastUpdate;
		
		if (W2010061616144807ConditionsIntervalID)
		{
			clearInterval( W2010061616144807ConditionsIntervalID );
			W2010061616144807ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144807LastCustomInterval != customInterval)
				||(W2010061616144807Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144807UpdateConditions();
				W2010061616144807LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144807LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144807ConditionsIntervalID = setInterval(W2010061616144807CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Sky

	function W2010061616144807UpdateConditions()
	{
		var globalObj 			= W2010061616144807Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144807Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144807Image");
		var	theTextObj			= document.getElementById("W2010061616144807Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144807TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144807Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144807Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144807IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144807LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144807LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144807Clicked)
		{
			W2010061616144807Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Sky
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Sky
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Sky
		//---
		
		
		// Conditions - yes

		if (1)
			{localObj.period98 = 86400.000000;}

		if (1)
			{localObj.amplitude98 = 100.000000;}

		if (1)
			{localObj.userVar1 = widgetHalfSine98(globalObj, localObj);}

		if (1)
			{localObj.alpha = localObj.userVar1;}


		// Conditions - no


		
		//---
		// Sprite - Sky
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Sky
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144807ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144807ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144807ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144807ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144807ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144807ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144807ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144807ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144807TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144807TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Sky
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144807TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC004/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144807TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144807ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC004/" + W2010061616144807ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC004/" + W2010061616144807ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC004/" + W2010061616144807ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC004/" + W2010061616144807ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144807ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC004/" + W2010061616144807ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Sky
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Sky
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Sky
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Sky
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144806LoadWeather(sync)
	{
		var globalObj = W2010061616144806Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144806WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144806WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144806Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Moon and Sun

	var W2010061616144806Global = new widgetGlobalVars;
	
	var W2010061616144806ConditionsIntervalID	= 0;
	var W2010061616144806LastUpdate			= 0;
	var W2010061616144806LastCustomInterval	= 0;
	var	W2010061616144806Clicked				= 0;
	
	var W2010061616144806ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144806TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Moon and Sun
	
	function W2010061616144806CheckConditions()
	{
		var globalObj 		= W2010061616144806Global;
		var interval 		= 100;
		var	customInterval	= 1000;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144806LastUpdate;
		
		if (W2010061616144806ConditionsIntervalID)
		{
			clearInterval( W2010061616144806ConditionsIntervalID );
			W2010061616144806ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144806LastCustomInterval != customInterval)
				||(W2010061616144806Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144806UpdateConditions();
				W2010061616144806LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144806LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144806ConditionsIntervalID = setInterval(W2010061616144806CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Moon and Sun

	function W2010061616144806UpdateConditions()
	{
		var globalObj 			= W2010061616144806Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144806Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144806Image");
		var	theTextObj			= document.getElementById("W2010061616144806Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144806TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144806Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144806Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144806IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144806LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144806LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144806Clicked)
		{
			W2010061616144806Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Moon and Sun
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Moon and Sun
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Moon and Sun
		//---
		
		
		// Conditions - yes

		if (1)
			{localObj.angle = globalObj.hourAngle24;}


		// Conditions - no


		
		//---
		// Sprite - Moon and Sun
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Moon and Sun
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144806ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144806ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144806ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144806ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144806ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144806ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144806ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144806ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144806TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144806TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Moon and Sun
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144806TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC007/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144806TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144806ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC007/" + W2010061616144806ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC007/" + W2010061616144806ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC007/" + W2010061616144806ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC007/" + W2010061616144806ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144806ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC007/" + W2010061616144806ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Moon and Sun
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Moon and Sun
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Moon and Sun
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Moon and Sun
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144805LoadWeather(sync)
	{
		var globalObj = W2010061616144805Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144805WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144805WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144805Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Mountain

	var W2010061616144805Global = new widgetGlobalVars;
	
	var W2010061616144805ConditionsIntervalID	= 0;
	var W2010061616144805LastUpdate			= 0;
	var W2010061616144805LastCustomInterval	= 0;
	var	W2010061616144805Clicked				= 0;
	
	var W2010061616144805ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144805TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Mountain
	
	function W2010061616144805CheckConditions()
	{
		var globalObj 		= W2010061616144805Global;
		var interval 		= 100;
		var	customInterval	= 300000;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144805LastUpdate;
		
		if (W2010061616144805ConditionsIntervalID)
		{
			clearInterval( W2010061616144805ConditionsIntervalID );
			W2010061616144805ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144805LastCustomInterval != customInterval)
				||(W2010061616144805Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144805UpdateConditions();
				W2010061616144805LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144805LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144805ConditionsIntervalID = setInterval(W2010061616144805CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Mountain

	function W2010061616144805UpdateConditions()
	{
		var globalObj 			= W2010061616144805Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144805Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144805Image");
		var	theTextObj			= document.getElementById("W2010061616144805Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144805TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144805Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144805Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144805IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144805LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144805LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144805Clicked)
		{
			W2010061616144805Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Mountain
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Mountain
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Mountain
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Mountain
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Mountain
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144805ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144805ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144805ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144805ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144805ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144805ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144805ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144805ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144805TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144805TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Mountain
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144805TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC001/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144805TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144805ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC001/" + W2010061616144805ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC001/" + W2010061616144805ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC001/" + W2010061616144805ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC001/" + W2010061616144805ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144805ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC001/" + W2010061616144805ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Mountain
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Mountain
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Mountain
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Mountain
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144804LoadWeather(sync)
	{
		var globalObj = W2010061616144804Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144804WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144804WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144804Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Mountain Dim

	var W2010061616144804Global = new widgetGlobalVars;
	
	var W2010061616144804ConditionsIntervalID	= 0;
	var W2010061616144804LastUpdate			= 0;
	var W2010061616144804LastCustomInterval	= 0;
	var	W2010061616144804Clicked				= 0;
	
	var W2010061616144804ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144804TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Mountain Dim
	
	function W2010061616144804CheckConditions()
	{
		var globalObj 		= W2010061616144804Global;
		var interval 		= 100;
		var	customInterval	= 1000;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144804LastUpdate;
		
		if (W2010061616144804ConditionsIntervalID)
		{
			clearInterval( W2010061616144804ConditionsIntervalID );
			W2010061616144804ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144804LastCustomInterval != customInterval)
				||(W2010061616144804Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144804UpdateConditions();
				W2010061616144804LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144804LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144804ConditionsIntervalID = setInterval(W2010061616144804CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Mountain Dim

	function W2010061616144804UpdateConditions()
	{
		var globalObj 			= W2010061616144804Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144804Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144804Image");
		var	theTextObj			= document.getElementById("W2010061616144804Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144804TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144804Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144804Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144804IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144804LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144804LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144804Clicked)
		{
			W2010061616144804Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Mountain Dim
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Mountain Dim
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Mountain Dim
		//---
		
		
		// Conditions - yes

		if (1)
			{localObj.period98 = 86400.000000;}

		if (1)
			{localObj.amplitude98 = 100.000000;}

		if (1)
			{localObj.userVar1 = widgetHalfSine98(globalObj, localObj);}

		if (1)
			{			localObj.userVar1 = 100.000000 - localObj.userVar1;
		;}

		if (1)
			{if (localObj.userVar1 > (80.000000)) localObj.userVar1 = 80.000000;}

		if (1)
			{localObj.alpha = localObj.userVar1;}


		// Conditions - no


		
		//---
		// Sprite - Mountain Dim
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Mountain Dim
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144804ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144804ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144804ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144804ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144804ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144804ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144804ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144804ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144804TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144804TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Mountain Dim
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144804TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC002/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144804TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144804ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC002/" + W2010061616144804ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC002/" + W2010061616144804ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC002/" + W2010061616144804ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC002/" + W2010061616144804ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144804ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC002/" + W2010061616144804ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Mountain Dim
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Mountain Dim
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Mountain Dim
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Mountain Dim
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144803LoadWeather(sync)
	{
		var globalObj = W2010061616144803Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144803WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144803WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144803Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Cloud

	var W2010061616144803Global = new widgetGlobalVars;
	
	var W2010061616144803ConditionsIntervalID	= 0;
	var W2010061616144803LastUpdate			= 0;
	var W2010061616144803LastCustomInterval	= 0;
	var	W2010061616144803Clicked				= 0;
	
	var W2010061616144803ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144803TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Cloud
	
	function W2010061616144803CheckConditions()
	{
		var globalObj 		= W2010061616144803Global;
		var interval 		= 100;
		var	customInterval	= 100;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144803LastUpdate;
		
		if (W2010061616144803ConditionsIntervalID)
		{
			clearInterval( W2010061616144803ConditionsIntervalID );
			W2010061616144803ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144803LastCustomInterval != customInterval)
				||(W2010061616144803Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144803UpdateConditions();
				W2010061616144803LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144803LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144803ConditionsIntervalID = setInterval(W2010061616144803CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Cloud

	function W2010061616144803UpdateConditions()
	{
		var globalObj 			= W2010061616144803Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144803Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144803Image");
		var	theTextObj			= document.getElementById("W2010061616144803Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144803TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144803Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144803Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144803IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144803LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144803LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144803Clicked)
		{
			W2010061616144803Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Cloud
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Cloud
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Cloud
		//---
		
		
		// Conditions - yes

		if (1)
			{			localObj.offset98 = -localObj.width;
		;}

		if (1)
			{localObj.userVar1 = gDevice_ScreenWidth;}

		if (1)
			{localObj.userVar1 += (localObj.width) ;}

		if (1)
			{localObj.amplitude98 = localObj.userVar1;}

		if (1)
			{localObj.period98 = 900.000000;}

		if (1)
			{localObj.left = widgetQuarterSine98(globalObj, localObj);}

		if (((globalObj.CurrentHours24) < (6.000000))||((globalObj.CurrentHours24) > (18.000000)))
		{
			localObj.alpha = 25.000000;
		}
		else
		{
			localObj.alpha = 80.000000;
		}


		// Conditions - no


		
		//---
		// Sprite - Cloud
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Cloud
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144803ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144803ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144803ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144803ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144803ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144803ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144803ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144803ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144803TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144803TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Cloud
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144803TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC005/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144803TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144803ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC005/" + W2010061616144803ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC005/" + W2010061616144803ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC005/" + W2010061616144803ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC005/" + W2010061616144803ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144803ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC005/" + W2010061616144803ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Cloud
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Cloud
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Cloud
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Cloud
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144802LoadWeather(sync)
	{
		var globalObj = W2010061616144802Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144802WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144802WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144802Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Time

	var W2010061616144802Global = new widgetGlobalVars;
	
	var W2010061616144802ConditionsIntervalID	= 0;
	var W2010061616144802LastUpdate			= 0;
	var W2010061616144802LastCustomInterval	= 0;
	var	W2010061616144802Clicked				= 0;
	
	var W2010061616144802ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144802TextArray			= 
	[
		"$HOUR12:$MINUTE0  $AMPM<br>$WEEKDAY, $MONTH_NAME $DAY &apos;$YEAR0"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Time
	
	function W2010061616144802CheckConditions()
	{
		var globalObj 		= W2010061616144802Global;
		var interval 		= 100;
		var	customInterval	= 1000;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144802LastUpdate;
		
		if (W2010061616144802ConditionsIntervalID)
		{
			clearInterval( W2010061616144802ConditionsIntervalID );
			W2010061616144802ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144802LastCustomInterval != customInterval)
				||(W2010061616144802Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144802UpdateConditions();
				W2010061616144802LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144802LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144802ConditionsIntervalID = setInterval(W2010061616144802CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Time

	function W2010061616144802UpdateConditions()
	{
		var globalObj 			= W2010061616144802Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144802Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144802Image");
		var	theTextObj			= document.getElementById("W2010061616144802Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144802TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144802Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144802Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144802IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 1;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144802LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144802LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144802Clicked)
		{
			W2010061616144802Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Time
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Time
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Time
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Time
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Time
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144802ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144802ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144802ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144802ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144802ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144802ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144802ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144802ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144802TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144802TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Time
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144802TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC003/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144802TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144802ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC003/" + W2010061616144802ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC003/" + W2010061616144802ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC003/" + W2010061616144802ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC003/" + W2010061616144802ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144802ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC003/" + W2010061616144802ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Time
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Time
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Time
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Time
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144801LoadWeather(sync)
	{
		var globalObj = W2010061616144801Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144801WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144801WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144801Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Plane

	var W2010061616144801Global = new widgetGlobalVars;
	
	var W2010061616144801ConditionsIntervalID	= 0;
	var W2010061616144801LastUpdate			= 0;
	var W2010061616144801LastCustomInterval	= 0;
	var	W2010061616144801Clicked				= 0;
	
	var W2010061616144801ImageArray			= 
	[
		"image 0.png"
 
	];

	var W2010061616144801TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Plane
	
	function W2010061616144801CheckConditions()
	{
		var globalObj 		= W2010061616144801Global;
		var interval 		= 100;
		var	customInterval	= 100;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144801LastUpdate;
		
		if (W2010061616144801ConditionsIntervalID)
		{
			clearInterval( W2010061616144801ConditionsIntervalID );
			W2010061616144801ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144801LastCustomInterval != customInterval)
				||(W2010061616144801Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144801UpdateConditions();
				W2010061616144801LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144801LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144801ConditionsIntervalID = setInterval(W2010061616144801CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Plane

	function W2010061616144801UpdateConditions()
	{
		var globalObj 			= W2010061616144801Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144801Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144801Image");
		var	theTextObj			= document.getElementById("W2010061616144801Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144801TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144801Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144801Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144801IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144801LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144801LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144801Clicked)
		{
			W2010061616144801Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Plane
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Plane
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Plane
		//---
		
		
		// Conditions - yes

		if (1)
			{			localObj.offset98 = -gDevice_ScreenWidth;
		;}

		if (1)
			{localObj.userVar1 = gDevice_ScreenWidth;}

		if (1)
			{localObj.userVar1 += (localObj.width) ;}

		if (1)
			{localObj.amplitude98 = localObj.userVar1;}

		if (1)
			{localObj.period98 = 60.000000;}

		if (1)
			{			localObj.left = -widgetQuarterSine98(globalObj, localObj);
		;}


		// Conditions - no


		
		//---
		// Sprite - Plane
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Plane
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144801ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144801ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144801ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144801ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144801ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144801ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144801ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144801ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144801TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144801TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Plane
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144801TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC006/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144801TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144801ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC006/" + W2010061616144801ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC006/" + W2010061616144801ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC006/" + W2010061616144801ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC006/" + W2010061616144801ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144801ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC006/" + W2010061616144801ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Plane
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Plane
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Plane
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Plane
		//---
		
		return;
	}
		


	//-------------------------------------------------------------

	function W2010061616144800Click()
	{
		W2010061616144800Clicked = 1;
	}

	//-------------------------------------------------------------

	function W2010061616144800LoadWeather(sync)
	{
		var globalObj = W2010061616144800Global;
		
		globalObj.waitForWeather = 1;
		
		url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=92101";

		var xmlReq = new XMLHttpRequest();
		xmlReq.onreadystatechange = function(e){W2010061616144800WeatherCallback(e, xmlReq);}
		xmlReq.overrideMimeType("text/xml");
		
		if (sync)	xmlReq.open("GET", url, false);
		else		xmlReq.open("GET", url);
		
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
	}

	//-------------------------------------------------------------

	function W2010061616144800WeatherCallback(event, xmlReq)
	{
		var globalObj = W2010061616144800Global;
		
		if (xmlReq.readyState != 4)						return;
		if (xmlReq.status != 200 && xmlReq.status != 0)	return;
		if (!xmlReq.responseXML)						return;
		
		var weatherObj = new Object();
		var	oldObj;
		
		parseWeatherInfo(xmlReq.responseXML, weatherObj);
		widgetTransferWeatherInfo(weatherObj, globalObj);

		oldObj = globalObj.weatherObj;
		globalObj.weatherObj = weatherObj;
		globalObj.LastWeatherUpdate = globalObj.CurrentRealTime;
		
		try
		{
			if (oldObj)	
			{
				if (oldObj.forecast)
				{
					for (i = 0; i <= 6; ++i)
						if (oldObj.forecast[i])
							delete oldObj.forecast[i];
				}
				
				delete oldObj;
			}
		}
		
		catch(err)
		{}
	}
	
	//-------------------------------------------------------------



	// Sprite - Time Scale

	var W2010061616144800Global = new widgetGlobalVars;
	
	var W2010061616144800ConditionsIntervalID	= 0;
	var W2010061616144800LastUpdate			= 0;
	var W2010061616144800LastCustomInterval	= 0;
	var	W2010061616144800Clicked				= 0;
	
	var W2010061616144800ImageArray			= 
	[
		"image 0.png",
		"image 1.png"
 
	];

	var W2010061616144800TextArray			= 
	[
		"My Text"
 
	];

	//-----------------------------------------------------------------
	// Sprite - Time Scale
	
	function W2010061616144800CheckConditions()
	{
		var globalObj 		= W2010061616144800Global;
		var interval 		= 100;
		var	customInterval	= 100;
		var realDateObj		= new Date();
		var	realMs 			= realDateObj.getTime();
		var	elapsed 		= realMs - W2010061616144800LastUpdate;
		
		if (W2010061616144800ConditionsIntervalID)
		{
			clearInterval( W2010061616144800ConditionsIntervalID );
			W2010061616144800ConditionsIntervalID = 0;
		}
		
		//---
		{
			if (gCond_CurrentTimeScale != 1)
				if (gCond_CurrentTimeScale > 0)
					customInterval /= gCond_CurrentTimeScale;

			if (globalObj.CurrentTimeScale != 1)
				if (globalObj.CurrentTimeScale > 0)
					customInterval /= globalObj.CurrentTimeScale;
			
			if ((elapsed >= customInterval)
				||(W2010061616144800LastCustomInterval != customInterval)
				||(W2010061616144800Clicked)
				||(globalObj.Steps < 2)
				||(globalObj.Count < 2)
				||(0)
			)
			{
				W2010061616144800UpdateConditions();
				W2010061616144800LastUpdate = realDateObj.getTime();
			}
			
			W2010061616144800LastCustomInterval = customInterval;
		}
		//---
		
		if (interval)
			W2010061616144800ConditionsIntervalID = setInterval(W2010061616144800CheckConditions, interval);
		
		delete realDateObj;
	}
	
	//-----------------------------------------------------------------
	// Sprite - Time Scale

	function W2010061616144800UpdateConditions()
	{
		var globalObj 			= W2010061616144800Global;
		var localObj			= new widgetLocalVars(globalObj);
		
		var	theDivObj			= document.getElementById("W2010061616144800Div");
		
		var	theImageObj 		= document.getElementById("W2010061616144800Image");
		var	theTextObj			= document.getElementById("W2010061616144800Text");
		var	theTextLinkObj		= document.getElementById("W2010061616144800TextLink");
		var	theTxtContentObj	= document.getElementById("W2010061616144800Content1"); 	// text
		var	theImgContentObj	= document.getElementById("W2010061616144800Content2"); 	// image

		var	theIFrameObj 		= document.getElementById("W2010061616144800IFrame");

		var	colorObj			= null;

		//---
		// set up some initial values
		
		if (! globalObj.Count) 
		{
			localObj.content 		= 0;
			localObj.useWeather 	= 0;
			
			if (localObj.useWeather)
			{
				W2010061616144800LoadWeather(1);
			}
		}
		else
		{
			if (localObj.useWeather)
				if ((globalObj.CurrentRealTime - globalObj.LastWeatherUpdate) >= 300000) // 5 min.
					W2010061616144800LoadWeather(0);
		}

		//---
		
		++globalObj.Count;
		
		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				if ((globalObj.Count > 2)&&(! globalObj.waitForWeather))
					return;
			}
		}
		
		//---
					
		if (W2010061616144800Clicked)
		{
			W2010061616144800Clicked = 0;
			localObj.buttonClicked = 1;
		}
		
		widgetUpdateTime(globalObj);

		// localObj.time98 ranges from 0..1
		
		if (0)
		{
			localObj.time98 = globalObj.CurrentTime;
		}
		else // use a unit appropriate for the period to get a 'reasonable' 0 point
		{
			if (localObj.period98 <= 1)				localObj.time98 = globalObj.msAngle * 1000 / 360; 										
			else if (localObj.period98 <= 60)		localObj.time98 = globalObj.secondAngle * 60 * 1000 / 360; 							
			else if (localObj.period98 <= 3600)		localObj.time98 = globalObj.minuteAngle * 60 * 60 * 1000 / 360;			
			else if (localObj.period98 <= 86400)	localObj.time98 = globalObj.hourAngle24 * 24 * 60 * 60 * 1000 / 360;		
			else									localObj.time98 = globalObj.dayAngle * 31 * 24 * 60 * 60 * 1000 / 360;	
		}
		
		localObj.time98 = (localObj.time98 % (1000 * localObj.period98)) / (1000 * localObj.period98); // adjust to the period

		//---
		
		if (! ON_DEVICE)
		{
			if (! DO_ANIMATE)
			{
				localObj.time98 = 0.5;
			}
		}
		
		//---
		// Sprite - Time Scale
		//---
		
		localObj.elapsedTime = Math.abs(globalObj.CurrentRealTime - globalObj.LastEvalTime);
		
		widgetKeepValuesInRange(localObj);
		
		str = theDivObj.style.left;
		localObj.left = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.top;
		localObj.top = parseInt(trimWhiteSpace(str), 10);
		
		str = theDivObj.style.width;
		localObj.width = parseInt(trimWhiteSpace(str), 10);

		str = theDivObj.style.height;
		localObj.height = parseInt(trimWhiteSpace(str), 10);

		if (globalObj.OrgWidth == undefined)	
			globalObj.OrgWidth = localObj.width;

		if (globalObj.OrgHeight == undefined)	
			globalObj.OrgHeight = localObj.height;

		if (theTextObj) 			colorObj = theTextObj;
		else if (theTextLinkObj)	colorObj = theTextLinkObj;
		else						colorObj = null;
		
		if (theDivObj)
		{
			var hslaArr = widgetGetHSLA(theDivObj.style.backgroundColor);
			
			if (hslaArr)
			{
				localObj.backHue 			= hslaArr[0];
				localObj.backSat			= hslaArr[1];
				localObj.backLite 			= hslaArr[2];
				localObj.backColorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.backHue 			= 0;
				localObj.backSat			= 100;
				localObj.backLite 			= 100;
				localObj.backColorAlpha 	= 100;
			}
		}
		
		if (colorObj)
		{
			var hslaArr = widgetGetHSLA(colorObj.style.color);

			if (hslaArr)
			{
				localObj.hue 			= hslaArr[0];
				localObj.sat			= hslaArr[1];
				localObj.lite 			= hslaArr[2];
				localObj.colorAlpha 	= hslaArr[3];
			}
			else
			{
				localObj.hue 			= 0;
				localObj.sat			= 100;
				localObj.lite 			= 50;
				localObj.colorAlpha 	= 100;
			}
		}

		localObj.left	+= gLast_left;
		localObj.top	+= gLast_top;
		
		// NOTE: we can't 'precompute' and values that depend on others
		// they may get changed by any of the conditions
		// so we need to always calculate them on the spot
		// (for example, distance to screen edge will change if we adjust the location before testing the distance)

		localObj.prevHue			= localObj.hue;
		localObj.prevSat			= localObj.sat;
		localObj.prevLite			= localObj.lite;
		localObj.prevColorAlpha		= localObj.colorAlpha;
		
		localObj.prevBackHue		= localObj.backHue;
		localObj.prevBackSat		= localObj.backSat;
		localObj.prevBackLite		= localObj.backLite;
		localObj.prevBackColorAlpha	= localObj.backColorAlpha;
	
	{
		// this causes a blank until all widgets are ready - not so great
		// the alternative, though, is that we see the widgets in various states of unreadiness...
			
		if (DO_ANIMATE)
		{
			if (globalObj.Count)											
				if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
					theDivObj.style.display	= 'block';
		}
		else if (theDivObj.style.display == 'none')
		{
			theDivObj.style.display	= 'block';
		}
	}
		
		//---
		// Sprite - Time Scale
		//---
		
		
		// Conditions - yes


		// Conditions - no


		
		//---
		// Sprite - Time Scale
		//---
		
		
		// Conditions - yes

		if (localObj.buttonClicked)
			{gGlobalVar1 = (gGlobalVar1) ? 0 : 1;}

		if ((gGlobalVar1) == (1.000000))
		{
			gCond_CurrentTimeScale = 3600.000000;
		}
		else
		{
			gCond_CurrentTimeScale = 1.000000;
		}

		if ((gGlobalVar1) == (1.000000))
		{
			localObj.imageID = 1;
		}
		else
		{
			localObj.imageID = 0;
		}

		if (1)
			{localObj.period98 = 2.000000;}

		if (1)
			{localObj.offset98 = 50.000000;}

		if (1)
			{localObj.amplitude98 = 50.000000;}

		if (1)
			{				localObj.alpha = widgetHalfSine98(globalObj, localObj);
			;}


		// Conditions - no


		
		//---
		// Sprite - Time Scale
		//---
		
		if (theIFrameObj) // if we have a full page iFrame, then we can only adjust visibility and orientation
		{
			try // these methods are only available on our own pages
			{
				if (localObj.visible)
				{
					theIFrameObj.contentWindow.hidePage(0);

					if (globalObj.LastAngle != gCond_DeviceAngle)
					{
						theIFrameObj.contentWindow.setAngle(gCond_DeviceAngle);
						theIFrameObj.contentWindow.updateOrientation();
						
						globalObj.LastAngle = gCond_DeviceAngle;
					}
				}
				else
				{
					theIFrameObj.contentWindow.hidePage(1);
				}
			}
			
			catch(err)
			{}
			
			//if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	
				{
					document.getElementById("Main").style.display 		= 'none';  
					document.getElementById("Secondary").style.display 	= 'block';  
					
					theIFrameObj.style.visibility = 'visible';
					theDivObj.style.display	= 'block';  
					hidePage(1);
				}
				else			
				{
					document.getElementById("Secondary").style.display 	= 'none';  // otherwise *links* on 'Main' are disabled!
					document.getElementById("Main").style.display 		= 'block';  

					hidePage(0);
					theIFrameObj.style.visibility = 'hidden';
					theDivObj.style.display	= 'none';   
				}
			}
			
			globalObj.LastVisible = localObj.visible;
		}
		else
		{
			//---
			// Sprite - Time Scale
			//---
			
			if (globalObj.LastVisible != localObj.visible)
			{	
				if (localObj.visible)	theDivObj.style.display	= 'block';  
				else					theDivObj.style.display	= 'none';   
			}
			
			if ((localObj.active)
				||(globalObj.LastActive) // when *becoming* inactive adjust settings one more time
			)
			{	
				if ((localObj.itIsTime)
					||(globalObj.LastDevAngle != gCond_DeviceAngle)
				)
				{
					localObj.left	-= gLast_left;
					localObj.top	-= gLast_top;

					//---
					
					if (localObj.setRotToDir)
					{
						var deltaX = localObj.left - globalObj.LastLeft;
						var deltaY = localObj.top - globalObj.LastTop;
						
						localObj.angle = 90 + Math.atan2(deltaY, deltaX)*(180/Math.PI); // NOTE: Y direction first; result in radians
					}
					
					if (localObj.absoluteRotation)
						localObj.angle -= gCond_DeviceAngle;
					
					widgetKeepValuesInRange(localObj);

					//---
					// keep text and image ids in range
					
					if ((localObj.imageID >= 0)&&(W2010061616144800ImageArray.length)) 	localObj.imageID = localObj.imageID % W2010061616144800ImageArray.length;
					else															localObj.imageID = -1;

					if ((localObj.varImage0 >= 0)&&(W2010061616144800ImageArray.length))	localObj.varImage0 = localObj.varImage0 % W2010061616144800ImageArray.length;
					else															localObj.varImage0 = -1;
					
					if ((localObj.varImage1 >= 0)&&(W2010061616144800ImageArray.length))	localObj.varImage1 = localObj.varImage1 % W2010061616144800ImageArray.length;
					else															localObj.varImage1 = -1;
					
					if ((localObj.varImage2 >= 0)&&(W2010061616144800ImageArray.length))	localObj.varImage2 = localObj.varImage2 % W2010061616144800ImageArray.length;
					else															localObj.varImage2 = -1;
					
					if ((localObj.textID >= 0)&&(W2010061616144800TextArray.length)) 		localObj.textID = localObj.textID % W2010061616144800TextArray.length;
					else															localObj.textID = -1;
					
					//---
					// due to substitutions we have to process the text every time!
					
					if (globalObj.LastTextID != localObj.textID)
					{
						localObj.textChanged = 1;
						globalObj.LastTextID = localObj.textID;
					}

					if (globalObj.LastVarImage0 != localObj.varImage0)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage0 = localObj.varImage0;
					}

					if (globalObj.LastVarImage1 != localObj.varImage1)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage1 = localObj.varImage1;
					}

					if (globalObj.LastVarImage2 != localObj.varImage2)
					{
						localObj.textChanged = 1;
						globalObj.LastVarImage2 = localObj.varImage2;
					}

					if (localObj.content == 1)
					{
						//---
						// Sprite - Time Scale
						//---
						
						if (theTextObj)
						{
							if ((localObj.textID >= 0)&&(localObj.textID < W2010061616144800TextArray.length))	
							{
								var str, rep, src;
								var imgHeightStr;
								
								str = theTextObj.style.fontSize;
								
								//"035_Sprite_RSRC008/WeatherIcons/"
								//"_Support_/WeatherIcons/"
								
								globalObj.weatherIconsPath 	= "../bSEWidgetsCommon/WeatherIcons/";
								globalObj.weatherIconSet 	= "Accu1";
								globalObj.fontSize 			= parseInt(trimWhiteSpace(str), 10);
								
								imgHeightStr = sprintf("%dpx", globalObj.fontSize);
								
								localObj.theText = widgetReplaceFormatPlaceholders(globalObj, W2010061616144800TextArray[ localObj.textID ]);
								
								//---

								for (var i = 0; i < W2010061616144800ImageArray.length; ++i)	
								{
									str = sprintf("\\$IMAGE_%d_", i);
									src = "035_Sprite_RSRC008/" + W2010061616144800ImageArray[i] + "?v=1276708574";
									rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
									
									localObj.theText = localObj.theText.replace(new RegExp(str,'g'), rep);
								}
								
								rep = "";
								src = "035_Sprite_RSRC008/" + W2010061616144800ImageArray[ localObj.varImage0 ] + "?v=1276708574";
								if (localObj.varImage0 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE0/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC008/" + W2010061616144800ImageArray[ localObj.varImage1 ] + "?v=1276708574";
								if (localObj.varImage1 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE1/g, rep);
								
								rep = "";
								src = "035_Sprite_RSRC008/" + W2010061616144800ImageArray[ localObj.varImage2 ] + "?v=1276708574";
								if (localObj.varImage2 >= 0) rep = '<img src="' + src + '" height="' + imgHeightStr + '" alt="" align=absmiddle>';
								localObj.theText = localObj.theText.replace(/\$VAR_IMAGE2/g, rep);
							}

							//if (localObj.theText != theTextObj.innerHTML)
							
							if (localObj.theText != globalObj.LastText)
							{
								localObj.textChanged = 1;
								globalObj.LastText = localObj.theText;
							}
						}
					}
					
					if (globalObj.LastContent != localObj.content)
					{
						if (localObj.content == 0)	
						{
							if (theImgContentObj) theImgContentObj.style.display = 'block';
							if (theTxtContentObj) theTxtContentObj.style.display = 'none';
						}
						else
						{
							if (theTxtContentObj) theTxtContentObj.style.display = 'block';
							if (theImgContentObj) theImgContentObj.style.display = 'none';
						}
						
						globalObj.LastContent = localObj.content;
					}
					
					if (localObj.content == 0)
					{
						if (globalObj.LastImageID != localObj.imageID)
						{
							if (theImageObj)
							{
								if ((localObj.imageID >= 0)&&(localObj.imageID < W2010061616144800ImageArray.length))	
									theImageObj.src = "035_Sprite_RSRC008/" + W2010061616144800ImageArray[ localObj.imageID ] + "?v=1276708574";
							}
								
							globalObj.LastImageID = localObj.imageID;
						}
					}
					
					if (localObj.content == 1)
					{
						if (localObj.textChanged)
						{
							if (theTextObj)
								theTextObj.innerHTML = localObj.theText;
						}
					}

					if (globalObj.LastMirror != localObj.mirror)
					{
						if (theTextObj)
						{
							if (localObj.mirror)	theTextObj.style.webkitTransform = sprintf(" matrix(-1, 0, 0, 1, 0, 0)  ");
							else					theTextObj.style.webkitTransform = sprintf(" matrix(1, 0, 0, 1, 0, 0)  ");
						}
					}

					if ((globalObj.LastBackPerspective != localObj.backPerspective)
					)
					{
						theDivObj.style.webkitPerspective = sprintf("%dpx", localObj.backPerspective);
						globalObj.LastBackPerspective = localObj.backPerspective;
					}
					
					if ((globalObj.LastBackAngleY != localObj.backAngleY)
					)
					{
						theDivObj.style.webkitTransform = sprintf("rotateY(%fdeg)", localObj.backAngleY);
						globalObj.LastBackAngleY = localObj.backAngleY;
					}
					
					//---
					
					if (globalObj.LastOriginX != localObj.originX)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginX = sprintf(" %f%% ", localObj.originX);
							
						globalObj.LastOriginX = localObj.originX;
					}
					
					if (globalObj.LastOriginY != localObj.originY)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginY = sprintf(" %f%% ", localObj.originY);
							
						globalObj.LastOriginY = localObj.originY;
					}
					
					if (globalObj.LastOriginZ != localObj.originZ)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransformOriginZ = sprintf(" %f%% ", localObj.originZ);
							
						globalObj.LastOriginZ = localObj.originZ;
					}
					
					//---
					// Sprite - Time Scale
					//---
					
					if ((globalObj.LastAngle != localObj.angle)
						||(globalObj.LastAngleY != localObj.angleY)
						||(globalObj.LastAngleX != localObj.angleX)
						||(globalObj.LastPosZ != localObj.posZ)
						||(globalObj.LastScale != localObj.scale)
					)
					{
						if (theImgContentObj) 
							theImgContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
						
						if (theTxtContentObj)
							theTxtContentObj.style.webkitTransform = sprintf(" rotate(%fdeg) rotateY(%fdeg) rotateX(%fdeg) translateZ(%dpx) scale(%f) ", localObj.angle, localObj.angleY, localObj.angleX, localObj.posZ, Math.abs(localObj.scale) / 100);
							
						globalObj.LastPosZ 		= localObj.posZ;
						globalObj.LastAngle 	= localObj.angle;
						globalObj.LastAngleY 	= localObj.angleY;
						globalObj.LastAngleX 	= localObj.angleX;
						globalObj.LastScale 	= localObj.scale;
					}
					
					//---
					// set the color only if the conditions changed them
					// otherwise we'll always set a background color!
					
					if ((localObj.prevHue != localObj.hue)
						||(localObj.prevSat != localObj.sat)
						||(localObj.prevLite != localObj.lite)
						||(localObj.prevColorAlpha != localObj.colorAlpha)
					)
					{
						if (colorObj)
						{
							colorObj.style.color = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.hue, localObj.sat, localObj.lite, localObj.colorAlpha / 100);
							
							//var hslaArr = widgetGetHSLA(colorObj.style.color);
						}
					}

					if ((localObj.prevBackHue != localObj.backHue)
						||(localObj.prevBackSat != localObj.backSat)
						||(localObj.prevBackLite != localObj.backLite)
						||(localObj.prevBackColorAlpha != localObj.backColorAlpha)
					)
					{
						theDivObj.style.backgroundColor = sprintf("hsla(%d, %d%%, %d%%, %f)", localObj.backHue, localObj.backSat, localObj.backLite, localObj.backColorAlpha / 100);
					}

					//---
					// Sprite - Time Scale
					//---
					
					if (globalObj.LastLeft != localObj.left)
					{
						theDivObj.style.left = sprintf("%dpx", localObj.left);
						globalObj.LastLeft = localObj.left;
					}
					
					if (globalObj.LastTop != localObj.top)
					{
						theDivObj.style.top = sprintf("%dpx", localObj.top);
						globalObj.LastTop = localObj.top;
					}
					
					if (globalObj.LastWidth != localObj.width)
					{
						theDivObj.style.width = sprintf("%dpx", localObj.width);
						globalObj.LastWidth = localObj.width;
					}
					
					if (globalObj.LastHeight != localObj.height)
					{
						theDivObj.style.height = sprintf("%dpx", localObj.height);
						globalObj.LastHeight = localObj.height;
					}
					
					if (globalObj.LastAlpha != localObj.alpha)
					{
						theDivObj.style.opacity = sprintf("%f", localObj.alpha / 100);
						globalObj.LastAlpha = localObj.alpha;
					}

					globalObj.LastEvalTime = globalObj.CurrentRealTime;
					
					++globalObj.Steps;
				}

				//---
				// Sprite - Time Scale
				//---

				globalObj.LastDevAngle			= gCond_DeviceAngle
				
				globalObj.LastAngleDirection	= localObj.angleDirection;
				globalObj.LastAngleYDirection	= localObj.angleYDirection;
				globalObj.LastAngleXDirection	= localObj.angleXDirection;
				globalObj.LastXDirection		= localObj.XDirection;
				globalObj.LastYDirection		= localObj.YDirection;
				globalObj.LastZDirection		= localObj.ZDirection;
				globalObj.LastWDirection		= localObj.WDirection;
				globalObj.LastHDirection		= localObj.HDirection;
				globalObj.LastAlphaDir			= localObj.alphaDirection;
				globalObj.LastScaleDir			= localObj.scaleDirection;
				
				globalObj.LastAngleSpeed		= localObj.angleSpeed;
				globalObj.LastAngleXSpeed		= localObj.angleXSpeed;
				globalObj.LastAngleYSpeed		= localObj.angleYSpeed;
				globalObj.LastXSpeed			= localObj.XSpeed;
				globalObj.LastUpSpeed			= localObj.upSpeed;
				globalObj.LastDownSpeed			= localObj.downSpeed;
				globalObj.LastZSpeed			= localObj.ZSpeed;
				globalObj.LastWSpeed			= localObj.WSpeed;
				globalObj.LastHSpeed			= localObj.HSpeed;
				globalObj.LastScaleSpeed		= localObj.scaleSpeed;
				
				globalObj.UserVar1Transition	= (globalObj.LastUserVar1 != localObj.userVar1) ? 1 : 0;
				globalObj.UserVar2Transition	= (globalObj.LastUserVar2 != localObj.userVar2) ? 1 : 0;
				globalObj.UserVar3Transition	= (globalObj.LastUserVar3 != localObj.userVar3) ? 1 : 0;
				globalObj.UserVar4Transition	= (globalObj.LastUserVar4 != localObj.userVar4) ? 1 : 0;
				globalObj.UserVar5Transition	= (globalObj.LastUserVar5 != localObj.userVar5) ? 1 : 0;

				globalObj.LastUserVar1			= localObj.userVar1;
				globalObj.LastUserVar2			= localObj.userVar2;
				globalObj.LastUserVar3			= localObj.userVar3;
				globalObj.LastUserVar4			= localObj.userVar4;
				globalObj.LastUserVar5			= localObj.userVar5;

				globalObj.LastTime98			= localObj.time98;
				globalObj.LastDecay98			= localObj.decay98;
				globalObj.LastPeriod98			= localObj.period98;
				globalObj.LastOffset98			= localObj.offset98;
				globalObj.LastAmplitude98		= localObj.amplitude98;
				globalObj.LastOscillation98		= localObj.oscillation98;
			}
			
			globalObj.LastVisible 	= localObj.visible;
			globalObj.LastActive 	= localObj.active;
		}
		
		//---

		if (DO_ANIMATE)
		{
			if (globalObj.Count < 2)											
				theDivObj.style.display	= 'none';
			else if ((localObj.visible)&&(theDivObj.style.display == 'none'))	
				theDivObj.style.display	= 'block';
		}
		else
		{
			theDivObj.style.display	= 'block';
		}

		//---
		// Sprite - Time Scale
		//---
		
		return;
	}
		



//-----------------------------------------------------------------

function weatherIconPath(weatherIconsPath, iconSet, index)
{
	if (iconSet == 'Apple')
	{
		iconPath = weatherIconsPath + iconSet + "/" + WeatherAppleIcons[index];
	}
	else if ((iconSet == 'Accu1')||(iconSet == 'Accu2'))
	{
		icon = sprintf("%02d.gif", index+1); // array index 0... translates to name 01...
		iconPath = weatherIconsPath + iconSet + "/" + icon;
	}
	else
	{
		iconPath = weatherIconsPath + iconSet + "/" + WeatherIcons[index];
	}
	
	return iconPath;
}

//-----------------------------------------------------------------

function parseWeatherInfo(responseXML, obj)
{
	var CurrentConditions 	= findChild(findChild(responseXML, "adc_Database"), "CurrentConditions");
	var Planets 			= findChild(findChild(responseXML, "adc_Database"), "Planets");
	var AirAndPollen 		= findChild(findChild(responseXML, "adc_Database"), "AirAndPollen");
	var Forecast 			= findChild(findChild(responseXML, "adc_Database"), "Forecast");

	tag = findChild(CurrentConditions, "City");
	obj.city = trimWhiteSpace(tag.firstChild.data.toString());
	
	//---
	{
		var j = 0;
		
		obj.forecast = new Array;
	
		for (child = Forecast.firstChild; child; child = child.nextSibling)
		{
			if (child.nodeName == 'day')
			{
				var foreObj = new Object();
				
				tag = findChild(child, 'DayCode');
				if (tag != null)
					foreObj.day = trimWhiteSpace(tag.firstChild.data.toString()).substring(0, 3);

				tag = findChild(child, 'ObsDate');
				if (tag != null)
					foreObj.date = trimWhiteSpace(tag.firstChild.data.toString());

				tag = findChild(child, 'High_Temperature');
				if (tag != null)
					foreObj.tempHi = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'Low_Temperature');
				if (tag != null)
					foreObj.tempLo = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'Real_Feel_High');
				if (tag != null)
					foreObj.realFeelHi = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'Real_Feel_Low');
				if (tag != null)
					foreObj.realFeelLo = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'TXT_Short');
				if (tag != null)
					foreObj.desc = ucwords(trimWhiteSpace(tag.firstChild.data).toLowerCase());

				tag = findChild(child, 'TXT_Long');
				if (tag != null)
					foreObj.longDesc = ucwords(trimWhiteSpace(tag.firstChild.data).toLowerCase());

				tag = findChild(child, 'WindSpeed');
				if (tag != null)
					foreObj.windSpeed = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'WindDirection');
				if (tag != null)
					foreObj.windDir = trimWhiteSpace(tag.firstChild.data);

				tag = findChild(child, 'WindGust');
				if (tag != null)
					foreObj.windGust = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'Max_UV');
				if (tag != null)
					foreObj.maxUV = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'Rain_Amount');
				if (tag != null)
					foreObj.rainAmt = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'Snow_Amount');
				if (tag != null)
					foreObj.snowAmt = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'Precip_Amount');
				if (tag != null)
					foreObj.precipAmt = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'TStorm_Prob');
				if (tag != null)
					foreObj.tStormProb = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(child, 'WeatherIcon');
				if (tag != null)
				{
					foreObj.icon = parseInt(trimWhiteSpace(tag.firstChild.data), 10);
					foreObj.icon -= 1; //Accuweather starts at 1
				}
				
				obj.forecast[j++] = foreObj;
			}
		}
	}
	
	//---
	
	tag = findChild(CurrentConditions, "Temperature");
	obj.forecast[0].temp = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

	tag = findChild(CurrentConditions, "RealFeel");
	obj.forecast[0].realFeel = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

	tag = findChild(CurrentConditions, "WeatherText");
	obj.forecast[0].desc = ucwords(trimWhiteSpace(tag.firstChild.data).toLowerCase());

	tag = findChild(CurrentConditions, "Humidity");
	obj.forecast[0].humidity = trimWhiteSpace(tag.firstChild.data);

	tag = findChild(CurrentConditions, "Pressure");
	obj.forecast[0].pressure = trimWhiteSpace(tag.firstChild.data);
	obj.forecast[0].pressureDir = tag.getAttribute("state");
	
	tag = findChild(CurrentConditions, "WindSpeed");
	obj.forecast[0].windSpeed = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

	tag = findChild(CurrentConditions, "WindDirection");
	obj.forecast[0].windDir = trimWhiteSpace(tag.firstChild.data);

	tag = findChild(CurrentConditions, "Visibility");
	obj.forecast[0].visibility = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

	tag = findChild(CurrentConditions, "Precip");
	obj.forecast[0].precip = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

	tag = findChild(CurrentConditions, "UVIndex");
	obj.forecast[0].UVIndex = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

	tag = findChild(CurrentConditions, "WeatherIcon");
	obj.forecast[0].icon = parseInt(trimWhiteSpace(tag.firstChild.data), 10);
	obj.forecast[0].icon -= 1; //Accuweather starts at 1
	
	//---
	
	tag = findChild(AirAndPollen, "Tree");
	obj.forecast[0].pollenTree = trimWhiteSpace(tag.firstChild.data);

	tag = findChild(AirAndPollen, "Weed");
	obj.forecast[0].pollenWeed = trimWhiteSpace(tag.firstChild.data);

	tag = findChild(AirAndPollen, "Grass");
	obj.forecast[0].pollenGrass = trimWhiteSpace(tag.firstChild.data);

	tag = findChild(AirAndPollen, "Mold");
	obj.forecast[0].pollenMold = trimWhiteSpace(tag.firstChild.data);

	tag = findChild(AirAndPollen, "AirQuality");
	obj.forecast[0].airQuality = trimWhiteSpace(tag.firstChild.data);

	//---
	
	tag = findChild(Planets, "Sun");
	if (tag != null)
	{
		var rise = tag.getAttribute("rise");
		var set = tag.getAttribute("set");

		if (rise != null && set != null)
		{
			obj.forecast[0].sunSet = parseTimeString(set);
			obj.forecast[0].sunRise = parseTimeString(rise);
		}
	}

	tag = findChild(Planets, "Moon");
	if (tag != null)
	{
		var rise = tag.getAttribute("rise");
		var set = tag.getAttribute("set");

		if (rise != null && set != null)
		{
			obj.forecast[0].moonSet = parseTimeString(set);
			obj.forecast[0].moonRise = parseTimeString(rise);
		}
	}

	//---
	
	return;
}

//-----------------------------------------------------------------

function setAngle(angle)
{
	gPageAngle = angle;
}

//-----------------------------------------------------------------

function hidePage(hide)
{
	gPageHidden = hide;
}

//-----------------------------------------------------------------

function widgetGlobalVars()
{
	this.LastEvalTime			= 0;
	this.LastDevAngle			= 0;
	
	//---
	
	this.LastRealTime			= 0;
	this.CurrentRealTime		= 0;
	this.CurrentTimeScale		= 1;
	this.CurrentTimeOffset		= 0;
	this.OffsetTo0AM			= 0;
	
	this.CurrentTime			= 0;
	this.Current1000			= 0;
	this.Current100				= 0;
	this.Current10				= 0;
	this.CurrentHours24			= 0;
	this.CurrentHours12			= 0;
	this.CurrentMinutes			= 0;
	this.CurrentSeconds			= 0;
	this.CurrentWeekday			= 0;
	this.CurrentDay				= 0;
	this.CurrentMonth			= 0;
	this.CurrentYear			= 0;

	this.Last1000				= -1;
	this.Last100				= -1;
	this.Last10					= -1;
	this.LastSecond				= -1;
	this.LastMinute				= -1;
	this.LastHour				= -1;
	this.LastDay				= -1;
	this.LastMonth				= -1;

	this.T1000Transition		= 0;
	this.T100Transition			= 0;
	this.T10Transition			= 0;
	this.secondTransition		= 0;
	this.minuteTransition		= 0;
	this.hourTransition			= 0;
	this.dayTransition			= 0;
	this.monthTransition		= 0;

	this.msAngle				= 0;
	this.secondAngle			= 0;
	this.secondAngleDis			= 0;
	this.minuteAngle			= 0;
	this.minuteAngleDis			= 0;
	this.hourAngle				= 0;
	this.hourAngleDis			= 0;
	this.hourAngle24			= 0;
	this.hourAngleDis24			= 0;
	this.dayAngle				= 0;
	this.dayAngleDis			= 0;
	this.monthAngle				= 0;
	this.monthAngleDis			= 0;

	//---
	
	this.Steps					= 0;
	this.Count					= 0;
	this.LastVisible			= 1;
	this.LastActive				= 1;
	
	this.LastAngle				= 0.0;
	this.LastAngleDirection		= 1;
	this.LastAngleSpeed			= 1;
	this.LastOriginZ			= 50.0;
	
	this.LastLeft				= undefined;
	this.LastXDirection			= 1;
	this.LastXSpeed				= 1;
	
	this.LastTop				= undefined;
	this.LastYDirection			= 1;
	this.LastUpSpeed			= 1;
	this.LastDownSpeed			= 1;
	
	this.LastPosZ				= 0;
	this.LastZDirection			= 1;
	this.LastZSpeed				= 1;
	
	this.LastWidth				= undefined;
	this.LastWDirection			= 1;
	this.LastWSpeed				= 1;
	
	this.LastHeight				= undefined;
	this.LastHDirection			= 1;
	this.LastHSpeed				= 1;
	
	this.LastScale				= 100;
	this.LastScaleDir			= 1;
	this.LastScaleSpeed			= 1; 
	
	this.LastAlpha				= 100;
	this.LastAlphaDir			= 1;
	
	this.LastAngleY				= 0.0;
	this.LastAngleYDirection	= 1;
	this.LastAngleYSpeed		= 1;
	this.LastOriginY			= 50.0;
	
	this.LastAngleX				= 0.0;
	this.LastAngleXDirection	= 1;
	this.LastAngleXSpeed		= 1;
	this.LastOriginX			= 50.0;
	
	this.LastMirror				= 0;
	this.LastContent			= 0;
	this.LastBackAngleY			= 0.0;
	this.LastBackPerspective	= 1000.0;

	this.OrgWidth				= undefined;
	this.OrgHeight				= undefined;

	this.LastUserVar1			= 0;
	this.LastUserVar2			= 0;
	this.LastUserVar3			= 0;
	this.LastUserVar4			= 0;
	this.LastUserVar5			= 0;

	this.UserVar1Transition		= 0;
	this.UserVar2Transition		= 0;
	this.UserVar3Transition		= 0;
	this.UserVar4Transition		= 0;
	this.UserVar5Transition		= 0;
	
	this.LastImageID			= -1;
	this.LastTextID				= -1;
	
	this.LastVarImage0			= 0;
	this.LastVarImage1			= 1;
	this.LastVarImage2			= 2;

	this.LastTime98				= -1;
	this.LastDecay98			= 0;
	this.LastPeriod98			= 2;
	this.LastOffset98			= 0;
	this.LastAmplitude98		= 100;
	this.LastOscillation98		= 0;

	this.TextVar1				= 1;
	this.TextVar2				= 2;
	this.TextVar3				= 3;

	this.LastText				= undefined;
	
	//---
	
	this.useWeather				= 0;
	this.LastWeatherUpdate		= 0;
	this.weatherObj				= undefined;
	this.weatherIconsPath		= "/";
	this.weatherIconSet			= "";
	this.fontSize				= 18;
	
	this.waitForWeather			= 0; // for UI only
	
	//---
	
	this.weather_icon				= 0;
	
	this.weather_tempF				= 0;
	this.weather_tempHiF 			= 0;
	this.weather_tempLoF			= 0;
	
	this.weather_tempC				= 0;
	this.weather_tempHiC 			= 0;
	this.weather_tempLoC			= 0;
	
	this.weather_humidity			= 0;
	this.weather_windSpeed			= 0;
	this.weather_windAngle			= 0;
	this.weather_visibility			= 0;
	this.weather_pressure			= 0;
	this.weather_precip				= 0;
	this.weather_UVIndex			= 0;

	this.weather_sunSet_hour		= 0;
	this.weather_sunSet_minute		= 0;
	this.weather_sunSetAngle12		= 0;
	
	this.weather_sunRise_hour		= 0;
	this.weather_sunRise_minute		= 0;
	this.weather_sunRiseAngle12		= 0;
	
	this.weather_moonSet_hour		= 0;
	this.weather_moonSet_minute		= 0;
	this.weather_moonSetAngle12		= 0;
	
	this.weather_moonRise_hour		= 0;
	this.weather_moonRise_minute	= 0;
	this.weather_moonRiseAngle12	= 0;
}

//-----------------------------------------------------------------

function widgetLocalVars(globalObj)
{
	this.itIsTime			= 1;
	this.elapsedTime		= 0;
	this.absoluteRotation	= 0;
	this.setRotToDir		= 0;
	this.textChanged		= 0;
	this.theText			= "";
	
	this.visible			= globalObj.LastVisible;
	this.active				= globalObj.LastActive;
	this.mirror				= globalObj.LastMirror;
	this.content			= globalObj.LastContent;
	this.imageID			= globalObj.LastImageID;
	this.textID				= globalObj.LastTextID;
		
	this.angle 				= globalObj.LastAngle;
	this.angleDirection 	= globalObj.LastAngleDirection;
	this.angleSpeed	 		= globalObj.LastAngleSpeed;
	this.originZ		 	= globalObj.LastOriginZ;
		
	this.angleY 			= globalObj.LastAngleY;
	this.angleYDirection 	= globalObj.LastAngleYDirection;
	this.angleYSpeed		= globalObj.LastAngleYSpeed;
	this.originY		 	= globalObj.LastOriginY;

	this.angleX 			= globalObj.LastAngleX;
	this.angleXDirection 	= globalObj.LastAngleXDirection;
	this.angleXSpeed		= globalObj.LastAngleXSpeed;
	this.originX		 	= globalObj.LastOriginX;
		
	this.left				= globalObj.LastLeft;
	this.XDirection 		= globalObj.LastXDirection;
	this.XSpeed				= globalObj.LastXSpeed;
		
	this.top 				= globalObj.LastTop;
	this.YDirection 		= globalObj.LastYDirection;
	this.upSpeed			= globalObj.LastUpSpeed;
	this.downSpeed			= globalObj.LastDownSpeed;
		
	this.posZ				= globalObj.LastPosZ;
	this.ZDirection			= globalObj.LastZDirection;
	this.ZSpeed				= globalObj.LastZSpeed;

	this.width				= globalObj.LastWidth;
	this.WDirection 		= globalObj.LastWDirection;
	this.WSpeed	 			= globalObj.LastWSpeed;

	this.height 			= globalObj.LastHeight;
	this.HDirection 		= globalObj.LastHDirection;
	this.HSpeed	 			= globalObj.LastHSpeed;
		
	this.scale				= globalObj.LastScale;
	this.scaleDirection		= globalObj.LastScaleDir;
	this.scaleSpeed			= globalObj.LastScaleSpeed;
	this.scaleSpeedAdjust	= 1;
		
	this.alpha				= globalObj.LastAlpha;
	this.alphaDirection		= globalObj.LastAlphaDir;
		
	this.varImage0			= globalObj.LastVarImage0;
	this.varImage1			= globalObj.LastVarImage1;
	this.varImage2			= globalObj.LastVarImage2;
		
	this.backAngleY 		= globalObj.LastBackAngleY;
	this.backPerspective 	= globalObj.LastBackPerspective;

	this.randNum1			= Math.floor(Math.random()*1000+1);
	this.randNum2			= Math.floor(Math.random()*100+1);
	this.randNum3			= Math.floor(Math.random()*359+1);
	this.randNum4			= undefined;

	this.userVar1			= globalObj.LastUserVar1;
	this.userVar2			= globalObj.LastUserVar2;
	this.userVar3			= globalObj.LastUserVar3;
	this.userVar4			= globalObj.LastUserVar4;
	this.userVar5			= globalObj.LastUserVar5;
		
	this.buttonClicked		= 0;
		
	this.prevHue			= undefined;
	this.prevSat			= undefined;
	this.prevLite			= undefined;
	this.hue				= 0;
	this.sat				= 100;
	this.lite				= 50;
	this.colorAlpha			= 100;
		
	this.prevBackHue		= undefined;
	this.prevBackSat		= undefined;
	this.prevBackLite		= undefined;
	this.backHue			= 0;
	this.backSat			= 100;
	this.backLite			= 100;
	this.backColorAlpha		= 100;

	this.decay98			= globalObj.LastDecay98;
	this.period98			= globalObj.LastPeriod98;
	this.offset98			= globalObj.LastOffset98;
	this.amplitude98		= globalObj.LastAmplitude98;
	this.oscillation98		= undefined;
	this.direction98		= undefined;
	this.time98				= undefined;
	
	//---
	{
		var	localObj = this;
		
		localObj.randNum4 = (Math.floor(Math.random()*1000+1) >= 500) ? 1 : -1;

		if (! globalObj.Steps) // set initial image and text
		{
			localObj.imageID	= 0;
			localObj.textID		= 0;
		}
	}
	//---

	return;
}

//-----------------------------------------------------------------

function widgetKeepValuesInRange(localObj)
{
	// keep angles in range -359..359
				
	if (localObj.angle < 0)			localObj.angle = -((-localObj.angle) % 360);
	else							localObj.angle = localObj.angle % 360;
		
	if (localObj.angleY < 0)		localObj.angleY = -((-localObj.angleY) % 360);
	else							localObj.angleY = localObj.angleY % 360;
	
	if (localObj.angleX < 0)		localObj.angleX = -((-localObj.angleX) % 360);
	else							localObj.angleX = localObj.angleX % 360;
	
	if (localObj.backAngleY < 0)	localObj.backAngleY = -((-localObj.backAngleY) % 360);
	else							localObj.backAngleY = localObj.backAngleY % 360;

	// keep percentages in range 0..100

	if (localObj.alpha < 0)			localObj.alpha = 0;
	if (localObj.alpha > 100)		localObj.alpha = 100;
				
	// keep speeds non-negative
	
	if (localObj.angleSpeed < 0) 	localObj.angleSpeed = 0;
	if (localObj.angleXSpeed < 0) 	localObj.angleXSpeed = 0;
	if (localObj.angleYSpeed < 0) 	localObj.angleYSpeed = 0;
	if (localObj.XSpeed < 0) 		localObj.XSpeed = 0;
	if (localObj.upSpeed < 0) 		localObj.upSpeed = 0;
	if (localObj.downSpeed < 0) 	localObj.downSpeed = 0;
	if (localObj.ZSpeed < 0) 		localObj.ZSpeed = 0;
	if (localObj.WSpeed < 0) 		localObj.WSpeed = 0;
	if (localObj.HSpeed < 0) 		localObj.HSpeed = 0;
	if (localObj.scaleSpeed < 0) 	localObj.scaleSpeed = 0;
}

//-----------------------------------------------------------------

function widgetTransferWeatherInfo(weatherObj, globalObj)
{
	var obj = weatherObj;
	var useObj; 
	
	if (obj)
	{
		if (obj.forecast)
			if (obj.forecast[0])
			{
				foreObj = obj.forecast[0];

				globalObj.weather_icon				= foreObj.icon;
				
				globalObj.weather_tempF				= foreObj.temp;
				globalObj.weather_tempHiF			= foreObj.tempHi;
				globalObj.weather_tempLoF			= foreObj.tempLo;

				globalObj.weather_tempC				= toCelsius(foreObj.temp);
				globalObj.weather_tempHiC			= toCelsius(foreObj.tempHi);
				globalObj.weather_tempLoC			= toCelsius(foreObj.tempLo);
				
				globalObj.weather_humidity			= trimWhiteSpace(foreObj.humidity.replace(/%/g, " ")); // remove "%"
				globalObj.weather_windSpeed			= foreObj.windSpeed;
				
				if (foreObj.windDir == "N")			globalObj.weather_windAngle	= 0;
				if (foreObj.windDir == "NNE")		globalObj.weather_windAngle	= 22.5;
				if (foreObj.windDir == "NE")		globalObj.weather_windAngle	= 45;
				if (foreObj.windDir == "ENE")		globalObj.weather_windAngle	= 67.5;
				if (foreObj.windDir == "E")			globalObj.weather_windAngle	= 90;
				if (foreObj.windDir == "ESE")		globalObj.weather_windAngle	= 112.5;
				if (foreObj.windDir == "SE")		globalObj.weather_windAngle	= 135;
				if (foreObj.windDir == "SSE")		globalObj.weather_windAngle	= 157.5;
				if (foreObj.windDir == "S")			globalObj.weather_windAngle	= 180;
				if (foreObj.windDir == "SSW")		globalObj.weather_windAngle	= 202.5;
				if (foreObj.windDir == "SW")		globalObj.weather_windAngle	= 225;
				if (foreObj.windDir == "WSW")		globalObj.weather_windAngle	= 247.5;
				if (foreObj.windDir == "W")			globalObj.weather_windAngle	= 270;
				if (foreObj.windDir == "WNW")		globalObj.weather_windAngle	= 292.5;
				if (foreObj.windDir == "NW")		globalObj.weather_windAngle	= 315;
				if (foreObj.windDir == "NNW")		globalObj.weather_windAngle	= 337.5;
				
				// flip the angle so an image pointing up will point to where the wind is blowing *to*
				globalObj.weather_windAngle = globalObj.weather_windAngle-180;
				if (globalObj.weather_windAngle < 0) globalObj.weather_windAngle += 360;
				
				globalObj.weather_visibility		= foreObj.visibility;
				globalObj.weather_pressure			= foreObj.pressure;
				globalObj.weather_precip			= foreObj.precip;
				globalObj.weather_UVIndex			= foreObj.UVIndex;

				globalObj.weather_sunSet_hour		= foreObj.sunSet.hour;
				globalObj.weather_sunSet_minute		= foreObj.sunSet.minute;
				globalObj.weather_sunSetAngle12		= twelveHourAngle(foreObj.sunSet.hour, foreObj.sunSet.minute);
				
				globalObj.weather_sunRise_hour		= foreObj.sunRise.hour;
				globalObj.weather_sunRise_minute	= foreObj.sunRise.minute;
				globalObj.weather_sunRiseAngle12	= twelveHourAngle(foreObj.sunRise.hour, foreObj.sunRise.minute);
				
				globalObj.weather_moonSet_hour		= foreObj.moonSet.hour;
				globalObj.weather_moonSet_minute	= foreObj.moonSet.minute;
				globalObj.weather_moonSetAngle12	= twelveHourAngle(foreObj.moonSet.hour, foreObj.moonSet.minute);
				
				globalObj.weather_moonRise_hour		= foreObj.moonRise.hour;
				globalObj.weather_moonRise_minute	= foreObj.moonRise.minute;
				globalObj.weather_moonRiseAngle12	= twelveHourAngle(foreObj.moonRise.hour, foreObj.moonRise.minute);
			}
	}
}

//-----------------------------------------------------------------

function twelveHourAngle(hour, minute)
{
	if (hour >= 12)		hour = hour - 12;
	if (hour == 0)		hour = 12;
	
	minutePerc 	= minute / 60;
	hourPerc	= hour / 12;

	hourAngleDis = (hourPerc * 360);
	angle = hourAngleDis + (minutePerc * 360/12);

	return angle;
}

//-----------------------------------------------------------------

function widgetUpdateTime(globalObj)
{
	updateTime();
	
	var realDateObj = new Date(gCond_CurrentTime + globalObj.CurrentTimeOffset * 1000);
	var	realMs = realDateObj.getTime();
	var	deltaMs, customMs = realMs;
	
	delete realDateObj;
	
	if (globalObj.CurrentRealTime) 
	{
		if (globalObj.CurrentTimeScale != 1)
		{
			deltaMs 	= realMs-globalObj.CurrentRealTime;
			customMs	= globalObj.CurrentTime + deltaMs * globalObj.CurrentTimeScale;
		}
	}
	
	globalObj.LastRealTime		= globalObj.CurrentRealTime;
	globalObj.CurrentRealTime 	= realMs;
	
	var dateObj = new Date(customMs);
	
	globalObj.CurrentTime		= dateObj.getTime();
	globalObj.CurrentHours24 	= dateObj.getHours();
	globalObj.CurrentHours12 	= dateObj.getHours();
	globalObj.CurrentMinutes 	= dateObj.getMinutes();
	globalObj.CurrentSeconds 	= dateObj.getSeconds();
	globalObj.CurrentWeekday 	= dateObj.getDay();
	globalObj.CurrentDay    	= dateObj.getDate();
	globalObj.CurrentMonth   	= dateObj.getMonth()+1;   //!
	globalObj.CurrentYear    	= dateObj.getFullYear();

	delete dateObj;

	if (globalObj.CurrentHours12 >= 12)		globalObj.CurrentHours12 = globalObj.CurrentHours12 - 12;
	if (globalObj.CurrentHours12 == 0)		globalObj.CurrentHours12 = 12;
	
	globalObj.Current1000		= globalObj.CurrentTime % 1000;
	globalObj.Current100		= globalObj.CurrentTime % 100;
	globalObj.Current10			= globalObj.CurrentTime % 10;
	
	// time transitions, 'points' in time
	// '1' only once after the corresponding time unit changed
	
	globalObj.T1000Transition	= 0;
	globalObj.T100Transition	= 0;
	globalObj.T10Transition		= 0;
	globalObj.secondTransition	= 0;
	globalObj.minuteTransition	= 0;
	globalObj.hourTransition	= 0;
	globalObj.dayTransition		= 0;
	globalObj.monthTransition	= 0;

	if (globalObj.Last1000 		!= globalObj.Current1000)		globalObj.T1000Transition = 1;
	if (globalObj.Last100 		!= globalObj.Current100)		globalObj.T100Transition = 1;
	if (globalObj.Last10	 	!= globalObj.Current10)			globalObj.T10Transition = 1;
	if (globalObj.LastSecond 	!= globalObj.CurrentSeconds)	globalObj.secondTransition = 1;
	if (globalObj.LastMinute 	!= globalObj.CurrentMinutes)	globalObj.minuteTransition = 1;
	if (globalObj.LastHour 		!= globalObj.CurrentHours24)	globalObj.hourTransition = 1;
	if (globalObj.LastDay 		!= globalObj.CurrentDay)		globalObj.dayTransition = 1;
	if (globalObj.LastMonth 	!= globalObj.CurrentMonth)		globalObj.monthTransition = 1;

	globalObj.Last1000		= globalObj.Current1000;
	globalObj.Last100		= globalObj.Current100;
	globalObj.Last10		= globalObj.Current10;
	globalObj.LastSecond	= globalObj.CurrentSeconds;
	globalObj.LastMinute	= globalObj.CurrentMinutes;
	globalObj.LastHour		= globalObj.CurrentHours24;
	globalObj.LastDay		= globalObj.CurrentDay;
	globalObj.LastMonth		= globalObj.CurrentMonth;
	
	// angles for analog clocks
	// angle 0 is at the 12 o'clock position
	// postfix 'Dis' denotes discrete angles, i.e. they skip from one value to the next
	// the others vary smoothly between values
	
	msPerc		= (globalObj.CurrentTime % 1000) / 1000;
	secondPerc 	= globalObj.CurrentSeconds / 60;
	minutePerc 	= globalObj.CurrentMinutes / 60;
	hourPerc	= globalObj.CurrentHours12 / 12;
	hourPerc24	= globalObj.CurrentHours24 / 24;
	dayPerc		= globalObj.CurrentDay / 31;
	monthPerc	= globalObj.CurrentMonth / 12;

	globalObj.msAngle			= (msPerc * 360);
	
	globalObj.secondAngleDis	= (secondPerc * 360);
	globalObj.secondAngle		= globalObj.secondAngleDis + (msPerc * 360/60);

	globalObj.minuteAngleDis	= (minutePerc * 360); 							
	globalObj.minuteAngle		= globalObj.minuteAngleDis + (secondPerc * 360/60) + (msPerc * 360/60/60);
								
	globalObj.hourAngleDis		= (hourPerc * 360);
	globalObj.hourAngle			= globalObj.hourAngleDis + (minutePerc * 360/12) + (secondPerc * 360/12/60) + (msPerc * 360/12/60/60);

	globalObj.dayAngleDis		= (dayPerc * 360);						
	globalObj.dayAngle			= globalObj.dayAngleDis	+ (hourPerc * 360/31)  + (minutePerc * 360/31/60);						

	globalObj.monthAngleDis		= (monthPerc * 360);
	globalObj.monthAngle		= globalObj.monthAngleDis + (dayPerc * 360/12) + (hourPerc * 360/12/31);

	globalObj.hourAngleDis24	= (hourPerc24 * 360);
	globalObj.hourAngle24		= globalObj.hourAngleDis24 + (minutePerc * 360/24) + (secondPerc * 360/24/60);
}

//-----------------------------------------------------------------

function widgetReplaceFormatPlaceholders(globalObj, theText)
{
	var AmPm = "";
	var str;

	// first pick the proper language arrays

	var	WeekdayNames_		= WeekdayNames['0'];
	var	ShortWeekdayNames_	= ShortWeekdayNames['0'];
	var MonthNames_			= MonthNames['0'];
	var ShortMonthNames_	= ShortMonthNames['0'];

	if (WeekdayNames[LANGUAGE] 		!= undefined) 	WeekdayNames_ 		= WeekdayNames[LANGUAGE];
	if (ShortWeekdayNames[LANGUAGE]	!= undefined) 	ShortWeekdayNames_ 	= ShortWeekdayNames[LANGUAGE];
	if (MonthNames[LANGUAGE] 		!= undefined) 	MonthNames_ 		= MonthNames[LANGUAGE];
	if (ShortMonthNames[LANGUAGE]	!= undefined) 	ShortMonthNames_ 	= ShortMonthNames[LANGUAGE];

	if (globalObj.CurrentHours24 >= 12)	AmPm = "PM";
	else								AmPm = "AM";
	
	// replace format placeholders
	// NOTE: escape $ and . !!!
	
	str = sprintf("%02d", globalObj.CurrentHours12);
	theText = theText.replace(/\$HOUR012/g, str);
	theText = theText.replace(/\$HOUR12/g, globalObj.CurrentHours12);
	
	theText = theText.replace(/\$AMPM/g, AmPm);
	
	str = sprintf("%02d", globalObj.CurrentHours24);
	theText = theText.replace(/\$HOUR024/g, str);
	theText = theText.replace(/\$HOUR24/g, globalObj.CurrentHours24);
	
	str = sprintf("%02d", globalObj.CurrentMinutes);
	theText = theText.replace(/\$MINUTE0/g, str);
	theText = theText.replace(/\$MINUTE/g, globalObj.CurrentMinutes);
	
	str = sprintf("%02d", globalObj.CurrentSeconds);
	theText = theText.replace(/\$SECOND0/g, str);
	theText = theText.replace(/\$SECOND/g, globalObj.CurrentSeconds);
	
	str = sprintf("%03d", globalObj.Current1000);
	theText = theText.replace(/\$MS0/g, str);
	theText = theText.replace(/\$MS/g, globalObj.Current1000);
	
	str = sprintf("%02d", globalObj.Current100);
	theText = theText.replace(/\$HUNDREDTHS0/g, str);
	theText = theText.replace(/\$HUNDREDTHS/g, globalObj.Current100);
	
	str = sprintf("%d", globalObj.Current10);
	theText = theText.replace(/\$TENTHS/g, str);
	
	theText = theText.replace(/\$MONTH_NAME3/g, ShortMonthNames_[globalObj.CurrentMonth-1]);
	theText = theText.replace(/\$MONTH_NAME/g, MonthNames_[globalObj.CurrentMonth-1]);
	
	str = sprintf("%02d", globalObj.CurrentMonth);
	theText = theText.replace(/\$MONTH0/g, str);
	theText = theText.replace(/\$MONTH/g, globalObj.CurrentMonth);
	
	theText = theText.replace(/\$WEEKDAY3/g, ShortWeekdayNames_[globalObj.CurrentWeekday]);
	theText = theText.replace(/\$WEEKDAY/g, WeekdayNames_[globalObj.CurrentWeekday]);
	
	str = sprintf("%02d", globalObj.CurrentDay);
	theText = theText.replace(/\$DAY0/g, str);
	theText = theText.replace(/\$DAY/g, globalObj.CurrentDay);

	str = sprintf("%02d", globalObj.CurrentYear-2000);
	theText = theText.replace(/\$YEAR0/g, str);
	theText = theText.replace(/\$YEAR/g, globalObj.CurrentYear);

	str = sprintf("%.3f", globalObj.TextVar1);
	theText = theText.replace(/\$VAR1\.3/g, str);
	str = sprintf("%.2f", globalObj.TextVar1);
	theText = theText.replace(/\$VAR1\.2/g, str);
	str = sprintf("%.1f", globalObj.TextVar1);
	theText = theText.replace(/\$VAR1\.1/g, str);
	str = sprintf("%.0f", globalObj.TextVar1);
	theText = theText.replace(/\$VAR1\.0/g, str);
	theText = theText.replace(/\$VAR1/g, globalObj.TextVar1);

	str = sprintf("%.3f", globalObj.TextVar2);
	theText = theText.replace(/\$VAR2\.3/g, str);
	str = sprintf("%.2f", globalObj.TextVar2);
	theText = theText.replace(/\$VAR2\.2/g, str);
	str = sprintf("%.1f", globalObj.TextVar2);
	theText = theText.replace(/\$VAR2\.1/g, str);
	str = sprintf("%.0f", globalObj.TextVar2);
	theText = theText.replace(/\$VAR2\.0/g, str);
	theText = theText.replace(/\$VAR2/g, globalObj.TextVar2);

	str = sprintf("%.3f", globalObj.TextVar3);
	theText = theText.replace(/\$VAR3\.3/g, str);
	str = sprintf("%.2f", globalObj.TextVar3);
	theText = theText.replace(/\$VAR3\.2/g, str);
	str = sprintf("%.1f", globalObj.TextVar3);
	theText = theText.replace(/\$VAR3\.1/g, str);
	str = sprintf("%.0f", globalObj.TextVar3);
	theText = theText.replace(/\$VAR3\.0/g, str);
	theText = theText.replace(/\$VAR3/g, globalObj.TextVar3);
	
	//---

	theText = theText.replace(/\$MAIL_COUNT/g, gCond_NumMail);
	theText = theText.replace(/\$SMS_COUNT/g, gCond_NumSMS);
	theText = theText.replace(/\$CALLS_COUNT/g, gCond_NumPhone);
	
	str = sprintf("%.0f", gCond_SpaceUsed);
	theText = theText.replace(/\$SPACE_USED/g, str);

	str = sprintf("%d", gCond_BatteryLevel);
	theText = theText.replace(/\$BATTERY_LEVEL/g, str);
	
	//---
	{
		var obj = globalObj.weatherObj;
		
		if (obj)
		{
			var useObj 				= {error:false, errorString:null};
			var	fontSize 			= globalObj.fontSize;
			var	weatherIconsPath	= globalObj.weatherIconsPath;
			var	weatherIconSet		= globalObj.weatherIconSet;
			
			theText = theText.replace(/\$CITY/g, obj.city);
			
			if (obj.forecast)
				if (obj.forecast[0])
				{
					useObj = obj.forecast[0];
			
					theText = theText.replace(/\$CTF/g, useObj.temp + "&#176;F");
					theText = theText.replace(/\$RCTF/g, useObj.realFeel + "&#176;F");
					
					theText = theText.replace(/\$CTC/g, toCelsius(useObj.temp) + "&#176;C");
					theText = theText.replace(/\$RCTC/g, toCelsius(useObj.realFeel) + "&#176;C");

					theText = theText.replace(/\$HUM/g, useObj.humidity);
					theText = theText.replace(/\$PRESDIR/g, useObj.pressureDir);
					theText = theText.replace(/\$PRES/g, useObj.pressure);
					theText = theText.replace(/\$PRECIP/g, useObj.precip);
					theText = theText.replace(/\$SR/g, useObj.sunRise.str);
					theText = theText.replace(/\$SS/g, useObj.sunSet.str);
					theText = theText.replace(/\$MR/g, useObj.moonRise.str);
					theText = theText.replace(/\$MS/g, useObj.moonSet.str);
					theText = theText.replace(/\$UV/g, useObj.UVIndex);
					theText = theText.replace(/\$VIS/g, useObj.visibility);
					theText = theText.replace(/\$AIR/g, useObj.airQuality);
					theText = theText.replace(/\$PTREE/g, useObj.pollenTree);
					theText = theText.replace(/\$PWEED/g, useObj.pollenWeed);
					theText = theText.replace(/\$PGRASS/g, useObj.pollenGrass);
					theText = theText.replace(/\$PMOLD/g, useObj.pollenMold);
					
					for (i = 0; i <= 6; ++i)
					{
						if (obj.forecast[i])
						{
							tmpObj = obj.forecast[i];
							
							sel = sprintf("%02d", i);
							
							iconPath = weatherIconPath(weatherIconsPath, weatherIconSet, tmpObj.icon);
							
							rep = '<img src=' + "\"" + iconPath + "\"" + ' height="' + fontSize + 'px" alt="" align=absmiddle>';
							rx = new RegExp("\\$WICON"+sel, "gi"); 	theText = theText.replace(rx, rep);
							
							rep = '<img src=' + "\"" + iconPath + "\"" + ' height="' + (fontSize/2) + 'px" alt="" align=absmiddle>';
							rx = new RegExp("\\$SICON"+sel, "gi"); 	theText = theText.replace(rx, rep);
							
							rep = '<img src=' + "\"" + iconPath + "\"" + ' height="' + (fontSize*2) + 'px" alt="" align=absmiddle>';
							rx = new RegExp("\\$LICON"+sel, "gi"); 	theText = theText.replace(rx, rep);
							
							rx = new RegExp("\\$SD"+sel, "g");		theText = theText.replace(rx, tmpObj.desc);
							rx = new RegExp("\\$LD"+sel, "g");		theText = theText.replace(rx, tmpObj.longDesc);
							rx = new RegExp("\\$DAY"+sel, "g");		theText = theText.replace(rx, tmpObj.day);
							rx = new RegExp("\\$DATE"+sel, "g");	theText = theText.replace(rx, tmpObj.date);
						
							rx = new RegExp("\\$HTF"+sel, "g");		theText = theText.replace(rx, tmpObj.tempHi + "&#176;F");
							rx = new RegExp("\\$RHTF"+sel, "g");	theText = theText.replace(rx, tmpObj.realFeelHi + "&#176;F");
							rx = new RegExp("\\$LTF"+sel, "g");		theText = theText.replace(rx, tmpObj.tempLo + "&#176;F");
							rx = new RegExp("\\$RLTF"+sel, "g");	theText = theText.replace(rx, tmpObj.realFeelLo + "&#176;F");
						
							rx = new RegExp("\\$HTC"+sel, "g");		theText = theText.replace(rx, toCelsius(tmpObj.tempHi) + "&#176;C");
							rx = new RegExp("\\$RHTC"+sel, "g");	theText = theText.replace(rx, toCelsius(tmpObj.realFeelHi) + "&#176;C");
							rx = new RegExp("\\$LTC"+sel, "g");		theText = theText.replace(rx, toCelsius(tmpObj.tempLo) + "&#176;C");
							rx = new RegExp("\\$RLTC"+sel, "g");	theText = theText.replace(rx, toCelsius(tmpObj.realFeelLo) + "&#176;C");

							rx = new RegExp("\\$WS"+sel, "g");		theText = theText.replace(rx, tmpObj.windSpeed);
							rx = new RegExp("\\$WD"+sel, "g");		theText = theText.replace(rx, tmpObj.windDir);
							rx = new RegExp("\\$WG"+sel, "g");		theText = theText.replace(rx, tmpObj.windGust);
							rx = new RegExp("\\$RAIN"+sel, "g");	theText = theText.replace(rx, tmpObj.rainAmt);
							rx = new RegExp("\\$SNOW"+sel, "g");	theText = theText.replace(rx, tmpObj.snowAmt);
							rx = new RegExp("\\$PR"+sel, "g");		theText = theText.replace(rx, tmpObj.precipAmt);
							rx = new RegExp("\\$MAXUV"+sel, "g");	theText = theText.replace(rx, tmpObj.maxUV);
							rx = new RegExp("\\$TSTORM"+sel, "g");	theText = theText.replace(rx, tmpObj.tStormProb);
						}
					}
				}

			globalObj.waitForWeather = 0;
		}
	}
	//---
	
	return theText;
}

//-----------------------------------------------------------------

function widgetSine98(globalObj, localObj)
{
	localObj.oscillation98 = Math.sin(localObj.time98*2*Math.PI) / Math.exp(localObj.decay98*localObj.time98);
	localObj.direction98 = (Math.abs(localObj.oscillation98) >= Math.abs(globalObj.LastOscillation98)) ? 1 : -1;
	
	return localObj.offset98 + localObj.amplitude98 * localObj.oscillation98;
}

//-----------------------------------------------------------------

function widgetHalfSine98(globalObj, localObj)
{
	localObj.oscillation98 = Math.sin(localObj.time98*Math.PI) / Math.exp(localObj.decay98*localObj.time98);
	localObj.direction98 = (Math.abs(localObj.oscillation98) >= Math.abs(globalObj.LastOscillation98)) ? 1 : -1;
	
	return localObj.offset98 + localObj.amplitude98 * Math.abs( localObj.oscillation98 );
}

//-----------------------------------------------------------------

function widgetQuarterSine98(globalObj, localObj)
{
	localObj.oscillation98 = Math.sin(localObj.time98*Math.PI/2) / Math.exp(localObj.decay98*localObj.time98);
	localObj.direction98 = (Math.abs(localObj.oscillation98) >= Math.abs(globalObj.LastOscillation98)) ? 1 : -1;
	
	return localObj.offset98 + localObj.amplitude98 * Math.abs( localObj.oscillation98 );
}

//-----------------------------------------------------------------

function widgetSawtooth98(globalObj, localObj)
{
	localObj.oscillation98 = (localObj.time98*4) / Math.exp(localObj.decay98*localObj.time98);
	
	if (localObj.time98 <= 0.25) 		localObj.oscillation98 = localObj.oscillation98;
	else if (localObj.time98 <= 0.75)	localObj.oscillation98 = 2-localObj.oscillation98;
	else								localObj.oscillation98 = -(4-localObj.oscillation98);
	
	localObj.direction98 = (Math.abs(localObj.oscillation98) >= Math.abs(globalObj.LastOscillation98)) ? 1 : -1;
	
	return localObj.offset98 + localObj.amplitude98 * localObj.oscillation98;
}

//-----------------------------------------------------------------

function widgetHalfSawtooth98(globalObj, localObj)
{
	localObj.oscillation98 = (localObj.time98*2) / Math.exp(localObj.decay98*localObj.time98);
	
	if (localObj.time98 <= 0.5) localObj.oscillation98 = localObj.oscillation98;
	else						localObj.oscillation98 = 2-localObj.oscillation98;
	
	localObj.direction98 = (Math.abs(localObj.oscillation98) >= Math.abs(globalObj.LastOscillation98)) ? 1 : -1;
	
	return localObj.offset98 + localObj.amplitude98 * Math.abs( localObj.oscillation98 );
}

//-----------------------------------------------------------------

function widgetQuarterSawtooth98(globalObj, localObj)
{
	localObj.oscillation98 = localObj.time98 / Math.exp(localObj.decay98*localObj.time98);
	localObj.direction98 = (Math.abs(localObj.oscillation98) >= Math.abs(globalObj.LastOscillation98)) ? 1 : -1;
	
	return localObj.offset98 + localObj.amplitude98 * Math.abs( localObj.oscillation98 );
}

//-----------------------------------------------------------------

function widgetGetHSLA(colorStyle)
{
	var colorReRGBA		= /^(?:rgba)?\((\d{1,3}),\s?(\d{1,3}),\s?(\d{1,3}),\s?([0.123456789]{1,})\)$/i;
	var colorReRGB		= /^(?:rgb)?\((\d{1,3}),\s?(\d{1,3}),\s?(\d{1,3})\)$/i;
	var colorReHSLA		= /^(?:hsla)?\((\d{1,3})%,\s?(\d{1,3})%,\s?(\d{1,3})%,\s?([0.123456789]{1,})\)$/i;
	var colorReHSL		= /^(?:hsl)?\((\d{1,3})%,\s?(\d{1,3})%,\s?(\d{1,3})\)$/i;
	
	var	hue = 0, sat = 0, lite = 0, alpha = 100;
	
	if (colorStyle.indexOf("rgba") != -1)
	{
		var resArr = colorStyle.match(colorReRGBA);
		
		if (resArr)
		{
			var hslArr = rgbToHsl(resArr[1], resArr[2], resArr[3]);
			
			hue 	= hslArr[0];
			sat		= hslArr[1];
			lite 	= hslArr[2];
			alpha 	= resArr[4] * 100;
		}
		else
			return null;
	}
	else if (colorStyle.indexOf("rgb") != -1)
	{
		var resArr = colorStyle.match(colorReRGB);
		
		if (resArr)
		{
			var hslArr = rgbToHsl(resArr[1], resArr[2], resArr[3]);
			
			hue 	= hslArr[0];
			sat		= hslArr[1];
			lite 	= hslArr[2];
		}
		else
			return null;
	}
	else if (colorStyle.indexOf("hsla") != -1)
	{
		var resArr = colorStyle.match(colorReHSLA);
		
		if (resArr)
		{
			hue 	= resArr[1];
			sat		= resArr[2];
			lite 	= resArr[3];
			alpha 	= resArr[4] * 100;
		}
		else
			return null;
	}
	else if (colorStyle.indexOf("hsl") != -1)
	{
		var resArr = colorStyle.match(colorReHSL);
		
		if (resArr)
		{
			hue 	= resArr[1];
			sat		= resArr[2];
			lite 	= resArr[3];
		}
		else
			return null;
	}
	else
		return null;
	
	return [hue, sat, lite, alpha];
}

//-----------------------------------------------------------------

function updateTime()
{
	var realDateObj = new Date();
	var	realMs = realDateObj.getTime() + gCond_CurrentTimeOffset * 1000;
	var	deltaMs, customMs = realMs;

	delete realDateObj;
		
	if (gCond_CurrentRealTime) 
	{
		if (gCond_CurrentTimeScale != 1)
		{
			deltaMs 	= realMs-gCond_CurrentRealTime;
			customMs	= gCond_CurrentTime + deltaMs * gCond_CurrentTimeScale;
		}
	}
	
	gCond_CurrentRealTime = realMs;
	
	var dateObj = new Date(customMs);
	
	gCond_CurrentTime		= dateObj.getTime();
	gCond_CurrentHours24 	= dateObj.getHours();
	gCond_CurrentHours12 	= dateObj.getHours();
	gCond_CurrentMinutes 	= dateObj.getMinutes();
	gCond_CurrentSeconds 	= dateObj.getSeconds();
	gCond_CurrentWeekday 	= dateObj.getDay();
	gCond_CurrentDay    	= dateObj.getDate();
	gCond_CurrentMonth   	= dateObj.getMonth()+1;   //!
	gCond_CurrentYear    	= dateObj.getFullYear();

	delete dateObj;

	if (gCond_CurrentHours12 >= 12)	gCond_CurrentHours12 = gCond_CurrentHours12 - 12;
	if (gCond_CurrentHours12 == 0)	gCond_CurrentHours12 = 12;

	// time transitions, 'points' in time
	// '1' only once after the corresponding time unit changed
	
	gCond_secondTransition	= 0;
	gCond_minuteTransition	= 0;
	gCond_hourTransition	= 0;
	gCond_dayTransition		= 0;
	gCond_monthTransition	= 0;

	if (gCond_LastSecond != gCond_CurrentSeconds)	gCond_secondTransition = 1;
	if (gCond_LastMinute != gCond_CurrentMinutes)	gCond_minuteTransition = 1;
	if (gCond_LastHour != gCond_CurrentHours24)		gCond_hourTransition = 1;
	if (gCond_LastDay != gCond_CurrentDay)			gCond_dayTransition = 1;
	if (gCond_LastMonth != gCond_CurrentMonth)		gCond_monthTransition = 1;

	gCond_LastSecond	= gCond_CurrentSeconds;
	gCond_LastMinute	= gCond_CurrentMinutes;
	gCond_LastHour		= gCond_CurrentHours24;
	gCond_LastDay		= gCond_CurrentDay;
	gCond_LastMonth		= gCond_CurrentMonth;
}

//-----------------------------------------------------------------

function updateConditions()
{
	//---
	// time and date
	//---
	{
		updateTime();
	}

	//---
	// special dates
	//---
	{
	}

	//---
	// device orientation
	//---
	{
		gCond_DeviceAngle = gLastValidAngle;
			
		try
		{
			var Database;
			var tag;
			var	fileData;
			
			fileData = loadLocalFile("/tmp/Orientation.xml");
			
			Database = findChild(fileData, "bSE_Database");
			if (Database) 
			{
				tag = findChild(Database, "Angle");
				if (tag) gCond_DeviceAngle = parseInt(trimWhiteSpace(tag.firstChild.data), 10);
			}
		}
		
		catch(err)
		{}
		
		gLastValidAngle	= gCond_DeviceAngle;
		
		//---
		DEVICE_ANGLE = gCond_DeviceAngle;
		//---
		
		if ((gCond_DeviceAngle == 90)||(gCond_DeviceAngle == -90))
		{
			gCond_Portrait 	= 0;
			gCond_Landscape	= 1;

			gDevice_ScreenWidth		= gDevice_ScreenMaxDim;
			gDevice_ScreenHeight	= gDevice_ScreenMinDim;
		}
		else
		{
			gCond_Portrait	= 1;
			gCond_Landscape	= 0;

			gDevice_ScreenWidth		= gDevice_ScreenMinDim;
			gDevice_ScreenHeight	= gDevice_ScreenMaxDim;
		}
	}
		
	//---
	// battery status
	//---
	{
		/* retain previous values to avoid flashing if file is not accessible
		
		gCond_BatteryLevel			= 0;
		gCond_BatteryDischarging 	= 0;
		gCond_BatteryCharging 		= 0;
		gCond_BatteryFull 			= 0;
		gCond_BatteryAngle			= 0;

		gDevice_Name				= "";
		gDevice_SystemVersion		= "";
		
		*/
		
		try
		{
			var Database;
			var tag;
			var	fileData;
			
			fileData = loadLocalFile("/tmp/DeviceInfo.xml");
			
			Database = findChild(fileData, "bSE_Database");
			if (Database) 
			{
				tag = findChild(Database, "BatteryState");
				if (tag) 
				{
					var batteryState;
					batteryState = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

					if (batteryState == 1)	gCond_BatteryDischarging = 1;
					if (batteryState == 2)	gCond_BatteryCharging = 1;
					if (batteryState == 3)	gCond_BatteryFull = 1;
				}
				
				tag = findChild(Database, "BatteryLevel");
				if (tag) 
				{
					gCond_BatteryLevel = trimWhiteSpace(tag.firstChild.data) * 100.0;
				}

				tag = findChild(Database, "Name");
				if (tag) gDevice_Name = trimWhiteSpace(tag.firstChild.data);

				tag = findChild(Database, "SystemVersion");
				if (tag) gDevice_SystemVersion = trimWhiteSpace(tag.firstChild.data);
				
				gCond_BatteryAngle = gCond_BatteryLevel * 3.599;
			}
		}
		
		catch(err)
		{}
	}

	//---
	// widget info
	//---
	{
		/* retain previous values to avoid flashing if file is not accessible
		
		gCond_NumMail				= 0;
		gCond_NumSMS				= 0;
		gCond_NumPhone				= 0;
		gCond_SpaceUsed				= 0;
		
		gDevice_PhoneNumber			= "";
		gDevice_Language			= "";
		
		*/
		
		try
		{
			var Database;
			var tag;
			var fileData;
			
			fileData = loadLocalFile("/tmp/WidgetInfo.xml");
			
			Database = findChild(fileData, "bSE_Database");
			if (Database) 
			{
				tag = findChild(Database, "Mail");
				if (tag) gCond_NumMail = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(Database, "SMS");
				if (tag) gCond_NumSMS = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(Database, "Call");
				if (tag) gCond_NumPhone = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(Database, "SpaceUsed");
				if (tag) gCond_SpaceUsed = parseInt(trimWhiteSpace(tag.firstChild.data), 10);

				tag = findChild(Database, "Phone");
				if (tag) gDevice_PhoneNumber = trimWhiteSpace(tag.firstChild.data);

				tag = findChild(Database, "Language");
				if (tag) gDevice_Language = trimWhiteSpace(tag.firstChild.data);
			}
		}
		
		catch(err)
		{}
	}
}

//-----------------------------------------------------------------

function updateOrientation()
{
	updateConditions();
	adjustOrientation();
}

//-----------------------------------------------------------------

function adjustOrientation()
{
	var		forceOrientation 		= -1; // -2: 'do nothing', -1: 'auto';
	var		mode 					= "LS";
	var		lockScreenAutoRotates 	= 0;

	var		orientationOffset 	= (gDevice_ScreenMaxDim-gDevice_ScreenMinDim)/2;
	var		debug			 	= gDevice_Debug;
	var		minDim		 		= gDevice_ScreenMinDim;
	var		maxDim		 		= gDevice_ScreenMaxDim;
	
	var 	left = 0, top = 0, orientation = 0, rotAngle = 0, width, height, topRotationOffset, leftRotationOffset, currentOrientation, doOpposite = -2;
	var 	refWidth, refHeight, imgWidth, imgHeight, img1_left, img1_top, img2_left, img2_top, img3_left, img3_top;
	var		whichScreen, isWebPage = 0;
	var 	pageName;
	var 	loc;	

	// lock screen rotates - adjust image and widget layer offsets to keep both centered on screen
	// home screen does *not* rotate and does not change width/height, so we have to use 'DEVICE_ANGLE'

	if (gPageHidden)
		return;
	
	if (forceOrientation == -2)
		return;

{	
	// get the mode of the 'parent' screen
	// we need to handle web pages (WPn) differently depending on which screen they're on
	
	// also get the angle from the parent screen
	// (trying to get the updates in order)
	
	try
	{
		whichScreen = parent.document.getElementById('pageID').innerText;
	}
	
	catch(err)
	{
		whichScreen = "???";
	}
	
	// look for an anchor tag specifying the mode of the parent screen
	// this is for links that come from the lock screen
	
	loc = document.location.href;	
	pageName = loc.substring(loc.lastIndexOf('/')+1);
	
	if (pageName.match("#LS"))
		whichScreen = "LS";
		
	//---
	
	if ((mode == "WP1")
		||(mode == "WP2")
		||(mode == "WP3")
		||(mode == "WP4")
	)
	isWebPage = 1;
}

	if (gPageAngle != -1)	currentOrientation	= gPageAngle;
	else					currentOrientation	= DEVICE_ANGLE;
	
	//---
	
	if (forceOrientation != -1)	orientation = forceOrientation;
	else						orientation = currentOrientation;

	if ((forceOrientation == 90)||(forceOrientation == -90))
	{
		width 	= maxDim;
		height	= minDim;
	}
	else
	{
		width 	= minDim;
		height	= maxDim;
	}

	//---
	
	refWidth			= width;
	refHeight			= height;
	
    left 				= 0;
    top 				= 0;
	rotAngle 			= 0;
	leftRotationOffset 	= 0;
    topRotationOffset 	= 0;
	
	if (((mode == "LS")||(whichScreen == "LS"))
		&&(lockScreenAutoRotates)
	)
	{
		if (forceOrientation != -1)
		{
			switch(orientation)
			{
				case 0:
						switch(currentOrientation)
						{
							case 0:		
	    						left 				= 0;
	    						top 				= 0;
	    						rotAngle 			= 0;
							break;

							case 90:	
	    						left 				= 2*orientationOffset;
	    						top 				= 0;
	    						rotAngle 			= -90;
							break;
							
							case 180:	
	    						left 				= 2*orientationOffset;
	    						top 				= 0;
	    						rotAngle 			= 180;
							break;
							
							case -90:	
	    						left 				= 0;
	    						top 				= 0;
	    						rotAngle 			= 90;
							break;
						}
				break;
				
				case 90:
						switch(currentOrientation)
						{
							case 0:		
	    						left 				= orientationOffset;
	    						top 				= orientationOffset;
	    						rotAngle 			= 90;
							break;
							
							case 90:	
	    						left 				= orientationOffset;
	    						top 				= -orientationOffset;
	    						rotAngle 			= 0;
							break;

							case 180:	
	    						left 				= orientationOffset;
	    						top 				= -orientationOffset;
	    						rotAngle 			= -90;
							break;
							
							case -90:	
	    						left 				= orientationOffset;
	    						top 				= orientationOffset;
	    						rotAngle 			= 180;
							break;
						}
				break;
				
				case 180:
						switch(currentOrientation)
						{
							case 0:		
	    						left 				= 2*orientationOffset;
	    						top 				= 0;
	    						rotAngle 			= 180;
							break;
							
							case 90:	
	    						left 				= 0;
	    						top 				= 0;
	    						rotAngle 			= 90;
							break;
							
							case 180:	
	    						left 				= 0;
	    						top 				= 0;
	    						rotAngle 			= 0;
							break;

							case -90:	
	    						left 				= 2*orientationOffset;
	    						top 				= 0;
	    						rotAngle 			= -90;
							break;
						}
				break;
				
				case -90:
						switch(currentOrientation)
						{
							case 0:		
	    						left 				= orientationOffset;
	    						top 				= -orientationOffset;
	    						rotAngle 			= -90;
							break;
							
							case 90:	
	    						left 				= orientationOffset;
	    						top 				= orientationOffset;
	    						rotAngle 			= 180;
							break;
							
							case 180:	
	    						left 				= orientationOffset;
	    						top 				= orientationOffset;
	    						rotAngle 			= 90;
							break;
							
							case -90:	
	    						left 				= orientationOffset;
	    						top 				= -orientationOffset;
	    						rotAngle 			= 0;
							break;
						}
				break;
			}
			
			if (width > height)	
			{
				refWidth	= height;
				refHeight	= width;
			}
			else
			{
				refWidth	= width;
				refHeight	= height;
			}

			doOpposite = 1;
		}
		else
		{
			if ((orientation == 90)||(orientation == -90))
			{
		    	left 			= orientationOffset;
		    	top 			= -orientationOffset;
			}
		}
	}
	else if (((mode == "HS")||(whichScreen == "HS"))
			||((mode == "LS")||(whichScreen == "LS"))
	)
	{
		if (orientation == 180) // Portrait (upside-down)
		{
	    	rotAngle 			= 180;
	    	left 				= 2*orientationOffset;
		}
		else if (orientation == -90) // Landscape (home button left, screen turned clockwise)
		{
	    	left 				= orientationOffset;
	    	top 				= -orientationOffset;
	    	rotAngle 			= -90;
		}
		else if (orientation == 90)	// Landscape (home button right, screen turned counterclockwise)
		{
	    	left 				= orientationOffset;
	    	top					= orientationOffset;
	    	rotAngle 			= 90;
		}

		if (width > height)	
		{
			refWidth	= height;
			refHeight	= width;
		}
		else
		{
			refWidth	= width;
			refHeight	= height;
		}
	}
	
	//---
	// set rotation of top enclosing layer	
	
	if (gLast_rotAngle != rotAngle)
	{
		document.getElementById("Background").style.webkitTransform = sprintf("rotate(%ddeg) skew(0deg) scale(1.0) translate(%dpx,%dpx)", rotAngle, 0, 0);
	}
	
	// set offsets of widget layer (encloses background images)
	
	if ((gLast_left != left)||(gLast_top != top))
	{
		document.getElementById("WidgetLayer").style.left	= sprintf("%dpx", left);
		document.getElementById("WidgetLayer").style.top	= sprintf("%dpx", top);	
	}
		
	//---
	// center the background images
	
	//---
	img = document.getElementById('DefaultBackgroundImage');

	imgWidth 	= img.naturalWidth;
	imgHeight 	= img.naturalHeight;
	
	img1_left	= (refWidth-imgWidth)/2 + leftRotationOffset;
	img1_top	= (refHeight-imgHeight)/2 + topRotationOffset;
	
	if ((gLast_img1_left != img1_left)||(gLast_img1_top != img1_top))
	{
		img.style.left	= sprintf("%dpx", img1_left);
		img.style.top	= sprintf("%dpx", img1_top);
	}
	
	//---
	img = document.getElementById('BackgroundImage');

	imgWidth 	= img.naturalWidth;
	imgHeight 	= img.naturalHeight;
	
	img2_left	= (refWidth-imgWidth)/2 + leftRotationOffset;
	img2_top	= (refHeight-imgHeight)/2 + topRotationOffset;
	
	if ((gLast_img2_left != img2_left)||(gLast_img2_top != img2_top))
	{
		img.style.left	= sprintf("%dpx", img2_left);
		img.style.top	= sprintf("%dpx", img2_top);
	}
	
	//---
	
	gLast_left			= left;
	gLast_top			= top;
	gLast_rotAngle		= rotAngle;
	gLast_img1_left		= img1_left;
	gLast_img1_top		= img1_top;
	gLast_img2_left		= img2_left;
	gLast_img2_top		= img2_top;

	//---
	
	if ((1)&&(debug))
	{
		document.getElementById("debug"+mode).style.display = 'block';
		
		document.getElementById("debug"+mode).innerHTML = sprintf(
		"Orientation: %d<br>Screen: %d x %d<br>Ref: %d x %d<br>Image: %d x %d<br>"
		+"ForceOri: %d<br>WinOri: %d<br>DevOri: %d<br>CurOri: %d<br>LT: %d, %d<br>Offset: %d<br>Angle: %d<br>Opposite: %d<br>"
		+"Mode: %s<br>WhichScreen: %s<br>PageName: %s<br>Seconds: %d<br>"
		, orientation
		, width, height
		, refWidth, refHeight
		, imgWidth, imgHeight
		, forceOrientation
		, window.orientation
		, DEVICE_ANGLE
		, currentOrientation
		, left, top
		, orientationOffset
		, rotAngle
		, doOpposite
		, mode
		, whichScreen
		, pageName
		, gCond_CurrentSeconds
		);
	}
	
	//---
	
	if (gOrientationIntervalID)
	{
		clearInterval( gOrientationIntervalID );
		gOrientationIntervalID = 0;
	}
	
	if (gOrientationInterval)
		gOrientationIntervalID = setInterval(updateOrientation, gOrientationInterval);
}

//-----------------------------------------------------------------

function onLoad()
{
	if (gOrientationInterval)
		updateOrientation();
	
	window.onorientationchange=updateOrientation;
	
	//---

	

   DefaultBackgroundImageLoad(0);



	W2010061616144808CheckConditions();
	


	W2010061616144807CheckConditions();
	


	W2010061616144806CheckConditions();
	


	W2010061616144805CheckConditions();
	


	W2010061616144804CheckConditions();
	


	W2010061616144803CheckConditions();
	


	W2010061616144802CheckConditions();
	


	W2010061616144801CheckConditions();
	


	W2010061616144800CheckConditions();
	


	
	//---

	if (gOnLoadIntervalID)
	{
		clearInterval( gOnLoadIntervalID );
		gOnLoadIntervalID = 0;
	}
	
	gOnLoadIntervalID = setInterval(onLoad, 1000 * gOnLoadInterval);
	
	if (! gOnLoadCount)
	{
		var	theMainObj = document.getElementById("Main");
		
		if (theMainObj)
			if (theMainObj.style.display == 'none')
				theMainObj.style.display = 'block';
	}
	
	checkReload();
}

//-----------------------------------------------------------------

function reLoad()
{
	if (gOnLoadIntervalID)
	{
		clearInterval( gOnLoadIntervalID );
		gOnLoadIntervalID = 0;
	}
	
	gOnLoadIntervalID = setInterval(onLoad, 200);
}

//-----------------------------------------------------------------

function checkReload()
{
	if (gOnLoadCount)
	{
		if (gDoReload)
		{
			gDoReload = 0;
			window.location.href = window.location.href;
			window.location.reload(true);
		}
	}

	++gOnLoadCount;
}

//-----------------------------------------------------------------

function loadLocalFile(url)
{
	var responseXML;
	var responseText;

	if (ON_DEVICE)
	{
		var xmlReq = new XMLHttpRequest();

	//	xmlReq.onreadystatechange = function(e){updateOrientationCallback(e, xmlReq);} // synchronous!

		xmlReq.overrideMimeType("text/xml");
		xmlReq.open("GET", url, false); // synchronous!
		xmlReq.setRequestHeader("Cache-Control", "no-cache");
		xmlReq.setRequestHeader("wx", "385");
		xmlReq.send(null); 
		responseXML = xmlReq.responseXML;
		delete xmlReq;
		return responseXML;
	}
	else
	{
		responseText = '<?xml version="1.0" encoding="LATIN1"?>';
		responseText += '<bSE_Database>';
		
		if (url == "/tmp/Orientation.xml")
		{
			responseText += ''
			+'<Orientation>1</Orientation>'
			+'<Angle>0</Angle>'
			;
		}
		else if (url == "/tmp/DeviceInfo.xml")
		{
			responseText += ''
			+'<BatteryState>2</BatteryState>'
			+'<BatteryLevel>1.000000</BatteryLevel>'
			+'<Orientation>1</Orientation>'
			+'<SystemName>iPhone OS</SystemName>'
			+'<SystemVersion>3.2</SystemVersion>'
			+'<Name>iFunPad</Name>'
			+'<Model>iPad</Model>'
			+'<UUID>0000000000000000000000000000000000000000</UUID>'
			+'<Proximity>0</Proximity>'
			;
		}
		else if (url == "/tmp/WidgetInfo.xml")
		{
			responseText += ''
			+'<Mail>49</Mail>'
			+'<Call>0</Call>'
			+'<SMS>0</SMS>'
			+'<Calendar>0</Calendar>'
			+'<Phone></Phone>'
			+'<Language>en</Language>'
			+'<SpaceUsed>38</SpaceUsed>'
			;
		}

		responseText += '</bSE_Database>';

		parser = new DOMParser();
		responseXML = parser.parseFromString(responseText,"text/xml");
		delete parser;
		return responseXML;
	}
}

//-----------------------------------------------------------------

