function setMarquee( duration ){

	document.getElementById("marqueetext").innerHTML = 'Xzibit - X';

//	if( duration == 258 ){
//		document.getElementById("marqueetext").innerHTML = 'Snoop Dogg - Gin & Juice (Uncensored)';
//	}
//	if( duration == 274 ){
//		document.getElementById("marqueetext").innerHTML = 'N.W.A - Express your self';
//	}
//	if( duration == 407 ){
//		document.getElementById("marqueetext").innerHTML = '2Pac - California Love';
//	}
//	if( duration == 232 ){
//		document.getElementById("marqueetext").innerHTML = 'Dr.Dre & Eminem - Forgot About Dre';
//	}
}

function updateHTML(elmId, value) {
          document.getElementById(elmId).innerHTML = value;
}

function setytplayerState(newState) {
//    updateHTML("playerstate", newState);
}

function onYouTubePlayerReady(playerId) {
    ytplayer = document.getElementById("myytplayer");
    setInterval(updateytplayerInfo, 250);
    updateytplayerInfo();
    ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
    ytplayer.addEventListener("onError", "onPlayerError");
}

function onytplayerStateChange(newState) {
   setytplayerState(newState);
}

function onPlayerError(errorCode) {
  alert("An error occurred: "+ errorCode);
}

function updateytplayerInfo() {
//  updateHTML("bytesloaded", getBytesLoaded());
//  updateHTML("bytestotal", getBytesTotal());
//  updateHTML("videoduration", getDuration());
   setMarquee(getDuration());
//  updateHTML("videotime", getCurrentTime());
//  updateHTML("startbytes", getStartBytes());
}

// functions for the api calls
function play() {
  if (ytplayer) {
    ytplayer.playVideo();
  }
}

function pause() {
  if (ytplayer) {
    ytplayer.pauseVideo();
  }
}

function stop() {
  if (ytplayer) {
    ytplayer.stopVideo();
  }
}

function getPlayerState() {
  if (ytplayer) {
    return ytplayer.getPlayerState();
  }
}

function seekTo(seconds) {
  if (ytplayer) {
    ytplayer.seekTo(seconds, true);
  }
}

function getBytesLoaded() {
  if (ytplayer) {
    return ytplayer.getVideoBytesLoaded();
  }
}

function getBytesTotal() {
  if (ytplayer) {
    return ytplayer.getVideoBytesTotal();
  }
}

function getCurrentTime() {
  if (ytplayer) {
    return ytplayer.getCurrentTime();
  }
}

function getDuration() {
  if (ytplayer) {
    return ytplayer.getDuration();
  }
}

function getStartBytes() {
  if (ytplayer) {
    return ytplayer.getVideoStartBytes();
  }
}

function mute() {
  if (ytplayer) {
    ytplayer.mute();
  }
}

function unMute() {
  if (ytplayer) {
    ytplayer.unMute();
  }
}
