$(function(){
	$.ajax({
		url: "index.xml",//RSSファイル名
		async: true,
		cache: false,
		dataType:"xml",
		success: function(xml){
			$(xml).find('item').each(function(i){
				var title = $(this).find('title').text();
				var url = $(this).find('link').text();
                var description = $(this).find('description').text();
				//日付を整形
				var date = dateParse($(this).find('pubDate').text());
				if (url == '') {
				    $('.scroll').append('<dl class="Topnews clearfix"><dt class="Update basicTxt12">'+date[0]+'</dt><dd class="TopnewsContent basicTxt12"><span class="red">'+title+'</span>'+description+'</dd>');
				} else {
				    $('.scroll').append('<dl class="Topnews clearfix"><dt class="Update basicTxt12">'+date[0]+'</dt><a href="' + url+ '"><dd class="TopnewsContent basicTxt12"><span class="red">'+title+'</span>'+description+'</dd></a>');
				}
    		});
		}
	});
});

function dateParse(str){
    var objDate = new Date(str);
    var nowDate = new Date();
    //現在の日付との差を計算
    myDay = Math.floor((nowDate.getTime()-objDate.getTime()) / (1000*60*60*24)) + 1;
    var year = objDate.getFullYear();
    var month = objDate.getMonth() + 1;
    var date = objDate.getDate();
    if ( month < 10 ) { month = "0" + month; }
    if ( date < 10 ) { date = "0" + date; }
    str = year + '.' + month + '.' + date;
    rtnValue = new Array(2);
    rtnValue[0] = str;
    return rtnValue;
}