$(function(){
	
	$.ajax({  
		url: 'common/php/hannari_rss.php',  
		type: 'GET',  
		dataType: 'xml',
		timeout: 5000,
		error: function(){  
			//alert('xmlファイルの読み込みに失敗しました');
		},
		success: function(xml){
			var tag = '<ul>';
			$(xml).find("item").each(function(){
				var item = {};
				$(this).children().each(function() {
					var thisItem = $(this);
					switch(thisItem[0].tagName){
						case "title":
							item.title = thisItem.text();
							break;
						case "link":
							item.link = thisItem.text();
							break;
						case "dc:date":
							item.date = thisItem.text();
							break;
						case "dc:publisher":
							item.publisher = thisItem.text();
							break;
					}
				});
				item.date.match(/\d\d(\d\d)-(\d\d)-(\d\d)/);
				item.date = RegExp.$1 + '/' + RegExp.$2 + '/' + RegExp.$3;
				tag +=	'<li>\n' +
							'<span class="datefield">' + item.date + '</span><br />\n' +
							'<a href="' + item.link + '" target="_New" class="titlefield">' + item.title + '</a>\n' +
							'<span class="publisherfield">(' + item.publisher + ')</span><br />\n' +
						'</li>\n';
			});
			tag += '</ul>';
			$('#feeds').append(tag);
		}
	});

});
