jQuery(document).ready(function($) {
	var cnt = 0;

	get_xml("#bx_info","rss.xml",parse_info_xml);
	
	// xmlデータ解析
	function parse_info_xml(xml,status){
	
		if(status!='success')return;

		$("DIV#bx_info .hd").ready(function(){
			$("<h2>" +
			"<div style=\"float:left;\">おしらせ</div>" +
			"<div style=\"float:right;\"><a href=\"rss.xml\"><img src=\"img/icon_rss.gif\"></a></div>" +
			"<br style=\"clear:both;\" />" +
			"</h2>").appendTo('DIV#bx_info .hd');
		});
		
		cnt = 0;
		$(xml).find('item').each(write_info_row);
		
	}
	/////////////////
	// 1件分のデータをtable要素に追加
	function write_info_row(){

		var title=$(this).find('title').text();
		var link=$(this).find('link').text();
		var description=$(this).find('description').text();

		var date;
		$(this).children().each(function() {
			if ($(this)[0].tagName == "dc:date") {
				date = $(this).text();
			}
		});
		
		var c_item = "";
		c_item += "<li>";
		c_item += "<div class=\"info_date\">"+date+"</div>";
		c_item += "<p>";
		if (link != "") {
			c_item += "<a class=\"info_title\" href=\""+link+"\">";
		}
		c_item += title;
		if (link != "") {
			c_item += "</a>";
		}
		cnt++;
		c_item += "<div class=\"info_description\" id=\"info_"+date+"_"+cnt+"\">";
		c_item += description;
		c_item += "</div>";
		c_item += "</p>";

		///////////////////
		//if (description != "") {
		//	c_item += "<br>" + description;
		//}
		///////////////////
		c_item += "</li>";

		$('DIV#bx_info .bd ul').ready(function(){
			$(c_item).appendTo('DIV#bx_info .bd ul');
		});
	}

});

