var pVid;
var pVideoURL = 'http://www.youtube.com/v/';
var pWatchURL = 'http://www.youtube.com/watch?v=';

function jumpPageTop() {
 var anim = new YAHOO.util.Scroll(
  document.getElementsByTagName("html")[0],
  { scroll: { to: [0, 0] } },
  0.5,
  YAHOO.util.Easing.eathBoth
 );
 anim.animate();
}

// Ajaxプログラム
function YouTubeAjax(vid) {	
	pVid = vid;
	var display = document.getElementById("YouTubeVideo");
	display.style.visibility ='hidden';
	var loading = document.getElementById("loading-icon");	
	loading.style.display ='block';
	
	var url = 'connect_detail.php';
	var pars = 'vid=' + encodeURI(vid);			
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get', 
			parameters: pars,
			onComplete: showDetail
		});
}

// Ajax処理後に動作するプログラム
function showDetail(o) {
	var videoWidth = 374;
	var videoHeight = 308;
	var root = o.responseXML.documentElement;	
	var title       = root.getElementsByTagName('title')[0].firstChild.nodeValue;
	var description = root.getElementsByTagName('description')[0].firstChild.nodeValue;	
	
	var loading = document.getElementById("loading-icon");	
	loading.style.display ='none';
	
	var display = document.getElementById("YouTubeVideo");	
	display.innerHTML ='<object id="youtube-obj" width="' + videoWidth + '" height="' + videoHeight + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="' + pVideoURL + pVid + '"></param><param name="wmode" value="transparent"></param><embed src="' + pVideoURL + pVid + '" type="application/x-shockwave-flash" wmode="transparent" width="' + videoWidth + '" height="' + videoHeight + '"></embed></object><h4><a href="http://www.youtube.com/watch?v=' + pVid + '" title="' + title + '">' + title + '</a></h4><h5>' + description + '</h5>';
	display.style.visibility ='visible';
}