$(document).ready(function() {
	/* twitter @anywhere */
	/*
	twttr.anywhere(function(T) {
		T.hovercards();
		T(".menu_twitter_icon").hovercards({
			username: function(){
				return "nycgo";			
				}
		});
	});
	*/
	/* end twitter @anywhere */
	
	/* newsletter form */
	$("#menu_email_icon").fancybox({ 
		href: "/index.php/ajax/newsletter-signup"
	}); 
	/* end newsletter form */

    /* weather */
	$.get('/public/php/GetWeather.php', function(data){
        
        // build an HTML string
        myHTMLOutput = '';
        myHTMLOutput += '<ul>';

        // run the function for each day tag in the XML file
        $('current_observation',data).each(function(i) {
            temperature_f = $(this).find("temp_f").text();
            temperature_f = Math.round(temperature_f);
            temperature_c = $(this).find("temp_c").text();
            temperature_c = Math.round(temperature_c);
            temperature = temperature_f + "&deg;F/" + temperature_c + "&deg;C";
            condition = $(this).find("weather").text();
            
            switch(condition)
            {
	            case "Heavy Snow": case "Heavy Snow Showers":  case "Heavy Showers Snow": case "Heavy Snow Fog/Mist": 
	            case "Heavy Snow Showers Fog/Mist":  case "Heavy Showers Snow Fog/Mist":  case "Heavy Snow Low Drifting Snow": 
	            case "Heavy Snow Blowing Snow": case "Heavy Snow Grains": case "Heavy Blowing Snow":
	            	image = "Blizzard.png";
	            	break;
	            case "Fair": case "Clear": case "Fair with Haze": case "Clear with Haze": 
	            case "Fair and Breezy": case "Clear and Breezy": case "Windy": case "Breezy": 
	            case "Fair and Windy": case "Haze":
	            	image = "Clear.png";
	            	break;
	            case "Mostly Cloudy": case "Mostly Cloudy with Haze": case "Mostly Cloudy and Breezy": 
	            case "Overcast": case "Overcast with Haze": case "Overcast and Breezy": case "Mostly Cloudy and Windy": 
	            case "Overcast and Windy": case "Funnel Cloud": case "Funnel Cloud in Vicinity":
	            case "Tornado/Water Spout":
	            	image = "Cloudy.png";
	            	break;
	            case "A Few Clouds": case "A Few Clouds with Haze": case "A Few Clouds and Breezy": 
	            case "Partly Cloudy": case "Partly Cloudy with Haze": case "Partly Cloudy and Breezy":
	            case "Fog/Mist": case "Fog": case "Freezing Fog": case "Shallow Fog": case "Partial Fog": 
	            case "Patches of Fog": case "Fog in Vicinity": case "Freezing Fog in Vicinity": 
	            case "Shallow Fog in Vicinity": case "Partial Fog in Vicinity": case "Patches of Fog in Vicinity": 
	            case "Showers in Vicinity Fog": case "Light Freezing Fog": case "Heavy Freezing Fog": case "Smoke":
	            case "A Few Clouds and Windy": case "Partly Cloudy and Windy":
	            	image = "PartlyCloudy.png";
	            	break;
	            case "Freezing Rain": case "Freezing Drizzle": case "Light Freezing Rain": case "Light Freezing Drizzle": 
	            case "Heavy Freezing Rain": case "Heavy Freezing Drizzle": case "Freezing Rain in Vicinity": 
	            case "Freezing Drizzle in Vicinity": case "Rain Showers": case "Light Rain Showers": 
	            case "Light Rain and Breezy": case "Heavy Rain Showers": case "Rain Showers in Vicinity":
	            case "Light Showers Rain": case "Heavy Showers Rain": case "Showers Rain": case "Showers Rain in Vicinity": 
	            case "Rain Showers Fog/Mist": case "Light Rain Showers Fog/Mist": case "Heavy Rain Showers Fog/Mist": 
	            case "Rain Showers in Vicinity Fog/Mist": case "Light Showers Rain Fog/Mist": case "Heavy Showers Rain Fog/Mist": 
	            case "Showers Rain Fog/Mist": case "Showers Rain in Vicinity Fog/Mist": case "Showers in Vicinity": 
	            case "Showers in Vicinity Fog/Mist": case "Showers in Vicinity Fog": case "Showers in Vicinity Haze":
	            case "Freezing Rain Rain": case "Light Freezing Rain Rain": case "Heavy Freezing Rain Rain": case "Rain Freezing Rain": 
	            case "Light Rain Freezing Rain": case "Heavy Rain Freezing Rain": case "Freezing Drizzle Rain": case "Light Freezing Drizzle Rain":
	            case "Heavy Freezing Drizzle Rain": case "Rain Freezing Drizzle": case "Light Rain Freezing Drizzle": case "Heavy Rain Freezing Drizzle":
	            case "Light Rain": case "Drizzle": case "Light Drizzle": case "Heavy Drizzle": case "Light Rain Fog/Mist": 
	            case "Drizzle Fog/Mist": case "Light Drizzle Fog/Mist": case "Heavy Drizzle Fog/Mist": 
	            case "Light Rain Fog": case "Drizzle Fog": case "Light Drizzle Fog": case "Heavy Drizzle Fog":
	            case "Rain": case "Heavy Rain": case "Rain Fog/Mist": case "Heavy Rain Fog/Mist": 
	            case "Rain Fog": case "Heavy Rain Fog":
	            	image = "Rain.png";
	            	break;
	            case "Ice Pellets": case "Light Ice Pellets": case "Heavy Ice Pellets": case "Ice Pellets in Vicinity": 
	            case "Showers Ice Pellets": case "Thunderstorm Ice Pellets": case "Ice Crystals": case "Hail": 
	            case "Small Hail/Snow Pellets": case "Light Small Hail/Snow Pellets": case "Heavy small Hail/Snow Pellets": 
	            case "Showers Hail": case "Hail Showers": case "Freezing Rain Snow": case "Light Freezing Rain Snow": 
	            case "Heavy Freezing Rain Snow": case "Freezing Drizzle Snow": case "Light Freezing Drizzle Snow": 
	            case "Heavy Freezing Drizzle Snow": case "Snow Freezing Rain": case "Light Snow Freezing Rain": 
	            case "Heavy Snow Freezing Rain": case "Snow Freezing Drizzle": case "Light Snow Freezing Drizzle": 
	            case "Heavy Snow Freezing Drizzle": case "Rain Ice Pellets": case "Light Rain Ice Pellets": 
	            case "Heavy Rain Ice Pellets": case "Drizzle Ice Pellets": case "Light Drizzle Ice Pellets": 
	            case "Heavy Drizzle Ice Pellets": case "Ice Pellets Rain": case "Light Ice Pellets Rain": 
	            case "Heavy Ice Pellets Rain": case "Ice Pellets Drizzle": case "Light Ice Pellets Drizzle": 
	            case "Heavy Ice Pellets Drizzle": case "Rain Snow": case "Light Rain Snow": case "Heavy Rain Snow": 
	            case "Snow Rain": case "Light Snow Rain": case "Heavy Snow Rain": case "Drizzle Snow": 
	            case "Light Drizzle Snow": case "Heavy Drizzle Snow": case "Snow Drizzle": case "Light Snow Drizzle": 
	            case "Heavy Drizzle Snow":
	            case "Snow": case "Light Snow": case "Snow Showers": case "Light Snow Showers": 
	            case "Showers Snow": case "Light Showers Snow": case "Snow Fog/Mist": case "Light Snow Fog/Mist": 
	            case "Snow Showers Fog/Mist": case "Light Snow Showers Fog/Mist": case "Showers Snow Fog/Mist": 
	            case "Light Showers Snow Fog/Mist": case "Snow Fog": case "Light Snow Fog": case "Heavy Snow Fog":
	            case "Snow Showers Fog": case "Light Snow Showers Fog": case "Heavy Snow Showers Fog": 
	            case "Showers Snow Fog": case "Light Showers Snow Fog": case "Heavy Showers Snow Fog": 
	            case "Showers in Vicinity Snow": case "Snow Showers in Vicinity": 
	            case "Snow Showers in Vicinity Fog/Mist": case "Snow Showers in Vicinity Fog": 
	            case "Low Drifting Snow": case "Blowing Snow": case "Snow Low Drifting Snow": 
	            case "Snow Blowing Snow": case "Light Snow Low Drifting Snow": case "Light Snow Blowing Snow": 
	            case "Light Snow Blowing Snow Fog/Mist": case "Thunderstorm Snow": case "Light Thunderstorm Snow": 
	            case "Heavy Thunderstorm Snow": case "Snow Grains": case "Light Snow Grains": 
	            case "Blowing Snow in Vicinity":
	            	image = "Snow.png";
	            	break;
	            case "Thunderstorm": case "Thunderstorm Rain": case "Light Thunderstorm Rain": case "Heavy Thunderstorm Rain": 
	            case "Thunderstorm Rain Fog/Mist": case "Light Thunderstorm Rain Fog/Mist": case "Heavy Thunderstorm Rain Fog and Windy": 
	            case "Heavy Thunderstorm Rain Fog/Mist": case "Thunderstorm Showers in Vicinity": case "Light Thunderstorm Rain Haze": 
	            case "Heavy Thunderstorm Rain Haze": case "Thunderstorm Fog": case "Light Thunderstorm Rain Fog": 
	            case "Heavy Thunderstorm Rain Fog": case "Thunderstorm Light Rain": case "Thunderstorm Heavy Rain": 
	            case "Thunderstorm Rain Fog/Mist": case "Thunderstorm Light Rain Fog/Mist": case "Thunderstorm Heavy Rain Fog/Mist": 
	            case "Thunderstorm in Vicinity Fog/Mist": case "Thunderstorm Showers in Vicinity": case "Thunderstorm in Vicinity Haze": 
	            case "Thunderstorm Haze in Vicinity": case "Thunderstorm Light Rain Haze": case "Thunderstorm Heavy Rain Haze": 
	            case "Thunderstorm Fog": case "Thunderstorm Light Rain Fog": case "Thunderstorm Heavy Rain Fog": 
	            case "Thunderstorm Hail": case "Light Thunderstorm Rain Hail": case "Heavy Thunderstorm Rain Hail": 
	            case "Thunderstorm Rain Hail Fog/Mist": case "Light Thunderstorm Rain Hail Fog/Mist": 
	            case "Heavy Thunderstorm Rain Hail Fog/Hail": case "Thunderstorm Showers in Vicinity Hail": 
	            case "Light Thunderstorm Rain Hail Haze": case "Heavy Thunderstorm Rain Hail Haze": case "Thunderstorm Hail Fog": 
	            case "Light Thunderstorm Rain Hail Fog": case "Heavy Thunderstorm Rain Hail Fog": case "Thunderstorm Light Rain Hail": 
	            case "Thunderstorm Heavy Rain Hail": case "Thunderstorm Rain Hail Fog/Mist": case "Thunderstorm Light Rain Hail Fog/Mist": 
	            case "Thunderstorm Heavy Rain Hail Fog/Mist": case "Thunderstorm in Vicinity Hail": case "Thunderstorm in Vicinity Hail Haze": 
	            case "Thunderstorm Haze in Vicinity Hail": case "Thunderstorm Light Rain Hail Haze": case "Thunderstorm Heavy Rain Hail Haze": 
	            case "Thunderstorm Hail Fog": case "Thunderstorm Light Rain Hail Fog": case "Thunderstorm Heavy Rain Hail Fog": 
	            case "Thunderstorm Small Hail/Snow Pellets": case "Thunderstorm Rain Small Hail/Snow Pellets": 
	            case "Light Thunderstorm Rain Small Hail/Snow Pellets": case "Heavy Thunderstorm Rain Small Hail/Snow Pellets":
	            case "Thunderstorm in Vicinity": case "Thunderstorm in Vicinity Fog": case "Thunderstorm in Vicinity Haze":
	            	image = "Thunderstorm.png";
	            	break;
	            default:
	            	image = "Clear.png";
	            	break;
            }

            // build <li> data and store in string
            mydata = BuildWeatherHTML(temperature,image);
            myHTMLOutput = myHTMLOutput + mydata;
        });
        myHTMLOutput += '</ul>';
        
        // update the DIV called weatherBlock with the HTML string
        $(".weatherBlock").html(myHTMLOutput);
        
	});
	
	function BuildWeatherHTML(temperature,image) {
		var weather_image_prefix = "H_";
	
	    // Build HTML string and return
	    output = '';
	    output += '<li>';
	    output += '<span>'+ temperature +' <img src="/images/weather/' + weather_image_prefix + image +'"></span>';
	    output += '</li>';
	    return output;
	}
    /* end weather */


});
