var volume=100; var mute_a = 0;
function onytplayerStateChange(newState) {setytplayerState(newState);}
function onPlayerError(errorCode) {alert("An error occured: " + errorCode);}
function loadNewVideo(id, startSeconds) {if (ytplayer) {ytplayer.loadVideoById(id, parseInt(startSeconds));}}
function cueNewVideo(id, startSeconds) {if (ytplayer) {ytplayer.cueVideoById(id, startSeconds);}}
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();}}
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 volup() {if (volume == 100) {} else {volume = volume + 10; setVolume(volume);}}
function voldn() {if (volume == 0) {} else {volume = volume - 10; setVolume(volume);}}
function toggle_mute() {if (mute_a == 1) {unMute(); mute_a = 0;} else if (mute_a == 0) {mute(); mute_a = 1;}}
function ajaxLoad(targetID,fileCall) {
	var xmlhttp;
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById(targetID).innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET",fileCall,true);
	xmlhttp.send();
}
function makeVideoPlayer(ytID) {
	//var code = "http://www.strand-theatre-shelbyville.org/wp-content/themes/paalam-11/video_player.php?video=" + ytID;
	//var codeFile = "http://www.strand-theatre-shelbyville.org/wp-content/themes/paalam-11/video_player.php";
	//ajaxLoad("video-post-holder",codeFile);
	//setTimeout("startPlayer();",5000);
	var html='';
	html=html+'<iframe src="http://www.strand-theatre-shelbyville.org/wp-content/themes/paalam-11/video_player_frame.php?video=';
	html=html+ytID+'" width="100%" height="570" frameborder="0" style="background: transparent;"></iframe>';
	document.getElementById('video-post-holder').innerHTML=html;
}
function statusLoop() {
	updateLoadStatus();
	updatePlayStatus();
	setTimeout("statusLoop();", 1000)
}
function updateLoadStatus() {
	var percentLoaded = getBytesLoaded() / getBytesTotal();
	var loadedWidth = Math.round(percentLoaded * 575); //575 = status bar width
	document.getElementById('loaded-status').style.width=loadedWidth+'px';
}
function updatePlayStatus() {
	var percentLoaded = getCurrentTime() / getDuration();
	var loadedWidth = Math.round(percentLoaded * 575); //575 = status bar width
	document.getElementById('play-status').style.width=loadedWidth+'px';
}
