var g_functionToCall = "MicrosoftGadget.requestUpdate()";
var gDefaultDisplayMode = "docked";
var gDisplaySizeDocked = { width: 130, height: 67 }
var gDisplaySizeUnDocked = { width: 264, height: 194 }
var gDefaultRefreshInterval = 60;
var gDefaultPollingForServiceExistence = 1;
var gDefaultSunRise = "06:30:00";
var gDefaultSunSet = "18:30:00";
var gDefaultWeatherLocation = getLocalizedString('DefaultCity');
var gDefaultWeatherLocationCode = getLocalizedString('DefaultLocationCode');
var gDefaultDisplayDegreesIn = 'Celsius';
var gTimeStampLastRefreshAvailable = false;
var gTimeToNextRefresh = 1; // default to 1 minute
var gMinimumDistance = 10; // Threshold distance (in kilometres) to do a location update ( when recieving location change events )
var bUseCelsius = false;
var LCID_ARRAY = new Array(1025,1028,1029,1030,1031,1032,1033,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1053,1054,1055,1056,1057,1058,1060,1061,1062,1063,1068,1070,1080,1081,1083,1106,1117,1122,1124,1131,1134,1135,1146,1153,1158,2049,2052,2055,2057,2058,2060,2064,2067,2068,2070,2074,2092,2094,2107,2108,2141,2155,3073,3076,3079,3081,3082,3084,3098,3131,3179,4097,4100,4103,4105,4106,4108,4155,5121,5127,5129,5130,5132,5146,5179,6145,6153,6154,6156,6203,7169,7177,7178,7227,8193,8202,8218,8251,9217,9226,9275,10241,10250,11265,11274,12289,12298,13313,13321,13322,14337,15361,15370,16385,16393,16394,17417,17418,18441,18442,19466,20490,21514);
var LOCCODE_ARRAY = new Array("wc:SAXX0017","wc:TWXX0021","wc:EZXX0012","wc:DAXX0009","wc:GMXX0007","wc:GRXX0004","wc:USNY0996","wc:FIXX0002","wc:FRXX0076","wc:ISXX0010","wc:HUXX0002","wc:ICXX0002","wc:ITXX0067","wc:JAXX0085","wc:KSXX0037","wc:NLXX0002","wc:NOXX0029","wc:PLXX0028","wc:BRXX0232","wc:7162","wc:ROXX0003","wc:RSXX0063","wc:HRXX0005","wc:LOXX0001","wc:SWXX0031","wc:THXX0002","wc:TUXX0014","wc:PKXX0008","wc:IDXX0022","wc:UPXX0016","wc:SIXX0002","wc:ENXX0004","wc:LGXX0004","wc:LHXX0005","wc:AJXX0001","wc:3166","wc:33739","wc:INXX0096","wc:9734330","wc:UKXX0030","wc:CAXX0202","wc:NLXX0002","wc:RPXX0017","wc:BLXX0006","wc:LUXX0003","wc:GLXX0003","wc:CIXX0020","wc:NZXX0049","wc:GTXX0002","wc:IZXX0008","wc:CHXX0008","wc:SZXX0033","wc:UKXX0085","wc:MXDF0132","wc:BEXX0005","wc:SZXX0005","wc:BEXX0005","wc:NOXX0029","wc:POXX0016","wc:YIXX0005","wc:AJXX0001","wc:GMXX0171","wc:SWXX0019","wc:EIXX0014","wc:CAXX0202","wc:ECXX0008","wc:EGXX0004","wc:CHXX0049","wc:AUXX0025","wc:ASXX0023","wc:SPXX0050","wc:CAXX0385","wc:YIXX0005","wc:8633427","wc:PEXX0011","wc:LYXX0009","wc:SNXX0006","wc:LUXX0003","wc:CAXX0343","wc:GTXX0002","wc:SZXX0013","wc:9746201","wc:AGXX0001","wc:LSXX0002","wc:NZXX0049","wc:CSXX0009","wc:LUXX0003","wc:BKXX0004","wc:SWXX0019","wc:MOXX0007","wc:EIXX0014","wc:PMXX0004","wc:8548036","wc:NOXX0049","wc:TSXX0010","wc:SFXX0023","wc:DRXX0009","wc:24724","wc:MUXX0003","wc:VEXX0008","wc:BKXX0004","wc:8633427","wc:YMXX0005","wc:COXX0004","wc:8633427","wc:SYXX0004","wc:PEXX0011","wc:JOXX0002","wc:ARBA0009","wc:LEXX0003","wc:ECXX0008","wc:KUXX0003","wc:RPXX0017","wc:CIXX0020","wc:AEXX0004","wc:BAXX0001","wc:PAXX0001","wc:QAXX0003","wc:INXX0096","wc:BLXX0006","wc:MYXX0008","wc:ESXX0001","wc:SNXX0006","wc:HOXX0008","wc:NUXX0004","wc:USPR0087","wc:USCA0638","wc:MXDF0132","wc:USWA0367","wc:AEXX0004","wc:AEXX0004");
var UNIT_ARRAY = new Array("C","C","C","C","C","C","F","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","C","F","C","C","C","C");
// If new latlong event fired with location coordinates more than the
// threshold distance since the last attempt to update using location coordinates, update using new coordinates recieved
// NOTE: This assumes that the location sensor is working ie REPORT_RUNNING state (4) since latlong is only recieved through events when reports are running
{
self.clearWeatherUpdateTimer();
bTimerReset = true;
System.Debug.outputString("Updating weather to new location");
self.lastPositionUsedForGPSQuery = currentPosition; // Always maintain current GPS position locally before calling getCurrentLocationCode()