function onYouTubePlayerReady(playerId) {
  ytplayer = document.getElementById("myytplayer");
  setInterval(updateytplayerInfo, 250);
  updateytplayerInfo();
  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
  ytplayer.addEventListener("onError", "onPlayerError");
}
function onPlayerError(errorCode) {
  alert("An error occured: " + errorCode);
}
function onytplayerStateChange(newState) {
  setytplayerState(newState);
}
function loadNewVideo(id, startSeconds) {
  if (ytplayer) {
    ytplayer.loadVideoById(id, parseInt(startSeconds));
  }
}
function cueNewVideo(id, startSeconds) {
  document.getElementById('flvplayerbuttons').style.display='none';
  document.getElementById('wmvplayer').style.display='none';
  document.getElementById('ytvideo').style.display='';
  document.getElementById('videoplayer').style.display='none';
  document.getElementById('flvplayer').innerHTML='';
  var ytplayer=document.getElementById('myytplayer');
  if (ytplayer) {
    ytplayer.cueVideoById(id, startSeconds);
    setTimeout ( 'timeoutroutine()', 500 );
    url='http://www.youtube.com/v/' + id + '&hl=en&fs=1&autoplay=1';
  }
}
function timeoutroutine() {
  if (ytplayer) {
    play();
  }
}
function play() {
  if (ytplayer) {
	ytplayer.playVideo();
    setTimeout ( 'timeoutroutine()', 34816 );
  }
}
var url='http://www.youtube.com/v/8AGTpu_i8sc&hl=en&fs=1&autoplay=1'
function fullscreen() {
    if (ytplayer) {
      ytplayer.stopVideo();
      window.open(url,'mywindow','width=1000','height=1000');
    }
}
function ytpause() {
    if (ytplayer) {
	    ytplayer.pauseVideo();
    }
}
function ytstop() {
    if (ytplayer) {
	    ytplayer.stopVideo();
    }
}
function ytmute() {
	if (ytplayer) {
		ytplayer.mute();
	}
}
function ytunmute() {
	if (ytplayer) {
		ytplayer.unMute();
	}
}
google.load("swfobject", "2.1");
