/* [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','30712',jdecode('Home'),jdecode(''),'/30712.html','false',[],''],
	['PAGE','3657',jdecode('What%26%23x27%3Bs+New'),jdecode(''),'/3657.html','true',[],''],
	['PAGE','3552',jdecode('About+Tom'),jdecode(''),'/3552.html','true',[],''],
	['PAGE','3573',jdecode('Alex+and+Jackie'),jdecode(''),'/3573/index.html','true',[ 
		['PAGE','3594',jdecode('First+Night'),jdecode(''),'/3573/3594.html','true',[],''],
		['PAGE','3615',jdecode('The+Elf+of+Luxembourg'),jdecode(''),'/3573/3615.html','true',[],'']
	],''],
	['PAGE','32112',jdecode('The+Critics'),jdecode(''),'/32112/index.html','true',[ 
		['PAGE','32133',jdecode('Praise+for+First+Night'),jdecode(''),'/32112/32133.html','true',[],''],
		['PAGE','3636',jdecode('The+Guest+Book'),jdecode(''),'/32112/3636.html','true',[],'']
	],''],
	['PAGE','3678',jdecode('Shop'),jdecode(''),'/3678/index.html','true',[ 
		['PAGE','16612',jdecode('Thank+You'),jdecode(''),'/3678/16612.html','false',[],''],
		['PAGE','22912',jdecode('Cancelled'),jdecode(''),'/3678/22912.html','false',[],''],
		['PAGE','37212',jdecode('The+Elf+of+Luxembourg'),jdecode(''),'/3678/37212.html','false',[],''],
		['PAGE','21812',jdecode('First+Night'),jdecode(''),'/3678/21812.html','false',[],''],
		['PAGE','27212',jdecode('eBooks'),jdecode(''),'/3678/27212.html','false',[],'']
	],''],
	['PAGE','3699',jdecode('Contact'),jdecode(''),'/3699.html','true',[],'']];
var siteelementCount=16;
theSitetree.topTemplateName='Comic';
theSitetree.paletteFamily='1B4082';
theSitetree.keyvisualId='9982';
theSitetree.keyvisualName='kv1.swf';
theSitetree.fontsetId='17761';
theSitetree.graphicsetId='13129';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Comic',
				paletteFamily: 	'1B4082',
				keyvisualId: 	'9982',
				keyvisualName: 	'kv1.swf',
				fontsetId: 		'17761',
				graphicsetId: 	'13129',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				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: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['7050']=webappMappings['7050-5707']={
webappId:    '7050',
documentId:  '3657',
internalId:  '5707',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-9645']={
webappId:    '7008',
documentId:  '3699',
internalId:  '9645',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22912',
internalId:  '',
customField: '20090113-203354'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3552',
internalId:  '',
customField: '20100219-181037'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3573',
internalId:  '',
customField: '20100127-084605'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3594',
internalId:  '',
customField: '20091123-131005'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3615',
internalId:  '',
customField: '20100127-083820'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3636',
internalId:  '',
customField: '20090403-143918'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3657',
internalId:  '',
customField: '20090112-172344'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3678',
internalId:  '',
customField: '20100219-150803'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3699',
internalId:  '',
customField: '20090202-203440'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16612',
internalId:  '',
customField: '20090114-140541'
};
webappMappings['1002']=webappMappings['1002-3636aendu0ineqgq']={
webappId:    '1002',
documentId:  '3636',
internalId:  '3636aendu0ineqgq',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21812',
internalId:  '',
customField: '20100219-171933'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27212',
internalId:  '',
customField: '20090202-152023'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30712',
internalId:  '',
customField: '20090228-130545'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32112',
internalId:  '',
customField: '20090305-113758'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32133',
internalId:  '',
customField: '20091211-132252'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '37212',
internalId:  '',
customField: '20100219-171917'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0INEQGQ';
var companyName   = 'tom+weston+media';
var htmlTitle	  = 'tom+weston+media';
var metaKeywords  = 'tom+weston%2C+first+night%2C+ghosts%2C+witches%2C+boston%2C+luxembourg%2C+alex+and+jackie.';
var metaContents  = 'tom+weston+media+-+Official+site+of+author+Tom+Weston.';
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();
};
