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){
        jQuery('li#navWeather').html('<a href="#" class="parent"><strong>' + temp.city + ', ' + temp.state + '</strong> ' + temp.temp + '&deg;</a>'
          + '<div class="flyout">'
          + '<div class="whead">current conditions</div> '
          + '<div class="conditions"><p class="degree">' + temp.temp + '&deg;</p>'
 		  + '<p class="hiLo"> Hi ' + temp.todaysHigh + '&deg; Lo ' + temp.todaysLow + '&deg;</p>' 
          + '<p class="status">' + temp.condition + '</p></div>' 
          + '<img height="69" width="75" class="todaysWeather" alt="partlycloudy" src="' + temp.icon + '"/>'
          + '<div class="radar"><p>radar</p>'
          + '<a href="/wundermap"><img class="radarMap" alt="current radar map" src="http://resize.wunderground.com/cgi-bin/resize?filename=/data/nids/OKX19_thumb_t.jpg&amp;width=100&amp;height=70"/></a>'
 		  + '</div><div class="detail"><ul><li><strong>Humidity:</strong> ' + temp.humidity + '</li>'
          + '<li><strong>Wind:</strong> ' + temp.winds + '</li></ul>'
          + '<ul><li><strong>Barometer:</strong> ' + temp.airPressure + '" Hg</li></ul></div>'
          + '<ul class="weatherLinks">'
          + '<li><a href="http://weather.newsday.com/cgi-bin/findweather/getForecast?brand=newsday&amp;query='+gUserZip+'">full forecast</a></li>'
          + '<li><a href="http://weather.newsday.com/cgi-bin/findweather/getForecast?hourly=1&amp;query='+gUserZip+'&amp;yday=&amp;weekday=&amp;brand='+ temp.site+'">hour-by-hour</a></li>'
          + '<li class="last"><a href="/wundermap">local map</a></li></ul></div>' );               
      });
	});