var chromeColor = "#003399";   //Blue
var chromeWidth = 994;
var flashWidth = 994;
var firstload = true;
var channelLoading = false;
var frameworkRegistered = false;
var adsRefreshing = false;
var adz = 10; // was 70000
var adzStartingValue = 11; //added by CES.
var ads = new Array();
var adPadding = 7;
var slugPadding = 20;
var adContentArray = new Object();
var adResizeTimers = new Object();
var refreshTimeout;
var adsRefreshing = false;
var bSkyscraperExpanded = false
var bLeaderboardExpanded = false;
var iframeResizeTimer = 100;
var currentPageWidth = 0;
var today = new Date();
var expire = new Date(today.getTime() - 10);
var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
var oneMonth = new Date(today.getTime() + 30 * 24 * 60 *60 * 1000);
var oneWeek = new Date(today.getTime() + 7 * 24 * 60 *60 * 1000);
var twoWeek = new Date(today.getTime() + 14 * 24 * 60 *60 * 1000);

var animateDXDSwf;
var animationStep = 10;
var mouseX, mouseY; // <- Global variables allow your other functions to access the current position
var siteWidth = "994";
var siteHeight = "700";

var nonbranded = "http://disney.go.com/detect/nonbranded.html";
var countryMatch = "false";

function registerFramework() {
	frameworkRegistered = true;
}

function getPanelSetConfiguration() {
	if (!firstload && !channelLoading) {
		channelLoading = true;
	}
}

function onPanelSetLoaded(panelSet) {
	//alert('onPanelSetLoaded');
}

function onPanelSetShowing(panelSet) {
	//alert('onPanelSetShowing inside');
}

function onTransitionComplete() {
	if (firstload) {
		firstload = false;
	}
	if (channelLoading) {
		channelLoading = false;
	}
}

function scrollToTop(y) {
	if (y == undefined) {
		y = 0;
	}
	if (getYOffset() > parseInt(y)) {
		window.scrollBy(0,-40); // horizontal and vertical scroll increments
		scrolldelay = setTimeout('scrollToTop('+y+')',5); // scrolls every 5 milliseconds
	}
}

function getYOffset() {
    var pageY;
    if( typeof( window.pageYOffset ) == 'number' ) {
		//Mozilla compliant
		pageY = window.pageYOffset;
	} else {
		//DOM compliant
		pageY = document.body.scrollTop;
	}
    return pageY;
}


function popCopyright(url, name, params){
	window.open("http://disney.go.com/dxd/dxd_copyright.html", "copyrightPop", "width=500,height=625, scrollbar=yes");
}

function setWmode(mode) {

	//user agent
	var ua = navigator.userAgent.toLowerCase();
	//is mac
	var mac = (ua.indexOf("mac")>-1);
	//firefox 2
	var ff2 = (ua.indexOf("firefox/2")>-1);
	//firefox 3
	var ff3 = (ua.indexOf("firefox/3")>-1);
	//safari 2
	var s2 = (ua.indexOf('safari') > -1 && ua.indexOf('applewebkit') > -1 && (ua.indexOf('416') > -1 || ua.indexOf('412') > -1));	
	//default wmode
	var wmode = 'Window';
	
	if (mode == 'true' || mode) {
		//if mac and firefox 2 or safari 2
		if (mac && (ff2 || s2)) {
			wmode = "Transparent";
			
		//if firefox 3 on a mac
		} else if (ff3 && mac) {
			//ff3 on a mac seems to handle layered content above flash fine.
			wmode = "Window";
		} else {
			wmode = "Opaque";
		}
	}
	if(navigator.appName.toLowerCase().indexOf("micro") != -1 && navigator.userAgent.toLowerCase().indexOf("mac") ==-1){
      wmode = "Transparent";
   	}
	//if there is a new wmode switch it
	if (getWmode() != wmode) {
		getSWF('dxdcontent').wmode = wmode;
	}
}

function getWmode() {
	return getSWF('dxdcontent').wmode;
}

function resizeDXD(w, h) {
	getSWF('dxdcontent').style.height = h + 'px';
	getSWF('dxdcontent').style.width = w + 'px';
	try {
		document.getElementById("footerwrapper").style.visibility = "visible";
	} catch(e) {
	}
}

function repositionDXD(x,y) {
	var dxd = getSWF('dxdcontent');
	if (x != null && x >= 0) {
		dxd.style.left = x;
	}
	
	if (y != null && y >= 0) {
		dxd.style.top = y;
	}
}

function changeBackgroundColor(color) {
//alert("color: " + color);
	if(color == "inherit"){
		//alert("color: " + color);
		setDefaultBackgroundColor();
		return;
	}
	//Change the background color as well as the Legal Footer text color and the Legal Footer image if you are not on a Games page.
	var appVersion=navigator.appVersion.split("MSIE"),browserVersion=parseFloat(appVersion[1]);
	document.body.style.backgroundColor = color;
	var channelURLId = location.hash;
//	var legalTextColor = "#000000";
	var ftrImg = "games.png";//"disney_footer.png";
	var ftrHref = "http://disney.go.com/games";//"http://disney.go.com/index";
	var isIE6 = ((browserVersion>=5.5&&browserVersion<7)&&(document.body.filters));
	var footerImage = "http://a.dolimg.com/media/en-US/globalmedia/legal_footer/images/" + ftrImg;
	try
	{
		if(isIE6){
			document.getElementById("lgDcomFtrImg").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+footerImage+"')";
			
			var alphaFilter = document.getElementById("lgDcomFtrImg").filters["DXImageTransform.Microsoft.AlphaImageLoader"];
			alphaFilter.apply();
			
		} else {
			document.getElementById("lgDcomFtrImg").src = footerImage;
		}
		document.getElementById("legalFooterImageAnchor").href = ftrHref;
		var legalFooterElements = ["lgCopyRight","lgGuestServices","lgSiteMap","lgPrivacyPolicy","lgTermsOfUse","lgInternetSafety","lgContent","dxdCopyRight"];
		//if(color == "#000000"){legalTextColor = "#FFFFFF";}
			for(i=0; i < legalFooterElements.length ; i++){
				var element = document.getElementById(legalFooterElements[i]);
				if(element) element.style.color = legalFooterColor;
			}
	}
	catch(err){}
}

function setDefaultBackgroundColor(){
	document.body.style.backgroundColor=siteDefaultBGColor;
}

function setDefaultBackgroundImage(){
	document.body.style.backgroundImage="url(" + siteBaseURL + siteDefaultBGImage + ")";
}

function setDefaultBackground(){
	setDefaultBackgroundImage();
	setDefaultBackgroundColor();
}

function changeBackgroundImage(imageURL) {
	if(imageURL != null && imageURL != "null" && imageURL != "undefined"){
		document.body.style.backgroundImage="url(" + siteBaseURL + imageURL + ")";
	}else{
		setDefaultBackgroundImage();
	}	
}

function getSWF (movieName) {
    return swfobject.getObjectById(movieName)
}

function removeResizeTimers() {
	for (var p in adResizeTimers) {
		clearTimeout(adResizeTimers[p]);
	}
	adResizeTimers = {};
}

function hideAdPanels() {
	
	removeResizeTimers();
	
	if (!adsRefreshing) {
		moveDXDSwfUpTo(0);
	}
	adsRefreshing = false;
	
	clearTimeout(refreshTimeout);
	var len = ads.length;
	if (len > 0) {
		for (i = 0; i<len; i++) {
			document.getElementById("frame").removeChild(ads[0]);
			ads.shift();
		}
	}
}


function refreshAd(id) {
	adsRefreshing = true;
	removeResizeTimers();
	var adData = adContentArray[id];
	getSWF('dxdcontent').refreshAd(adData);
}


function adjustAdX(x) {
	var adjustedX = parseInt((document.body.offsetWidth - flashWidth) / 2);
	if (adjustedX < 0) {
		adjustedX = 0;
	}
	adjustedX += x;	
	return adjustedX;
}

//re-position the popup game player
function adjustGCX(gcwidth)
{
	var adjustedX = parseInt((document.body.offsetWidth - flashWidth) / 2);
	if (adjustedX < 0) {
		adjustedX = flashWidth/2;
	}
	else
	{
		adjustedX = parseInt(gcwidth/2) + parseInt((document.body.offsetWidth - gcwidth) / 2);
	}
	
	return adjustedX;
}

function bumpAds() {
	for (var i = 0; i < ads.length; i++) {
		try {
			var thisAdIDOffset = ads[i].id.replace("ab_dxd_ad","");
			var thisAd = document.getElementById(ads[i].id);
			thisAd.style.left = adjustAdX(adContentArray[thisAdIDOffset].x) + 'px';
		} catch(e) {

		}
	}
	//re-position the popup game player
	try
	{
		var gc = document.getElementById('game');
		gc.style.left = adjustGCX(gc.style.width) + 'px';	
	}
	catch(e){}
}

function addAdTracking(data) {

	if (data != null) {
		adz++;
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id', 'ab_dxd_ad' + adz);
		
		ads.push(newdiv);
		
		newdiv.style.width = 10;
		newdiv.style.height = 1;
		newdiv.style.position = "absolute";
		newdiv.style.left = 0;
		newdiv.style.top = 0;
		newdiv.style.zIndex = adz;

		document.getElementById("frame").appendChild(newdiv);

		var adframe = document.createElement('iframe');
	   	adframe.setAttribute('name', 'adframe' + adz);
	   	adframe.setAttribute('id', 'adframe' + adz);
	   	adframe.setAttribute('frameBorder', 0);
	   	adframe.setAttribute('marginHeight', 0);
	   	adframe.setAttribute('marginWidth', 0);
	   	adframe.setAttribute('height', 10);
	   	adframe.setAttribute('width', 10);
	   	adframe.setAttribute('scrolling', 'no');
	   	adframe.setAttribute('allowTransparency', true);
	   	adframe.setAttribute('transparency', true);
	   	adframe.setAttribute('style', 'background-color:transparent;filter:alpha(opacity=100)!important');
		adframe.src = 'about:blank';
		
	   	newdiv.appendChild(adframe);
	
		adframe.contentWindow.document.open("text/html","replace");
	   	adframe.contentWindow.document.write('<html><head><title></title><script>function errorHandler(){return true;}; window.onerror=errorHandler</script></head><body id="adBody" class="adBody" style="background-color:transparent"><div id="content">'+unescape(data)+'</div></body></html>');
	   	adframe.contentWindow.document.close();
		adframe.contentWindow.onerror = errorsuppressor;
	}

}

function manualAdRefresh(){
/*
	var calledIDS = [];
	for(s in adContentArray){
		var abort = false;
		for(i=0;i<calledIDS.length;i++)
		{
			if(calledIDS[i] == adContentArray[s].id)
			{
				abort = true;
			}
		}
		if(abort == false)
		{
			refreshAd(adContentArray[s].id);
			calledIDS.push(adContentArray[s].id);
		}
	}
	*/
	for(s in adContentArray){
		refreshAd(adContentArray[s].id);
	}
}

function addAdPanel(id, x, y, w, h, r, s, bg, url, data, adCategory) {
	adz++;
	if (!x) {
		adContentArray[adz] = {id:adContentArray[id].id, x:adContentArray[id].x, y:adContentArray[id].y, w:adContentArray[id].w, h:adContentArray[id].h, r:adContentArray[id].r, s:adContentArray[id].s, bg:adContentArray[id].bg, url:adContentArray[id].url, data:adContentArray[id].data, adCategory:adContentArray[id].adCategory};
		adContentArray.splice(id);
	} else {
		adContentArray[adz] = {id:id, x:x, y:y, w:w, h:h, r:r, s:s, bg:bg, url:url, data:data, adCategory:adCategory};
   	}
   	
   	var newdiv = document.createElement('div');
   
	newdiv.setAttribute('id', 'ab_dxd_ad' + adz);
	ads.push(newdiv);

	if (r > 0) {
		clearTimeout(refreshTimeout);
		refreshTimeout = setTimeout('refreshAd("'+adz+'")', r*1000);
	}

	if (adContentArray[adz]) {

   		newdiv.style.width = (adContentArray[adz].w - adPadding) + 'px';
   		newdiv.style.height = (adContentArray[adz].h - adPadding) + 'px';
   		newdiv.style.position = "absolute";
   		newdiv.style.textAlign = 'center';
   		newdiv.style.left = adjustAdX(adContentArray[adz].x) + 'px';
   		newdiv.style.top = adContentArray[adz].y + 'px';
   		newdiv.style.zIndex = adz;
   		newdiv.style.paddingTop = adPadding + 'px';
   		newdiv.style.paddingLeft = adPadding + 'px';

   		var container = document.createElement('div');
   		container.setAttribute('id', 'container');

   		if (adContentArray[adz].data == null) {
			if (id.indexOf('Leaderboard') > -1) {
				makeHttpRequest(adContentArray[adz].url, 'loadBanner', false, newdiv, true);
			} else if (adContentArray[adz].id.indexOf('Skyscraper') > -1) {
				makeHttpRequest(adContentArray[adz].url, 'loadBanner', false, newdiv, true);
			} else if (adContentArray[adz].id.indexOf('Rectangle') > -1) {
				makeHttpRequest(adContentArray[adz].url, 'loadBanner', false, newdiv, true);
			} else {
				var adData = '';
				return;
			}  	
   			if (adData) {
  	 			newdiv.innerHTML = adData;
     			newdiv.runttimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bg + "',sizingMethod='scale')";
     			newdiv.appendChild(container);
   			}
	   	} else {
	   		document.getElementById("frame").appendChild(newdiv);
	   		setTimeout("displayAdData("+adz+")", 1000);
	  	}
		if (adContentArray[adz].id.indexOf('Leaderboard') > -1) {
			adContentArray[adz].type = 'Leaderboard';
   			if (adContentArray[adz].s) {
    			newdiv.style.width = (adContentArray[adz].w - slugPadding) + 'px';
  				newdiv.style.paddingLeft = slugPadding + 'px';
  			}
   			if (adContentArray[adz].bg == undefined) {
  				if (adContentArray[adz].s) {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/728x90_holder_ADSlug.png)';
 				} else {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/728x90_holder.png)';
  				}
  			}else{
  				newdiv.style.backgroundImage = 'url(' + siteBaseURL + adContentArray[adz].bg + ')';
  			}
			
   		} else if (adContentArray[adz].id.indexOf('Skyscraper') > -1) {
			adContentArray[adz].type = 'Skyscraper';
   			if (adContentArray[adz].s) {
    			newdiv.style.height = (adContentArray[adz].h - slugPadding) + 'px';
  				newdiv.style.paddingTop = slugPadding + 'px';
  			}
   			if (adContentArray[adz].bg == undefined) {
  				if (adContentArray[adz].s) {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/160x600_holder_ADSlug.png)';
  				} else {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/160x600_holder.png)';
  				}
  			}else{
  				newdiv.style.backgroundImage = 'url(' + siteBaseURL + adContentArray[adz].bg + ')';
  			}
  		} else if (adContentArray[adz].id.indexOf('Medium Rectangle') > -1) {
			adContentArray[adz].type = 'Medium Rectangle';
   			if (adContentArray[adz].s) {
    			newdiv.style.height = (adContentArray[adz].h - slugPadding) + 'px';
  				newdiv.style.paddingTop = slugPadding + 'px';
  			}
   			if (adContentArray[adz].bg == null) {
  				if (adContentArray[adz].s) {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/300x250_holder_ADSlug.png)';
  				} else {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/300x250_holder.png)';
  				}
  			}else{
  				newdiv.style.backgroundImage = 'url(' + siteBaseURL + adContentArray[adz].bg + ')';
  			}
   	
   		} else if (adContentArray[adz].id.indexOf('Rectangle') > -1) {
			adContentArray[adz].type = 'Rectangle';
   			if (adContentArray[adz].s) {
    			newdiv.style.height = (adContentArray[adz].h - slugPadding) + 'px';
  				newdiv.style.paddingTop = slugPadding + 'px';
  			}
  			newdiv.style.height = (newdiv.style.height + 50) + 'px';
   			if (adContentArray[adz].bg == null) {
  				if (adContentArray[adz].s) {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/180x150_holder_ADSlug.png)';
  				} else {
  					newdiv.style.backgroundImage = 'url(' + siteBaseURL + 'bitmaps/ads/180x150_holder.png)';
  				}
  			}else{
  				newdiv.style.backgroundImage = 'url(' + siteBaseURL + adContentArray[adz].bg + ')';
  			}
   		}
   		newdiv.style.backgroundRepeat = 'no-repeat';
   	}
}


function moveDXDSwfDownTo(y) {
	var cur = parseInt(getSWF('dxdcontent').style.marginTop);
	var newPos = (cur+animationStep);
	
	clearTimeout(animateDXDSwf);
	animateDXDSwf = setTimeout("animateDXDSwfDownTo('"+newPos+"','"+y+"')", 20);
}

function animateDXDSwfDownTo(y, end) {
	
	if (parseInt(end) > parseInt(y)) {
		getSWF('dxdcontent').style.marginTop = y + 'px';
		
		var cur = parseInt(getSWF('dxdcontent').style.marginTop);
		var newPos = (cur+animationStep);
		
		clearTimeout(animateDXDSwf);
		animateDXDSwf = setTimeout("animateDXDSwfDownTo('"+newPos+"','"+end+"')", 20);
	} else {
		clearTimeout(animateDXDSwf);
		getSWF('dxdcontent').style.marginTop = end + 'px'
	}
}

function moveDXDSwfUpTo(y) {
	var cur = parseInt(getSWF('dxdcontent').style.marginTop);
	var newPos = (cur-animationStep);
	
	clearTimeout(animateDXDSwf);
	animateDXDSwf = setTimeout("animateDXDSwfUpTo('"+newPos+"','"+y+"')", 20);
}

function animateDXDSwfUpTo(y, end) {
	if (parseInt(end) < parseInt(y)) {
		getSWF('dxdcontent').style.marginTop = y + 'px';
		
		var cur = parseInt(getSWF('dxdcontent').style.marginTop);
		var newPos = (cur-animationStep);
		
		clearTimeout(animateDXDSwf);
		animateDXDSwf = setTimeout("animateDXDSwfUpTo('"+newPos+"','"+end+"')", 20);
	} else {
		clearTimeout(animateDXDSwf);
		getSWF('dxdcontent').style.marginTop = end + 'px'
	}
}



function trackMouse(e) {
	if (!e) e = window.event;
	
	if (e) {
		if (e.pageX || e.pageY) {
			mouseX = e.pageX;
			mouseY = e.pageY;
		} else {
			mouseX = e.clientX;
			mouseY = e.clientY;
		}
	}
}




function iframeResizeWatcher(adz, w, h) {

	if (document.body.offsetWidth != currentPageWidth) {
		currentPageWidth = document.body.offsetWidth;
	}
	try {
	
		bumpAds();
		adframe = document.getElementById('adframe' + adz);
		addiv = document.getElementById('ab_dxd_ad' + adz);
				
		if (window.ActiveXObject && !adContentArray[adz].reloaded && adContentArray[adz].data.toLowerCase().indexOf('wallpaper') == -1) {
		//if (window.ActiveXObject && !adContentArray[adz].reloaded) {
			adContentArray[adz].reloaded = true;
			adframe.contentWindow.location.reload(false);
			clearTimeout(adResizeTimers[adz]);
			adResizeTimers[adz] = setTimeout("iframeResizeWatcher('"+adz+"', "+w+", "+h+")", iframeResizeTimer);
			return;
		}
		
		var embeds;
		var adObjects;	
		try {
			embeds = adframe.contentWindow.document.body.getElementsByTagName("embed");
			adObjects = adframe.contentWindow.document.body.getElementsByTagName("object");
		} catch (e) {
			
		}
		
		
		if (adContentArray[adz].type == 'Leaderboard') {
			
			var embedHeight = 0;
			var expansionHeight = 0;
			
			if (adObjects.length > 0 && (adObjects[0].height > h || adObjects[0].height == "100%")) {
				embedHeight = adObjects[0].height;
			} else if (embeds.length > 0 && (embeds[0].height > h || embeds[0].height == "100%")) {
				embedHeight = embeds[0].height;
			} else {
				//console.log("not expando!")
			}
			
			expansionHeight = adframe.contentWindow.document.body.scrollHeight;

			var element = (document.getElementById('container').offsetLeft - 498);
			var adLeft = parseInt(addiv.style.left) + element;
			var adTop = parseInt(addiv.style.top);
			var isOverLeaderBoard = false;
			
			if ((mouseX > adLeft && mouseY > adTop) && (mouseX < ((adLeft + w)+(slugPadding+20)) && mouseY < ((adTop+h)+((adPadding)*2)))) {
				isOverLeaderBoard = true;
			}

			if (embedHeight == "100%" || embedHeight > h || isOverLeaderBoard) {
				if (adframe.contentWindow.document.body.scrollHeight > h) {
					expansionHeight = 350;
				} else {
					expansionHeight = h;
				}
			} else {
					expansionHeight = h;
			}
			
			if (expansionHeight >= h)  {				
				addiv.style.height = (expansionHeight)+'px';
				adframe.style.height = (expansionHeight)+'px';
				bLeaderboardExpanded = true;
			}
			
			
		} else if (adContentArray[adz].type == 'Skyscraper') {
			var embeds;
			var adObjects;	
			try {
				embeds = adframe.contentWindow.document.body.getElementsByTagName("embed");
				adObjects = adframe.contentWindow.document.body.getElementsByTagName("object");
			} catch (e) {

			}
			var embedWidth = 0;
			var expansionWidth = 0;

			
			if (adObjects.length > 0 && (adObjects[0].width > w || adObjects[0].width == "100%")) {
				embedWidth = adObjects[0].width
			} else if (embeds.length > 0 && (embeds[0].width > w || embeds[0].width == "100%")) {
				embedWidth = embeds[0].width
			} else {
				//console.log("not expando!")
			}
			
			//var element = (document.getElementById('container').offsetLeft - 498);
			var element = 0;
			var adLeft = parseInt(addiv.style.left) + element;
			var adTop = parseInt(addiv.style.top);
			var isOverSkyscraper = false;
			
			if ((mouseX > adLeft && mouseY > adTop) && (mouseX < ((adLeft + w)+(adPadding)*2)) && mouseY < ((adTop+h)+((slugPadding+20)))) {
				isOverSkyscraper = true;
			}
			
			if (adContentArray[adz].type == 'Medium Rectangle') {
				var expandSize = 700;
				//var pos = 675;
				var pos = adjustAdX(adContentArray[adz].x);
			} else {
				var expandSize = 350; // CES: tried 167
				///var pos = 812;
				var pos = adjustAdX(adContentArray[adz].x);
				
			}
			
			if (embedWidth == "100%" || embedWidth > w || isOverSkyscraper) {
				if (adframe.contentWindow.document.body.scrollWidth > w) {
					expansionWidth = expandSize;
				}
			} else {
					expansionWidth = w;
			}
			
			
			if (expansionWidth >= w)  {
				adframe.contentWindow.document.getElementById('content').style.marginLeft = (expansionWidth-w) + 'px';
				
				
				
				addiv.style.backgroundPosition = (expansionWidth-w)+'px 0';
				
				adframe.contentWindow.document.body.style.left = (pos + (w-expansionWidth)) + 'px'
				
				addiv.style.left = (pos + (w-expansionWidth)) + 'px'
				addiv.style.width = (expansionWidth)+'px';
				adframe.style.width = (expansionWidth)+'px';
				bSkyscraperExpanded = true;
			}
			
		}
		
	} catch (e) {
		//console.log(e)
	};
	clearTimeout(adResizeTimers[adz]);
	adResizeTimers[adz] = setTimeout("iframeResizeWatcher('"+adz+"', "+w+", "+h+")", iframeResizeTimer);
}


function displayAdData(adz, target) {
	if (target == null) {
		target = document.getElementById('ab_dxd_ad' + adz);
	}
	
	var adframe = document.createElement('iframe');
   	adframe.setAttribute('name', 'adframe' + adz);
   	adframe.setAttribute('id', 'adframe' + adz);
   	adframe.setAttribute('frameBorder', 0);
   	adframe.setAttribute('marginHeight', 0);
   	adframe.setAttribute('marginWidth', 0);
   	adframe.setAttribute('height', target.style.height);
   	adframe.setAttribute('width', target.style.width);
   	adframe.setAttribute('scrolling', 'no');
   	adframe.setAttribute('allowTransparency', true);
   	adframe.setAttribute('transparency', true);
   	adframe.setAttribute('style', 'background-color:transparent;filter:alpha(opacity=100)!important');
   	
   	var adFrameContainer = document.getElementById('ab_dxd_ad' + adz);

   	adContentArray[adz].data.replace("'", "\'");
   	adContentArray[adz].data.replace('"', '\"');

   	if (adContentArray[adz].data.toLowerCase().indexOf('script') > -1) {
   		adframe.src = 'about:blank';
   		//adframe.onResize = alert('resize');
   		adFrameContainer.appendChild(adframe);
   		
		adframe.contentWindow.document.open("text/html","replace");
   		adframe.contentWindow.document.write('<html><head><title></title><script>function errorHandler(){return true;}; window.onerror=errorHandler</script></head><body id="adBody" class="adBody" style="background-color:transparent"><div id="content">'+unescape(adContentArray[adz].data)+'</div></body></html>');
   		adframe.contentWindow.document.close();
   		
   		
   		clearTimeout(adResizeTimers[adz]);
   		adResizeTimers[adz] = adframe.contentWindow.document.body.onLoad = setTimeout("iframeResizeWatcher('"+adz+"', "+target.style.width.replace('px', '')+", "+target.style.height.replace('px', '')+")", iframeResizeTimer);
   		adframe.contentWindow.onerror = errorsuppressor;
	} else {
	    target.innerHTML = unescape(adContentArray[adz].data);
		clearTimeout(adResizeTimers[adz]);
		adResizeTimers[adz] = setTimeout("iframeResizeWatcher('"+adz+"', "+target.style.width.replace('px', '')+", "+target.style.height.replace('px', '')+")", iframeResizeTimer);
	   	adframe.contentWindow.onerror = errorsuppressor;
    }
    
}

function makeHttpRequest(url, callback_function, return_xml, target, iframe) {

	document.getElementById("frame").appendChild(target);
	
	var adframe = document.createElement('iframe');
   	adframe.setAttribute('name', 'adframe' + adz);
   	adframe.setAttribute('id', 'adframe' + adz);
   	adframe.setAttribute('frameborder', 0);
   	adframe.setAttribute('marginheight', 0);
   	adframe.setAttribute('marginwidth', 0);
   	adframe.setAttribute('height', target.style.height);
   	adframe.setAttribute('width', target.style.width);
   	adframe.setAttribute('scrolling', 'no');
   	adframe.setAttribute('allowTransparency', 'true');
   	
   	var adFrameContainer = document.getElementById('ab_dxd_ad' + adz);
   	
	
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
		   http_request.overrideMimeType('text/xml');
		}

	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	}

	if (!http_request) {
		return false;
	}
	
	http_request.onreadystatechange = function() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200 || http_request.status == 0) {
			if (return_xml) {
				var xml = http_request.responseXML;
				target.innderHTML = xml.firstChild;
			} else {
				if (http_request.responseText.indexOf('script') > -1) {
					//adframe.setAttribute('src', url);
					//adFrameContainer.appendChild(adframe);
				} else {
					target.innerHTML = http_request.responseText;
					//adFrameContainer.removeChild(adframe);
					////alert(http_request.responseText)
					////alert('no script');
				}
			}
			document.getElementById("frame").appendChild(target);

			//document.getElementById("flashcontent").style.top = '110px';
		} else {
			//alert('There was a problem with the request.(Code: ' + http_request.status + ')');
	}
	}
   		}
   		http_request.open('GET', url, true);
   		http_request.send(null);
   //}
}


function writeDXDFlash(){

	var questionMark = window.location.href.indexOf("?");
	var hash = window.location.href.indexOf("#");
	
	if (hash > -1) {
		var flashVars = questionMark < 0 ? "" : window.location.href.substring(questionMark+1, hash);
		var hashString = window.location.href.substring(hash+1);
		var lastSlash = hashString.lastIndexOf("/")+1;
		if (lastSlash == -1) {
			lastSlash = 0;
		}
		var deeplink = hashString.substring(lastSlash);
		
		if (flashVars.length > 0) {
			var exists = flashVars.indexOf("channel") > -1 ? true : false;
			if (exists) {
				var startPos = flashVars.indexOf("channel=")+1;
				var choppedVars = flashVars.substring(startPos+6);
				var endPos = choppedVars.indexOf("&");
				if (endPos == -1) {
					endPos = choppedVars.length;
				}
				var replaceVal = choppedVars.substring(startPos, endPos);
				var splitString = flashVars.split(replaceVal);
				flashVars = splitString[0] + deeplink + splitString[1];
				
			} else {
				flashVars = flashVars + "&channel=" + deeplink;
			}
		} else {
			flashVars = "channel=" + deeplink;
		}
		
	} else {
		var flashVars = questionMark < 0 ? "" : window.location.href.substr(questionMark+1);
	}
	
	flashVars = (flashVars.length > 0) ? flashVars + "&" + deparams : deparams;
	flashVars = (flashVars.length > 0) ? flashVars + "&chromeData=" + escape(document.location.href) : "chromeData=" + escape(document.location.href);
	flashVars = (flashVars.length > 0) ? flashVars + "&bootURL=" + bootMainAppURL : "bootURL=" + bootMainAppURL;
	flashVars = (flashVars.length > 0) ? flashVars + "&basePath=" : "basePath=";
	flashVars = (flashVars.length > 0) ? flashVars + "&configURL=" + siteConfig + "&" + deparams : "?configURL=" + siteConfig + "&" + deparams;
	
	//browser detect for wmode stuff
	var ua = navigator.userAgent.toLowerCase();
	var mac = (ua.indexOf("mac")>-1);
	
	var ff2 = (ua.indexOf("firefox/2")>-1);
	var ff3 = (ua.indexOf("firefox/3")>-1);
	var s2 = (ua.indexOf('safari') > -1 && ua.indexOf('applewebkit') > -1 && (ua.indexOf('416') > -1 || ua.indexOf('412') > -1));
	
	
	var fvars = false;
	//allowScriptAccess: "always",
	var flashparams = {
  		menu: "false",
  		scale: "noscale",
		menu: "false",
		quality: "best",
		salign: "tl",
		base: ".",
		align: "t",
		flashVars: flashVars,
		allowFullScreen: "true",
		wmode: "transparent",
		allowScriptAccess: "always"
	};
	
	/*
	
	if (mac && (ff2 || s2)) {
		//alert ('transparent mode');
		flashparams.wmode = "Transparent";
	} else if (ff3 && mac) {
		//alert('ff3 mac');
		flashparams.wmode = "Window";
	} else {
		//alert ('opaque mode');
		flashparams.wmode = "Opaque";
	}
	*/
	var attributes = {
  		id: "dxdcontent",
 		 name: "dxdcontent"
	};
	swfobject.embedSWF(siteBaseURL + siteSwfURL, "flashcontent", siteWidth, siteHeight, "10.0.0","http://a.dolimg.com/swf/dcom/expressInstall.swf", fvars, flashparams, attributes);
}

function onExpressInstall() {
	////alert('got it');
}

function onLoadEventHandler() {
	
	for(var p in siteCountryArray)
	{
		if(siteCountryArray[p] == country)
		{
			//alert('we have a region match!!!!!!!' + siteCountryArray[p] + ' ' + country);
			countryMatch = "true";
		}
		
	}
	
	if(!document.getElementById)top.location.replace("http://disney.go.com/home/html/index.html");

	loaded=true;//(connection=="broadband"||connection=="xdsl"||connection=="cable"||connection=="?")?true:false;
	narrowBand=(!loaded)?true:false;

	cload=(countryMatch=="true"||country.indexOf("anon")>0)?true:false;

	if(!cload){
		document.location.replace((siteCountryArray[0]=='united states')?"http://disney.go.com/dxd/international.html":"http://www.disneyxd.eu/");
	}

	var modecheck = params(document.cookie,"MODE",null);
	if(modecheck=="1")loaded=false;
	if(modecheck=="0")loaded=true;

	deparams = "connection=" + connection;
	deparams += "&country=" + country;
	deparams += "&loaded=" + loaded;
	deparams += "&narrowBand=" + narrowBand;
	deparams += "&cload=" + cload;
	deparams += "&modecheck=" + modecheck;


	var FLASHVERSION = swfobject.getFlashPlayerVersion();
	if (loaded && (FLASHVERSION.major == 0)) {
		SetCookieUtil("return_path",document.location,oneWeek,"",".go.com","");
		document.location.replace("http://disney.go.com/home/html/index.html?flash=false");
	}

	writeDXDFlash();
	
	document.onmousemove=trackMouse;
	if(siteCountryArray[0] == "united states"){
	try {
		cto=new CTO();
	    cto.account='disneyxd';
		    cto.category='dtv';
		    cto.site='dxd';
		    cto.siteSection='';
		    cto.pageName='dxd_html_wrapper';
		    cto.contentType='regular';
		    cto.brandSegment='';
		    cto.property='';
		    cto.track();
		} catch (e) {
			//try catch just in case aglobal.go goes down again.
		}
	}else{
	     try {
	         cto=new CTO();
	         cto.account=omnitureAccount;
	    cto.category='dcore';
	    cto.site='dxd';
	    cto.siteSection='';
	    cto.pageName='dxd_html_wrapper';
	    cto.contentType='regular';
	    cto.brandSegment='';
	    cto.property='';
	         cto.region=omnitureRegion;
	         cto.country=omnitureCountry;
	         cto.unit=omnitureUnit ;        
	    cto.track();
	} catch (e) {
		//try catch just in case aglobal.go goes down again.
	}
     }



}

document.onLoad = onLoadEventHandler();

function errorsuppressor(){
	return true;
}
window.onerror = errorsuppressor;





/////eric.js


//redirect function

//sets the cookie
function SetCookieUtil (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +	((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "; path=/") + ((domain) ? "; domain=" + domain : "; domain=.go.com") +	((secure) ? "; secure" : "");
}

function SetCookieUtilRaw (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +	((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "; path=/") + ((domain) ? "; domain=" + domain : "; domain=.go.com") +	((secure) ? "; secure" : "");
}

function params(wut,qp,dflt) {
	dflt=(dflt==null)?'':dflt; 
	try {
		r = unescape(wut.match(new RegExp(qp+"=+([^&;]*)"))[1]);
	} catch (qp) {
		r=dflt;
	} 
	return r;
}

function GetCookie(name) {
    var cookieValue = params(document.cookie,name,null);
    return cookieValue;
}


//////utils.js
function popWindow(url, name, params) {
    window.open(url, name, params);
}
