function caricaPlayer() {
	var params = { allowScriptAccess: "always" };
   	var atts = { id: "myVideoPlayer" };
   	swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytPlayer", "videoPlayer", "463", "285", "8", null, null, params, atts);
}

function onYouTubePlayerReady(playerId) {
	ytPlayer = $("myVideoPlayer");
//	setInterval(updateytPlayerInfo, 250);
//	updateytPlayerInfo();
	ytPlayer.cueVideoById('-qYo8xesJm4');
	ytPlayer.setVolume(10);
//	ytPlayer.playVideo('qzCrgQEZr5I');
}

function loadNewVideo(id) {
	if (ytPlayer) {
		//ytPlayer.loadVideoById(id);
		ytPlayer.cueVideoById(id);
		ytPlayer.setVolume(10);
		ytPlayer.playVideo(id);
	}
}

function play() {
	if (ytPlayer) {
		ytPlayer.playVideo();
	}
}

function pause() {
	if (ytPlayer) {
		ytPlayer.pauseVideo();
	}
}

function setVolume(newVolume) {
	if (ytPlayer) {
		ytPlayer.setVolume(newVolume);
	}
}



/*
function updateytPlayerInfo() {
	var duration = getDuration();
	var currentTime = getCurrentTime();
	var volume = getVolume();
	$('videoduration').update(duration);
	$('videotime').update(currentTime);
	$('volume').update(volume);
}

   function getCurrentTime() {
	if (ytPlayer) {
		return ytPlayer.getCurrentTime();
	}
   }

   function getDuration() {
	if (ytPlayer) {
		return ytPlayer.getDuration();
	}
   }

   function mute() {
	if (ytPlayer) {
		ytPlayer.mute();
	}
   }

   function unMute() {
	if (ytPlayer) {
		ytPlayer.unMute();
	}
   }

   function stop() {
	if (ytPlayer) {
		ytPlayer.stopVideo();
		ytPlayer.clearVideo()
	}
   }

   function setVolume(newVolume) {
	if (ytPlayer) {
		ytPlayer.setVolume(newVolume);
	}
}

   function getVolume() {
	if (ytPlayer) {
		return ytPlayer.getVolume();
	}
   }
*/

google.load('search', '1');


function caricamentoRicercaVideo() {
	
		$('tv_more').show();
		
		// create a search control
 		var searchControl = new google.search.SearchControl();
 
  		// create a draw options object so that we
 		// can position the search form root
 		var optionsRicerca = new google.search.DrawOptions();
 		optionsRicerca.setSearchFormRoot($('ricerca'));
 
 		// So the results are expanded by default
 		var optionsRisultato = new google.search.SearcherOptions();
 		optionsRisultato.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
	
		searchControl.setResultSetSize(google.search.Search.SMALL_RESULTSET);

 		// Create a video searcher and add it to the control
 		searchControl.addSearcher(new google.search.VideoSearch(), optionsRisultato);
 
 		// Draw the control onto the page
 		searchControl.draw($('altrivideo'), optionsRicerca);

 		// Search for a YouTube channel
 		searchControl.execute("ytchannel:progettisti");

		$('link').replace('<a href="http://www.youtube.com/progettisti" style="float:right" id="link"><strong>Vai al nostro canale video su YouTube!</strong></a>');
}

//google.setOnLoadCallback(caricamentoRicercaVideo);

Event.observe(window, 'load', caricaPlayer);