/* [nodename, id, name, navigationtext, href, isnavigation, childs[], templatename] */

if (typeof(decodeURIComponent) == 'undefined') {
  decodeURIComponent = function(s) {
    return unescape(s);
  }
}

function jdecode(s) {
    s = s.replace(/\+/g, "%20")
    return decodeURIComponent(s);
}

var POS_NODENAME=0;
var POS_ID=1;
var POS_NAME=2;
var POS_NAVIGATIONTEXT=3;
var POS_HREF=4;
var POS_ISNAVIGATION=5;
var POS_CHILDS=6;
var POS_TEMPLATENAME=7;
var theSitetree=[ 
	['PAGE','2201',jdecode('Home'),jdecode(''),'/2201.html','true',[],''],
	['PAGE','30001',jdecode('News+in+the+Realms'),jdecode(''),'/30001.html','true',[],''],
	['PAGE','2294',jdecode('Journal+Blog'),jdecode(''),'/2294.html','true',[],''],
	['PAGE','2315',jdecode('The+Cybrarie'),jdecode(''),'/2315.html','true',[],''],
	['PAGE','33801',jdecode('Cybrarie+Emporium'),jdecode(''),'/33801.html','true',[],''],
	['PAGE','28201',jdecode('Author+Bios'),jdecode(''),'/28201.html','true',[],''],
	['PAGE','2336',jdecode('Fun+and+Games'),jdecode(''),'/2336.html','true',[],''],
	['PAGE','2378',jdecode('Guestbook+'),jdecode(''),'/2378.html','true',[],''],
	['PAGE','2399',jdecode('Messaging'),jdecode(''),'/2399.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Fantasy';
theSitetree.paletteFamily='906145';
theSitetree.keyvisualId='9901';
theSitetree.keyvisualName='kv1.swf';
theSitetree.fontsetId='17881';
theSitetree.graphicsetId='13064';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='000000';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Fantasy',
				paletteFamily: 	'906145',
				keyvisualId: 	'9901',
				keyvisualName: 	'kv1.swf',
				fontsetId: 		'17881',
				graphicsetId: 	'13064',
				contentColor: 	'FFFFFF',
				contentBGColor: '000000',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['7050']=webappMappings['7050-2974']={
webappId:    '7050',
documentId:  '2294',
internalId:  '2974',
customField: 'language:en;country:US;'
};
webappMappings['1002']=webappMappings['1002-2378aendu0in2xr4']={
webappId:    '1002',
documentId:  '2378',
internalId:  '2378aendu0in2xr4',
customField: 'icq=false'
};
webappMappings['7008']=webappMappings['7008-4863']={
webappId:    '7008',
documentId:  '2399',
internalId:  '4863',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2201',
internalId:  '',
customField: '20090512-172031'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '30001',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2294',
internalId:  '',
customField: '20090525-134213'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2378',
internalId:  '',
customField: '20080609-032339'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2399',
internalId:  '',
customField: '20080609-202907'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2201',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-9595331']={
webappId:    '1501',
documentId:  '2201',
internalId:  '9595331',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2315',
internalId:  '',
customField: '20090126-001709'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2336',
internalId:  '',
customField: '20080909-163805'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '28201',
internalId:  '',
customField: '20090327-114840'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2201',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '33801',
internalId:  '',
customField: '20090222-210607'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30001',
internalId:  '',
customField: '20090506-052654'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2294',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2315',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2336',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '28201',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2378',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2399',
internalId:  '',
customField: 'language:en;country:US;'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0IN2XR4';
var companyName   = 'Destineers-The+Legend+Begins+';
var htmlTitle	  = 'The+Destineers%3A+Saving+the+Worlds+One+Adventure+at+a+Time+%28NA+Sharpe%2C+Bobby+Sharpe%29';
var metaKeywords  = 'Destineers%2C+Legend+of+the+Netherscape%2C+Saving+the+Worlds+One+Adventure+at+a+Time%2C+Fantasy%2C+Fiction%2C+YA+Fantasy%2C+YA+Fiction%2C+Adventure%2C+YA+Adventure%2C+NA+Sharpe%2C+N.A.+Sharpe%2C+Nancy+Sharpe%2C+Bobby+Sharpe%2C+Netherscape%2C+Cybrarie%2C+The+Cybrarie%2C+Destineers+Journal%2C+Destineers+Journal%2C+Destineers+Journal%2C+Fantasy+Nations';
var metaContents  = 'Official+website+for+the+Destineers+YA+fantasy+series+written+by+N.A.+Sharpe+and+Bobby+Sharpe';
theSitetree.getById = function(id, ar) {
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		if (ar[i][POS_ID] == id){
			return ar[i];
		}
		if (ar[i][POS_CHILDS].length > 0) {
			var result=this.getById(id, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getParentById = function(id, ar) {
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		for (var j = 0; j < ar[i][POS_CHILDS].length; j++) {
			if (ar[i][POS_CHILDS][j][POS_ID] == id) {
				// child found
				return ar[i];
			}
			var result=this.getParentById(id, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getName = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_NAME];
	}
	return null;
};

theSitetree.getNavigationText = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_NAVIGATIONTEXT];
	}
	return null;
};

theSitetree.getHREF = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_HREF];
	}
	return null;
};

theSitetree.getIsNavigation = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_ISNAVIGATION];
	}
	return null;
};

theSitetree.getTemplateName = function(id, lastTemplateName, ar) {
	if (typeof(lastTemplateName) == 'undefined'){
		lastTemplateName = this.topTemplateName;
	}
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		var actTemplateName = ar[i][POS_TEMPLATENAME];
		if (actTemplateName == ''){
			actTemplateName = lastTemplateName;
		}
		if (ar[i][POS_ID] == id) {
			return actTemplateName;
		}
		if (ar[i][POS_CHILDS].length > 0) {
			var result=this.getTemplateName(id, actTemplateName, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getByXx = function(lookup, xx, ar) {
    if (typeof(ar) == 'undefined'){
    	ar = this;
    }
    for (var i=0; i < ar.length; i++) {
        if (ar[i][xx] == lookup){
        	return ar[i];
        }
        if (ar[i][POS_CHILDS].length > 0) {
        	var result=this.getByXx(lookup, xx, ar[i][POS_CHILDS]);
            if (result != null){
                return result;
               }
        }
    }
    return null;
};

function gotoPage(lookup) {
	if(__path_prefix__ == "/servlet/CMServeRES" && typeof (changePage) == 'function'){
		changePage(lookup);
		return;
	}
	var page = theSitetree.getHREF(lookup);
	if (!page) {
		var testFor = [ POS_NAME, POS_NAVIGATIONTEXT ];
		for (var i=0 ; i < testFor.length ; i++) {
			var p = theSitetree.getByXx(lookup, testFor[i]);
			if (p != null) {
				page = p[POS_HREF];
				break;
			}
		}
	}
	document.location.href = (new URL(__path_prefix__ + page, true, true)).toString();
};
