var uplayerLCId = new Date().getTime();
var flashProxy = new FlashProxy(uplayerLCId, sJavaScriptFlashGatewaySWF);

/*
*****************************************************
Flash Interface - In
*****************************************************
*/

function flashIn_showVideo () {
	document.getElementById("MediaPlayerDiv").style.visibility = "visible";
	var oe = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"'
			+ 'type="application/x-oleobject"'
			+ 'codebase="HTTP://ACTIVEX.MICROSOFT.COM/ACTIVEX/CONTROLS/MPLAYER/EN/NSMP2INF.CAB#VERSION=6,4,7,1112"'
			+ 'standby="Loading Windows Media Player components..."'
			+ 'id="MediaPlayer">'
			+ '<param name="AUTOSTART" value="TRUE">'
			+ '<param name="uiMode" value="full">'
			+ '<embed type="application/x-mplayer2">'
				+ '<param name="AUTOSTART" value="TRUE">'
				+ '<param name="uiMode" value="full">'
			+ '</embed>'
		+ '</object>'
		document.getElementById("MediaPlayerDiv").innerHTML = oe;
	if(typeof(document.getElementById("MediaPlayer").status) == "undefined"){
		_sUseLCSyncBanner = "true";
		var sBannerURL = _sBase150x125+"&site="+sSiteID.toUpperCase();
		var divBanner = document.getElementById("leavebehindad");
		divBanner.style.visibility = "visible";		
		var sBannerHTML = '<HTML><IFRAME src="' + sBannerURL + '" frameborder="0" scrolling="no" width="100%" height="100%" marginwidth="0" marginheight="0"/></HTML>';
		divBanner.innerHTML = sBannerHTML;
	}else{
		_sUseLCSyncBanner = "false";
	}
	flashOut_playerInited();
}

//Only for browsers that do not have access to the WM player
function flashIn_lcPlayVideo(sLevel, sVideo){
	lcPlayVideo ('MediaPlayer', sLevel, sVideo);
}

function flashIn_hideAd(sDiv, bIsNewSegment){
	upReplaceBanner(sDiv, "", bIsNewSegment);
}

function flashIn_nonLCPlayVideo(sVideoURL, sBannerParams, sActiveDiv, bIsContent){
	var divMediaPlayer = document.getElementById("MediaPlayer");
	upReplaceBanner(sActiveDiv, sBannerParams);
	divMediaPlayer.url = sVideoURL;
	divMediaPlayer.controls.play();
	if(bIsContent){
		divMediaPlayer.enabled = true;
	}else{
		divMediaPlayer.enabled = false;
	}
}

function flashIn_userTimeOut(nTime){
	var answer = confirm ("You have been inactive for over " + nTime + " minutes.\n\n   Click OK to continue watching videos.\n   Click CANCEL to stop.");
	if (answer){
		flashOut_resumePlayer();
	}else{
		flashOut_cancelPlayer();
	}
}

function flashIn_noChannelData(bCheckVideo){
	if(!bCheckVideo){
		var answer = confirm ("The channel you requested is unavailable.\nPlease enjoy our scheduled programming.\nClick \"OK\" or \"Cancel\" to continue.");
		if (answer){
			flashOut_noChannelDataConfirm(false);
		}else{
			flashOut_noChannelDataConfirm(false);
		}
	}else{
		var answer = confirm ("The channel you requested is unavailable.\nWe will attempt to play your requested video.\nPlease click \"OK\" or \"Cancel\" to continue");
		if (answer){
			flashOut_noChannelDataConfirm(true);
		}else{
			flashOut_noChannelDataConfirm(true);
		}
	}
}

function flashIn_noVideoData(){
	var answer = confirm ("The video you requested is not available in our library.\nPlease enjoy our scheduled programming.\nClick \"OK\" or \"Cancel\" to continue.");
	if (answer){
		flashOut_noVideoDataConfirm();
	}else{
		flashOut_noVideoDataConfirm();
	}
}

function flashIn_noVideoInChannel(){
	var answer = confirm ("The video you requested is no longer available in this channel.\nWe will attempt to play your requested video from our library.\nPlease click \"OK\" or \"Cancel\" to continue");
	if (answer){
		flashOut_noVideoInChannelConfirm();
	}else{
		flashOut_noVideoInChannelConfirm();
	}
}

/*
*****************************************************
Flash Interface - Out
*****************************************************
*/

function flashOut_onLCPlayVideo(){
	flashProxy.call("jsIn_onLCPlayVideo");
}

function flashOut_playerInited(){
	flashProxy.call("jsIn_playerInited", _sUseLCSyncBanner);
}

function flashOut_onVideoComplete(){
	flashProxy.call("jsIn_onVideoComplete");
}

function flashOut_resumePlayer(){
	flashProxy.call("jsIn_resumePlayer");
}

function flashOut_cancelPlayer(){
	flashProxy.call("jsIn_cancelPlayer");
}

function flashOut_skipVideo(){
	flashProxy.call("jsIn_skipVideo");
}

function flashOut_noVideoDataConfirm(){
	flashProxy.call("jsIn_noVideoDataConfirm");
}

function flashOut_noChannelDataConfirm(bCheckVideo){
	if(bCheckVideo){
		flashProxy.call("jsIn_checkIfVideoExist");
	}else{
		flashProxy.call("jsIn_playFirstChannel");
	}
}

function flashOut_noVideoInChannelConfirm(bCheckVideo){
	flashProxy.call("jsIn_noVideoInChannelConfirm");

}