//////chromeSettings.js
var chromeColor = "#003399";   //Blue
var chromeWidth = 994;
var flashWidth = 994;
var legalFtrCpyRgt = "&copy; Disney Enterprises, Inc.";
var firstload = true;
var channelLoading = false;
var frameworkRegistered = false;
var adz = 10; // was 70000
var adzStartingValue = 11; //added by CES.
var ads = new Array();
var adPadding = 7;
var slugPadding = 8;
var adContentArray = new Object();
var adResizeTimers = new Object();
var iframeResizeTimer = 100;
var legalFooterDCOM3 = true;
var currentPageWidth = 0;
var refreshTimeout;
var animationStep = 10;


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 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 = Number(h);
	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) {
	//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 = "disney_footer.png";
	var ftrHref = "http://disney.go.com/index";
	
	if(channelURLId.indexOf("games")!=-1){
		ftrImg = "games.png";
		ftrHref = "http://disney.go.com/games";
	}
	if(channelURLId.indexOf("videos")!=-1){
		ftrImg = "videos.png";
		ftrHref = "http://disney.go.com/videos";
	}
	if(channelURLId.indexOf("characters")!=-1){
		ftrImg = "characters.png";
		ftrHref = "http://disney.go.com/characters";
	}
	if(channelURLId.indexOf("mypage")!=-1){
		ftrImg = "mypage.png";
		ftrHref = "http://disney.go.com/mypage";
	}
	if(channelURLId.indexOf("create")!=-1){
		ftrImg = "disney_footer_create.png"
		ftrHref = "http://disney.go.com/create"
	}
	
	var isIE6 = ((browserVersion>=5.5&&browserVersion<7)&&(document.body.filters));
	var footerImage = "http://a.dolimg.com/media/en-US/globalmedia/legal_footer/images/" + ftrImg;
	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;
	}
	try {
		var theFooterObject = document.getElementById("legalFooterImageAnchor");
		theFooterObject.innerHTML = '<a href="' + ftrHref + '">' + theFooterObject.innerHTML + '</a>';
	} catch(e) {
	}
	try {
		var theFooterObject2 = document.getElementById("legalFooterImage");
		theFooterObject2.innerHTML = '<a href="' + ftrHref + '">' + theFooterObject2.innerHTML + '</a>';
	} catch(e) {
	}
	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 = legalTextColor;
		}
}

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();
		}
	}
}

var adsRefreshing = false;
function refreshAd(id) {
	
	adsRefreshing = true;
	removeResizeTimers();
	
	//var frame = document.getElementById('adframe' + id);
	//var div = document.getElementById('ab_dxd_ad' + id);
	var adData = adContentArray[id];
	/*
	frame.contentWindow.document.open("text/html","replace");
   	frame.contentWindow.document.write('');
   	frame.contentWindow.document.close();
	document.getElementById("frame").removeChild(div);
	*/
	getSWF('dxdcontent').refreshAd(adData);
	
	/*
	var len = ads.length;
	var idx = 0;
	
	for (i = 0; i<len; i++) {
		if (div == ads[i]) {
			idx = i;
			break;
		}
	}

	if (len > 0) {
		ads.splice(idx);
	}
	*/
}


function adjustAdX(x) {
	var adjustedX = parseInt((document.body.offsetWidth - flashWidth) / 2);
	if (adjustedX < 0) {
		adjustedX = 0;
	}
	adjustedX += x;
	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) {

		}
	}
}

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;
		//newdiv.style.border = "1px #FF0000 solid";

		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;
	}

}

var floater = false;
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 (id.indexOf('Floating') > -1) {
		floater = true;
		//alert('floating' + unescape(adContentArray[adz].data));
		newdiv.innerHTML = unescape(adContentArray[adz].data);
		//return;
	}

	if (r > 0) {
		clearTimeout(refreshTimeout);
		refreshTimeout = setTimeout('refreshAd("'+adz+'")', r*1000);
	}

if (adContentArray[adz]) {

   if (!floater) {
   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.overflow = "hidden";
   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 {
	   // if (!floater) {
   			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(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/728x90_holder_ADSlug.png)';
 				} else {
  					newdiv.style.backgroundImage = 'url(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/728x90_holder.png)';
  				}
  			}
			if (parseInt(getSWF('dxdcontent').style.height) <= 800) {
				//disneygroups ad
				moveDXDSwfDownTo(115);
			}
			
   		} 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(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/160x600_holder_ADSlug.png)';
  				} else {
  					newdiv.style.backgroundImage = 'url(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/160x600_holder.png)';
  				}
  			}
  		} 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(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/300x250_holder_ADSlug.png)";
  				} else {
  					newdiv.style.backgroundImage = 'url(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/300x250_holder.png)';
  				}
  			}
   	
   		} 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.paddingLeft = '2px';
  			newdiv.style.height = (newdiv.style.height + 50) + 'px';
   			if (adContentArray[adz].bg == null) {
  				if (adContentArray[adz].s) {
  					newdiv.style.backgroundImage = "url(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/180x150_holder_ADSlug.png)";
  				} else {
  					newdiv.style.backgroundImage = 'url(http://a.dolimg.com/media/en-US/dxd/bitmaps/ads/180x150_holder.png)';
  				}
  			}
   		}
		if (!floater) {
   			newdiv.style.backgroundRepeat = 'no-repeat';
		}
   }
}

var animateDXDSwf;
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'
	}
}



var mouseX, mouseY; // <- Global variables allow your other functions to access the current position
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;
		}
	}
}

var bSkyscraperExpanded = false
var bLeaderboardExpanded = false;

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].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 {
					//console.log("1 not expando! " + h)
					expansionHeight = h;
				}
			} else {
				//console.log("2 not expando! " + h)
					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.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();
   		
		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 saf = (ua.indexOf('safari') > -1 && ua.indexOf('applewebkit') > -1);
		


   		clearTimeout(adResizeTimers[adz]);
		if (adContentArray[adz].data.toLowerCase().indexOf('pointroll') > -1 && unescape(adContentArray[adz].data).toLowerCase().indexOf('indapif = true') > -1 && !saf) {
			//alert('pointroll iframe buster')
   			//adResizeTimers[adz] = adframe.contentWindow.document.body.onLoad = setTimeout("iframeResizeWatcher('"+adz+"', "+target.style.width.replace('px', '')+", 0)", iframeResizeTimer);
		} else {
			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);
    }
    
}

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=" + document.location.href : "chromeData=" + document.location.href;
	flashVars = (flashVars.length > 0) ? flashVars + "&configURL=data/config_cds.xml&" + deparams : "configURL=data/config_cds.xml&" + deparams;
	
	
	//browser detect for wmode stuff
	var ua = navigator.userAgent.toLowerCase();
	var mac = (ua.indexOf("mac")>-1);
	
	var ff = (ua.indexOf("firefox/2")>-1);
	
	
	var fvars = false;
	//allowScriptAccess: "always",
	var flashparams = {
  		menu: "false",
  		scale: "noscale",
		menu: "false",
		quality: "best",
		salign: "tl",
		base: ".",
		align: "t",
		bgcolor: "#FFFFFF",
		flashVars: flashVars,
		allowFullScreen: "true",
		allowScriptAccess: "always"
	};
	
	if (mac && ff) {
		flashparams.wmode = "transparent";
	} else {
		flashparams.wmode = "opaque";
	}
	
	var attributes = {
  		id: "dxdcontent",
 		 name: "dxdcontent"
	};
	swfobject.embedSWF("http://a.dolimg.com/media/en-US/dxd/DFSF.swf", "flashcontent", "994", "700", "9.0.115","expressInstall.swf", fvars, flashparams, attributes);

}

function onExpressInstall() {
	////alert('got it');
}

function onLoadEventHandler() {
	
	if(!document.getElementById)top.location.replace("http://disney.go.com/home/html/index.html");

    cto=new CTO();
    cto.account='disneycom';
    cto.category='dcore';
    cto.site='dcom';
    cto.siteSection='';
    cto.pageName='dxd_html_wrapper';
    cto.contentType='regular';
    cto.brandSegment='dxd';
    cto.property='';
    cto.track();

	loaded=(connection=="broadband"||connection=="xdsl"||connection=="cable"||connection=="?")?true:false;
	narrowBand=(!loaded)?true:false;
	cload=(country=="united states"||country=="canada"||country.indexOf("anon")>0)?true:false;

	if(!cload){
		//document.location.replace("http://www.disneyinternational.com/");
		document.location.replace("http://disney.go.com/dxd/international.html");
	}

	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;

	if(!loaded) {
		document.location.replace("http://home.disney.go.com/lite/index");
	}

	//top.document.body.scroll = 'yes';
	
	
	writeDXDFlash();
	
	document.onmousemove=trackMouse;

}

document.onLoad = onLoadEventHandler();

function errorsuppressor(){
	return true;
}
window.onerror = errorsuppressor;





/////eric.js
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 nonbranded = "http://disney.go.com/detect/nonbranded.html";
//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);
}


