// JavaScript Document
function controls(playerID){
	this.playerID = playerID;
	var checkStream = new checkLive();
	this.play = function() {
		if($f(this.playerID).isPlaying()){
			$f(this.playerID).pause();
			document.getElementById('play').style.backgroundImage = "url('./img/play.png')";
		}else if($f(this.playerID).isPaused()) {
			$f(this.playerID).play()
			document.getElementById('play').style.backgroundImage = "url('./img/pause.png')";
		}
	}
	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('qualitySettings').style.visibility = 'visible';
			clearInterval(this.checkStatus);
			if(alertDisplay == 'block') {
				$f(this.playerID).getPlugin('liveAlert').hide();
			}
		}else if(newProvider == 'prerecord'){
			document.getElementById('qualitySettings').style.visibility = 'hidden';
			this.checkStatus = setInterval(checkStream.sendCheck,10000);
		}
	}
	this.cVol = function(nVol){
		$f(playerID).setVolume(nVol.value);
	}
	this.mute = function(){
		var volume = $f(playerID).getVolume();
		if(volume == 0) {
			$f(playerID).setVolume(50)
			document.getElementById('volTxt').style.backgroundImage = "url('./img/speaker.png')";
		}else{
			$f(playerID).setVolume(0);
			document.getElementById('volTxt').style.backgroundImage = "url('./img/speakerEX.png')";
		}
	}
}

var controlPlayer = new controls('player');