$(document).ready(function(){
	getWeather();
});

function getWeather() {
	var icon_location = '/fileadmin/system/assets/img/weather/';
	
	var i=0;
	$('#weather_box li').each(function() {
		var li = $(this);
		$.get('/typo3temp/wunderground/'+getTimestamp(i)+'.xml', function(data){
			$(data).find('weather').each(function() {
				//alert($('#weather_box .condition').text());
				li.find('.condition').html($(this).find('temp').text()+'&deg; '+$(this).find('weather_txt').text());
				li.find('.date').html($(this).find('date').text());
				//if (i==0) {
					li.find('.time').html($(this).find('time').text()+' Uhr');
				//}
				li.find('.icon').attr('src',icon_location+$(this).find('icon').text()+'.png').attr('alt',$(this).find('weather_txt').text());
			});
		}); // $.get
		i++;
		
	});
	/*
	$.get('/typo3temp/wunderground/'+getTimestamp()+'.xml', function(data){
		$(data).find('weather').each(function() {
			//alert($('#weather_box .condition').text());
			$('#weather_box .condition').html($(this).find('temp').text()+'&deg; '+$(this).find('weather_txt').text());
			$('#weather_box .date').html($(this).find('date').text());
			$('#weather_box .time').html($(this).find('time').text()+' Uhr');
			$('#weather_box .icon').attr('src',icon_location+$(this).find('icon').text()+'.png');
		});
	}); // $.get
	*/
	getTimestamp(1);
}

function getTimestamp(days) {
	days = (days) ? days : 0;

	var jetzt = new Date();
	var neu = new Date(jetzt.getFullYear(),jetzt.getMonth(),jetzt.getDate()+1+days,0,0,0).getTime()/1000;
	
	//alert(neu);
	
	return neu;
}
