//Gecko Detection

function IsGekko(){
	return(navigator.appName == "Netscape")?true:false
}

function GetTheVersion(gt){
	var gua = navigator.userAgent;
	if(gt == "Mozilla"){
		temp = gua.split("rv:");
		major_version = parseFloat(temp[1]);

	}
	else{
		var marker = gua.lastIndexOf("/");
		var subMe = gua.substr(marker + 1);
		var major_version = parseFloat(subMe);
	}
	return major_version;	
}
function PassVersion(bt,version,req_version){
	defaultAr = new Array(1.2,2,7,85.8);
	this.strippedAppVersion = version
	if(req_version){
		reqAr = req_version.split(",");
		for(i=0;i<reqAr.length;i++){
			if(reqAr[i] == "" || reqAr[i] == 0) reqAr[i] = defaultAr[i];
			reqAr[i] = parseFloat(reqAr[i]);
		}
	}else{
		reqAr = defaultAr;
	}
	switch(bt){
		case "Mozilla":
			this.browser = "Mozilla";
			return(version >= reqAr[0])?true:false
		case "Firefox":
			this.browser = "Firefox";
			//if(version >= 1 || version == .10) return true;
			return(version >= reqAr[1])?true:false;
		case "Netscape":
			this.browser = "Netscape";
			return(version >= reqAr[2])?true:false;
		case "Safari":
			this.browser = "Safari";
			return(version >= reqAr[3])?true:false;
		case "default":
			return false;
		}
	return true;
}

//pop-up window
function DolOpenWin(the_window,win_name,args,what_return){
	this[win_name] = window.open(the_window,win_name,args);
	has_pop = SendCommand(win_name);
	if(!has_pop){
		try{
			eval(win_name).focus();
		}catch(e){
			has_pop = true;
		}
	}
	if(what_return);
	else return has_pop;
}
function SendCommand(wn){
	try{
		return(wn)?false:true;
	}catch(e){
		return true;
	}
}
function WhatGecko(){
	var use_agent = navigator.userAgent;
	if(use_agent.indexOf("Netscape") != -1) nua = "Netscape";
	else if(use_agent.indexOf("Safari") != -1) nua = "Safari";
	else if(use_agent.indexOf("Firefox") != -1) nua = "Firefox";
	else if(use_agent.indexOf("Mozilla/5.0") != -1) nua = "Mozilla";
	else return false;
	return nua;
}
function GeckoInterface(page_transition,req_version){
	var myGecko = WhatGecko();
	var theVersion = GetTheVersion(myGecko);
	var passBrowser = this.PassVersion(myGecko,theVersion,req_version);
	if(page_transition)return passBrowser;
	else{
		if(passBrowser)return true;
		else goURL(defaultLP);
	}
}
// end gecko detection
//SP2 Detection
function IsServicePack(){
	var ua = navigator.userAgent;
	if(ua.indexOf("SV1") != -1) return true;
	else return false;
}
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";
function goURL(url){
	winLoc = window.location.toString();
	SetCookieUtil("detect_cookie","SW|" + winLoc);
	top.location.replace(url);
	}
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 GetCookieUtil (name) {
	var result = null;
	var myCookie = " " + document.cookie + ";";
	var searchName = " " + name + "=";
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1) {
		startOfCookie += searchName.length;
		endOfCookie = myCookie.indexOf(";", startOfCookie);
		result = unescape(myCookie.substring(startOfCookie, endOfCookie));
	}
	return result;
}


if (!document.getElementById) top.location.replace(defaultLP);

function PullVersionNumber(arg){
	var toReturn = arg.split(" ");
	for(var i=0;i<toReturn.length;i++){
		var num = toReturn[i];
		var num = parseFloat(num);
		if(num >= 1){
			return num;
		}
	
	}
	
}
function FindVersionNumber(){
	var ret;
	var version = navigator.appVersion;
	var versionAr = version.split(";");
	for(i=0;i<versionAr.length;i++){
		if(versionAr[i].indexOf("MSIE") != -1){
			ret = PullVersionNumber(versionAr[i]);
		}
	}
	return ret;
}
function FindNetscapeVersionNumber(){
	var ret = navigator.userAgent;
	var retAr = ret.split(" ");
	for(var i=0;i<retAr.length;i++){
		if(retAr[i].indexOf("Netscape") != -1){
			breakDownAr = retAr[i].split("/");
			ret = parseFloat(breakDownAr[1]);
			
			break;
		}
	}
	return ret;
	
}
function BiFindVersionNumber(){
	if(navigator.appName.indexOf("Microsoft") != -1){
		var ret = FindVersionNumber();
	}
	if(navigator.appName.indexOf("Netscape") != -1){
		var ret = FindNetscapeVersionNumber();
	}
	return ret;

}

function GetAx(ax){
	try{
		oMotion=eval("new  ActiveXObject('"+ax+"');");
		return true;
		}
		catch(e){
			return false;
		}
		return true;
}

function GetShockwave(){
	var shockwave=new Object();
	shockwave.installed=false;
	shockwave.version='0.0';
	if (navigator.plugins && navigator.plugins.length)
	{
		for (x=0; x<navigator.plugins.length; x++)
		{
			if (navigator.plugins[x].name.indexOf('Shockwave for Director') != -1)
			{
				shockwave.version=parseFloat(navigator.plugins[x].description.split('version ')[1]);
				shockwave.installed=true;
				break;
			}
		}
	}
		else if (window.ActiveXObject)
		{
			try{
				nox = new ActiveXObject("SWCtl.SWCtl");
				var preversion = nox.ShockwaveVersion("")
				shockwave.version = parseFloat(preversion);
			}catch(e){
				shockwave.version = -1;
			}
		}
	
	return shockwave.version;
}
function CheckShockwaveVersion(version){
	if(version <= parseFloat(shockwave)) return true;
	else return false;
}
function CompareShockwave(version,redirect,override,opt){
	if(!version)version = 7;
	if(!redirect) redirect = "http://disney.go.com/home/html/index.html?shockwave=true";
	
	if (CheckShockwaveVersion(version) == false){
		if(override == true){
			return false;
		}
		else{
			retFull = (!opt)?retFull = window.location.toString() : opt;
			SetCookieUtil("return_path",retFull,oneWeek);
			goURL(redirect);
		}
		
	}
	else return true;

}
function GetActiveX(){
	hasActiveX=(this.d_appName.indexOf("Microsoft") != -1 && this.d_platForm.indexOf("Win") != -1)?true:false;
	return hasActiveX;

}
function SuperObj(gecko_val,gecko_require){
	this.d_appName = navigator.appName;
	this.d_appVersion = navigator.appVersion
	this.d_platForm = navigator.platform
	// addition 12-01-2004
	this.hasServicePack = false
	this.passGecko = false;
	// end addition
	this.GetActiveX = GetActiveX;
	this.hasActiveX = this.GetActiveX();
	d_appName = this.d_appName;
	d_appVersion = this.d_appVersion;
	d_platForm = this.d_platForm;
	hasActiveX = this.hasActiveX;
	//addition
	this.GeckoInterface = GeckoInterface;
	this.PassVersion = PassVersion
	this.browser = "";
	if(this.d_appName == "Netscape"){
		this.passGecko = this.GeckoInterface(gecko_val,gecko_require);
	}
	else if(this.d_appName.indexOf("Micro") != -1){
		this.hasServicePack = IsServicePack();
		this.browser = "ie";
	}
	//end additon
	strippedAppVersion = BiFindVersionNumber();
	shockwave = GetShockwave();

}
function CreateInterface(loc,gecko_val,gecko_require){
	de_prot = window.location.host;
	if(de_prot.indexOf("disney.go.com") != -1 || de_prot.indexOf("family.go.com") != -1)de_host = "disney";
	else de_host = "global"
	if(!loc){
		defaultLP = "http://"+de_host+".go.com/home/html/index.html";
		
	}
	else{
		defaultLP = loc;
		
	}
	browser_object = new SuperObj(gecko_val,gecko_require);
}
//*********************************************
//WRITER CODE**********************************




function setDefault(variable,value){
	this[variable] = value;

}
function setBrowserDefault(activex,name,value){
	if(activex == true && this.ax==true){
		this[name] = value;
	}else{
		this[name] = value;
	}
	
}

function addAdditionalValue(param,value,browser){
	if(!browser){
		if(this.ax){
			var toPush = "<param name=\""+param+"\" value=\""+value+"\" />";
		}else{
			var toPush = " "+param+"=\""+value+"\" ";
		}
	}else if(browser == "ax" && this.ax==true){
		var toPush = "<param name=\""+param+"\" value=\""+value+"\" />";
		
	}else if(broser == "nonax" && this.ax != true){
		var toPush = " "+param+"=\""+value+"\" ";
	}
	this.shockAr.push(toPush);
	
}
function renderShockaveObject(){
	this.swRemote = (this.ignoreSwRemote)?"":"swSaveEnabled='"+this.swSaveEnabled+"' swRestart='"+this.swRestart+"' swPausePlay='"+this.swPausePlay+"' swFastForward='"+this.swFastForward+"' swContextMenu='"+this.swContextMenu+"' \" ";
	if(this.ax){
		//IE
		this.tagOpen= "<object classid=\"clsid:166B1BCA-3F9C-11CF-8075-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version="+this.version+",0,0,0\" ID=\""+this.id+"\" width=\""+this.width+"\" height=\""+this.height+" \" />";
		this.shockAr.push("<param name=\"swObjectName\" value=\"pub/shockwave/default/english/win95nt/10.1.0.011/slim_installer_disney.foo\" />");
		this.shockAr.push("<param name=\"SRC\" value=\""+this.url+"\" />");
		this.shockAr.push("<param name=\"bgColor\" VALUE=\""+this.bgColor+"\" />");
		if(!this.ignoreSwRemote) this.shockAr.push("<param name=\"swRemote\" value=\""+this.swRemote+" \" id=\"swRemote\" />");
		this.tagClose = "</object>";		
	}else{
		//Non-IE;
		this.tagOpen = "<embed "
		this.shockAr.push("src=\""+this.url+"\" id=\""+this.id+"\" width=\""+this.width+"\" height=\""+this.height+"\" bgColor=\""+this.bgColor+"\" swRemote=\""+this.swRemote+"\"  swStretchStyle=\""+this.swStretchStyle+"\" type=\"application/x-director\" pluginspage=\"http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=Disney&UI=plain&ReturnURL=www.disney.com&ReturnName=Disney\" ");
		this.tagClose = "/ >"
	}
	document.write(this.tagOpen);
	for(i=0;i<this.shockAr.length;i++){
		document.write(this.shockAr[i]);
	}
	
	document.write(this.tagClose);
}

function shockwaveObject(url,width,height,bgColor,id,version,ignoreSwRemote){
	//Setting arguments to the object
	//Required Variables
	this.url = url;
	this.width = width;
	this.height = height;
	//Setting Default Arguments
	this.bgColor = (bgColor == null || bgColor=="")?document.bgColor:bgColor;
	if(this.bgColor.substring(0,1) != "#")this.bgColor = "#" + this.bgColor
	this.id = (id==null || id=="")?"DOL":id;
	this.version = (version == null || version == "")?"6":version;
	this.ignoreSwRemote = ignoreSwRemote
	//Setting basic Defaults 
	//
	this.swSaveEnabled = "false";
	this.swVolume = "false";
	this.swRestart = "false";
	this.swPausePlay = "false";
	this.swFastForward = "false";
	this.swContextMenu = "false";
	this.swStretchStyle = "none";
	//SW REMOTE
	
	//end defaults
	//methods
	this.addAdditionalValue = addAdditionalValue;
	this.setDefault = setDefault;
	this.setBrowserDefault = setBrowserDefault;
	this.render = renderShockaveObject;
	//end methods
	this.ax = ((navigator.appName.indexOf("Micro") != -1) && (navigator.platform.indexOf("Win") != -1 || navigator.platform.toLowerCase().indexOf("ce") != -1))?true:false;
	this.shockAr = new Array();

	

}

//END WRITER CODE

//Midi Writer Code


function MidiObject(url,autostart,hidden,loop,id,enablejavascript){
	this.url = url;
	this.autostart = (autostart == null || autostart == "")?"true":autostart;
	this.hidden = (hidden != null || hidden == "")?"true":hidden;
	this.loop = (loop != null || loop == "")?"true":loop;
	this.id = (id == null || id == "")?"DOL":id;
	this.enablejavascript = (enablejavascript == null || enablejavascript == "")?"true":enablejavascript;
	this.addAdditionalMidiValue = addAdditionalMidiValue;
	this.render = renderMidi;
	this.additionalElements = " ";
	
}

function addAdditionalMidiValue(name,value){
	this.additionalElements += " " + name + "=" + value + " ";
}

function renderMidi(){
	var renderedString = "<embed src=\""+this.url+"\" height=\"1\" "+this.additionalElements+" width=\"1\" autostart=\""+this.autostart+"\" hidden=\""+this.hidden+"\" loop=\""+this.loop+"\" id=\""+this.id+"\"enablejavascript=\""+this.enablejavascript+"\" />"
	document.write(renderedString);
}


// End midi writer code