// JavaScript Document
// controls for main player. PlayerID is the ID of the HTML element that the player is in.
function controls(playerID){
	this.playerID = playerID;
	this.play = function() {
		if($f(this.playerID).isPlaying()){
			$f(this.playerID).pause();
		}else if($f(this.playerID).isPaused()) {
			$f(this.playerID).play()
		}
	}
	// shows and hides quality settings if the stream is live or prerecorded along with "check live" button
	this.clip = function(newClip,newProvider) {
		$f(this.playerID).play({provider:newProvider,url:newClip});
		var alertDisplay = $f(this.playerID).getPlugin('liveAlert').display;
		if(newProvider != 'prerecord') {
			document.getElementById('quality').style.visibility = 'visible';
			document.getElementById('qImg').style.visibility = 'visible';
			if(alertDisplay == 'block') {
				$f(this.playerID).getPlugin('liveAlert').hide();
			}
		}else if(newProvider == 'prerecord'){
			if(alertDisplay == 'none') {
				$f(this.playerID).getPlugin('liveAlert').show();
			}
			document.getElementById('quality').style.visibility = 'hidden';
			document.getElementById('qImg').style.visibility = 'hidden';
		}
	}
}

var controlPlayer = new controls('live');
