/* [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 POS_TARGET=8;
var theSitetree=[ 
	['PAGE','3801',jdecode('Home'),jdecode(''), jdecode('%2F3801%2Findex.html'), 'true',[ 
		['PAGE','11701',jdecode('Contact'),jdecode(''), jdecode('%2F3801%2F11701.html'), 'true',[],'',''],
		['PAGE','11722',jdecode('Ted%26%23x27%3Bs+Blog'),jdecode(''), jdecode('%2F3801%2F11722.html'), 'true',[],'','']
	],'',''],
	['PAGE','4001',jdecode('Bio'),jdecode(''), jdecode('%2F4001%2Findex.html'), 'true',[ 
		['PAGE','7901',jdecode('Vitae+Part+1'),jdecode(''), jdecode('%2F4001%2F7901.html'), 'true',[],'',''],
		['PAGE','7922',jdecode('Vitae+Part+2'),jdecode(''), jdecode('%2F4001%2F7922.html'), 'true',[],'',''],
		['PAGE','26201',jdecode('Vitae+Part+3'),jdecode(''), jdecode('%2F4001%2F26201.html'), 'true',[],'','']
	],'',''],
	['PAGE','4401',jdecode('Publications'),jdecode(''), jdecode('%2F4401%2Findex.html'), 'true',[ 
		['PAGE','6101',jdecode('Books'),jdecode(''), jdecode('%2F4401%2F6101.html'), 'true',[],'',''],
		['PAGE','23301',jdecode('Book+Chapters'),jdecode(''), jdecode('%2F4401%2F23301.html'), 'true',[],'',''],
		['PAGE','22301',jdecode('Book+Reviews'),jdecode(''), jdecode('%2F4401%2F22301.html'), 'true',[],'',''],
		['PAGE','6201',jdecode('Journal+Articles'),jdecode(''), jdecode('%2F4401%2F6201.html'), 'true',[],'',''],
		['PAGE','22801',jdecode('Major+Blog+Posts'),jdecode(''), jdecode('%2F4401%2F22801.html'), 'true',[],'',''],
		['PAGE','6222',jdecode('Opinion+Editorials'),jdecode(''), jdecode('%2F4401%2F6222.html'), 'true',[],'',''],
		['PAGE','6243',jdecode('Policy+Studies'),jdecode(''), jdecode('%2F4401%2F6243.html'), 'true',[],'','']
	],'',''],
	['PAGE','4701',jdecode('Quick+Thoughts'),jdecode(''), jdecode('%2F4701%2Findex.html'), 'true',[ 
		['PAGE','5201',jdecode('Ted%26%23x27%3Bs+Blog'),jdecode(''), jdecode('%2F4701%2F5201.html'), 'true',[],'',''],
		['PAGE','5401',jdecode('Multi-Media'),jdecode(''), jdecode('%2F4701%2F5401.html'), 'true',[],'',''],
		['PAGE','5422',jdecode('Speaches+and+Testimony'),jdecode(''), jdecode('%2F4701%2F5422.html'), 'true',[],'','']
	],'',''],
	['PAGE','4901',jdecode('Other+Voices'),jdecode(''), jdecode('%2F4901.html'), 'true',[],'','']];
var siteelementCount=20;
theSitetree.topTemplateName='Diablo';
theSitetree.paletteFamily='CA2828';
theSitetree.keyvisualId='8770';
theSitetree.keyvisualName='kv_8770.jpg';
theSitetree.fontsetId='17089';
theSitetree.graphicsetId='12466';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='E6E6E6';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'easycgi',
  product: 'WSCSYSSSSLY0XRN4'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Diablo',
				paletteFamily: 	'CA2828',
				keyvisualId: 	'8770',
				keyvisualName: 	'kv_8770.jpg',
				fontsetId: 		'17089',
				graphicsetId: 	'12466',
				contentColor: 	'000000',
				contentBGColor: 'E6E6E6',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3801',
internalId:  '',
customField: '20120209-120612'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4001',
internalId:  '',
customField: '20120201-151447'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4401',
internalId:  '',
customField: '20120209-123738'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4701',
internalId:  '',
customField: '20090128-070320'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4901',
internalId:  '',
customField: '20090128-073515'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5201',
internalId:  '',
customField: '20090128-071510'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5401',
internalId:  '',
customField: '20100624-150843'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5422',
internalId:  '',
customField: '20120209-120559'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6101',
internalId:  '',
customField: '20120201-145453'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6201',
internalId:  '',
customField: '20120206-152043'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6222',
internalId:  '',
customField: '20120208-145452'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6243',
internalId:  '',
customField: '20120201-154054'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7901',
internalId:  '',
customField: '20120209-121535'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7922',
internalId:  '',
customField: '20120209-123422'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11701',
internalId:  '',
customField: '20090129-014921'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11722',
internalId:  '',
customField: '20090129-015152'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '3801',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22301',
internalId:  '',
customField: '20120206-160625'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22801',
internalId:  '',
customField: '20120209-115656'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23301',
internalId:  '',
customField: '20120206-161015'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '26201',
internalId:  '',
customField: '20120209-123143'
};
var webAppHostname = 'cgiwsc.enhancedsitebuilder.com:80';
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0INEZ6U';
var companyName   = 'Ted+Galen+Carpenter+Peace+and+Freedom';
var htmlTitle	  = '';
var metaKeywords  = '';
var metaContents  = '';
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();
};

