/*
	player.js
	Logic to handle flash player/page integration
*/

//Tracking
function sendPixelHit(url, comp) // comp -> It is from a companion display ad
{
	log('sendPixelHit', url)
	if(comp)
		url += '?count=%s'.format(compIndex++); // This will help make sure that the pixel requests dont get cached.
	var image = new Image(1,1);
	setTimeout(function() { image.src = url; }, 1);
}


var mn_showTitle = "";

function getShowTitle(){
	return mn_showTitle;	
}

function sendNielsenCall(url)
{
	//log('sendNielsenCall: ', url);
	var image = new Image(1,1);
	setTimeout(function() { image.src = url; }, 1);
}

function getSrnd(){
	if(typeof adid != 'undefined'){
		return adid;
	}
	return 0;	
}

//Player calls
function setMinimalControls() {
	$('mn_player').setMinimalControls();
}
function setDefaultControls() {
	$('mn_player').setDefaultControls();
}
function initControls(){
	MN.Event.Observe($('player'), 'mouseover', setDefaultControls);
	MN.Event.Observe($('player'), 'mouseout', setMinimalControls);
}
function playFlash(clipUrl, streaming){
	$("mn_player").PlayURL(clipUrl, streaming);
}
function showEndEpisode(show){
	if(show){
		$('endofvideo').style.display = "block";
		MN.Event.StopObserving($('player'), 'mouseover', setDefaultControls);
		MN.Event.StopObserving($('player'), 'mouseout', setMinimalControls);
	}
	else{
		$('endofvideo').style.display = "none";
		MN.Event.Observe($('player'), 'mouseover', setDefaultControls);
		MN.Event.Observe($('player'), 'mouseout', setMinimalControls);
	}
}
function replayVideo(){
	showEndEpisode(false);
	$('mn_player').replayEpisode();
}
function watchMore(){
	var show = "simpsons"; //Needs to be set dynamically!!!!!
	window.location.href = "/fod/play.php?sh=" + show;
}
function initEndEpisode(){
	MN.Event.Observe($('replayvideo'), 'click', replayVideo);
	MN.Event.Observe($('watchmore'), 'click', watchMore);
}
MN.Event.Observe(window,'load',initEndEpisode);