
  /******************************************************
  * The <code>AsToHbxConnection</code> function is called by
  * ActionScript from com.mpf.metrics.trackers.JsHitBoxTracker
  * to send the request on to hitbox since swfs cannot generate
  * their own non-user initiated requests in the production 
  * environment. 
  *
  * Here we pass the nicely marshalled hbxObject into this 
  * function, and using the "modal" JS trick, we create a
  * request via a pseudo src call. the full hitbox url is 
  * contained in the request
  */
	function AsToHbxConnection ( hbxObject ) {
		var fakeImage = new Image();
		fakeImage.src = hbxObject.toString();
	}
	
	
	
  /******************************************************
  * The <code>AsToAdSystemConnection</code> is called by the 
  * MPF to make a request to the ad system.   The AS MPF class
  * com.disney.vendors.DisneyAdSystem ususally uses the com.disney.utils.external
  * for this request, but because the ad system uses the illegal Colon character 
  * in the request URL, and this character must be encoded, the work around 
  * is to make the request using an External call to JS and unescaping the 
  * string as passing it from here.
  */
	function AsToAdSystemConnection ( adObject ) {
		var t=unescape(adObject.toString())
		var fakeImage = new Image();
		fakeImage.src = t;	
	}
	
	
// *********************************************************************************
//  @property swfID -- this is the linked ID / name of the Swf in the page.
var swfId = "player";
var swfReady = false;
var playerOffsetX = 0;
var playerOffsetY = 0;

var tempX = 0;
var tempY = 0;

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);

var pageHeight = null;
var pageWidth = null;

window.addEvent('domready',function(){
	var page = $('page');
	if(page){
		pageHeight = $('page').getStyle('height');
		pageWidth = $('page').getStyle('width');
	}
	if(document.getElementById('overlay')){
		document.getElementById('overlay').style.width = pageWidth; //'1590px';
		document.getElementById('overlay').style.height = pageHeight; //'1700px';
	}
});

// *********************************************************************************
//  thisMovie(String) sets the proper DOM reference for the Flash Object
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	}
	else {
		return document[movieName];
	}
}

// *********************************************************************************
// reloadPlayer calls the function reloadContent in the  and passes the new ad.xml and playlist.xml
function reloadPlayer(newPlaylist, newAdlist) {
	//  alert('reloadPlayer method fired:' + newPlaylist);	
	try{
		thisMovie(swfId).reloadContent(newPlaylist, newAdlist);
	}catch(e){}
}

function findPos(obj) {
	if(obj == null)
		return;
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	playerOffsetX = curleft;
	playerOffsetY = curtop;
}

function getMouseXY(e) {
	findPos(thisMovie(swfId));
	if(!e) e = window.event; 
	if (e.clientX || e.clientY) {
		tempX = e.clientX + document.documentElement.scrollLeft;
		tempY = e.clientY + document.documentElement.scrollTop;
	} else if(e.pageX || e.pageY){
		tempX = e.pageX;
		tempY = e.pageY;
	}
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}
	tempX -= playerOffsetX;
	tempY -= playerOffsetY;
	try{
		thisMovie("player").returnMousePos(tempX,tempY);
	}catch(e){}
}

// flag for ready state of player. 
function setSwfReady() {
    document.onmousemove = getMouseXY;
	swfReady = true;
}

// flag for ready state of player. 
function setSwfLocked() {
	swfReady = false;
}


var tweenObject = new Object();

tweenObject.t = 1;

var tweenFull = new Tween(tweenObject,'goFull',Tween.regularEaseOut,1,0,0.5);
var tweenSmall = new Tween(tweenObject,'goSmall',Tween.regularEaseOut,0,1,0.5);
tweenSmall._pos = 1;

//media player full screen
var wFull = 780; //864; //widht
var hFull =	500; //513; //height
var tFull =	0; //top
var lFull = -90;//-140; //left = -((wFull-wSmall)/2)
var aFull = 85; //alpha 
//media player small screen
var wSmall = 600; //width
var hSmall = 413; //height
var tSmall = 0; //top
var lSmall = 0; //left
var aSmall = 0; //alpha

function tweenUpdate(evt){
		var overlay					= document.getElementById('overlay').style;
		var pos						= Math.round(evt.target._pos*100);
		var alph					= aFull - ((aFull-aSmall)*(pos/100));
		
	
	// at the beginning of a Tween,
	if(evt.type == 'onMotionChanged'){
		
		//alert(evt.type);
		overlay.opacity				= alph/100;
		overlay['-moz-opacity']		= alph/100;
		overlay.filter				= 'alpha(opacity='+alph+')';
	// or at the end of a Tween, 
	} else if(evt.type == 'onMotionFinished'){
		
	// check the event type 
		if(evt.target.prop == 'goFull'){
			//try{
				thisMovie(swfId).finishScreenFull();	
				overlay.visibility = 'visible';
			//}catch(e){}
		}
		else if(evt.target.prop == 'goSmall'){
			//try{
				thisMovie(swfId).finishScreenSmall();
				overlay.visibility = 'hidden';
			//}catch(e){}
		}
		
	}
}

tweenFull.onMotionChanged = tweenUpdate;
tweenSmall.onMotionChanged = tweenUpdate;
tweenFull.onMotionFinished = tweenUpdate;
tweenSmall.onMotionFinished = tweenUpdate;



function goFullscreen(){
	//alert("goFullScreen")
	animateFullscreen();
	document.getElementById('overlay').style.visibility = 'visible';
	document.getElementById('abclocal-go-com').className = 'fullScreenOn';
	
	tweenSmall.stop();
	tweenFull.begin = tweenSmall._pos;
	tweenFull.change = -tweenSmall._pos;
	tweenFull.start();
	
}

function goSmallscreen(){
	//alert('goSmallScreen');
	animateSmallscreen();
	document.getElementById('overlay').style.visibility = 'hidden';
	document.getElementById('abclocal-go-com').className = 'fullScreenOff';
	
	tweenFull.stop();
	tweenSmall.begin = tweenFull._pos;
	tweenSmall.change = 1 - tweenFull._pos;
	tweenSmall.start();
}

function animateSmallscreen(){
	var flash					= document.getElementById('mediaPlayer').style;
	flash.width					= wSmall+'px';
	flash.height				= hSmall+'px';
	flash.top					= tSmall+'px';
	flash.left					= lSmall+'px';
}

function animateFullscreen(){
	var flash					= document.getElementById('mediaPlayer').style;
	flash.width					= wFull+'px';
	flash.height				= hFull+'px';
	flash.top					= tFull+'px';
	flash.left					= lFull+'px';
	try{
		if(isVDI == true){
			flash.left = 80+'px';
		}
	}catch(e){}
}

//media player promo open frequency capping
function fireMpCapping(){
	//determines if the media player should start with an open sequence
	if(defaultOpen){
		//true: check for cookie status
		if (mpCookie.get('openFlag')) {
			//the mp cookie is set, therefore only load mp if max count is greater than 3, number of defaults open per day
			mpSectionValue = mpCookie.get(mpSectionName);
			count = mpSectionCount;
			if(mpSectionValue){
				count = mpSectionValue['maxCount'];
			}else{
				count = mpSectionCount;
				mpSectionValue = {maxCount:count};
				mpCookie.set(mpSectionName,mpSectionValue);
			}
			//decrement the count if neccesary
			if(count > 0){
				mpSectionValue['maxCount'] = count-1;
				mpCookie.set(mpSectionName,mpSectionValue);
				mpOpen = true;
			}else{
				mpOpen = false;
			}
		} else {
			//the mp cookie is not set. Set it and LOAD the mp with an open
			mpCookie.extend(settings);
			count = mpSectionCount;
			mpSectionValue = {maxCount:count};
			mpSectionValue['maxCount'] = count-1;
			mpCookie.set(mpSectionName,mpSectionValue);
			mpOpen = true;
		}
	}else{
		//false: this page always defaults to no open
		mpOpen = defaultOpen;
	}
}

/*****************************************************************/
//CLIENT SIDE FLASH PLAYER DETECTION SCRIPT

// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 15;

// Version check based upon the values defined in globals
//this method is defined in AC_RunActiveContent.js
var hasRequiredVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

// Version check for the Flash Player that has the ability to start Player Product Install
var hasProductInstall = DetectFlashVer(8, 0, 0);
var shouldNotify = false;

var updatedFlashPlayerHtml = '<div id="updateFlashPlayer" style= "margin-top:100px; margin-left:10px;">'
							+'It appears that you have an older Flash Player version.  '
							+'Older versions of the Flash Player may display errors when viewing site content. '
							+'One such error is "Out of Memory at Line 56".<br><br>'
							+'To ensure an optimal user experience on our site, please upgrade to the latest Flash Player version available below.  '
							+'It is quick, easy and takes just a minute or two.<br><br>'
							+'<a target="_blank" href="http://www.adobe.com/go/getflash/"><b>[Upgrade Now]</b></a>'
							+' | <a href="javascript:void(0);"><b>[Upgrade Later]</b></a>'
							+'<div>';
							
var installFlashPlayerHtml = '<div id="installFlashPlayer" style= "margin-top:100px; margin-left:10px;">'
							+'It appears that you do not have Flash Player.<br><br>'
							+'To ensure an optimal user experience on our site, please install the latest Flash Player available below.  '
							+'It is quick, easy and takes just a minute or two.<br><br>'
							+'<a target="_blank" href="http://www.adobe.com/go/getflash/"><b>[Upgrade Now]</b></a> '
							+'<div>';
										  
/********************************************************************/											  
