/* [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','76',jdecode('Home'),jdecode(''),'/76.html','true',[],'',''],
	['PAGE','97',jdecode('DEEP+IN+THE+MOUNTAINS'),jdecode(''),'/97/index.html','true',[ 
		['PAGE','2023',jdecode('About+Zhu+Qizhan'),jdecode(''),'/97/2023.html','true',[],'','']
	],'',''],
	['PAGE','2891',jdecode('SONS+OF+HEAVEN'),jdecode(''),'/2891.html','true',[],'',''],
	['PAGE','780',jdecode('News'),jdecode(''),'/780.html','true',[],'',''],
	['PAGE','789',jdecode('Reviews'),jdecode(''),'/789.html','true',[],'',''],
	['PAGE','798',jdecode('Media'),jdecode(''),'/798.html','true',[],'',''],
	['PAGE','807',jdecode('Biography'),jdecode(''),'/807.html','true',[],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='Delta';
theSitetree.paletteFamily='080245';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10615';
theSitetree.graphicsetId='10811';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='080245';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Delta',
				paletteFamily: 	'080245',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10615',
				graphicsetId: 	'10811',
				contentColor: 	'FFFFFF',
				contentBGColor: '080245',
				a_color: 		'221785',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '76',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '76',
internalId:  '',
customField: '20100629-104232'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2891',
internalId:  '',
customField: '20100629-104143'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '798',
internalId:  '',
customField: '20090415-111058'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '97',
internalId:  '',
customField: '20080210-150440'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2023',
internalId:  '',
customField: '20070716-224250'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '780',
internalId:  '',
customField: '20100214-162639'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '789',
internalId:  '',
customField: '20090415-213557'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '807',
internalId:  '',
customField: '20090729-174350'
};
var canonHostname = 'wsc-worker02.chi.us.siteprotect.com';
var accountId     = 'AHW050IN3704';
var companyName   = 'Terrence+Cheng%3A+Official+Website';
var htmlTitle	  = 'Official+Website+for+Author+Terrence+Cheng';
var metaKeywords  = 'tank+man%2C+tank+man%2C+tank+man%2C+unknown+rebel%2C+unknown+hero%2C+tiananmen+square%2C+tiananmen%2C+tianenmen%2C+communism%2C+communist%2C+deng+xiaoping%2C+mao+zedong%2C+chiang+kai-shek%2C+china%2C+taiwan%2C+asia%2C+terrence+cheng%2C+chinese+writers%2C+chinese+authors%2C+cheng%2C+terrance+chang%2C+chang%2C+sons+of+heaven%2C+harper+collins%2C+asian%2C+asian-american%2C+asian+authors%2C+asian-american+authors%2C+asian+writers%2C+asian-american+writers%2C+chinese+books%2C+asian+books%2C+asian-american+books%2C+history%2C+chinese+history%2C+asian-history%2C+asian-american+history%2C+japan%2C+korea%2C+chinatown%2C+china%2C+authors%2C+oprah%2C+publishing%2C+chinese%2C+publishers%2C+writers%2C+writing%2C+ha+jin%2C+gao+xingjian%2C+writers+workshop%2C+current+events%2C+news%2C+politics';
var metaContents  = 'Official+Website+for+Author+Terrence+Cheng';
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();
};
