$(function(){
	var today = new Date()//(2010,5,28);
	var Year = today.getFullYear();
	var rankCount = 0;
	$.ajax({
		url:"./xml/ranking_"+Year+".xml",//RSSファイル名
		async:false,
		cache:false,
		dataType:"xml",
		success: function(xml){
			//タイトルバーに年月反映
			$('#top_ranking_title').html($(xml).find('title').text());
			$('#top_ranking_now').html($(xml).find('now').text());

			$(xml).find('ranking').each(function(){
				if($(this).find('team').text() =="東京２３フットボールクラブ"){
					$('#ranking_tableArea').append('<table cellpadding=0 cellspacing=0 border=0 width=228><tr><td width=25 align=center id=top_tablesel2_center>'+$(this).find('rank').text()+'</td><td width=148 align=left id=top_tablesel2_left>'+$(this).find('team').text()+'</td><td width=25 align=center id=top_tablesel2_center>'+$(this).find('match').text()+'</td><td width=25 align=center id=top_tablesel2_center>'+$(this).find('wpoint').text()+'</td></tr></table>')
				} else {
					$('#ranking_tableArea').append('<table cellpadding=0 cellspacing=0 border=0 width=228><tr><td width=25 align=center id=top_tablesel1_center>'+$(this).find('rank').text()+'</td><td width=148 align=left id=top_tablesel1_left>'+$(this).find('team').text()+'</td><td width=25 align=center id=top_tablesel1_center>'+$(this).find('match').text()+'</td><td width=25 align=center id=top_tablesel1_center>'+$(this).find('wpoint').text()+'</td></tr></table>')
				}
				rankCount++;
			});
		},
		error: function(xml){
			//alert("xmlファイルの読み込みに失敗しました");
		}
	});
	
	if(rankCount==0){
		Year--;
		$.ajax({
			url:"./xml/ranking_"+Year+".xml",//RSSファイル名
			async:false,
			cache:false,
			dataType:"xml",
			success: function(xml){
				//タイトルバーに年月反映
				$('#top_ranking_title').html($(xml).find('title').text());
				$('#top_ranking_now').html($(xml).find('now').text());

				$(xml).find('ranking').each(function(){
					if($(this).find('team').text() =="東京２３フットボールクラブ"){
						$('#ranking_tableArea').append('<table cellpadding=0 cellspacing=0 border=0 width=228><tr><td width=25 align=center id=top_tablesel2_center>'+$(this).find('rank').text()+'</td><td width=148 align=left id=top_tablesel2_left>'+$(this).find('team').text()+'</td><td width=25 align=center id=top_tablesel2_center>'+$(this).find('match').text()+'</td><td width=25 align=center id=top_tablesel2_center>'+$(this).find('wpoint').text()+'</td></tr></table>')
					} else {
						$('#ranking_tableArea').append('<table cellpadding=0 cellspacing=0 border=0 width=228><tr><td width=25 align=center id=top_tablesel1_center>'+$(this).find('rank').text()+'</td><td width=148 align=left id=top_tablesel1_left>'+$(this).find('team').text()+'</td><td width=25 align=center id=top_tablesel1_center>'+$(this).find('match').text()+'</td><td width=25 align=center id=top_tablesel1_center>'+$(this).find('wpoint').text()+'</td></tr></table>')
					}
					rankCount++;
				});
			},
			error: function(xml){
				//alert("xmlファイルの読み込みに失敗しました");
			}
		});
	}
	
});


