youtube.LiveSearchView = {
    update: function(videos) {
        var entries = videos.feed.entry;
	var html = "";
	if (! entries) {
	    html = '<span class="not_found">検索結果が見つかりませんでした。</span>';
	}
	else {
	    entries.each(function(entry, index) {
		var template = 
		    '<div id="#{id}" class="video">' + 
                    '  <a href="javascript:void(0)"><img class="thumbnail" src="#{thumbnail}" width="185" alt="#{title}" /></a>' +
                    '  <a href="javascript:void(0)"><div class="title">#{title}</div></a>' +
                    '</div>';
		html += template.interpolate({id:        entry.id.$t.match(/\/([^\/]+)$/)[1],
			                      thumbnail: entry.media$group.media$thumbnail[0].url,
			                      width:     entry.media$group.media$thumbnail[0].width,
			                      height:    entry.media$group.media$thumbnail[0].height,
		                          title:     entry.title.$t});
		if (index % 3 == 2) {
		    html += '<br class="clear" />';
 		}

	    });
	}
	$('search_results').update(html);
    },
    show: function(video) {
	var so = new SWFObject("http://www.youtube.com/v/" + video.id, 
	                       "video", "425", "353", "7", "#FFFFFF");
	so.write("player");

        myLightWindow.activateWindow({
	    href: document.location + '#player',
	    width: 425,
	    height: 353,
	    title: video.getElementsByClassName('title')[0].innerHTML
	});

    }
};
