var Volume=parseInt(getCookie("NewPlayer_Volume"));
var playerState=parseInt(getCookie("NewPlayer_State"));
var expdate = new Date();


	expdate.setDate(expdate.getDate() + 30); 

	if (isDigit(Volume) == false) {
		Volume=49;
	}

	if (isDigit(playerState) == false) {
		playerState=1;
	}

	function isDigit(strNum){
		return /^\-?\d+(\.\d+)?$/.test(strNum);
	}


	function UpdateAlt(){
		document.getElementById("num").innerHTML = Volume
	}

	function SetVol(x){
		MediaPlayer.settings.volume=x
		setCookie("NewPlayer_Volume", x, expdate, "/", null);
		setTimeout('UpdateAlt();', 500);


	}
	


	function VolMax(){
		if (MediaPlayer.playState == 3){
			if (Volume == 90){
				Volume += 9;
				SetVol(Volume);
			}
			else
			if (Volume != 99){
				Volume += 10;
				SetVol(Volume);
			}
		}
	}



	function VolMin(){
		if (MediaPlayer.playState == 3){
			if (Volume == 9){
				Volume -= 9;
				SetVol(Volume);
			}
			else
			if (Volume != 0){
				Volume -= 10;
				SetVol(Volume);
			}
		}
		
	}

	function MPplay(){
		/* Check first to be sure the operation is valid. */
		if (MediaPlayer.controls.isAvailable('Play'))
			/* Start playback. */
			MediaPlayer.controls.play();
	}

	function MPstop(){
		/* Check first to be sure the operation is valid. */
		if (MediaPlayer.controls.isAvailable('Stop'))
			/* Stop the player. */
			MediaPlayer.controls.stop();
	}

	function MPpause(){
		/* Check first to be sure the operation is valid. */
		if (MediaPlayer.controls.isAvailable('Pause')){
			/* Pause the player. */
			MediaPlayer.controls.pause();
			}
	}

	function MPnext(){
		/* Check first to be sure the operation is valid. */
		if (MediaPlayer.controls.isAvailable('Next')){
			/* Move to the next item in the playlist. */
			MediaPlayer.controls.next();
			}
	}

	function MPback(){
		/* Check first to be sure the operation is valid. */
		if (MediaPlayer.controls.isAvailable('Previous')){
			/* Move to the preceding item in the playlist. */
			MediaPlayer.controls.previous();
			}
	}

	function MPfastforward(){
		/* Execute JScript when the BUTTON is clicked. 
		Check first to make sure fast-forward mode is available for this particular media item */
		if (MediaPlayer.controls.isAvailable('FastForward')){
			MediaPlayer.controls.fastForward();
			}
	}

	function MPfastreverse(){
		/* Execute JScript when the BUTTON is clicked. 
		Check first to make sure fast-reverse mode is available for this particular media item */
		if (MediaPlayer.controls.isAvailable('FastReverse')){
			MediaPlayer.controls.fastReverse();
			}
	}

	function thisMovie(movieName) {
		// IE and Netscape refer to the movie object differently.
		// This function returns the appropriate syntax depending on the browser.
		if (navigator.appName.indexOf ("Microsoft") !=-1) {
			return window[movieName]
			}
		else {
			return document[movieName]
		}
	}

	// Checks if movie is completely loaded.
	// Returns true if yes, false if no.
	function movieIsLoaded (theMovie) {
		if (typeof(theMovie) != "undefined") {
			return theMovie.PercentLoaded() == 100;
			}
		else {
		    return false;
		}
	}

	function playmovie(movieName) {
		if (movieIsLoaded(thisMovie(movieName))) {
			thisMovie(movieName).Play();
		}
	}

	function stopmovie(movieName) {
		if (movieIsLoaded(thisMovie(movieName))) {
			thisMovie(movieName).StopPlay();
		}
	}

	function go(movieName, theFrame) {
		if (movieIsLoaded(thisMovie(movieName))) {
			thisMovie(movieName).GotoFrame(theFrame);
		}
	}

	function golabel(movieName, lbl) {
		if (movieIsLoaded(thisMovie(movieName))) {
			thisMovie(movieName).TGotoLabel("_level0/",lbl);
		}
	}

	function StopFunction() {
		if (player != 'stop') {
			PlayBtn.src='images/play.gif'
			setCookie("NewPlayer_State", "0", expdate, "/", null);
			MPstop();
			stopflash('playerleft');
			stopflash('playerright');
			x = 'play'
			setTimeout("SetPlayerStatus('stop')",1000);
		}
	}

	function PlayOrPauseFunction() {
		if (player != 'play')
			{
			PlayBtn.src='images/pause.gif'
			PlayBtn.alt='Pause'
			setCookie("NewPlayer_State", "1", expdate, "/", null);
			MPplay();
			playflash('playerleft');
			playflash('playerright');
			x = 'pause'
			setTimeout("SetPlayerStatus('play')",1000);
			}
		else
			{
			PlayBtn.src='images/play.gif'
			PlayBtn.alt='Play'
			MPpause();
			stopflash('playerleft');
			stopflash('playerright');
			x = 'play'
			setTimeout("SetPlayerStatus('stop')",1000);
			}
			
	}


	function NextFunction() {
		MPnext();
	}

	function BackFunction() {
		MPback();
	}

	function SetPlayerStatus(status) {
		player=status;
	}

	function playflash(obj)
		{
		go(obj, 1)
		playmovie(obj)
		}

	function stopflash(obj)
		{
		go(obj, 2)
		stopmovie(obj)
		}


	function setCookie(name, value, expires, path, domain, secure)
	{
	    document.cookie= name + "=" + escape(value) +
	        ((expires) ? "; expires=" + expires.toGMTString() : "") +
	        ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        ((secure) ? "; secure" : "");
	}

	function getCookie(name) {
		var prefix = name + "=";
		var begin = document.cookie.indexOf(prefix);

		if (begin == -1) return null;

			var end = document.cookie.indexOf(";", begin);


		if (end == -1) end = document.cookie.length;

			return unescape(document.cookie.substring(begin + prefix.length, end));
	}

				
	function IsAvailble(btn){
		if (MediaPlayer.controls.isAvailable(btn))
			return true;
		else
			return false;
	}
				
	function btn_flip(objBtn, a, btn){
		var b_path='Images/tv/tv_'
		
		if (a == true)
			objBtn.src=b_path + btn + '_on.gif'
		else
			objBtn.src=b_path + btn + '_off.gif'
	}


