function getWeatherZipcode()
{
	var sCookieValue = polopoly.base64.stringDecode(polopoly.cookie.get("zipcoordinates"));
	if( (sCookieValue !== null) && (sCookieValue != "") )
    {
        var HOME_ZIPCODE=0;
        var WEATHER_ZIPCODE=3;

        var saZip = sCookieValue.split(",");

        // 1) Get the Weather zipcode from the Cookie
        if( saZip.length > WEATHER_ZIPCODE )
        {
        	if( (saZip[WEATHER_ZIPCODE] !== null) && (saZip[WEATHER_ZIPCODE] !== "") && (saZip[WEATHER_ZIPCODE] != "null") )
            {
        		return saZip[WEATHER_ZIPCODE];
            }
        }

        // 2) Get the Home Zip Code from the Cookie if the Weather zipcode is unavailablle
        if( (saZip[HOME_ZIPCODE] !== null) && (saZip[HOME_ZIPCODE] != "") )
        {
        	return saZip[HOME_ZIPCODE];
        }
    }

	return "11751"; // Default Islip Zipcode
}

var gUserZip=getWeatherZipcode();
var gWeatherPath="/cmlink/imported.weather."+gUserZip+"?view=json_weather";


jQuery.getJSON(gWeatherPath, function(json) {
        jQuery.each(json.temps, function(i,temp){
		$('#wcity').html(temp.city + ', ');
		$('#wstate').html(temp.state);
		$('#wtemp').html(temp.temp + '&deg;');
		$('#wtemplg').html(temp.temp);
		$('#wtemphi').html(temp.todaysHigh);
		$('#wtemplo').html(temp.todaysLow);
		$('#wtempcondition').html(temp.condition);
		$('.todaysWeather').attr('src', '/img/' + weathersite + '/weather/sm/' + temp.icon);
		$('#whumid').html(temp.humidity);
		$('#wwind').html(temp.winds);
		$('#wpress').html(temp.airPressure);
		$('#forecastfull').attr('href', 'http://weather.newsday.com/cgi-bin/findweather/getForecast?brand=newsday&query=' + gUserZip);
		$('#forecasthour').attr('href', 'http://weather.newsday.com/cgi-bin/findweather/getForecast?hourly=1&query=' + gUserZip + '&yday=&weekday=');
      });
	});
