var source = 'yahooWeather'
var	enabled = true;
var postal;
var GMT = 0;

function onLoad(){
	document.getElementById("clock").style.display = "block";
	updateClock();
	updateCalendarBar();
	updateElements();
	setInterval("updateClock(); updateCalendarBar(); updateElements();", "2000");
	if (enabled == true){ 
	document.getElementById("weatherIcon").src="Private/WeatherIcons/"+"dunno"+".png";
	validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)
	}else{
		document.getElementsByTagName("body")[0].innerText='';
	}
}

//This affects the calendar.
function updateCalendarBar() {
	var theDate = new Date();
	var theWeekday = theDate.getDay();
	var theMonth = theDate.getMonth();
	var theDay = theDate.getDate();

if (language == 'EN') {	
	
	var weekdaysArray = new Array();
	//Change the Weekdays here
	weekdaysArray[0] = "sunday";
	weekdaysArray[1] = "monday";
	weekdaysArray[2] = "tuesday";
	weekdaysArray[3] = "wednesday";
	weekdaysArray[4] = "thursday";
	weekdaysArray[5] = "friday";
	weekdaysArray[6] = "saturday";
	theWeekday = weekdaysArray[theWeekday];
	
	
	var monthsArray = new Array();
	//Change the Months here
	monthsArray[0] = "January";
	monthsArray[1] = "February";
	monthsArray[2] = "March";
	monthsArray[3] = "April";
	monthsArray[4] = "May";
	monthsArray[5] = "June";
	monthsArray[6] = "July";
	monthsArray[7] = "August";
	monthsArray[8] = "September";
	monthsArray[9] = "October";
	monthsArray[10] = "November";
	monthsArray[11] = "December";
	theMonth = monthsArray[theMonth];
	
} else if (language == 'FR') {	
	
	//This affects the calendar.
	var weekdaysArray = new Array();
	//Change the Weekdays here
	weekdaysArray[0] = "dimanche";
	weekdaysArray[1] = "lundi";
	weekdaysArray[2] = "mardi";
	weekdaysArray[3] = "mercredi";
	weekdaysArray[4] = "jeudi";
	weekdaysArray[5] = "vendredi";
	weekdaysArray[6] = "samedi";
	theWeekday = weekdaysArray[theWeekday];
	
	var monthsArray = new Array();
	//Change the Months here
	monthsArray[0] = "Janvier";
	monthsArray[1] = "Fevrier";
	monthsArray[2] = "Mars";
	monthsArray[3] = "Avril";
	monthsArray[4] = "Mai";
	monthsArray[5] = "Juin";
	monthsArray[6] = "Juillet";
	monthsArray[7] = "Aout";
	monthsArray[8] = "Septembre";
	monthsArray[9] = "Octobre";
	monthsArray[10] = "Novembre";
	monthsArray[11] = "Decembre";
	theMonth = monthsArray[theMonth];
	
} else if (language == 'IT') {	
	
	//This affects the calendar.
	var weekdaysArray = new Array();
	//Change the Weekdays here
	weekdaysArray[0] = "Domenica";
	weekdaysArray[1] = "Lunedì";
	weekdaysArray[2] = "Martedì";
	weekdaysArray[3] = "Mercoledì";
	weekdaysArray[4] = "Giovedì";
	weekdaysArray[5] = "Venerdì";
	weekdaysArray[6] = "Sabato";
	theWeekday = weekdaysArray[theWeekday];
	
	var monthsArray = new Array();
	//Change the Months here
	monthsArray[0] = "Gennaio";
	monthsArray[1] = "Febbraio";
	monthsArray[2] = "Marzo";
	monthsArray[3] = "Aprile";
	monthsArray[4] = "Maggio";
	monthsArray[5] = "Giugno";
	monthsArray[6] = "Luglio";
	monthsArray[7] = "Agosto";
	monthsArray[8] = "Settembre";
	monthsArray[9] = "Ottobre";
	monthsArray[10] = "Novembre";
	monthsArray[11] = "Dicembre";
	theMonth = monthsArray[theMonth];
	
} else if (language == 'ES') {	
	
	//This affects the calendar.
	var weekdaysArray = new Array();
	//Change the Weekdays here
	weekdaysArray[0] = "Domingo";
	weekdaysArray[1] = "Lunes";
	weekdaysArray[2] = "Martes";
	weekdaysArray[3] = "Miércoles";
	weekdaysArray[4] = "Jueves";
	weekdaysArray[5] = "Viernes";
	weekdaysArray[6] = "Sábado";
	theWeekday = weekdaysArray[theWeekday];
	
	var monthsArray = new Array();
	//Change the Months here
	monthsArray[0] = "Enero";
	monthsArray[1] = "Febrero";
	monthsArray[2] = "Marzo";
	monthsArray[3] = "Abril";
	monthsArray[4] = "Mayo";
	monthsArray[5] = "Junio";
	monthsArray[6] = "Julio";
	monthsArray[7] = "Agosto";
	monthsArray[8] = "Septiembre";
	monthsArray[9] = "Octubre";
	monthsArray[10] = "Noviembre";
	monthsArray[11] = "Diciembre";
	theMonth = monthsArray[theMonth];
	
} else if (language == 'DE') {	
	
	//This affects the calendar.
	var weekdaysArray = new Array();
       //Change the Weekdays here
       weekdaysArray[0] = "Sonntag";
       weekdaysArray[1] = "Montag";
       weekdaysArray[2] = "Dienstag";
       weekdaysArray[3] = "Mittwoch";
       weekdaysArray[4] = "Donnerstag";
       weekdaysArray[5] = "Freitag";
       weekdaysArray[6] = "Samstag";
	theWeekday = weekdaysArray[theWeekday];
	
	var monthsArray = new Array();
       //Change the Months here
       monthsArray[0] = "Januar";
       monthsArray[1] = "Februar";
       monthsArray[2] = "März";
       monthsArray[3] = "April";
       monthsArray[4] = "Mai";
       monthsArray[5] = "Juni";
       monthsArray[6] = "Juli";
       monthsArray[7] = "August";
       monthsArray[8] = "September";
       monthsArray[9] = "Oktober";
       monthsArray[10] = "November";
       monthsArray[11] = "Dezember";
	theMonth = monthsArray[theMonth];
	
};	
	if (theDay < 10) {theDay = "0" + theDay};
	
	var formattedDays = String(theDay);
	formattedDays = formattedDays.split("");
	document.getElementById("week").innerHTML = theWeekday;
	document.getElementById("month").innerHTML = theMonth;
	document.getElementById("day").innerHTML = theDay;

};

function updateClock() {
			var theDate = new Date();
			var currentHours = theDate.getHours();
			if (twentyFourHourTime == false) {
				if (currentHours > 12) {currentHours = currentHours - 12};
				if (currentHours == "0") {
					currentHours = "12";
				}
			}
			var currentMinutes = theDate.getMinutes();
			if (currentHours < 10) {currentHours = "0" + currentHours};
			if (currentMinutes < 10) {currentMinutes = "0" + currentMinutes};
			var formattedMinutes = String(currentMinutes);
			var formattedHours = String(currentHours);
			formattedMinutes = formattedMinutes.split("");
			formattedHours = formattedHours.split("");
			document.getElementById("hours").innerHTML = "<span></span>" + formattedHours[0] + " " + formattedHours[1];
			document.getElementById("minutes").innerHTML = "<span></span>" + formattedMinutes[0] + " " + formattedMinutes[1];	
}

function convertTemp(num)
{
	if (isCelsius == true)
		return Math.round ((num - 32) * 5 / 9);
	else
		return num;
}
function setPostal(obj){
	if (obj.error == false){
		if(obj.cities.length > 0){
			postal = escape(obj.cities[0].zip).replace(/^%u/g, "%")
			document.getElementById("WeatherContainer").className = "";	
			weatherRefresherTemp();
		}else{
			document.getElementById("city").innerText="Not Found";
			document.getElementById("WeatherContainer").className = "errorLocaleNotFound";	
		}
	}else{
		document.getElementById("city").innerText=obj.errorString;
		document.getElementById("WeatherContainer").className = "errorLocaleValidate";	
		setTimeout('validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)', Math.round(1000*60*5));
	}
}
function dealWithWeather(obj){
	if (obj.error == false){
		document.getElementById("city").innerText=obj.city;
		//document.getElementById("desc").innerText=obj.description.toLowerCase();
		document.getElementById("desc").innerText= conditions57[obj.description];
		if(useRealFeel == true){
			tempValue = convertTemp(obj.realFeel);
		}else{
			tempValue = convertTemp(obj.temp)
		}
		document.getElementById("temp").innerHTML=tempValue+ "&#176;";
		
		
		sunriseh = obj.sunrise.substring(0,obj.sunrise.indexOf(":",0));
		sunrisem = obj.sunrise.substring(obj.sunrise.indexOf(":",0)+1,obj.sunrise.indexOf(" ",0));
		sunriseh = parseInt(sunriseh) + GMT;
		sunseth = obj.sunset.substring(0,obj.sunset.indexOf(":",0));
		sunsetm = obj.sunset.substring(obj.sunset.indexOf(":",0)+1,obj.sunset.indexOf(" ",0));
		sunseth = parseInt(sunseth) + GMT;
		sunseth = sunseth + 12;
		dayhour = parseInt(sunriseh) + parseInt(sunrisem)/60;
		nighthour = parseInt(sunseth) + parseInt(sunsetm)/60;
		if (twentyFourHourTime == true){
		sunriseh = ( sunriseh < 10 ? "0" : "" ) + sunriseh;
		sunseth = ( sunseth < 10 ? "0" : "" ) + sunseth;
		obj.sunrise = sunriseh + ":" + sunrisem;		
		obj.sunset = sunseth + ":" + sunsetm;
		}else{
		var timeOfSunset = ( sunseth < 12 ) ? "am" : "pm";
		var timeOfSunrise = ( sunriseh < 12 ) ? "am" : "pm";
		sunriseh = ( sunriseh > 12 ) ? sunriseh - 12 : sunriseh;
		sunriseh = ( sunriseh == 0 ) ? 12 : sunriseh;
		sunseth = ( sunseth > 12 ) ? sunseth - 12 : sunseth;
		sunseth = ( sunseth == 0 ) ? 12 : sunseth;
		obj.sunrise = sunriseh + ":" + sunrisem + " " + timeOfSunrise;	
		obj.sunset = sunseth + ":" + sunsetm + " " + timeOfSunset;
		}
		document.getElementById("sunrise").innerText=obj.sunrise;
		document.getElementById("sunset").innerText=obj.sunset;
		document.getElementById("weatherIcon").src="Private/WeatherIcons/"+icons57[obj.icon]+".png";
		document.getElementById("WeatherContainer").className = "";	
	}else{
		//Could be down to any number of things, which is unhelpful...
		document.getElementById("WeatherContainer").className = "errorWeatherDataFetch";	
	}
}
function weatherRefresherTemp(){
	fetchWeatherData(dealWithWeather,postal);
	setTimeout(weatherRefresherTemp, 60*1000*updateInterval);
}
if (language == 'EN') {	
var conditions57 =
[
	"tornado",							//0		tornado
	"tropical storm",					//1		tropical storm
	"hurricane",						//2		hurricane
	"severe thunderstorms",				//3		severe thunderstorms
	"thunderstorms",					//4		thunderstorms
	"mixed rain and snow",				//5		mixed rain and snow
	"mixed rain and sleet",				//6		mixed rain and sleet
	"mixed snow and sleet",				//7		mixed snow and sleet
	"freezing drizzle",					//8		freezing drizzle
	"drizzle",							//9		drizzle
	"freezing rain",					//10	freezing rain
	"showers",							//11	showers
	"showers",		       				//12	showers
	"snow flurries",		     		//13	snow flurries
	"light snow showers",		        //14	light snow showers
	"blowing snow",		     			//15	blowing snow
	"snow",		       					//16	snow
	"hail",		      					//17	hail
	"sleet",		   				    //18	sleet
	"dust",		      					//19	dust
	"foggy",		       				//20	foggy
	"haze",		       					//21	haze
	"smoky",		       				//22	smoky
	"blustery",		       				//23	blustery
	"windy",		       				//24	windy
	"cold",		       					//25	cold
	"cloudy",		       				//26	cloudy
	"mostly cloudy",		   			//27	mostly cloudy (night)
	"mostly cloudy",		   	    	//28	mostly cloudy (day)
	"partly cloudy",		  			//29	partly cloudy (night)
	"partly cloudy",		  	     	//30	partly cloudy (day)
	"clear",		      				//31	clear (night)
	"sunny",		       				//32	sunny
	"fair",		       					//33	fair (night)
	"fair",		       					//34	fair (day)
	"mixed rain and hail",		        //35	mixed rain and hail
	"hot",		       					//36	hot
	"isolated thunderstorms",		    //37	isolated thunderstorms
	"scattered thunderstorms",		    //38	scattered thunderstorms
	"scattered thunderstorms",		    //39	scattered thunderstorms
	"scattered showers",		        //40	scattered showers
	"heavy snow",		       			//41	heavy snow
	"scattered snow showers",		    //42	scattered snow showers
	"heavy snow",		       			//43	heavy snow
	"partly cloudy",		       		//44	partly cloudy
	"thundershowers",		       		//45	thundershowers
	"snow showers",		       			//46	snow showers
	"isolated thundershowers",		    //47	isolated thundershowers
	"not available",		   			//3200	 not available
]

} else if (language == 'FR') {	

var conditions57 =
[
	"Tornade",							//0		tornado
	"Tempête tropicale",					//1		tropical storm
	"Ouragan",						//2		hurricane
	"Gros orages",				//3		severe thunderstorms
	"Orages",					//4		thunderstorms
	"Pluie et neige",				//5		mixed rain and snow
	"Pluie et verglas",				//6		mixed rain and sleet
	"Neige et verglas",				//7		mixed snow and sleet
	"Bruine verglaçante",					//8		freezing drizzle
	"Buine",							//9		drizzle
	"Pluie verglaçante",					//10	freezing rain
	"Orages",							//11	showers
	"Orage",		       				//12	showers
	"Averses de neige",		     		//13	snow flurries
	"Légères averses de neige",		        //14	light snow showers
	"Vent et neige",		     			//15	blowing snow
	"Neige",		       					//16	snow
	"Grêle",		      					//17	hail
	"Verglas",		   				    //18	sleet
	"Poussièreux'",		      					//19	dust
	"Brumeux",		       				//20	foggy
	"Brume",		       					//21	haze
	"Brumeux",		       				//22	smoky
	"Tempête",		       				//23	blustery
	"Venteux",		       				//24	windy
	"Froid",		       					//25	cold
	"Nuageux",		       				//26	cloudy
	"Très nuageux",		    //27	mostly cloudy (night)
	"Très nuageux",		       	//28	mostly cloudy (day)
	"Partiellement nuageux",		    //29	partly cloudy (night)
	"Partiellement nuageux",		       	//30	partly cloudy (day)
	"Ciel dégagé",		      		//31	clear (night)
	"Ensoleillé",		       				//32	sunny
	"Ciel dégagé",		       			//33	fair (night)
	"Ciel dégagé",		       			//34	fair (day)
	"Pluie et la grêle",		        //35	mixed rain and hail
	"Chaud",		       					//36	hot
	"Orages isolés",		    //37	isolated thunderstorms
	"Orages éparses",		    //38	scattered thunderstorms
	"Orages éparses",		    //39	scattered thunderstorms
	"Averses éparses",		        //40	scattered showers
	"Fortes chutes de neige",		       			//41	heavy snow
	"Chutes de neige éparses",		    //42	scattered snow showers
	"Forte neige",		       			//43	heavy snow
	"Partiellement nuageux",		       		//44	partly cloudy
	"Orages",		       		//45	thundershowers
	"Rafales de neige'",		       			//46	snow showers
	"Orages isolés",		    //47	isolated thundershowers
	"not disponible",		   			//3200 not available
]
} else if (language == 'IT') {	

var conditions57 =
[
	"temporale",							//0		tornado
	"forte temporale",					//1		tropical storm
	"forte temporale",						//2		hurricane
	"forte temporale",				//3		severe thunderstorms
	"temporale",					//4		thunderstorms
	"pioggia e nev",				//5		mixed rain and snow
	"pioggia e nevischio",				//6		mixed rain and sleet
	"neve con nevischio",				//7		mixed snow and sleet
	"pioggia fredda",					//8		freezing drizzle
	"pioggia leggera",							//9		drizzle
	"pioggia gelata",					//10	freezing rain
	"pioggia",							//11	showers
	"pioggia",		       				//12	showers
	"folate di neve",		     		//13	snow flurries
	"neve leggera",		        //14	light snow showers
	"neve con vento",		     			//15	blowing snow
	"neve",		       					//16	snow
	"grandine",		      					//17	hail
	"nevischio",		   				    //18	sleet
	"pulviscolo",		      					//19	dust
	"nebbia",		       				//20	foggy
	"foschia",		       					//21	haze
	"nebbia fitta",		       				//22	smoky
	"foschia fitta",		       				//23	blustery
	"vento",		       				//24	windy
	"freddo",		       					//25	cold
	"nuvoloso",		       				//26	cloudy
	"molto nuvoloso",		    //27	mostly cloudy (night)
	"molto nuvoloso",		       	//28	mostly cloudy (day)
	"poco nuvoloso",		    //29	partly cloudy (night)
	"poco nuvoloso",		       	//30	partly cloudy (day)
	"sereno",		      		//31	clear (night)
	"soleggiato",		       				//32	sunny
	"chiaro",		       			//33	fair (night)
	"chiaro",		       			//34	fair (day)
	"pioggia e grandine",		        //35	mixed rain and hail
	"caldo",		       					//36	hot
	"temporali isolati",		    //37	isolated thunderstorms
	"temporali sparsi",		    //38	scattered thunderstorms
	"temporali sparsi",		    //39	scattered thunderstorms
	"piogge sparse",		        //40	scattered showers
	"neve",		       			//41	heavy snow
	"neve a tratti",		    //42	scattered snow showers
	"neve",		       			//43	heavy snow
	"poco nuvoloso",		       		//44	partly cloudy
	"rovesci",		       		//45	thundershowers
	"rovesci nevosi",		       			//46	snow showers
	"rovesci isolati",		    //47	isolated thundershowers
	"non disponibile",		   			//3200 not available
]

} else if (language == 'ES') {	

var conditions57 =
[
	"tornado",						//0		tornado
	"tormenta tropical",					//1		tropical storm
	"huracán",						//2		hurricane
	"fuertes tormentas",			//3		severe thunderstorms
	"tormentas eléctricas",					//4		thunderstorms
	"lluvia y nieve",			//5		mixed rain and snow
	"lluvia y granizo",			//6		mixed rain and sleet
	"nieve y granizo",			//7		mixed snow and sleet
	"llovizna helada",					//8		freezing drizzle
	"llovizna",							//9		drizzle
	"lluvia helada",					//10		freezing rain
	"lluvias",						//11		showers
	"lluvias",		       				//12		showers
	"copos de nieve",		     			//13		snow flurries
	"nieve ligera",		        	//14		light snow showers
	"viento y nieve",		     			//15		blowing snow
	"nieve",		       					//16		snow
	"granizo",		      					//17		hail
	"aguanieve",		   				    	//18		sleet
	"polvo",		      					//19		dust
	"brumas",		       					//20		foggy
	"neblina",		       					//21		haze
	"con humo",		       					//22		smoky
	"tempestuoso",		       				//23		blustery
	"con viento",		       					//24		windy
	"frío",		       					//25		cold
	"nublado",		       					//26		cloudy
	"muy nublado",		    	//27		mostly cloudy (night)
	"muy nublado",		       		//28		mostly cloudy (day)
	"parcialmente nublado",		    		//29		partly cloudy (night)
	"parcialmente nublado",		       		//30		partly cloudy (day)
	"despejado",		      			//31		clear (night)
	"soleado",		       					//32		sunny
	"despejado",		       				//33		fair (night)
	"despejsado",		       				//34		fair (day)
	"alluvia y granizo",		        	//35		mixed rain and hail
	"caluroso",		       					//36		hot
	"tormentas eléctricas aisladas",		    	//37		isolated thunderstorms
	"tormentas eléctricas aisladas",		    	//38		scattered thunderstorms
	"tormentas eléctricas aisladas",		    	//39		scattered thunderstorms
	"lluvias aisladas",		        	//40		scattered showers
	"fuertes nevadas",		       			//41		heavy snow
	"nevadas aisladas",		    	//42		scattered snow showers
	"fuertes nevadas",		       			//43		heavy snow
	"parcialmente nublado",		       			//44		partly cloudy
	"chaparrones",		       		//45		thundershowers
	"nieve",		       			//46		snow showers
	"chubascos aislados",		//47		isolated thundershowers
	"no disponible",		   			//3200	 not available
]

} else if (language == 'DE') {	

var conditions57 =
[
	"tornado",						//0		tornado
	"tropischer sturm",					//1		tropical storm
	"hurricane",						//2		hurricane
	"schwere gewitterstürme",			//3		severe thunderstorms
	"gewitterstürme",					//4		thunderstorms
	"gemischter regen mit schnee",			//5		mixed rain and snow
	"schneeregen",			//6		mixed rain and sleet
	"schneeregen",			//7		mixed snow and sleet
	"gefrierender nieselregen",					//8		freezing drizzle
	"nieselregen",							//9		drizzle
	"gefrierender regen",					//10		freezing rain
	"regenschauer",						//11		showers
	"regenschauer",		       				//12		showers
	"schneeböen",		     			//13		snow flurries
	"leichte schneeschauer",		        	//14		light snow showers
	"wehender schnee",		     			//15		blowing snow
	"schnee",		       					//16		snow
	"hagel",		      					//17		hail
	"schneeregen",		   				    	//18		sleet
	"staub",		      					//19		dust
	"neblig",		       					//20		foggy
	"dunst",		       					//21		haze
	"rauchig",		       					//22		smoky
	"stuermisch",		       				//23		blustery
	"windig",		       					//24		windy
	"kalt",		       					//25		cold
	"bewölkt",		       					//26		cloudy
	"meist bewölkt",		    	//27		mostly cloudy (night)
	"meist bewölkt",		       		//28		mostly cloudy (day)
	"teilweise bewölkt",		    		//29		partly cloudy (night)
	"teilweise bewölkt",		       		//30		partly cloudy (day)
	"klar",		      			//31		clear (night)
	"sonnig",		       					//32		sunny
	"heiter",		       				//33		fair (night)
	"heiter",		       				//34		fair (day)
	"hagelregen",		        	//35		mixed rain and hail
	"heiss",		       					//36		hot
	"isolierte gewitterstürme",		    	//37		isolated thunderstorms
	"verstreute gewitterstürme",		    	//38		scattered thunderstorms
	"verstreute gewitterstürme",		    	//39		scattered thunderstorms
	"verstreute regenschauer",		        	//40		scattered showers
	"schwere schneefälle",		       			//41		heavy snow
	"verstreute schneeschauer",		    	//42		scattered snow showers
	"schwere schneefälle",		       			//43		heavy snow
	"teilweise bewölkt",		       			//44		partly cloudy
	"regenschauer mit gewitter",		       		//45		thundershowers
	"schneeschauer",		       			//46		snow showers
	"isolierte regenschauer mit gewitter",		//47		isolated thundershowers
	"nicht verfügbar",		   			//3200	 not available
]

};	
var icons57 =
[
	"0",		       //0	tornado
	"1",		       //1	tropical storm
	"2",		       //2	hurricane
	"3",		       //3	severe thunderstorms
	"4",		       //4	thunderstorms
	"5",		       //5	mixed rain and snow
	"6",		       //6	mixed rain and sleet
	"7",		       //7	mixed snow and sleet
	"8",		       //8	freezing drizzle
	"9",		       //9	drizzle
	"10",		       //10	freezing rain
	"11",		       //11	showers
	"12",		       //12	showers
	"13",		       //13	snow flurries
	"14",		       //14	light snow showers
	"15",		       //15	blowing snow
	"16",		       //16	snow
	"17",		       //17	hail
	"18",		       //18	sleet
	"19",		       //19	dust
	"20",		       //20	foggy
	"21",		       //21	haze
	"22",		       //22	smoky
	"23",		       //23	blustery
	"24",		       //24	windy
	"25",		       //25	cold
	"26",		       //26	cloudy
	"27",		      //27	mostly cloudy (night)
	"28",		       //28	mostly cloudy (day)
	"29",		      //29	partly cloudy (night)
	"30",		       //30	partly cloudy (day)
	"31",		      //31	clear (night)
	"32",		       //32	sunny
	"33",		       //33	fair (night)
	"34",		       //34	fair (day)
	"35",		       //35	mixed rain and hail
	"36",		       //36	hot
	"37",		       //37	isolated thunderstorms
	"38",		       //38	scattered thunderstorms
	"39",		       //39	scattered thunderstorms
	"40",		       //40	scattered showers
	"41",		       //41	heavy snow
	"42",		       //42	scattered snow showers
	"43",		       //43	heavy snow
	"44",		       //44	partly cloudy
	"45",		       //45	thundershowers
	"46",		       //46	snow showers
	"47",		       //47	isolated thundershowers
	"na",		   //3200 not available
]



function constructError (string)
{
	return {error:true, errorString:string};
}
function findChild (element, nodeName)
{
	var child;
	for (child = element.firstChild; child != null; child = child.nextSibling)
	{
		if (child.nodeName == nodeName)
			return child;
	}
	return null;
}
function fetchWeatherData (callback, zip)
{
	url="http://weather.yahooapis.com/forecastrss?u=f&p=" //u=Farenheit, because accuWeather sucks
	var xml_request = new XMLHttpRequest();
	xml_request.onload = function(e) {xml_loaded(e, xml_request, callback);}
	xml_request.overrideMimeType("text/xml");
	xml_request.open("GET", url+zip);
	xml_request.setRequestHeader("Cache-Control", "no-cache");
	xml_request.send(null); 
	return xml_request;
}
function xml_loaded (event, request, callback)
{
	if (request.responseXML)
	{
		var obj = {error:false, errorString:null};
		var effectiveRoot = findChild(findChild(request.responseXML, "rss"), "channel");
		obj.city = findChild(effectiveRoot, "yweather:location").getAttribute("city");
		obj.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");//Only accounts for windChill
		
		obj.sunrise = findChild(effectiveRoot, "yweather:astronomy").getAttribute("sunrise");//Sunrise
		obj.sunset = findChild(effectiveRoot, "yweather:astronomy").getAttribute("sunset");//Sunset
		
		conditionTag = findChild(findChild(effectiveRoot, "item"), "yweather:condition");
		obj.temp = conditionTag.getAttribute("temp");
		obj.icon = conditionTag.getAttribute("code");
		obj.description = conditionTag.getAttribute("code"); 
		callback (obj); 
	}else{
		callback ({error:true, errorString:"XML request failed. no responseXML"});
	}
}
function validateWeatherLocation (location, callback)
{
	var obj = {error:false, errorString:null, cities: new Array};
	obj.cities[0] = {zip: location}; //Not very clever, are we?
	callback (obj);
}


if (language == 'EN') {	
weekdays	=	new Array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
} else if (language == 'FR') {	
weekdays	=	new Array('dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam');
} else if (language == 'IT') {	
weekdays	=	new Array('dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab');
} else if (language == 'ES') {
weekdays	=	new Array('dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb');
} else if (language == 'DE') {	
weekdays	=	new Array('son', 'mon', 'die', 'mit', 'don', 'fre', 'sam');
}
months		=	new Array('January', 'February', 'Mars', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

/* -----------------------------------------------------------------------------------------------------------------
	Lineair Calendar Script
----------------------------------------------------------------------------------------------------------------- */	

	function $(selector) {
		return document.getElementById(selector);
	}
	function updateElements() {
		updateDate();
	}
	
	function updateDate() {
		var this_weekday_name_array = weekdays,
			this_month_name_array = months,
			this_date_timestamp = new Date(),
			this_weekday = this_date_timestamp.getDay(),
			this_date = this_date_timestamp.getDate(),
			this_month = this_date_timestamp.getMonth(),
			this_year = this_date_timestamp.getFullYear(),
			dim = [31,0,31,30,31,30,31,31,30,31,30,31],
			oD = new Date(this_year, this_date-1, 1),
			linecalendar = $('linecalendar').firstChild;
			oD.od = oD.getDay()+1;
			dim[1]=(((oD.getFullYear()%100 != 0) && (oD.getFullYear()%4 == 0)) || (oD.getFullYear()%400 == 0)) ? 29 : 28;
			var t = '',
			k = 0,
			days_TM = dim[this_month],
			days_PM = (this_month == 0) ? dim[11] : dim[this_month-1],
			days_NM = (this_month == 11) ? dim[0] : dim[this_month+1];
			do {
				var k2 = this_date-k,
				wkstart = (k2<=0) ? days_PM+k2 : k2;
				k++;
			} while(k <= this_weekday);
			for (s=0;s<7;s++) {
				t += (s == this_weekday) ? '<span class="linetoday">' + this_weekday_name_array[s] + '</span>' : '<span class="linedaysofweek">' + this_weekday_name_array[s] + '</span>';
			}
			t += '<span class="separator">&nbsp;&bull;&nbsp;</span>';
			for (L=0;L<this_weekday;L++) {
				var L2 = L+wkstart;
			if(L2>days_PM) 
				L2 = L2-days_PM;
				t += (L2 == this_date) ? '<span class="linetoday">' + L2 + '</span>' : '<span class="linedaysofweek">' + L2 + '</span>';
			}
			for (M=0;M<=6-this_weekday;M++) {
				var M2 = M+this_date;
				if(M2 > days_TM) 
					M2 = M2-days_TM;
				t += (M2 == this_date) ? '<span class="linetoday">' + M2 + '</span>' : '<span class="linedaysofweek">' + M2 + '</span>';
			}
					var texto = document.createElement('div');
					texto.innerHTML = '<div id="lineweek">' + t + '</div>';
					if (linecalendar)
						$('linecalendar').replaceChild(texto, linecalendar);
					else
						$('linecalendar').appendChild(texto);
			}
	function capitAll(str) {
		str = str.toLowerCase().replace(/([-\.']) */g,'$1 ');
		var rx = /\b([a-z'-\.]+)\b/ig;
		str = str.replace(rx,function(w){ return w.charAt(0).toUpperCase()+w.substring(1); });
		return str.replace(/^ *|(\-|') *| *$/g,'$1');
	}
	function constructError(string) {
		return {error:true, errorString:string};
	}
	function findChild(element, nodeName) {
		var child;
		for (child = element.firstChild; child != null; child = child.nextSibling) {
			if (child.nodeName == nodeName)
				return child;
			}
			return null;
	}