// RSS Feeds
function rss (param) {

	var rootPath = "http://www.opto.co.jp/";
	var categoryPath;
	var titleStr = "新着情報";
	
	switch (param) {
	case 'products':
		categoryPath = rootPath + "products/";
		xmlPath = '/rss/products.xml';
		trimStr = "【製品情報】";
		break;
	case 'ir':
		categoryPath = rootPath + "investors/";
		xmlPath = '/rss/ir.xml';
		trimStr = "【投資家情報】";
		break;
	case 'release':
		categoryPath = rootPath + "investors/";
		xmlPath = '/rss/release.xml';
		trimStr = "【プレスリリース】";
		break;
	case 'recruit':
		categoryPath = rootPath + "recruit/";
		xmlPath = '/rss/recruit.xml';
		trimStr = "【採用情報】";
		break;
	default:
		xmlPath = '/rss/index.xml';
		break;
	}

	jQuery(function() {
	jQuery.getFeed({
	
		url : xmlPath ,
		success: function(feed) {
	
		var html = new Array();

		if (feed.items.length > 0 ) {

		html.push('<h2>');
		html.push(titleStr);
		html.push('</h2>');
		
		html.push('<table class="tableInfo"><colgroup width="125"></colgroup><colgroup></colgroup>');
		for(var i = 0; i < feed.items.length && i < 5; i++) {

			var item = feed.items[i];
			var replacedTitle = item.title.replace(trimStr ,'');
			
			html.push('<tr>');
			html.push('<th>');
			html.push(changeDate(item.updated));
			html.push('</th>');
			html.push('<td><p>');
			if (item.link != rootPath){
				if (item.link != categoryPath){
				html.push('<a href="');
				html.push(item.link);
				html.push('">');
				}
			}
				html.push(replacedTitle);
			if (item.link != rootPath){
				html.push('</a>');
			}
			html.push('</p></td>');
			html.push('</tr>');
		}
		html.push('</table>');
		
		jQuery('#information').append(html.join(''));
		}
		}

	});
	});
	
	//日付表記を変換
	function changeDate(str){
		var myDate=new Date(str);
		var YYYY=myDate.getFullYear();
		var MM=myDate.getMonth()+1;
	//	if(MM<10){MM="0"+MM;}
		var DD=myDate.getDate();
	//	if(DD<10){DD="0"+DD;}
		var date=YYYY+"年"+MM+"月"+DD+"日";
		return date;
	}
}