﻿
$(function() {});
google.load("feeds", "1");

$(function() {
 // YouTube へのリンク
$("a[href*='.youtube.com/watch']").live("focus", function(){$(this).lightpop();});
$("a[href*='.youtube.com/watch']").live("mouseover", function(){$(this).lightpop();});
});

function initialize() {
var ytfeed = new google.feeds.Feed("http://gdata.youtube.com/feeds/base/users/sobaprm/uploads?alt=rss&amp;v=2&amp;orderby=published");
ytfeed.setNumEntries(4);//フィードの表示数の設定

ytfeed.load(function(result) {
  if (!result.error) {
    var containerObj = document.getElementById("youtube");
for (var i = 0; i < result.feed.entries.length; i++) {
      var item = result.feed.entries[i];
      var date = new Date(item.publishedDate);
      var yy = date.getYear();
      var mm = date.getMonth() + 1;
      var dd = date.getDate();
      if (yy < 2000) { yy += 1900; }
      if (mm < 10) { mm = "0" + mm; }
      if (dd < 10) { dd = "0" + dd; }
      var link = item.link.split("&")[0];
      var imglink =link.replace("www.youtube.com/watch?v=", "i.ytimg.com/vi/") + "/0.jpg";
      var dlObj = document.createElement("dl");
      var dtObj = document.createElement("dt");
      var ddObj = document.createElement("dd");
      var aObj =document.createElement("a");
      var imgObj = document.createElement("img");
      dtObj.appendChild(document.createTextNode(yy + "/" + mm + "/" + dd + " "));
      imgObj.setAttribute("src",imglink);
      imgObj.setAttribute("width", "160");
      imgObj.setAttribute("height", "120");

//      aObj.setAttribute("href", link);
//      aObj.setAttribute("rel", "lightbox[social 480 360]");
      aObj.setAttribute("href", link);
      aObj.setAttribute("title", item.title);
      aObj.appendChild(imgObj);
      aObj.appendChild(document.createElement("br"));
      aObj.appendChild(document.createTextNode(item.title));
      ddObj.appendChild(aObj);
      dlObj.appendChild(dtObj);
      dlObj.appendChild(ddObj);
      containerObj.appendChild(dlObj);
    }
  }

});

}



google.setOnLoadCallback(initialize);


