$(function(){
	$("dd.noscript").remove();
	var month={"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12"};
	var category;
	var gametitle = location.href.split("/")[3];
	if(gametitle==""||gametitle=="index.html")gametitle="gs24";
	var datacount=0;
	$.ajax({
		url: '/'+gametitle+'/main/info/'+gametitle+'.xml',
		type: 'GET',
		dataType: 'xml',
		timeout: 1000,
		error: function(){
			console.log("xmlファイルの読み込みに失敗しました");
		},
		success: function(xml){
			$(xml).find("item").each(function(){
				var pubdate = $(this).children("pubDate").text().split(" ");
					pubdate = "["+pubdate[3]+"-"+month[pubdate[2]]+"-"+pubdate[1]+"]";
				var title = $(this).children("title").text();
				var link = $(this).children("link").text();
				var newflag = $(this).children("new").text();
				var list = "";
				var icon = "";
				switch(gametitle) {
				case "wonderland":
					category={0:"announce",1:"event",2:"maintenance"};
					if(datacount<8) {
						$("<dd></dd>").html(pubdate + '<a href="' + link + '">' + title + '</a>').appendTo('dl.latest');
						datacount++;
					}
					break;

				case "359h":
					category={0:"announce",1:"event",2:"maintenance"};
					break;

				case "godius":
					category={0:"announce",1:"update",2:"announce"};
					break;

				case "navyfield-neo":
					category={0:"announce",1:"announce",2:"announce"};
					icon="<img src='/navyfield-neo/images/img_saymall_new.gif' alt='new' />";
					break;

				default:
					category={0:"announce",1:"announce",2:"announce"};
					break;
				}
				if(datacount<21) {
					(newflag==0)?(list="<dd></dd>",icon=""):list="<dd class='new'></dd>";
					$(list).html(pubdate + '<a href="' + link + '">' + title + '</a>' + icon).appendTo('dl.'+category[$(this).children("category").text()]);
					datacount++;
				}
			});
		}
	});
});

