/*Disney's Pirates of the Caribbean Online (c)*/
isLoggedIn="false";
//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
//Begin code found on layout_default

var blogLoadedContent = false; // flag to identify if Blog has loaded content
var blogLoadContent   = false; // flag to tell Blog to load page content based on URL hash


//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=" + piratesCookieDomain) +	((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=" + piratesCookieDomain) +	((secure) ? "; secure" : "");
}
function cookieParamsHelper(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=cookieParamsHelper(document.cookie,name,null);
  return cookieValue;
}
function popWindow(url, name, params){
  window.open(url, name, params);
};
// End INCLUDE FLASH ERIC.JS AND UTILS.JS
//End code found on layout_default

//Begin menu.js
var remember=true; // --> keep track of the menu positions
var default_closeAll= false; // -->menus open or close default
var varCurrentPage=["INIT","INIT"];
var menu, titles, submenus, arrows, bypixels;
var heights=[];
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 atlasTagCongratsBasic(){}
function atlasTagCongratsUnlimited(){}
function button_getUnlimited(){
	//alert("CALLED button_getUnlimited")
	top.window.location='https://'+PDomain+'/?pageId=getUnlimitedAccess';
	//button_createAnAccount()
}
var varMenu = null;
function menubutton_faq(xNum, xMenu){
	for (var i=1;i<20;i++){
		var varTempMenu=document.getElementById('menu_' + i);
		var varTempArrow= document.getElementById('meunuArrow_' + i);
		if (varTempMenu){
			if (xNum == i && varTempMenu.className == "DisplayBlock"){
			// menu is already open - close it
				xNum=0
			}
			varTempMenu.className="DisplayNone";
			varTempMenu.style.visibility="hidden";
			varTempArrow.src="http://a.disney.go.com/pirates/online/v3/global/images/arrow_closed.gif";
		}else{}
	}
	if (xNum != 0){
		varMenu=document.getElementById('menu_' + xNum);
		var varArrow=document.getElementById('meunuArrow_' + xNum);
		varMenu.className="DisplayBlock";
		varMenu.style.visibility="visible";
		varArrow.src="http://a.disney.go.com/pirates/online/v3/global/images/arrow_open.gif";
	}
	this[xMenu]=xNum;
}
var menu_faq=0;
function menupageInit(xMenu){
	menubutton_faq(this[xMenu], xMenu);
}

function updateheight(xheight){

thisMovie("leftnav").height = Number(xheight);
	//alert("updateheight xheight="+xheight)
}

function setBackButton_Hash(hash, sethashinelse){
	if(userAgent.indexOf("msie")>-1){
		document.getElementById('ajaxnav').setAttribute('src', "/v3/global/backbutton?hash=" + hash);
	} else if(isMacSafari_v1_v2){
		historyState.newState('#'+hash);
	} else {
		if(sethashinelse){
			window.location.hash="#" + hash;
		}
	}
	if(!sethashinelse){
		window.location.hash="#" + hash;
	}
}


function searchAndReplace(input, stringToFind, stringToInsert){
  var output="";
  var findLen=stringToFind.length;
  while (input.indexOf(stringToFind)>=0){
    var currOffset=input.indexOf(stringToFind);
    output += input.substr(0, currOffset);
    output=output.substr(0, output.length);
    // delete the last char of output
    output=output += stringToInsert;
    input=input.substr((currOffset)+findLen, input.length-1);
  }
  output += input;
  return output;
}
function resetHBandSend(xURL){
	//alert("CALLED resetHBandSend: xURL="+xURL)
	if (typeof(xURL) != "string" || xURL ==""){
		return;
	}

	var varPathArray=xURL.split("/");

	// Support "?splash" for community-home.html for tracking
	var qs = (location.href.indexOf('?')) ? location.href.substring(location.href.indexOf('?') + 1) : '';
	if (qs == 'splash' && varPathArray[varPathArray.length-1] == 'community-home.html') {
		varPathArray[varPathArray.length-1] = 'community-home-splash.html';
	}

	varHBPageName=varPathArray[varPathArray.length-1];
	varHBPath="";
	for (var i=1; i<(varPathArray.length-1); i++){
		varHBPath += varPathArray[i]+"/";
	}
	//alert("varPageName="+varPageName+" varPath="+varPath)
	//hitbox.Set_hbPageView(varHBPageName, "/pirates/"+varHBPath);
}
function resetFlashHBandSend(xPageName, xPath){
	//alert('resetFlashHBandSend [' + xPageName + '] [' + xPath + ']');
	hitbox.Set_hbPageView(xPageName, "/pirates/v3/"+xPath);
}
function initReleaseNotes(xDiv){
	//alert("tried to insert: "+varReleaseNotesContent)
	document.getElementById(xDiv).innerHTML=varReleaseNotesContent;
}
//LOGIN SCRIPTS
function button_logOut(){
	remove_cookie("SAUSALITO");
	remove_cookie("accountType");
	top.window.location='http://'+PDomain+'/'+PVersion+'/util/logout';
}
function button_logInHere(){
	remove_cookie("SAUSALITO");
	remove_cookie("accountType");
	top.window.location='http://'+PDomain+'/'+PVersion+'/util/logout';
}
function button_createAnAccount(){
	//window.location='/pirates/v3/register/betaKey';
	top.window.location='https://'+PDomain+'/'+PVersion+'/index?pageId=createAccount';
}
function button_forgotpassword(){
	//alert('change password');
	platform=navigator.platform.toLowerCase();
	userAgent=navigator.userAgent.toLowerCase();
	//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
	if(isMac && isSafari){ // SAFARI CANNOT OPEN WINDOW, SO WE REDIRECT
		top.window.location='http://register.go.com/global/pirates/recoverPassword';
	}else{
		top.window.open('http://register.go.com/global/pirates/recoverPassword','external','');
	}
}
function button_recoverpassword(){
	platform=navigator.platform.toLowerCase();
	userAgent=navigator.userAgent.toLowerCase();
	//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
	if(isMac && isSafari){ // SAFARI CANNOT OPEN WINDOW, SO WE REDIRECT
		top.window.location='https://register.go.com/global/pirates/recoverMemberNames';
	} else {
		top.window.open('https://register.go.com/global/pirates/recoverMemberNames','external','');
	}
}
function openUrl(url){
  top.window.open(url,'external','');//open new window for all browsers
}
function button_ManageAccount(){
	//alert("CALLED: button_ManageAccount");
}
function button_leftnav(hash){
	if (hash.indexOf('http') == -1){
    if (hash=='redirectToPiratesChannel'){
      redirectToPiratesChannel();
    }else{

	setBackButton_Hash(hash, false)
    }
	}else{
    //open new window for these two links
    if (hash=='http://www.disneypirates.com'){
      openUrl(hash);
    }else if (hash=='https://register.go.com/global/pirates/recoverPassword'){
      openUrl(hash);
    }else if (hash=='https://register.go.com/global/pirates/recoverMemberNames'){
      openUrl(hash);
    }else{
      top.window.location=hash;
    }
  }
}
function button_Back(){
	//alert("CALLED: button_Back");
	window.history.go(-1);
	//alert("POST: button_Back");
	//loadContent(varCurrentPage[1], "dynamicContent")
}
function buttonLogin(xUsername, xPassword){
	//alert("CALLED: buttonLogin")
	thisMovie("movieplay").loginCallBack("result=failure");
	//callLoginCommand(xUsername, xPassword);
}
function button_accountSettings(){
	//alert("CALLED: accountSettings");
}
/*
function loginCallBack(){
	thisMovie("movieplay").loginCallBack();
}
*/
function button_signupAndPlay(){
	//alert("CALLED: signupAndPlay");
	//onCheckForBrowserAndRedirect()
	//window.location='/pirates/v3/register/betaKey';
	top.window.location='https://'+PDomain+'/'+PVersion+'/index?pageId=createAccount';

}
function button_SignUp(){
	//alert("CALLED: signupAndPlay");
	//onCheckForBrowserAndRedirect()
	//window.location='/pirates/v3/register/betaKey';
	top.window.location='https://'+PDomain+'/'+PVersion+'/index?pageId=createAccount';
}
function bannedUrl(xName){
	var varURL="http://apps.dxd.go.com/dxd/guestservices/your_account/account_hold?bannedUsername="+xName;
	top.window.location=varURL;
}
function button_loggedin_play(xToken){
	callAccountChecksCommand();
}
function button_exit(){
	if(previousHash != undefined){
		window.top.location="http://" + PDomain + "/" + previousHash;
	} else {
		window.top.location="http://" + PDomain + "/#/community/community-home.html";
	}
}
function button_exittomain(){
	window.top.location='http://'+PDomain+'/';
}
function button_ExitReg(){
	//alert('button_ExitReg');
}
function test_play_button(){
	top.window.location='http://'+PDomain+'/'+PVersion+'/play/testPlayCheck';
}
function initNewsPage(){
  if (document.getElementById('promo_upgrade') == null){
    return;
  }
}
function initPageType(xPageType){
	var varRightTopElementPlatinum=document.getElementById('html_rightbar_sub1_platinum');
	var varRightTopElementBasic=document.getElementById('html_rightbar_sub1_basic');
	var varRightBottomElementPlatinum=document.getElementById('html_rightbar_sub2_platinum');
	var varRightBottomElementBasic=document.getElementById('html_rightbar_sub2_basic');
	var varGetunlimitedbutton=document.getElementById('getunlimitedbutton');
	var varMenu= getElementsByClassName("sdmenu", "div", document)[0];
	var varExit_back=document.getElementById('exit_back');
	var varPlay=document.getElementById('play');

	switch(xPageType){
	case "exit_form":
		if (thisMovie("exit_back").src != "http://a.disney.go.com/pirates/online/v3/global/images/exit_congrats.gif"){
		varExit_back.innerHTML="<a href='javascript:button_exittomain();'><img src=\"http://a.disney.go.com/pirates/online/v3/global/images/exit_congrats.gif\" height=\"184\" width=\"142\" border='0'></a>";
		}else{
			thisMovie("exit_back").height=184;
			thisMovie("exit_back").width=142;
		}
		if(thisMovie("leftnav") != undefined){
			thisMovie("leftnav").height=1;
			thisMovie("leftnav").width=1;
		}
		varExit_back.className="DisplayBlock";
		varExit_back.style.visibility="visible";
		if (varGetunlimitedbutton != null){
			varGetunlimitedbutton.style.visibility="hidden";
			varGetunlimitedbutton.className="DisplayNone";
		}
		varRightBottomElementPlatinum.className="DisplayNone";
		varRightBottomElementBasic.className="DisplayNone";
		
		if(getcookie("accountType") != null){
			var varAccountType=getcookie("accountType");
			if (varAccountType == 'platinum'){
				var varRightTopElement=varRightTopElementPlatinum;
			}else{
			var varRightTopElement=varRightTopElementBasic;
			}
		}else{
			var varRightTopElement=varRightTopElementBasic;
		}
		if(varRightTopElement != null){
		varRightTopElement.style.visibility="visible";
		varRightTopElement.className='DisplayBlock';
		}
		break;

	case "back_form":
		if (thisMovie("exit_back").src != "http://a.disney.go.com/pirates/online/v3/global/images/back_report.gif"){
		varExit_back.innerHTML="<a href='javascript:button_exit();'><img src=\"http://a.disney.go.com/pirates/online/v3/global/images/back_report.gif\" height=\"184\" width=\"142\" border='0'></a>";
		}else{
			thisMovie("exit_back").height=184;
			thisMovie("exit_back").width=142;
		}
		varExit_back.className="DisplayBlock";
		varExit_back.style.visibility="visible";
		if (varGetunlimitedbutton != null){
			varGetunlimitedbutton.style.visibility="hidden";
			varGetunlimitedbutton.className="DisplayNone";
		}
		varRightBottomElementPlatinum.className="DisplayNone";
		varRightBottomElementBasic.className="DisplayNone";

		if(getcookie("accountType") != null){
			var varAccountType=getcookie("accountType");
			if (varAccountType == 'platinum'){
				var varRightTopElement=varRightTopElementPlatinum;
			}else{
				var varRightTopElement=varRightTopElementBasic;
			}
		}else{
			var varRightTopElement=varRightTopElementBasic;

		}
		if(varRightTopElement != null){
			varRightTopElement.style.visibility="visible";
			varRightTopElement.className='DisplayBlock';
		}
		if(thisMovie("leftnav") != undefined){
			thisMovie("leftnav").height=1;
			thisMovie("leftnav").width=1;
		}
		break;

	//THIS IS ONLY FOR TESTING THE EXTERNALINTERFACE.CALL IN A FORM PAGE
	case "TEST_exit":
		if (thisMovie("exit_back").src != "http://a.disney.go.com/pirates/online/v3/global/flash/TEST_exit_btn.swf"){
			initFlash("http://a.disney.go.com/pirates/online/v3/global/flash/TEST_exit_btn.swf", "142", "184", "#000000", "8", "exit_back", "", "", "transparent", "exit_back");
		}else{
			thisMovie("exit_back").height=184;
			thisMovie("exit_back").width=142;
		}
		varExit_back.className="DisplayBlock";
		varExit_back.style.visibility="visible";
		if (varGetunlimitedbutton != null){
			varGetunlimitedbutton.style.visibility="hidden";
			varGetunlimitedbutton.className="DisplayNone";
		}
		varRightBottomElementPlatinum.className="DisplayNone";
		varRightBottomElementBasic.className="DisplayNone";
		if(getcookie("accountType") != null){
			var varAccountType=getcookie("accountType");
			if (varAccountType == 'platinum'){
				var varRightTopElement=varRightTopElementPlatinum;
			}else{
			var varRightTopElement=varRightTopElementBasic;
			}
		}else{
			var varRightTopElement=varRightTopElementBasic;
		}
		if(varRightTopElement != null){
		varRightTopElement.style.visibility="visible";
		varRightTopElement.className='DisplayBlock';
		}
	break;

	case "exit":
		if (thisMovie("exit_back").src != "http://a.disney.go.com/pirates/online/v3/global/flash/exit_btn.swf"){
			initFlash("http://a.disney.go.com/pirates/online/v3/global/flash/exit_btn.swf", "142", "184", "#000000", "8", "exit_back", "", "", "transparent", "exit_back");
		}else{
			thisMovie("exit_back").height=184;
			thisMovie("exit_back").width=142;
		}

		if(thisMovie("leftnav") != undefined){
			thisMovie("leftnav").height=1;
			thisMovie("leftnav").width=1;
		}
		varExit_back.className="DisplayBlock";
		varExit_back.style.visibility="visible";
		if (varGetunlimitedbutton != null){
			varGetunlimitedbutton.style.visibility="hidden";
			varGetunlimitedbutton.className="DisplayNone";
		}
		varRightBottomElementPlatinum.className="DisplayNone";
		varRightBottomElementBasic.className="DisplayNone";

		if(getcookie("accountType") != null){
			var varAccountType=getcookie("accountType");
			if (varAccountType == 'platinum'){
				var varRightTopElement=varRightTopElementPlatinum;
			}else{
			var varRightTopElement=varRightTopElementBasic;
			}
		}else{
			var varRightTopElement=varRightTopElementBasic;
		}
		if(varRightTopElement != null){
		varRightTopElement.style.visibility="visible";
		varRightTopElement.className='DisplayBlock';
		}
	break;

	case "exitToMain":
		if (thisMovie("exit_back").src != "http://a.disney.go.com/pirates/online/v3/global/flash/exitToMain_btn.swf"){
			initFlash("http://a.disney.go.com/pirates/online/v3/global/flash/exitToMain_btn.swf", "142", "184", "#000000", "8", "exit_back", "", "", "transparent", "exit_back");
		}else{
			thisMovie("exit_back").height=184;
			thisMovie("exit_back").width=142;
		}
		if(thisMovie("leftnav") != undefined){
			thisMovie("leftnav").height=1;
			thisMovie("leftnav").width=1;
		}
		varExit_back.className="DisplayBlock";
		varExit_back.style.visibility="visible";
		if (varGetunlimitedbutton != null){
			varGetunlimitedbutton.style.visibility="hidden";
			varGetunlimitedbutton.className="DisplayNone";
		}
		varRightBottomElementPlatinum.className="DisplayNone";
		varRightBottomElementBasic.className="DisplayNone";
		if(getcookie("accountType") != null){
			var varAccountType=getcookie("accountType");
			if (varAccountType == 'platinum'){
				var varRightTopElement=varRightTopElementPlatinum;
			}else{
			var varRightTopElement=varRightTopElementBasic;
			}
		}else{
			var varRightTopElement=varRightTopElementBasic;
		}
		if(varRightTopElement != null){
			varRightTopElement.style.visibility="visible";
			varRightTopElement.className='DisplayBlock';
		}
	break;

	case "back":
		if (thisMovie("exit_back").src != "http://a.disney.go.com/pirates/online/v3/global/flash/exit_btn.swf"){
			initFlash("http://a.disney.go.com/pirates/online/v3/global/flash/exit_btn.swf", "142", "184", "#000000", "7", "exit_back", "", "", "transparent", "exit_back");
		}else{
			thisMovie("exit_back").height=184;
			thisMovie("exit_back").width=142;
		}
		varExit_back.className="DisplayBlock";
		varExit_back.style.visibility="visible";
		if (varGetunlimitedbutton != null){
			varGetunlimitedbutton.style.visibility="hidden";
			varGetunlimitedbutton.className="DisplayNone";
		}
		varRightBottomElementPlatinum.className="DisplayNone";
		varRightBottomElementBasic.className="DisplayNone";
		if(getcookie("accountType") != null){
			var varAccountType=getcookie("accountType");
			if (varAccountType == 'platinum'){
				var varRightTopElement=varRightTopElementPlatinum;
			}else{
			var varRightTopElement=varRightTopElementBasic;
			}
		}else{
			var varRightTopElement=varRightTopElementBasic;
		}
		if(varRightTopElement != null){
			varRightTopElement.style.visibility="visible";
			varRightTopElement.className='DisplayBlock';
		}
	break;

	default:
		
		if(getcookie("accountType") != null){
			var varAccountType=getcookie("accountType");
			if (varAccountType == 'platinum'){
				var varRightBottomElement=varRightBottomElementPlatinum;
			}else{
			var varRightBottomElement=varRightBottomElementBasic;
			}
		}else{
			var varRightBottomElement=varRightBottomElementBasic;
		}
		if(thisMovie("exit_back") != null){
			thisMovie("exit_back").height=1;
			thisMovie("exit_back").width=1;
		}
		if(thisMovie("leftnav") != undefined){
			thisMovie("leftnav").height=800;
			thisMovie("leftnav").width=160;
		}
		if (varGetunlimitedbutton != null){
			varGetunlimitedbutton.className="DisplayBlock";
			varGetunlimitedbutton.style.visibility="visible";
		}
		if(varRightTopElementBasic != null){
			varRightTopElementBasic.className='DisplayNone';
		}
		if(varRightBottomElement != null){
			varRightBottomElement.className='DisplayBlock';
			varRightBottomElement.style.visibility="visible";
		}
		varExit_back.className="DisplayNone";
		varExit_back.style.visibility="hidden";
		varPlay.style.visibility="visible";
	}
}
function setDefault(){
	if (typeof menu!="undefined"){
		for(i=0; i<Math.max(titles.length, submenus.length); i++){
			if (submenus[i].id == "closed"){
		    titles[i].className="titlehidden";
		    submenus[i].style.height="0px";
		    submenus[i].style.display="none";
		    arrows[i].src="http://a.disney.go.com/pirates/online/v3/global/images/collapsed.gif";
			}else{
			titles[i].className="title";
			arrows[i].src="http://a.disney.go.com/pirates/online/v3/global/images/expanded.gif";
			submenus[i].style.display="";
			submenus[i].style.height=heights[i]+"px";
			}
		}
	}
}
function loadpage(page_request, containerid){
  if(containerid == undefined) return;
  if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
  //START -- THIS CODE MODIFIES THE LINKS ON THE FETCHED PAGE FOR THE AJAX BACK BUTTON FIX
  var platform=navigator.platform;
  var userAgent=userAgent=navigator.userAgent;
  if(platform == undefined || userAgent == undefined){
    return;
  }
  platform=navigator.platform.toLowerCase();
  userAgent=navigator.userAgent.toLowerCase();
  //var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
  var pageText="";
  if(pageText == undefined || page_request == undefined || page_request.responseText == undefined){
    return;
  }
  //alert(page_request.responseText)
  pageText += page_request.responseText;
  var re=new RegExp("<([aA].*?)[href|HREF]=.dummy.html.hash=(.*?)['\"]{1}(.*?)>", "g");

  if(navigator.userAgent.toLowerCase().indexOf("msie")>-1){
    pageText=pageText.replace(re, "<$1 href=\"javascript:document.getElementById('ajaxnav').setAttribute('src', '/v3/global/backbutton?hash=$2&t=" + Math.random() + "');\" $3>");
  } else if(isMac && isSafari && !isVer3Plus){ // TEMPORARY UNTIL WE STOP SUPPORTING MAC+SAFARI2
    pageText=pageText.replace(re, "<$1 href=\"javascript:historyState.newState('#$2');\" $3>");
  } else {
    pageText=pageText.replace(re, "<$1 href=\"#$2\" $3>");
  }

  //ADD THE FUNCTION TO CALL METHODS AT THE END OF THE CENTER CONTENT LOAD
  if (pageText.indexOf("initPageType('loader')")== -1){
	//alert("adding runPageLoaded")
    // -- ADD 1x1 PIXEL WITH ONLOAD - CALL PAGELOADED SCRIPTS
    pageText += "<img src='http://a.disney.go.com/pirates/online/v3/global/images/spacer.gif' height='1' width='1' onload='runPageLoaded()'>";
  }
  //END -- THIS CODE MODIFIES THE LINKS ON THE FETCHED PAGE FOR THE AJAX BACK BUTTON FIX
  pageText+=loadingHtml();
  document.getElementById(containerid).innerHTML=pageText;
}
function loadContent(sURL, xID, xJs){
  if (blogLoadedContent) // blog has loaded content so do nothing
  {
    blogLoadedContent = false; // reset flag
    return;
  }
  if (sURL == '/news/currentnews.html') // old page
  {
  	window.location.hash = '/news_blog/currentnews.html'; // redirect old links to new page
  	return;
  }
  var dir1 = sURL.substring(0,11);
  var dir2 = sURL.substring(0,12);
  if ((dir1 == '/news_blog/') || (dir2 == '#/news_blog/'))
  {
     sURL = '/news_blog/currentnews.html';
     blogLoadContent = true; // tell blog to load content based on hash
  }
  varCurrentPage=[sURL,varCurrentPage[0]];
  if(sURL == undefined || typeof(sURL) != "string") return;
  if(sURL != undefined && sURL.indexOf('/pirates/v3') == -1){
    sURL=ajaxhtmlpath + sURL;
  }
  ajaxpage(sURL, xID, xJs);
  scroll(0,0);
}
function init(xURL){
  //setBackground()//removed to allow Emergency Messaging System
  menu=getElementsByClassName("sdmenu", "div", document)[0];
  titles=getElementsByClassName("title", "span", menu);
  submenus=getElementsByClassName("submenu", "div", menu);
  arrows=getElementsByClassName("arrow", "img", menu);
  menuspacers=getElementsByClassName("menuspacer", "img", menu);
  for(i=0; i<Math.max(titles.length, submenus.length); i++){
    if (submenus[i].id != "static"){
      arrows[i].onclick=gomenu;
      menuspacers[i].onclick=gomenu;
    }
    heights[i]=submenus[i].offsetHeight;
    submenus[i].style.height=submenus[i].offsetHeight+"px";
  }
  // remember=false
  if(remember){
    restore();
  }else{
    setDefault();
  }
  params=getURLParams();
  if(params != undefined && params["pageId"] != undefined && params["pageId"] != ""){
    if(window.location.hash == 'undefined' || window.location.hash == ''){
	//alert("called init xURL="+xURL)
     // loadContent(xURL, "dynamicContent");
     newUrl = "http://"+PDomain+"/#"+xURL
     top.window.location = newUrl;
    }
  }
}
function setBackground(){
	var ran_unrounded=Math.random()*3;
	var ran_number=Math.floor(ran_unrounded);
	var varBGArray=["background1.jpg", "background2.jpg", "background3.jpg"];
  var varPath="http://a.disney.go.com/pirates/online/v3/global/images/background1_nomarkR1_small.gif";
	document.body.background=varPath;
}
function restore(){
  if(getcookie("menu") != null){
    var hidden=getcookie("menu").split(",");
    for(var i in hidden){
      if(titles[hidden[i]] == undefined){
      break;
    }
    titles[hidden[i]].className="titlehidden";
    submenus[hidden[i]].style.height="0px";
    submenus[hidden[i]].style.display="none";
    arrows[hidden[i]].src="http://a.disney.go.com/pirates/online/v3/global/images/collapsed.gif";
    arrows[hidden[i]].alt="Open Menu";
    }
  }
}
function gomenu(e){
  if (!e)
    var e=window.event;
  var ce=(e.target) ? e.target : e.srcElement;
  var sm;
  for(var i in titles){
    if(titles[i] == ce || arrows[i] == ce || menuspacers[i] == ce)
      sm=i;
  }
  if(parseInt(submenus[sm].style.height) > parseInt(heights[sm])-2){
    hidemenu(sm);
  }else if(parseInt(submenus[sm].style.height) < 2){
    titles[sm].className="title";
    showmenu(sm);
  }
}
function hidemenu(sm){
  submenus[sm].style.display="none";
  submenus[sm].style.height="0px";
  arrows[sm].src="http://a.disney.go.com/pirates/online/v2/images/collapsed.gif";
  arrows[sm].alt="Open Menu";
  titles[sm].className="titlehidden";
  return;
  var nr=submenus[sm].getElementsByTagName("a").length*bypixels;
  submenus[sm].style.height=(parseInt(submenus[sm].style.height)-nr)+"px";
  var to=setTimeout("hidemenu("+sm+")", 30);
  if(parseInt(submenus[sm].style.height) <= nr){
    clearTimeout(to);
    submenus[sm].style.display="none";
    submenus[sm].style.height="0px";
    arrows[sm].src="http://a.disney.go.com/pirates/online/v2/images/collapsed.gif";
    arrows[sm].alt="Open Menu";
    titles[sm].className="titlehidden";
  }
}
function showmenu(sm){
  submenus[sm].style.display="";
  submenus[sm].style.height=heights[sm]+"px";
  arrows[sm].src="http://a.disney.go.com/pirates/online/v2/images/expanded.gif";
  arrows[sm].alt="Close Menu";
  return;

  var nr=submenus[sm].getElementsByTagName("a").length*bypixels;
  submenus[sm].style.display="";
  submenus[sm].style.height=(parseInt(submenus[sm].style.height)+nr)+"px";
  var to=setTimeout("showmenu("+sm+")", 30);
  if(parseInt(submenus[sm].style.height) > (parseInt(heights[sm])-nr)){
  clearTimeout(to);
  submenus[sm].style.height=heights[sm]+"px";
  arrows[sm].src="http://a.disney.go.com/pirates/online/v2/images/expanded.gif";
  arrows[sm].alt="Close Menu";
  }
}
function store(){
  var hidden=[];
  for(var i in titles){
    if(titles[i].className == "titlehidden")
      hidden.push(i);
  }
  putcookie("menu", hidden.join(","), 30);
}
function getElementsByClassName(strClassName, strTagName, oElm){
  return -1;
}
function putcookie(c_name,value,expiredays){
	var date=new Date();
	date.setTime(date.getTime()+(expiredays*24*60*60*1000));
    document.cookie=c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+date.toGMTString() + ";path=/");
}
function remove_cookie(cookie_name){
  var cookie_date=new Date();//current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie=cookie_name += "=; expires=" + cookie_date.toGMTString();
}
function getcookie(c_name){

	var nameEQ = c_name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) { 
			return unescape(c.substring(nameEQ.length,c.length));
		}
	}
	return null;
}
function callLoginCommand(xmlData){
	var re=new RegExp("(<pirates>.*?</pirates>).*", "g");
	xmlData=xmlData.replace(re, "$1");
	xmlDoc=createXMLParser(xmlData);
	result=xmlDoc.getElementsByTagName("result")[0].childNodes[0].nodeValue;
	if(result == null || result == 'undefined' || result != "success"){
		thisMovie("movieplay").loginCallBack("result=failure");
	}else{
		isLoggedIn="true";
		setNavSection(document.location.toString());
		if(xmlDoc.getElementsByTagName("accountType").length > 0){
			accountType=xmlDoc.getElementsByTagName("accountType")[0].childNodes[0].nodeValue;
			document.getElementById("signUpAndPlayButton").className='DisplayNone';
			document.getElementById("playButton").className='DisplayBlock';
			if(accountType == 'platinum'){
				document.getElementById("html_rightbar_sub1_basic").className='DisplayNone';
				document.getElementById("html_rightbar_sub2_basic").className='DisplayNone';
				document.getElementById("html_rightbar_sub2_platinum").className='DisplayBlock';
				putcookie("accountType", "platinum", null);
			}else{
				putcookie("accountType", "basic", null);
			}
		}
		var varNewHeight=Number(submenus[3].offsetHeight);
		varNewHeight += 15;
		varNewHeight=String(varNewHeight);
		heights[3]= varNewHeight;
		if (titles[3].className=="title"){
			submenus[3].style.height=heights[3]+"px";
		}
		document.getElementById("piratesChannelLink").style.display='block';
		putcookie("piratesLoginCookie", 1, 365);
		if(xmlDoc.getElementsByTagName("redirect").length > 0){
			redirectionUrl=xmlDoc.getElementsByTagName("redirect")[0].childNodes[0].nodeValue;
			window.top.location=redirectionUrl;
		}else{
			username=xmlDoc.getElementsByTagName("username")[0].childNodes[0].nodeValue;
			//alert("tried to pass in username:"+username)
			thisMovie("movieplay").loginCallBack("result=success&username="+username);
			initNewsPage();
		}
	}
	//xmlHttp.open("GET","http://"+piratesDomain+"/pirates/v3/play/accountLogin?username=" + username + "&password=" + password + "&sid=" + Math.random(), true);
	//xmlHttp.send(null);
}
function callAccountChecksCommand(){
  //this function checks that a user has met all requirements to play before proceeding to the play page
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e){ // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e){
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				//alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
			//alert(xmlHttp.responseText);
			if(xmlHttp.responseText == "undefined" || xmlHttp.responseText == ""){
				return;
			}
			xmlDoc=createXMLParser(xmlHttp.responseText);
			result=xmlDoc.getElementsByTagName("result")[0].childNodes[0].nodeValue;
			if(result != null && result != 'undefined' && result == "success"){
				if(xmlDoc.getElementsByTagName("redirect").length > 0){
					redirectionUrl=xmlDoc.getElementsByTagName("redirect")[0].childNodes[0].nodeValue;
					window.top.location=redirectionUrl;
				} else {
					//onCheckForBrowserAndRedirect()
					window.top.location="http://"+PDomain+"/index?pageId=play";
				}
			}
		}
	};
	xmlHttp.open("GET","http://"+PDomain+"/"+PVersion+"/play/accountChecks?sid=" + Math.random(), true);
	xmlHttp.send(null);
}
function createXMLParser(xText){
	if(typeof DOMParser != "undefined"){
		var parseX=new DOMParser();
		return parseX.parseFromString(xText, "text/xml");
	} else if(typeof ActiveXObject != "undefined"){
		var XMLobj=new ActiveXObject("Microsoft.XMLDOM");
		if(XMLobj){
			XMLobj.async=false;
			XMLobj.loadXML(xText);
			return XMLobj;
		} else {
			//alert("Could not parse XML in IE");
			return false;
		}
	} else {
		//alert("Failed");
		return false;
	}
}
searchParams='';
function pgSearch(searchTerm){
	if(!searchTerm.match(/^$/) && !searchTerm.match(/^\s+$/)){
		searchTerm=searchTerm.replace("/'/g", "\'");
		searchUrl='/playersguide-search.html?zoom_query=' + searchTerm + '&zoom_per_page=10&zoom_and=0&zoom_sort=0';
		searchParams='?zoom_query=' + searchTerm + '&zoom_per_page=10&zoom_and=0&zoom_sort=0';
		loadContent(searchUrl, 'dynamicContent');
	}
	return false;
}
function pgSearch2(searchTerm){
	if(!searchTerm.match(/^$/) && !searchTerm.match(/^\s+$/)){
		platform=navigator.platform.toLowerCase();
		userAgent=navigator.userAgent.toLowerCase();
		//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
		searchTerm=searchTerm.replace("/'/g", "\'");
		searchUrl='/playersguide-search.html?zoom_query=' + searchTerm + '&zoom_per_page=10&zoom_and=0&zoom_sort=0';
		searchParams='?zoom_query=' + searchTerm + '&zoom_per_page=10&zoom_and=0&zoom_sort=0';
		var detect=navigator.userAgent.toLowerCase();
		/*
		if(detect.indexOf("msie")>-1){ // IE
			document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + searchUrl + "&mode=pgSearch");
		} else if(isMacSafari_v1_v2){ // Safari 2
			historyState.newState("#" + searchUrl + "&mode=pgSearch");
		} else { // Firefox, Safari 3, etc...
			top.window.location.hash="#" + searchUrl + "&mode=pgSearch";
		}
		*/
		setBackButton_Hash(searchUrl + "&mode=pgSearch", true)
	}
	return false;
}
window.onload=init;
if(remember) window.onunload=store;
//End menu.js

//Begin pg_menu_db.js
//alert("pg_menu_db.js loaded")
function runClearSpring(){
  //alert("CALLED CLEARSPRING")
  var varDiv=document.getElementById("flashcontent");
  varDiv.innerHTML =
    "<object width='334' height='392' type='application/x-shockwave-flash' quality='high' id='W4739fa3152c25e21'><param value='http://widgets.clearspring.com/o/473912c74f235778/4739fa3152c25e21/473912c74f235778/7d0e23fd' name='movie'/><object width='334' height='392' type='application/x-shockwave-flash' id='W4739fa3152c25e21' data='http://widgets.clearspring.com/o/473912c74f235778/4739fa3152c25e21/473912c74f235778/7d0e23fd'><!--<![endif]--><param name='wmode' value='transparent'/><param name='allowScriptAccess' value='always'/><param name='allowNetworking' value='all'/></object><script type='text/javascript' src= 'http://widgets.clearspring.com/o/473912c74f235778/4739fa3152c25e21/473912c74f235778/7d0e23fd/widget.js'></script>";
}
function initFlash(xSwf, xWidth, xHeight, xBGColor, xFlashVersion, xMovieName, xVars, xRenderType, xWindowMode, xDivName){
	var varURL=window.location.toString();
	if (varURL.indexOf("viewTrailer=true")>-1){
		xVars="viewTrailer=true";
	}
	if (varURL.indexOf("videoID=")>-1){
		var varURLSplit=varURL.split("videoID=");
		xVars="videoID="+varURLSplit[1];
	}
	var flashObj=new FlashObj(xSwf, xWidth, xHeight, xBGColor, xFlashVersion, xMovieName, xVars, "autoplay", ".", "", "", true);
	var flashObjText=flashObj.render(true,xWindowMode);
	var varDivName=document.getElementById(xDivName);
	varDivName.innerHTML=flashObjText;
}
//report - a - bug error checking
function echeck(str){
  var at="@";
  var dot=".";
  var lat=str.indexOf(at);
  var lstr=str.length;
  var ldot=str.indexOf(dot);
  var messageText="The e-mail address provided is not in the form 'xxx@xxx.xxx'";
  if (str == "xxx@xxx.xxx"){/* alert(messageText)*/ return false}
  if (str.indexOf(at)==-1){ /* alert(messageText)*/ return false}
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    //alert(messageText)
    return false;
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    return false;
  }
  if (str.indexOf(at,(lat+1))!=-1){
    return false;
  }
  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    return false;
  }
  if (str.indexOf(dot,(lat+2))==-1){
    return false;
  }
  if (str.indexOf(" ")!=-1){
    return false;
  }
  return true;
}
function getFormElement(f, field_name, num){
  var elements=document.getElementsByName(field_name);
  var y=0;
  for (var i=0; i < elements.length; i++){
    if (f != elements[i].form){
      continue;
    }
    if (num != null){
      if (y == num){
        return elements[i];
      }
      y++;
    } else {
      return elements[i];
    }
  }
  return false;
}
function getPageElement(id){
  if (document.getElementById){
    return document.getElementById(id);
  } else if (document.all){
    return document.all[id];
  }
}
function errorDetails(f, field_name, show){
  var field=getFormElement(f, field_name);
  var icon=getPageElement('error_icon_' + field_name);
  if (icon == null){
    return false;
  }
  if (show){
    field.style.backgroundColor='#FF9999';
  }else{
    field.style.backgroundColor='#FFFFFF';
  }
}
function checkAttachments(xAttach1,xAttach2, xAttach3){
	xAttach1=xAttach1.toLowerCase();
	xAttach2=xAttach2.toLowerCase();
	xAttach3=xAttach3.toLowerCase();
	//alert("CALLED checkAttachments: xAttach1="+xAttach1+" xAttach2="+xAttach2)
	var varAcceptTypes=".jpg, .gif, .BMP, .log, .doc, .txt";
	var varReturn=true;
	if (xAttach1 != "" && xAttach1 != " "){
		var varTypePos=xAttach1.lastIndexOf(".");
		var varType=xAttach1.substring(varTypePos);
		if (varAcceptTypes.indexOf(varType)>-1){
			varReturn=true;
		}else{
		return false;
		}
	}
	if (xAttach2 != "" && xAttach2 != " "){
		var varTypePos=xAttach2.lastIndexOf(".");
		var varType=xAttach2.substring(varTypePos);
		if (varAcceptTypes.indexOf(varType)>-1){
			return varReturn;
		}else{return false;}
	}else{return varReturn;}
	if (xAttach3 != "" && xAttach3 != " "){
		var varTypePos=xAttach3.lastIndexOf(".");
		var varType=xAttach3.substring(varTypePos);
		if (varAcceptTypes.indexOf(varType)>-1){
			return varReturn;
		}else{return false;}
	}else{return varReturn;}
}
function validateForm(theForm){
  var varAccountError=document.getElementById('error_accountname');
  var varDescriptionError=document.getElementById('error_description');
  var varEmailError=document.getElementById('error_email');
  var varAttachError=document.getElementById('fileattachalert');
  varEmailError.className="DisplayNone";
  varEmailError.style.visibility="hidden";
  varAttachError.className="DisplayNone";
  varAttachError.style.visibility="hidden";
  varAccountError.className="DisplayNone";
  varAccountError.style.visibility="hidden";
  varDescriptionError.className="DisplayNone";
  varDescriptionError.style.visibility="hidden";
  var varFieldsToCheck=["description","custom_fields[10]","custom_fields[14]"];
  var varReturn=true;
  for (var i=0;i<varFieldsToCheck.length;i++){
    var itemToCheck=document.report_form[varFieldsToCheck[i]];
    if ((itemToCheck.value==null)||(itemToCheck.value=="")){
  errorDetails(document.report_form, varFieldsToCheck[i], true);
      varReturn= false;
    }
    if (varFieldsToCheck[i] == "description"){
      if ((itemToCheck.value==null)||(itemToCheck.value=="")){
        varDescriptionError.className="DisplayBlock";
        varDescriptionError.style.visibility="visible";
      }
    }
    if (varFieldsToCheck[i] == "custom_fields[14]"){
      if ((itemToCheck.value==null)||(itemToCheck.value=="")){
        varAccountError.className="DisplayBlock";
        varAccountError.style.visibility="visible";
      }
    }
    if (varFieldsToCheck[i] == "custom_fields[10]"){
      if (echeck(itemToCheck.value)==false){
        //emailID.value=""
        //itemToCheck.focus()
        var varEmailError=document.getElementById('error_email');
        varEmailError.className="DisplayBlock";
        varEmailError.style.visibility="visible";
        varReturn= false;
      }
    }
    if (varReturn == true){
      errorDetails(document.report_form, varFieldsToCheck[i], false);
    }
  }
  var varAttachCheck=checkAttachments(theForm["file[]_1"].value, theForm["file[]_2"].value, theForm["file[]_3"].value);
  if (!varAttachCheck){
  varAttachError.className="DisplayBlock";
  varAttachError.style.visibility="visible";
  varReturn= false;
  }
  if (document.location.toString().indexOf("download.test.piratesonline.com")>-1){
	df=document.forms["report_form"];
	df.action="http://download.test.piratesonline.com/bugSubmit/forward.php?site=test&post_form=yes";

  }
  //alert("WOULD HAVE RETURNED ="+varReturn)
  //return false
  return varReturn;
}
function initFAQPage(){
	var varURL=window.location.toString();
	var varFAQHashPos=varURL.lastIndexOf("#");
	var varFAQNum=varURL.substring(varFAQHashPos+1);
	document.getElementById(varFAQNum).scrollIntoView(true);
}
function initMultiPage(xDB, xFirstPage){
	if (this[xDB]["activePage"] == 0){
		this[xDB]["activePage"]=0;
		var varPrevTop=document.getElementById('prev_top');
		var varPrevTopText=document.getElementById('prev_top_text');
		var varPrevBottom=document.getElementById('prev_bottom');
		var varPrevBottomText=document.getElementById('prev_bottom_text');
		var varTopSpacer=document.getElementById('top_text_spacer');
		var varBottomSpacer=document.getElementById('bottom_text_spacer');
		if (varPrevTop != null){
			varPrevTop.style.visibility="hidden";
			varPrevTopText.style.visibility="hidden";
			varTopSpacer.style.visibility="hidden";
		}
		if (varPrevBottom != null){
			varPrevBottom.style.visibility="hidden";
			varPrevBottomText.style.visibility="hidden";
			varBottomSpacer.style.visibility="hidden";
		}
	}
	if (this[xDB]["activePage"] == (this[xDB]["pageList"].length -1)){
		var varnextTop=document.getElementById('next_top');
		var varnextTopText=document.getElementById('next_top_text');
		var varnextBottom=document.getElementById('next_bottom');
		var varnextBottomText=document.getElementById('next_bottom_text');
		var varTopSpacer=document.getElementById('top_text_spacer');
		var varBottomSpacer=document.getElementById('bottom_text_spacer');
		if (varnextTop != null){
			varnextTop.style.visibility="hidden";
			varnextTopText.style.visibility="hidden";
			varTopSpacer.style.visibility="hidden";
		}
		if (varnextBottom != null){
			varnextBottom.style.visibility="hidden";
			varnextBottomText.style.visibility="hidden";
			varBottomSpacer.style.visibility="hidden";
		}
	}
}
function loadArrayByNum(xDB, xNum, xSetBackButton){
	var varPage=this[xDB]["pageList"][xNum];
	this[xDB]["activePage"]=xNum;
	//alert("CALLED loadArrayByNum varPage="+varPage)
	var platform=navigator.platform.toLowerCase();
	var userAgent=navigator.userAgent.toLowerCase();
	//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
	if (xSetBackButton != false){
		//alert("in back button=false detect="+detect)
		setBackButton_Hash(varPage, true)
		/*
		if(userAgent.indexOf("msie")>-1){
			document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varPage);
		} else if(isMacSafari_v1_v2){
			historyState.newState('#'+varPage);
		} else {
			window.location.hash="#" + varPage;
		}
		*/
	}else{
		//alert("xSetBackButton not equal to false")
		loadContent(varPage, 'dynamicContent');
	}
}
function loadprevpage(xDB){
	var platform=navigator.platform.toLowerCase();
	var userAgent=navigator.userAgent.toLowerCase();
	//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
	var varNextPageNum=this[xDB]["activePage"];
	varNextPageNum--;
	this[xDB]["activePage"]=varNextPageNum;
	var varNextPage=this[xDB]["pageList"][varNextPageNum];
	setBackButton_Hash(varNextPage, true)
	/*
	if(userAgent.indexOf("msie")>-1){
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage);
	} else if(isMacSafari_v1_v2){
		historyState.newState('#'+varNextPage);
	} else {
	  window.location.hash="#" + varNextPage;
	}
	*/
}
function getCurrentPageFromDB(xDB){
	pathList=top.location.toString().split("/");
	var varHTMLPageNum=0;
	for (var i=0;i<pathList.length;i++){
		if (pathList[i].indexOf(".html")>-1){
			varHTMLPageNum=i;
			break;
		}
	}
	var varHTMLPos=pathList[varHTMLPageNum].indexOf(".html");
	var varHTMLPage=pathList[varHTMLPageNum].substr(0,varHTMLPos);
	//alert("varHTMLPageNum="+varHTMLPageNum+" varHTMLPos="+varHTMLPos+" varHTMLPage="+varHTMLPage)
	var varDBNum=0;
	for (var j=0;j<this[xDB].length;j++){
		if (this[xDB].length[j].indexOf(varHTMLPage)>-1){
		varDBNum=j;
		break;
		}
	}
	return varDBNum;
}
function loadnextpage(xDB){
	var platform=navigator.platform.toLowerCase();
	var userAgent=navigator.userAgent.toLowerCase();
	//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
	var varTest=getCurrentPageFromDB(xDB);
	//alert("varTest="+varTest)
	var varNextPageNum=this[xDB]["activePage"];
	varNextPageNum++;
	this[xDB]["activePage"]=varNextPageNum;
	var varNextPage=this[xDB]["pageList"][varNextPageNum];
	setBackButton_Hash(varNextPage, true);
	/*
	if(userAgent.indexOf("msie")>-1){
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage);
	} else if(isMacSafari_v1_v2){
		historyState.newState('#'+varNextPage);
	} else {
		 window.location.hash="#" + varNextPage;
	}
	*/
}
// CONTEST Caption This
var varTempContestCaptionThis=[];
varTempContestCaptionThis.push("http://a.disney.go.com/pirates/online/v3/global/images/contests/caption_this/image_1.gif");
varTempContestCaptionThis.push("http://a.disney.go.com/pirates/online/v3/global/images/contests/caption_this/image_2.gif");
var contestCaptionThisArray=[];
contestCaptionThisArray=varTempContestCaptionThis;
for (var m=1;m<varTempContestCaptionThis.length;m++){
	//conceptpixArray[j]=new Image
	//conceptpixArray[j].src=varTempConceptArtArray[j-1]
}
var im=0;
function switchImage(dir, xArray){
	if (dir == 'up'){
		if (im >= (this[xArray].length-1)){
			im=0;
		} else {
			im++;
		}
	} else if (dir == 'dn'){
		if (im <= 0){
			im=(this[xArray].length-1);
		} else {
			im--;
		}
	}else{
		im=0;
	}
	//alert("this[xArray][im].src="+this[xArray][im].src)
	//document.images["img"].src=this[xArray][im].src
	document.images["img"].src=this[xArray][im];
}
function switchImgPhotoAlbum(dir,xArray,subHdr,captionTxt){
	if (dir=='up'){
		if (im>=(this[xArray].length-1)){
			im=0;
		}else{
	    im++;
		}
	}else if (dir=='dn'){
		if (im<=0){
			im=(this[xArray].length-1);
		}else{
			im--;
		}
	}else{
		im=0;
	}
	document.images["img"].src=this[xArray][im];
  if (this[subHdr][im]=='TalkPirate2008'){
    document.getElementById("photoAlbumSubHdrImg").src=imgPath+'photo_album/misc/TalkPirate2008.jpg';
    document.getElementById("photoAlbumSubHdrImg").alt='Talk Like a Pirate to a Pirate September 19-21, 2008';
    document.getElementById("photoAlbumCaptionHtml").innerHTML=this[captionTxt][im];
  }else if (this[subHdr][im]=='GMEvent'){
    document.getElementById("photoAlbumSubHdrImg").src=imgPath+'photo_album/misc/GM_tavern.jpg';
    document.getElementById("photoAlbumSubHdrImg").alt='GM Tavern Takeover November 15, 16, 22 & 23, 2008';
    document.getElementById("photoAlbumCaptionHtml").innerHTML=this[captionTxt][im];
  }else{
    document.getElementById("photoAlbumSubHdrImg").src=imgPath+'photo_album/misc/Halloween2007.jpg';
    document.getElementById("photoAlbumSubHdrImg").alt='Halloweeen Launch Event October 31, 2007';
    document.getElementById("photoAlbumCaptionHtml").innerHTML='';
  }
}
function switchImageCaptionThisContest(dir, xArray, index){
	if (dir == 'up'){
		if (im >= (this[xArray].length-1)){
			im=0;
		} else {
			im++;
		}
	} else if (dir == 'dn'){
		if (im <= 0){
			im=(this[xArray].length-1);
		} else {
			im--;
		}
	}else{
		im=0;
	}
  if (index){
    im=index;
  }
  //remove the cookie and updated with the current index (im)
  //update the id "image_number" in content_html\community\contests\caption_this.html as you navigate the array of images
  remove_cookie('contestCaptionThis');
  putcookie('contestCaptionThis',im);
  check_caption_this=getcookie('contestCaptionThis');
  //this only works for the first two images (im=0 or im=1): One and Two
  if (check_caption_this==1){document.getElementById("image_number").innerHTML='Two';}
  else {document.getElementById("image_number").innerHTML='One';}
	document.images["img"].src=this[xArray][im];
}
function setCaptionThisCookie(value){
  //cookie is set from content_html\community\contests.html
  remove_cookie('contestCaptionThis');
  putcookie('contestCaptionThis',value);
}
function displayContestCaptionThis(){
  check_caption_this=getcookie('contestCaptionThis');
  if (check_caption_this==1){
    document.getElementById("image_number").innerHTML='Two';
    switchImageCaptionThisContest('init', 'contestCaptionThisArray', '1');
  }else{
    document.getElementById("image_number").innerHTML='One';
    switchImageCaptionThisContest('init', 'contestCaptionThisArray');
  }
}
var remember=true;
var contractall_default= false;
var varCurrentSection="INIT";
var varSetPG_ByNum=false;
var menu, titles, submenus, arrows, bypixels;
var heights=[];
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 printSection(){
	frames["printframe"].focus();
	frames["printframe"].print();
}
function printAll(){
	//alert("triedToPrint")
	params="width=529,height=500,top=0,left=0,scrollbars=yes,menubar=0,resizable=1";
	win=window.open("https://"+PDomain+"/"+PVersion+"/content_html/players_guide/print_All.html", "PRINT_ALL", params);
}
function loadPGbyURL(xURLToParse){
	var varPageInfoDB=getPGDatabaseLoc(xURLToParse);
	var varSecNum=varPageInfoDB[0];
	var varPageNum=varPageInfoDB[1];
	varActiveInfo["section"]=varSecNum;
	varActiveInfo["page"]=varPageNum;
	varSetPG_ByNum=true;
	loadContent('/playersguide.html', 'dynamicContent', 'pg_init');
}
function getPGDatabaseLoc(xURLToGet){
	var varSplitURL=xURLToGet.split("/");
	var varPage=varSplitURL[varSplitURL.length-1];
	//alert("varPage="+varPage)
	for (var i=0;i<varSections_DB.length;i++){
		for (var j=0; j<varSections_DB[i].pageDB.length;j++){
			if (varSections_DB[i].pageDB[j] == varPage){
			var varReturn=[i,j];
			return varReturn;
			}
		}
	}
	//alert("didn't find it")
	var varReturn=[0,0];
	return varReturn;
}
function loadprev(){
	varActiveInfo["page"]--;
	//alert("newpage="+varActiveInfo["page"]+" section length="+varSections_DB[varActiveInfo["section"]].pageDB.length)
	if (varActiveInfo["page"]<0){
		varActiveInfo["section"]--;
		if (varActiveInfo["section"] < 0){
			varActiveInfo["section"]=varSections_DB.length -1;
		}
		varActiveInfo["page"]=(varSections_DB[varActiveInfo["section"]].pageDB.length -1);
	}
	var varSecNum=varActiveInfo["section"];
	var varPageNum=varActiveInfo["page"];
	//loadPGContent(varSections_DB[varSecNum].pageDB[varPageNum], varSections_DB[varSecNum].headerGraphic);
	var platform=navigator.platform.toLowerCase();
	var userAgent=navigator.userAgent.toLowerCase();
	var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
	var varNextPage="/players_guide/" + varSections_DB[varSecNum]["directory"] + "/" + varSections_DB[varSecNum].pageDB[varPageNum];
	var varHeaderGraphic=varSections_DB[varSecNum].headerGraphic;
	setBackButton_Hash(varNextPage + "&mode=pgByUrl", true);
	/*
	if(userAgent.indexOf("msie")>-1){
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage + "&mode=pgByUrl");
	} else if(isMacSafari_v1_v2){
		historyState.newState('#'+varNextPage + "&mode=pgByUrl");
	} else {
		 window.location.hash="#" + varNextPage + "&mode=pgByUrl";
	}
	*/
}
function loadnext(){
	//alert("CALLED loadnext()")
	varActiveInfo["page"]++;
	if (varActiveInfo["page"]>varSections_DB[varActiveInfo["section"]].pageDB.length-1){
		varActiveInfo["section"]++;
		varActiveInfo["page"]=0
		if (varActiveInfo["section"] > varSections_DB.length -1){
			varActiveInfo["section"]=0;
		}
	}
	var varSecNum=varActiveInfo["section"];
	var varPageNum=varActiveInfo["page"];
	baseUrl="/players_guide/"+varSections_DB[varSecNum].directory+"/";
	var detect=navigator.userAgent.toLowerCase();
	//loadPGContent(varSections_DB[varSecNum].pageDB[varPageNum], varSections_DB[varSecNum].headerGraphic);
	var platform=navigator.platform.toLowerCase();
	var userAgent=navigator.userAgent.toLowerCase();
	//var isMac=platform.indexOf('mac') == 0 || userAgent.indexOf('macintosh') >= 0 || userAgent.indexOf('mac os') >= 0;
	var varNextPage="/players_guide/" + varSections_DB[varSecNum]["directory"] + "/" + varSections_DB[varSecNum].pageDB[varPageNum];
	var varHeaderGraphic=varSections_DB[varSecNum].headerGraphic;
	setBackButton_Hash(varNextPage + "&mode=pgByUrl", true);
	/*
	if(userAgent.indexOf("msie")>-1){
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage + "&mode=pgByUrl");
	} else if(isMacSafari_v1_v2){
		historyState.newState('#'+varNextPage + "&mode=pgByUrl");
	} else {
		 window.location.hash="#" + varNextPage + "&mode=pgByUrl";
	}
	*/
}
function loadSection(xSecNum){
	varActiveInfo["section"]=xSecNum;
	varActiveInfo["page"]=0;
	var varSecNum=varActiveInfo["section"];
	var varPageNum=varActiveInfo["page"];
	loadPGContent(varSections_DB[varSecNum].pageDB[varPageNum], varSections_DB[varSecNum].headerGraphic);
}
function setPageNum(){
	var varSectStartNum=varSections_DB[varActiveInfo["section"]]["StartNum"];
	var varPageNum=varSectStartNum +varActiveInfo["page"];
	varPageNum++;
	var varPagenation=document.getElementById('pageNum');
	varPagenation.innerHTML="PG. "+varPageNum;
	//alert("varPageNum=" + varPageNum)
}
function loadPGContent(sURL, xHeader, xDiv){
	var varSecNum=varActiveInfo["section"];
	if (xDiv == undefined){
	xDiv="pg_maincontent";
	}
	sURL="/players_guide/"+varSections_DB[varSecNum].directory+"/"+sURL;
	//alert("sURL="+sURL)
	//var varSecNum=varActiveInfo["section"];
	var varDirectory=varSections_DB[varSecNum].directory;
	if (varCurrentSection != varDirectory){
		varCurrentSection=varDirectory;
		var varPrintURL="/players_guide/"+varDirectory+"/"+"print_"+varDirectory+"_section.html";
		var varPrint=document.getElementById('printframe');
		if (varPrint){
		varPrint.src=varPrintURL;
		}
	}
	// TG: Changed this to start with '/' so URLs like /v3/#/ and /#/ work.
	pg_ajaxpage("/content"+ajaxhtmlpath+sURL, xDiv);
	image=document.getElementById('header');
	if (image){
    image.src='http://a.disney.go.com/pirates/online/v3/global/images/'+xHeader;
	}
	setPageNum();
}
  //var loadedobjects=""
  //var rootdomain="https://"+window.location.hostname
function pg_ajaxpage(url, containerid){
  //alert("pg_ajaxpage")

  resetHBandSend(url);
  if (containerid == undefined){
    containerid="pg_maincontent";
  }
  //alert("pg_ajaxpage url="+url+" containerid="+containerid)
  var page_request=false
  if (window.XMLHttpRequest) // if Mozilla, Safari etc
  page_request=new XMLHttpRequest();
  else if (window.ActiveXObject){ // if IE
    try { page_request=new ActiveXObject("Msxml2.XMLHTTP") }
    catch (e){
      try{page_request=new ActiveXObject("Microsoft.XMLHTTP")}
        catch (e){}}
  }
  else return false;
  page_request.onreadystatechange=function(){
  loadpage(page_request, containerid);
  };
  page_request.open('GET', url, true);
  page_request.send(null);
}
function loadobjs(xArguments){
  if (!document.getElementById)
    return;
  for (i=0; i<xArguments.length; i++){
    var file=xArguments[i];
    var fileref="";
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
      if (file.indexOf(".js")!=-1){ //If object is a js file
      fileref=document.createElement('script');
      fileref.setAttribute("type","text/javascript");
      fileref.setAttribute("src", file);
      }
      else if (file.indexOf(".css")!=-1){ //If object is a css file
      fileref=document.createElement("link");
      fileref.setAttribute("rel", "stylesheet");
      fileref.setAttribute("type", "text/css");
      fileref.setAttribute("href", file);
      }
    }
    if (fileref!=""){
    document.getElementsByTagName("head").item(0).appendChild(fileref);
    loadedobjects+=file+" ";//Remember this object as being already added to page
    }
  }
}
function pg_init(){
	//alert("CALLED pg_init")
	if (varSetPG_ByNum == true){
	var varSecNum=varActiveInfo["section"];
	var varPageNum=varActiveInfo["page"];
	loadPGContent(varSections_DB[varSecNum].pageDB[varPageNum], varSections_DB[varSecNum].headerGraphic);
	}else{
		var varCurrentPageNum=1;
	varActiveInfo["section"]=0;
	varActiveInfo["page"]=0;
	loadPGContent(varSections_DB[0].pageDB[0], varSections_DB[0].headerGraphic);
	}
	varSetPG_ByNum=false;
	return;
  menu=getElementsByClassName("sdmenu", "div", document)[0];
  titles=getElementsByClassName("title", "span", menu);
  submenus=getElementsByClassName("submenu", "div", menu);
  arrows=getElementsByClassName("arrow", "img", menu);
  for(i=0; i<Math.max(titles.length, submenus.length); i++){
    if (submenus[i].id != "static"){
      titles[i].onclick=gomenu;
      arrows[i].onclick=gomenu;
    }
    heights[i]=submenus[i].offsetHeight;
    submenus[i].style.height=submenus[i].offsetHeight+"px";
    }
    remember=false;
    if(remember){
				restore();
		}else{ //DD added code
		setDefault();
		//slash_contractall() //DD added code
	}
	var varURL=varSections_DB[0].pageDB[0];
	var varHeader=varSections_DB[0]["headerGraphic"];
	//alert("varURL="+varURL+" varHeader="+varHeader)
	loadPGContent(varURL, varHeader);
}
//End pg_menu_db.js

//Begin installer.js
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 PassParameter(){
  DisneyOnlineGames.ModeId=2;
  DisneyOnlineGames.Token="UserLoggedOnToken";
  DisneyOnlineGames.runPiratesOnline();
}
function whichBrs(){
  //Detect Browser
	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://"+PDomain+"/"+PVersion+"/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")
	//alert(isTestEnvironment);
	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" || (isTestEnvironment != 'undefined' && isTestEnvironment != null && isTestEnvironment == true)){
      setBackButton_Hash('/installer/installer_mac_safari.html', false);
        //loadContent('/installer/installer_mac_safari.html', 'dynamicContent');
      }else{setBackButton_Hash('/installer/installer_mac.html', 'dynamicContent');}
      }else{setBackButton_Hash('/installer/installer_firefox.html', 'dynamicContent');}
  	  }else{
      //loadContent('/installer/installer_firefox.html', 'dynamicContent');
      //loadContent("/installer/xpsp2explain.html", 'dynamicContent')
//      if(isTestEnvironment != 'undefined' && isTestEnvironment != null && isTestEnvironment == true){
        setBackButton_Hash('/installer/installer_firefox.html', 'dynamicContent');
//      } else {checkOS();}
  }
}
//End installer.js

// Redirects to correct install page based on Browser and version
// /installer/install_ie_basic.html
// /installer/install_ie_unlimited.html
// /installer/install_firefox_basic.html
// /installer/install_firefox_unlimited.html
// /installer/install_safari_basic.html
// /installer/install_safari_unlimited.html
// version - pass in string 'basic' or 'unlimited'
function RedirectToInstall(version)
{
	var installPage = '/installer/install_ie_';
	var BrowserType=whichBrs();
	if(BrowserType == "Internet Explorer")
	{
		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)
			installPage = '/installer/install_safari_';
		else
			installPage = '/installer/install_firefox_';
	}
	var hash = installPage + version + '.html';
	window.location.hash = hash;
	setBackButton_Hash(hash, 'dynamicContent');
}



//Begin javascriptInit.js
function initHTBX(){
  hitbox = new HB_CreateObject("/pirates/v3/");
  hitbox.HB_PlaceAccount("DM560804E8WD","DM5103120MSF93EN3","DM51030813MR38EN3", "DM5103083LCA38EN3");
  hitbox.onlyMedia="y";
  hitbox.HB_PlaceName("initialize");
  hitbox.protocol = "http";
  hitbox.HB_render();
}
//End javascriptInit.js

//Begin clearspringwidget.js
function runClearSpring(){
  //alert("CALLED CLEARSPRING")
  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";
     }
  }
  var varDiv=document.getElementById("flashcontent");
  var varText="";
  if (BrowserType == "Internet Explorer"){
    varText="<object width='334' height='392' type='application/x-shockwave-flash' quality='high' id='W4739fa3152c25e21'><param value='http://widgets.clearspring.com/o/473912c74f235778/4739fa3152c25e21/473912c74f235778/7d0e23fd' name='movie'/><EMBED width='334' wmode='transparent' height='392' type='application/x-shockwave-flash' id='W4739fa3152c25e21' data='http://widgets.clearspring.com/o/473912c74f235778/4739fa3152c25e21/473912c74f235778/7d0e23fd'></EMBED>";
  }else{
    varText="<object width='334' height='392' type='application/x-shockwave-flash' id='W4739fa3152c25e21' data='http://widgets.clearspring.com/o/473912c74f235778/4739fa3152c25e21/473912c74f235778/7d0e23fd'>";
  }
  varText +="<param name='wmode' value='transparent'/><param name='allowScriptAccess' value='always'/><param name='allowNetworking' value='all'/></object><script type='text/javascript' src= 'http://widgets.clearspring.com/o/473912c74f235778/4739fa3152c25e21/473912c74f235778/7d0e23fd/widget.js'></script>";
  varDiv.innerHTML=varText;
}
//End clearspringwidget.js

function DoubleClickSpotlight(){
//congratunlimited.html
//Tag for Activity Group: Convert, Activity: convert, Type: Daily Visits, Code: JavaScript
//Start of DoubleClick Spotlight Tag: Please do not remove
//Activity name for this tag is:convert
//Web site URL where tag should be placed: http://www.giantrealm.com
//Creation Date:5/31/2008
var axel=Math.random()+"";
var a=axel * 10000000000000;
document.write('<IMG SRC="http://ad.doubleclick.net/activity;src=1853401;type=conve428;cat=conve434;ord=1;num='+ a + '?" WIDTH=1 HEIGHT=1 BORDER=0>');
}
function SmartAdserver(){
//congratunlimited.html
sas_tmstp=Math.round(Math.random()*10000000000);
document.write('<img src="http://ww38.smartadserver.com/track/pix.asp?35119;4759;'+sas_tmstp+';[value]" width=1 height=1 border=0>');
}
function getSWFById(id){
	return document.getElementById(id);
}
function resizeSwfHeightById(h,id){
	var obj = getSWFById(id);
	
	var varSwf = thisMovie(id)
	var varDiv = document.getElementById("flashcontent");
	thisMovie(id).height = Number(h.toString())
	varDiv.style.height = obj.height = (h.toString()+"px");
}
function scrollWindow(x,y){
  window.scrollTo(x,y);
}
// ***********************************************************
//            The code below is for the Blog ONLY
// ***********************************************************
var isFlashReady = false; // used to wait until Flash is ready before calling it
function initBlogCSS()
{
	var head = document.getElementsByTagName("head")[0]; 
	var css = document.createElement("link"); 
	css.setAttribute("rel", "stylesheet"); 
	css.setAttribute("href", "http://a.disney.go.com/pirates/online/v3/global/css/blog.css"); 
	css.setAttribute("type", "text/css"); 
	css.setAttribute("media", "screen"); 
	head.appendChild(css);
}
// This converts the blog URL from the new format to the old
// New: http://apps.pirates.go.com/pirates/v3/#/news_blog/entry/extreme_contest#comment
// Old: http://blog.piratesonline.go.com/blog/pirates/entry/extreme_contest#comment
function convertBlogURL()
{
	var url = window.location.href;
	var n = url.indexOf("/news_blog/", 0);
	n = n + 10; // skip past "/news_blog";
	var old = "http://blog.piratesonline.go.com/blog/pirates" + url.substring(n,url.length);
	n = old.indexOf("currentnews.html", 0);
	if (n > 0)
		old = old.substring(0, n); // remove "currentnews.html"
	return old;
}
function getBlogData()
{
	if (isFlashReady)
	{
		var url = 'http://blog.piratesonline.go.com/blog/pirates'; // default value
		if (blogLoadContent) // load content based on window.location
			url = convertBlogURL();
		var xml = "<xml><jscall>listenFlash</jscall><method>POST</method><url>" + url + "</url></xml>";
		thisMovie('blog_swf').callFlash("getBlogData", xml);
	}
	else
		setTimeout("getBlogData()",200);
}
function listenFlash(option,value)
{
	var blog = document.getElementById("htmlcontent");
	if (option=="setBlogData")
	{
		var TempFormURL = "TEMPFORMURL";
		//html1.innerHTML = value.replace("<", "&lt;").replace(">", "&gt;");

		// trim off everything but the content.  trims off chrome, footer and outer parchment
		var pos1 = value.indexOf("<div id=\"potco_main\">"); // start of blog content
		var pos2 = value.indexOf("<!--potco_main-->"); // end of blog content
		var html = value.substring(pos1,pos2); // blog content

		// fix forms
		// get URL from form
		var fpos1 = html.indexOf("<form method=\"post\" action=\"http://blog.piratesonline.go.com");
		var fpos2 = html.indexOf("</form>", fpos1) + 7; // include </form>
		if (fpos1 > 0) // if form found
		{
			var form = html.substring(fpos1,fpos2); // get form html

			// when it was saved encodeURIComponent() was used.  This reverts what encodeURIComponent() did.
			form = decodeURIComponent(form);

			pos1 = form.indexOf("action=\"http://blog.piratesonline.go.com");
			pos1 = form.indexOf("\"", pos1)+1; // find first double quote
			pos2 = form.indexOf("\"", pos1);   // find second double quote
			var formURL = form.substring(pos1, pos2); // get URL for form

			// change onclick="this.form.method.value='preview'" to onlclick="SubmitForm:SubmitForm('preview',formURL);"
			pos1 = form.indexOf("<div class=\"blgBtnPrv\">");
			pos1 = form.indexOf("onclick=\"", pos1) + 9; // position of first character in side double quotes
			pos2 = form.indexOf("\"", pos1); // closing double quote
			var f1 = form.substring(0,pos1);
			var f2 = form.substring(pos2,form.length);
			// we use a place holder URL so that the link fix code does not alter this URL
			form = f1 + "Javascript:SubmitForm('preview','" + TempFormURL + "');" + f2;

			// change onclick="this.form.method.value='post'" to onclick="SubmitForm:SubmitForm('post',formURL);"
			pos1 = form.indexOf("<div class=\"blgBtnSub\">");
			pos1 = form.indexOf("onclick=\"", pos1) + 9; // position of first character in side double quotes
			pos2 = form.indexOf("\"", pos1); // closing double quote
			f1 = form.substring(0,pos1);
			f2 = form.substring(pos2,form.length);
			// we use a place holder URL so that the link fix code does not alter this URL
			form = f1 + "Javascript:SubmitForm('post','" + TempFormURL + "');" + f2;

			// insert id="commentForm" so the form has an ID
			pos1 = form.indexOf("name=\"commentForm\"");
			f1 = form.substring(0,pos1);
			f2 = form.substring(pos1,form.length);
			form = f1 + "id=\"commentForm\" " + f2;

			// change id="comments" to id="blogcomments" because a DIV also has id="comments"
			form = form.replace("id=\"comments\"", "id=\"blogcomments\"");

			// replace onsubmit="return validateInput(this)" with onsubmit="return false" so form cannot submit
			form = form.replace("validateInput(this)", "false");

			// replace the old form with the new form
			html = html.substring(0,fpos1) + form + html.substring(fpos2,html.length);
		}

		// change http://blog.piratesonline.go.com/blog/foo.html to Javascript:BlogLink('http://blog.piratesonline.go.com/blog/foo.html');
		pos1 = 0;
		do
		{
			pos1 = html.indexOf("http://blog.piratesonline.go.com/blog/", pos1);
			if (pos1 > 0)
			{
				pos2 = html.indexOf("\"", pos1);
				html = html.substring(0,pos1) + "Javascript:BlogLink('" + html.substring(pos1,pos2) + "');" + html.substring(pos2,html.length);
				pos1 = pos2 + 25;
			}
		} while (pos1 > 0);
		// change short links "/blog/foo.html to Javascript:BlogLink('http://blog.piratesonline.go.com/blog/foo.html');
		pos1 = 0;
		do
		{
			pos1 = html.indexOf("\"/blog", pos1);
			if (pos1 > 0)
			{
				pos1++; // add 1 to skip the double quote
				pos2 = html.indexOf("\"", pos1);
				html = html.substring(0,pos1) + "Javascript:BlogLink('http://blog.piratesonline.go.com" + html.substring(pos1,pos2) + "');" + html.substring(pos2,html.length);
				pos1 = pos2 + 55;
			}
		} while (pos1 > 0);
		html = html.replace(TempFormURL, formURL).replace(TempFormURL, formURL); // replace the two place-holder URLs with actual URLs
		blog.innerHTML = html;
		var hash = window.location.hash;
		var n = hash.length;
		var s = hash.substring(n-9,n);
		if (s == "#comments") // hash ends with #comments
			document.getElementById('comments').scrollIntoView(true); // scroll comments into view
	}
	else if (option=="setFlashReady")
	{
		isFlashReady = true;
		getBlogData();
	}
	else if (option=="blogDataLoadError")
	{
		blog.innerHTML = "<p>&nbsp;</p><div style=\"text-align:center;vertical-align:middle;font-weight:bold;color:#300000;\">Sorry! We're experiencing technical difficulties. Please check back later.<br /><a href=\"http://www.piratesonline.com/\">Click here</a> to return to PiratesOnline.com</div>";
	}
}
// Given a URL like this
// http://blog.piratesonline.go.com/blog/pirates/entry/just_for_fun_finish_this#comments
// Return the Hash part after the #
// /news_blog/entry/just_for_fun_finish_this#comments
// which becomes the full URL we see in the browser address bar
// http://apps.pirates.go.com/pirates/v3/#/news_blog/entry/just_for_fun_finish_this#comments
function NewBlogURLHash(url)
{
	var n = url.indexOf("/pirates/", 0);
	n = n + 8; // skip past "/pirates";
	var hash = "/news_blog" + url.substring(n,url.length);
	return hash;
}
// old Blog URL
// ajax - Use AJAX to load content? true/false
function GetNewContent(url,ajax)
{
	window.location.hash = NewBlogURLHash(url); // set browser hash
	if (ajax)
		blogLoadedContent = false;
	else
		blogLoadedContent = true;
	var xml = "<xml><jscall>listenFlash</jscall><method>POST</method><url>" + url + "</url></xml>";
	thisMovie('blog_swf').callFlash("getBlogData", xml);
}
// For links to Blog from within Blog
// url - old blog url
function BlogLink(url)
{
	GetNewContent(url,false);
}
// For linking to Blog from outside the Blog
// url - old blog url
function Link2Blog(url)
{
	GetNewContent(url,true);
}
// This function does not submit a form.  It has the same effect as a submitted form.
// method param can be "post" or "preview"
// url is from form action
function SubmitForm(method, url)
{
	var nickname = document.getElementById("nickname");
	var content = document.getElementById("blogcomments");
	nickname.value = encodeURIComponent(nickname.value);	// URI encode nickname
	content.value = encodeURIComponent(content.value);	// URI encode content
	var form = document.forms["commentForm"];
	if (validateInput(form))
	{
		// escape ampersand character in name and comment
		var params = "method=" + method + "&name=" + nickname.value + "&content=" + content.value;
		var xml = "<xml><url>" + url + "</url><jscall>listenFlash</jscall><method>POST</method><params>" + params + "</params></xml>";
		thisMovie('blog_swf').callFlash("getBlogData", xml);
	}
}
function btnOn(image)
{
	image.src=image.src.replace("_off.", "_on.")
}
function btnOff(image)
{
	image.src=image.src.replace("_on.", "_off.")
}
//clientSideInclude('commentAuthenticator', '/blog/CommentAuthenticatorServlet');

var author = GetCookie("commentAuthor");
// check each field - IE will render "null"
if (author) {
	document.forms['commentForm'].name.value = author;
}

function validateComments(theForm) {
	if (theForm.content.value == "") {
		theForm.content.focus();
		return false;
	} else return true;
}

function validateInputName(theForm) {
	if (theForm.name.value == "") {
		theForm.name.focus();
		return false;
	} else return true;
}

function validateInput(theForm) {
	var goodComment = validateComments(theForm);
	var goodName = validateInputName(theForm);
	if (!goodComment && !goodName) {
		alert ("Please enter a name.\nPlease enter a comment.");
		return false;
	} else if (!goodName) {
	alert("Please enter a name.");
		return false;
	} else if (!goodComment) {
	alert("Please enter a comment.");
		return false;
	} else {
		return true;
	}
}

// ***********************************************************
//             The code above is for the Blog ONLY
// ***********************************************************
