var ismute=false;
        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");
        }

        function onytplayerStateChange(newState) {
          setytplayerState(newState);
        }

        function updateytplayerInfo() {
          /*updateHTML("bytesloaded", getBytesLoaded());
          updateHTML("bytestotal", getBytesTotal());
          updateHTML("videoduration", getDuration());
          updateHTML("videotime", getCurrentTime());
          updateHTML("startbytes", getStartBytes());
          updateHTML("volume", getVolume());*/
        }

        // functions for the api calls
        function loadNewVideo(id, startSeconds) {
						document.getElementById('googlePlayer').innerHTML='';
		document.getElementById('customPlayer').style.visibility='visible';
document.getElementById('googlePlayer').style.visibility='hidden';

          if (ytplayer) {
			 var oldid=currentVid;
		  	currentVid=id;
            ytplayer.loadVideoById(id, parseInt(startSeconds));
			updateColor(oldid);
          }
        }

        function cueNewVideo(id, startSeconds) {
          if (ytplayer) {
            ytplayer.cueVideoById(id, startSeconds);
          }
        }

        function play() {
          if (ytplayer) {
		  	if (document.getElementById('playerstate').innerHTML == '0') {
			loadNewVideo(currentVid,"0");
			}else{
            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) {
		  if (ismute == false) {
            ytplayer.mute();
			ismute=true;
			document.getElementById('myVolume').innerHTML="Muted";
			}else{
				unMute();
				ismute=false;
			}
          }
        }

        function unMute() {
          if (ytplayer) {
            ytplayer.unMute();
			document.getElementById('myVolume').innerHTML=getVolume() + "%";
          }
        }
        
        function getEmbedCode() {
          alert(ytplayer.getVideoEmbedCode());
        }

        function getVideoUrl() {
          alert(ytplayer.getVideoUrl());
        }
        
        function setVolume(newVolume) {
          if (ytplayer) {
            ytplayer.setVolume(newVolume);
          }
        }

        function getVolume() {
          if (ytplayer) {
            return ytplayer.getVolume();
          }
        }

        function clearVideo() {
          if (ytplayer) {
            ytplayer.clearVideo();
          }
        }
        
		function loadingVid() {
//alert(currentVid);
		//GvRG-BxB0b0
		
		loadNewVideo(currentVid,"0");
		setVolume(100);
		document.getElementById('myVolume').innerHTML="100%";
		}
		
		function updateColor(oldid) {

			
			var theParent="box_" + oldid;
			
			document.getElementById(theParent).style.backgroundColor="#ffffff";
			
			var theParent2="box_" + currentVid;
			
			document.getElementById(theParent2).style.backgroundColor="#D5D1C8";
			
			
		}
		
		function volAdjust(x) {
				var theVolume=getVolume();

					
			
				theVolume=theVolume + x;
				if ((theVolume <= 100)&&(theVolume >= 0)) {
				setVolume(theVolume);
				document.getElementById('myVolume').innerHTML=theVolume + "%";
				}
		}
		function googlePlayer(id) {
			document.getElementById('googlePlayer').innerHTML='<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=' + id + '" style="width:425px;height:344px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"> </embed>';
		}
		
		function loadGoogle(id) {
			stop();
googlePlayer(id);
			
document.getElementById('customPlayer').style.visibility='hidden';
document.getElementById('googlePlayer').style.visibility='visible';
//document.getElementById('VideoPlayback').src="http://video.google.com/googleplayer.swf?docid=" + id;

		}
		
		
