

var n = navigator.userAgent;
if(/Opera/.test(n)) bypixels = 2;
else if(/Firefox/.test(n)) bypixels = 3;
else if(/MSIE/.test(n)) bypixels = 2;

function errorReport(errormsg){
	alert(errormsg);
	return true
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";

	if (piratesCookieDomain == undefined){
		var piratesCookieDomain = "go.com"
	}
	document.cookie = name+"="+value+expires+"; path=/; domain=" + piratesCookieDomain;
}
function getCookieValue(cookieName) {
	thisCookie = document.cookie.split("; ")
   	for (i=0; i<thisCookie.length; i++) {
       	if (cookieName == thisCookie[i].split("=")[0]) {
       		return thisCookie[i].split("=")[1]
       	}
   	}
	return null; //default value
}

/*
function chkGMInstall(){
//alert("chkForGMInstall().SUCCESS")
	try{
		var testObj = new ActiveXObject("DIGGameManager.GameManagerCtrl.1");
	}catch(errormsg){
	msg=errormsg.message;
	}
	try{
		if(typeof(testObj) == "object"){
			clearInterval(chkGMInstallInterval);
			//alert("chkForGMInstall().SUCCESS");
			document.location = "http://www.gamekingdom.go.com/v3/startpage/index.html";
		}
	}catch(errormsg){
	msg=errormsg.message;
	}
}
*/


function PassParameter()
{
    DisneyOnlineGames.ModeId=2
    DisneyOnlineGames.Token="UserLoggedOnToken"
    DisneyOnlineGames.runPiratesOnline();
}

/********************************************************
   Detect Browser
 ********************************************************/
function whichBrs() {
			
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
	if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
	return navigator.userAgent.substr(0,agt.indexOf('\/'));}
	else return 'Netscape';} else if (agt.indexOf(' ') != -1)
	return navigator.userAgent.substr(0,agt.indexOf(' '));
	else return navigator.userAgent;
}
 
 
 function EULA_Agree(){
	//alert("CALLED EULA_Agree")
	 createCookie("EULA_Pirates","agree",9999)
	 checkOS()
 }
  function EULA_disAgree(){
		var varEulaDis = document.getElementById('eulaDisagree');
		varEulaDis.className = "DisplayBlock"
		varEulaDis.style.visibility = "visible"

	//eulaDisagree
 }
 //
function checkOS(){
	

	//--| first eula cookie check cookie
	var varEulaCookie = getCookieValue("EULA_Pirates") 
	var varPOTCOGMCookie = getCookieValue("POTCOGame") 
	
	//alert("varPOTCOGMCookie="+varPOTCOGMCookie)
	
	if (varPOTCOGMCookie == "installed"){
		top.window.location  = "http://disney.go.com/pirates/online/v3/installer/setToken.html"
		return
	
	}
	
	if (varEulaCookie == null){
		loadContent('/eula.html', 'dynamicContent');
		return;
	}
	
	
	var varRetURL = "https://"+piratesDomain+"/pirates/v3/index?pageId=axinstall"
	//var varRetURL = backToDownload()
	//alert("varRetURL="+varRetURL)
	var varAppVersion = navigator.appVersion.toLowerCase()
	var ua = navigator.userAgent.toLowerCase()
	//alert("varAppVersion="+varAppVersion)
	//alert("ua="+ua)
	if(ua.indexOf("sv1") != -1){
   		spb = true;
	}else{
		if (ua.indexOf("msie 7") == -1){
			spb = false;
		}else{
			spb = true;
		}
	}
	if (varAppVersion.indexOf("windows")<0){
		//alert ("its a Mac - redirect to the LearnMore Page")
	}
	varOsVersion = varAppVersion.substring(varAppVersion.indexOf("windows")+7, varAppVersion.length)
	//alert ("varOsVersion="+varOsVersion)

	varOsVersionNum = searchAndReplace(varOsVersion,"nt","")
	varOsVersionNum = searchAndReplace(varOsVersionNum," ","")
	varOsVersionNum = parseFloat(varOsVersionNum)
	
	var varSP1_URL = "http://disney.go.com/pirates/online/v3/installer/xpsp1explain.html"
	var varSP2_URL = "http://disney.go.com/pirates/online/v3/installer/xpsp2explain.html"
	var varVista_URL = "http://disney.go.com/pirates/online/v3/installer/vistaexplain.html"
	
	
	
	//alert("varOsVersionNum="+varOsVersionNum)
	switch(true){
		//javascript detect xp service pack
	case (varOsVersion.indexOf("nt")<0):
		//loadContent(varSP1_URL, 'dynamicContent')
		top.window.location = varSP1_URL
	break;
	//
	case (varOsVersionNum == 4.1):
		//loadContent(varSP1_URL, 'dynamicContent')
		top.window.location = varSP1_URL
		//alert("we are on win98")
	break;
	//
	case (varOsVersionNum == 4.9):
		//loadContent(varSP1_URL, 'dynamicContent')
		top.window.location = varSP1_URL
	//alert("we are on winME")
	break;
	//
	case (varOsVersionNum == 5):
		//loadContent(varSP1_URL, 'dynamicContent')
		top.window.location = varSP1_URL
		//alert("we are on win2k")
	break;
	//
	case (varOsVersionNum == 5.1):
		if (spb == true){
			//alert("varSP1_URL="+varSP1_URL)
			//loadContent(varSP1_URL, 'dynamicContent')
			top.window.location = varSP2_URL
		}else{
			//alert("varSP2_URL="+varSP2_URL)
			//loadContent(varSP2_URL, 'dynamicContent')
			//loadContent(sURL, xID, xJs) 
			top.window.location = varSP1_URL
			
		}

	break;
	case (varOsVersionNum >= 6 && varOsVersionNum != 98):
		//loadContent(varSP2_URL, 'dynamicContent')
		//window.location = varVista_URL
		loadContent('/installer/installer_firefox.html', 'dynamicContent');
	break;
	//
	//case (varOsVersionNum > 5.1):
	//alert("we are on win98")
		//window.location = "http://disney.go.com/games/downloads/setup/xpsp1explain.html?retURL="+varRetURL
	//break;
	default:
		//loadContent(varSP2_URL, 'dynamicContent')
		top.window.location = varSP2_URL
	}
}


function onCheckForBrowserAndRedirect(){
	//alert("called onCheckForBrowserAndRedirect")
	var BrowserType = whichBrs()
	if(BrowserType == "Internet Explorer"){
	   //if you have ie but you are on a mac then treat em like a netscape user (no vb support)
	   if(navigator.userAgent.toLowerCase().indexOf("mac") !=-1){
	      BrowserType = "mac"
	   }
	
	}
	/********************************************************
	   Detect MAC OS and Browsers
	 ********************************************************/
	if (BrowserType != "Internet Explorer"){
		
		if (navigator.userAgent.toLowerCase().indexOf("mac")>-1){
			if (BrowserType == "Safari"){
				loadContent('/installer/installer_mac_safari.html', 'dynamicContent');
			}else{
				loadContent('/installer/installer_mac.html', 'dynamicContent');
			}
		
			
		}else{
			loadContent('/installer/installer_firefox.html', 'dynamicContent');
		}
		
		
	}else{
		//loadContent('/installer/installer_firefox.html', 'dynamicContent');
		//loadContent("/installer/xpsp2explain.html", 'dynamicContent')
		checkOS()
	}


}






































































































































