$(function(){
	$.ajax({
		url: "http://www.sumacole.jp/common/js/proxy.php",
		async: true,
		cache: false,
		dataType:"xml",
		success: function(xml){
			$('#feedlist').html('');
			$(xml).find('item').each(function(i){
                if ( i > 10 ) {
                    return false;
                }
				var title = $(this).find('title').text();
				var url = $(this).find('link').text();
				var date = dateParse($(this).find('pubDate').text());
				$('#feedlist').append('<dl><dt>'+date[0]+date[1]+'</dt><dd><a href="'+url+'">'+title+'</a></dd></dl>');
    		});
		}
	});
});
function dateParse(str){
    var objDate = new Date(str);
	var nowDate = new Date();
    myDay = Math.floor((nowDate.getTime()-objDate.getTime()) / (1000*60*60*24)) + 1;
    if (myDay < 7 ){
        var newMsg = '&nbsp;<img src="./images/new.gif" />';
    } else {
        var newMsg = '';
    }
    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.substr(2,8);
    rtnValue[1] = newMsg;
    return rtnValue;
}
function remove_newline(text){
	text = text.replace(/\r\n|\n|\<br \/\>|\<div(.+?)\>|\<\/div\>|\<a(.+?)\<\/a\>/g, "");
	return text;
} 
