(function($){
	$.fn.getWeather = function(options) {
		var defaults = {};
		
		var options = $.extend(defaults, options);
		
		return this.each(function() {
			
			var $obj = $(this);
			$.ajax({
				type: "GET",
				url: "/wp-content/themes/tgs-theme/js/get-weather.php",
				dataType: "xml",
				complete: function(xml) {
				    
				    var json = $.xmlToJSON(xml.responseXML);
				    var code = json.channel[0].item[0].condition[0].code;
				    var tempf = json.channel[0].item[0].condition[0].temp;
				    var tempc = parseInt((tempf-32)* 5/9);

				    
								
					$obj.append("<span class='w-icon'><img src='/wp-content/themes/tgs-theme/images/weather/"+code+".png' border='0' width='22' height='18' /></span><span class='temp'>" + tempf+"&deg; F ("+tempc+"&deg; C)</span>"); 				    
				},
				error: function(request,tStatus,eThrown){
					console.debug("Error loading XML: "+eThrown);
					console.debug(request);
					console.debug(tStatus);
				}
			});
			
		});
	};
})(jQuery);

