//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){
//alert("called initFlash")
//'/flash/potc_crew_bios.swf', '509', '600', '#000000', '8', 'bios_movie', 'varVars=NONE, true,'transparent', 'flashcontent'
	// -- band-aid for video trailer
	var varURL = window.location.toString()
	if (varURL.indexOf("viewTrailer=true")>-1){
		xVars = "viewTrailer=true"
	}
	//var varURL = window.location.toString()
	if (varURL.indexOf("videoID=")>-1){
		//alert("tried to split")
		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
	
	/*
	var so = new SWFObject(xSwf, xMovieName, xWidth, xHeight, xFlashVersion, xBGColor);
	
	// var so = new SWFObject("/flash/potc_crew_bios.swf", "bios_movie", "626", "600", "8", "#000000");
	so.addParam("wmode", xWindowMode);
	so.write(xDivName);
	*/
	
}
//-- 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){
      // alert(messageText)
        return false
    }

     if (str.indexOf(at,(lat+1))!=-1){
      // alert(messageText)
        return false
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      // alert(messageText)
        return false
     }

     if (str.indexOf(dot,(lat+2))==-1){
       //alert(messageText)
        return false
     }

     if (str.indexOf(" ")!=-1){
      // alert(messageText)
       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';
         // icon.style.visibility = 'visible';
         // icon.width = 14;
         // icon.height = 14;
      } else {
          field.style.backgroundColor = '#FFFFFF';
          //icon.style.visibility = 'hidden';
          //icon.width = 1;
         // icon.height = 1;
      }
}
//
//

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
	}
	//alert("WOULD HAVE RETURNED ="+varReturn)
	//return false
	return varReturn
   }
  //-->

/*
function validateForm(theForm) {
	 var varAttachCheck = checkAttachments(theForm.screenShot1.value,theForm.screenShot2.value);
		 var varAttachError = document.getElementById('fileattachalert');
		// alert("varAttachCheck="+varAttachCheck)
		 if (varAttachCheck){
		 	varAttachError.className = "DisplayBlock"
			varAttachError.style.visibility = "hidden"
			 return true;
		 	
		 }else{
			var varAttachError = document.getElementById('fileattachalert');
		 		 	
			varAttachError.className = "DisplayNone"
			varAttachError.style.visibility = "visible"
			//alert("TRIED TO CHANGE DISPLAY")
			return false;
		 	
		 }

}
*/



function initFAQPage(){

	var varURL = window.location.toString()
	var varFAQHashPos = varURL.lastIndexOf("#")
	var varFAQNum = varURL.substring(varFAQHashPos)
	top.window.location.replace(varFAQNum)
	
}



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)
		if(userAgent.indexOf("msie")>-1) {
			document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varPage);
		} else if(isMac && userAgent.indexOf("safari") != -1 && userAgent.indexOf("version/3") == -1) {
			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]
	
	/* */
	if(userAgent.indexOf("msie")>-1) {
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage);
	} else if(isMac && userAgent.indexOf("safari") != -1 && userAgent.indexOf("version/3") == -1) {
		historyState.newState('#'+varNextPage);
	} else {
	
	//if (detect.indexOf("mac os")>-1 && detect.indexOf("safari")>-1){
		//loadContent(varNextPage, 'dynamicContent')
	//}else{
	
		 window.location.hash = "#" + varNextPage;
	}
	
	
	
   //by camartin
    //window.location.hash = "#" + varPage;//js error
	//}
	//loadContent(varNextPage, 'dynamicContent')
}


function getCurrentPageFromDB(xDB){
	//var varDB = 
	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;
	
	//alert("CALLED loadnextpage")
	var varTest = getCurrentPageFromDB(xDB)
	//alert("varTest="+varTest)
	var varNextPageNum = this[xDB]["activePage"]
	varNextPageNum++
	this[xDB]["activePage"] = varNextPageNum
	var varNextPage = this[xDB]["pageList"][varNextPageNum]
	
	if(userAgent.indexOf("msie")>-1) {
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage);
	} else if(isMac && userAgent.indexOf("safari") != -1 && userAgent.indexOf("version/3") == -1) {
		historyState.newState('#'+varNextPage);
	} else {
	//if (detect.indexOf("mac os")>-1 && detect.indexOf("safari")>-1){
		//loadContent(varNextPage, 'dynamicContent')
	//}else{
		 window.location.hash = "#" + varNextPage;
	//}

	}
	//loadContent(varNextPage, 'dynamicContent')
	
}

// --> CONTEST Caption This
var varTempContestCaptionThis = new Array();

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 = new Array()
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 switchImageCaptionThisContest(dir, xArray, index) {
//by camartin
//this is a duplicate function of switchImage() for Caption This Contest
//it takes a 3rd parameter for setting the 2nd image as the default image (index=1) 
//v3/content_html\community\contests.html
//v3/content_html\community\contests\caption_this.html

	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'
  }

	//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 setCaptionThisCookie(value)
{
  //cookie is set from content_html\community\contests.html
  remove_cookie('contestCaptionThis')
  putcookie('contestCaptionThis',value)
  //temp = getcookie('contestCaptionThis')
  //alert('contestCaptionThis: ' + temp )
}


function displayContestCaptionThis()
{
  check_caption_this = getcookie('contestCaptionThis')
  //alert ('check_caption_this: ' + check_caption_this)
  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 = new Array();

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://"+piratesDomain+"/v3/content_html/players_guide/print_All.html", "PRINT_ALL", params);
	//win.focus()
	//win.print()
	//frames["printAllframe"].focus();
	//frames["printAllframe"].print();
}

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;
}


/*

ORIGINAL - PRE-BACK BUTTON

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);

}
*/

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;
	
	if(userAgent.indexOf("msie")>-1) {
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage + "&mode=pgByUrl");
	} else if(isMac && userAgent.indexOf("safari") != -1 && userAgent.indexOf("version/3") == -1) {
		historyState.newState('#'+varNextPage + "&mode=pgByUrl");
	} else {
		 window.location.hash = "#" + varNextPage + "&mode=pgByUrl";
	}
	
	
	
	/*
	baseUrl = "/v3/content_html/players_guide/"+varSections_DB[varSecNum].directory+"/";
	
	var detect = navigator.userAgent.toLowerCase();

	if(detect.indexOf("msie")>-1) {
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + baseUrl + varSections_DB[varSecNum].pageDB[varPageNum] + "&mode=pgByUrl");
	} else {
		window.location.hash = "#" + baseUrl + varSections_DB[varSecNum].pageDB[varPageNum] + "&mode=pgByUrl";
	}
	*/
}

/*

ORIGINAL - PRE-BACK BUTTON

function 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"]
	loadPGContent(varSections_DB[varSecNum].pageDB[varPageNum], varSections_DB[varSecNum].headerGraphic);
	
}
*/


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;
	
	if(userAgent.indexOf("msie")>-1) {
		document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + varNextPage + "&mode=pgByUrl");
	} else if(isMac && userAgent.indexOf("safari") != -1 && userAgent.indexOf("version/3") == -1) {
		historyState.newState('#'+varNextPage + "&mode=pgByUrl");
	} else {
		 window.location.hash = "#" + varNextPage + "&mode=pgByUrl";
	}
	
	
	//if(detect.indexOf("msie")>-1) {
		//document.getElementById('ajaxnav').setAttribute('src', "/pirates/v3/global/backbutton?hash=" + baseUrl + varSections_DB[varSecNum].pageDB[varPageNum] + "&mode=pgByUrl");
	//} else {
	//	window.location.hash = "#" + baseUrl + varSections_DB[varSecNum].pageDB[varPageNum] + "&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;
		}
	}
	pg_ajaxpage("/v3/content_html"+sURL, xDiv)
	//
	/*
	iFrameReset = document.getElementById('myFrame');
	iFrameReset.frameborder="0" 
	iFrameReset.marginwidth="0"
	iFrameReset.marginheight="0"
	iFrameReset.width="100%"
	iFrameReset.scrolling="no"
	iFrameReset.src = sURL
	iFrameReset.style.visibility = "hidden"
	iFrameReset.style.overflow = "hidden"
	adjustIFrameSize("myFrame")
	*/
	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 loadpage(page_request, containerid){
		//alert("CALLED loadpage")
		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;
		}
		
		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', '/pirates/v3/global/backbutton?hash=$2');\" $3>");
		} else if(isMac && userAgent.indexOf("safari") != -1 && userAgent.indexOf("version/3") == -1) { // 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){
					
					// -- 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

		document.getElementById(containerid).innerHTML=pageText
		}
		*/
		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"]
	
	//alert("varSecNum="+varSecNum+" varPageNum="+varPageNum)
	
	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)
}



