// JavaScript Document

google.load("feeds", "1");
//google.setOnLoadCallback(initialize);
google.setOnLoadCallback(initialize2);
google.setOnLoadCallback(initialize3);
google.setOnLoadCallback(initialize4);

function initialize() {
	var feed = new google.feeds.Feed("http://www.f-plaza.co.jp/wp/story/feed");
	feed.load(function(result) {
		if (!result.error) {
			var container = document.getElementById("feed");
			var b_title = result.feed.title;
			var b_link = result.feed.link;
			var entry = result.feed.entries[0];
			var eTitle = entry.title;
			var eCont = entry.contentSnippet.substring(0, 30);
			var htmlstr = "";
			var imgstr ="";
			var imgCheck = entry.content.match(/(src="http:){1}[\S_-]+((\.jpg)|(\.JPG))/);
			if(imgCheck){
				imgstr += '<a href="http://www.f-plaza.co.jp/wp/story/">';
				imgstr += '<img ' + imgCheck[0] + '" height = 70 /></a>';
			}
			htmlstr += '<table width="215" cellpadding="5"><tbody><tr><td><span>' + b_title +  '</span></td><td align="right"><a href="http://www.f-plaza.co.jp/wp/story/"><img src="./images/more.gif"></a></td></tr></tbody></table>';
			htmlstr += '<table width="215" cellpadding="5"><tbody><tr>';
			htmlstr += '<td width="60">'+ imgstr +'</td><td>'+ eTitle +'</br>'+ eCont +'</td></tr></tbody></table>';
			
			container.innerHTML = htmlstr;
		}
	});
}
function initialize2() {
	var feed2 = new google.feeds.Feed("http://www.f-plaza.co.jp/wp/dog/feed");
	feed2.load(function(result) {
		if (!result.error) {
			var container = document.getElementById("feed2");
			var b_title = result.feed.title;
			var b_link = result.feed.link;
			var entry = result.feed.entries[0];
			var eTitle = entry.title;
			var eCont = entry.contentSnippet.substring(0, 30);
			var htmlstr = "";
			var imgstr ="";
			var imgCheck = entry.content.match(/(src="http:){1}[\S_-]+((\.jpg)|(\.JPG))/);
			if(imgCheck){
				imgstr += '<a href="http://www.f-plaza.co.jp/wp/dog/">';
				imgstr += '<img ' + imgCheck[0] + '" height = 70 /></a>';
			}
			htmlstr += '<table width="215" cellpadding="5"><tbody><tr><td><span>' + b_title +  '</span></td><td align="right"><a href="http://www.f-plaza.co.jp/wp/dog/"><img src="./images/more.gif"></a></td></tr></tbody></table>';
			htmlstr += '<table width="215" cellpadding="5"><tbody><tr>';
			htmlstr += '<td width="60">'+ imgstr +'</td><td>'+ eTitle +'</br>'+ eCont +'</td></tr></tbody></table>';
			
			container.innerHTML = htmlstr;
		}
	});
}

function initialize3() {
	var feed3 = new google.feeds.Feed("http://fplaza4228181.blog79.fc2.com/?xml");
	feed3.load(function(result) {
		if (!result.error) {
			var container = document.getElementById("feed3");
			var b_title = result.feed.title;
			var b_link = result.feed.link;
			var entry = result.feed.entries[0];
			var eTitle = entry.title;
			var eCont = entry.contentSnippet.substring(0, 30);
			var htmlstr = "";
			var imgstr ="";
			var imgCheck = entry.content.match(/(src="http:){1}[\S_-]+((\.jpg)|(\.JPG))/);
			if(imgCheck){
//				imgstr += '<a href="' + entry.link + '">';
				imgstr += '<a href="' + b_link + '" target="_blank">';
				imgstr += '<img ' + imgCheck[0] + '" height = 70 /></a>';
			}
			htmlstr += '<table width="215" cellpadding="5"><tbody><tr><td><span>STAFF BLOG</span></td><td align="right"><a href=' + b_link + ' target="_blank"><img src="./images/more.gif"></a></td></tr></tbody></table>';
			htmlstr += '<table width="215" cellpadding="5"><tbody><tr>';
			htmlstr += '<td width="60">'+ imgstr +'</td><td>'+ eTitle +'</br>'+ eCont +'...</td></tr></tbody></table>';
			
			container.innerHTML = htmlstr;
		}
	});
}

function initialize4() {
    var feed4 = new google.feeds.Feed("http://plazakochan.blog41.fc2.com/?xml");
    feed4.setNumEntries(3);
    feed4.load(function(result) {
        if (!result.error) {
            var ul = document.createElement("ul");
            for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var li = document.createElement("li");
                var a  = document.createElement("a");
                a.setAttribute("title", entry.title);
                a.setAttribute("href",  result.feed.link);
				a.setAttribute("target", "_blank");
                a.appendChild(document.createTextNode(entry.title));
                li.appendChild(a);
                ul.appendChild(li);
            }
            var container = document.getElementById("archives");
            container.appendChild(ul);
        }
    });
};

