/* [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','801',jdecode('Home++%E8%81%96%E5%9C%B0%E9%A6%96%E9%A0%81'),jdecode(''),'/801.html','true',[],'',''],
	['PAGE','915',jdecode('Products+%E8%81%96%E5%9C%B0%E6%9B%B8%E6%9E%B6'),jdecode(''),'/915.html','true',[],'',''],
	['PAGE','13201',jdecode('How+to+buy++%E8%B3%BC%E8%B2%B7%E6%9B%B8%E7%B1%8D'),jdecode(''),'/13201.html','true',[],'',''],
	['PAGE','21801',jdecode('Buddhism+%E4%BD%9B%E6%95%99%E6%96%87%E5%8C%96+'),jdecode(''),'/21801.html','true',[],'',''],
	['PAGE','35801',jdecode('Tibetan+Culture++%E8%A5%BF%E8%97%8F%E6%96%87%E5%8C%96'),jdecode(''),'/35801.html','true',[],'',''],
	['PAGE','37201',jdecode('Webcasts+%E8%81%96%E5%9C%B0%E5%BD%B1%E9%9F%B3'),jdecode(''),'/37201.html','true',[],'',''],
	['PAGE','852',jdecode('Photo+Gallery++%E8%81%96%E5%9C%B0%E9%A2%A8%E5%85%89'),jdecode(''),'/852.html','true',[],'',''],
	['PAGE','21822',jdecode('Contact+us+++%E8%81%AF%E7%B5%A1%E8%81%96%E5%9C%B0'),jdecode(''),'/21822.html','true',[],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='Qben';
theSitetree.paletteFamily='AA7138';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='17182';
theSitetree.graphicsetId='12656';
theSitetree.contentColor='2E2E2E';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'true',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				name: 			'Qben',
				paletteFamily: 	'AA7138',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'17182',
				graphicsetId: 	'12656',
				contentColor: 	'2E2E2E',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'FFFFFF',
				d_color: 		'A7E333',
				e_color: 		'D28C7F',
				f_color: 		'A7E333',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '801',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-4673648']={
webappId:    '1501',
documentId:  '801',
internalId:  '4673648',
customField: '1501'
};
webappMappings['7008']=webappMappings['7008-1861']={
webappId:    '7008',
documentId:  '21822',
internalId:  '1861',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '801',
internalId:  '',
customField: '20110314-070533'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21801',
internalId:  '',
customField: '20091220-235106'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '915',
internalId:  '',
customField: '20101125-054955'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21822',
internalId:  '',
customField: '20081024-041356'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '852',
internalId:  '',
customField: '20080718-091709'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13201',
internalId:  '',
customField: '20110110-063627'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '37201',
internalId:  '',
customField: '20080503-033212'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35801',
internalId:  '',
customField: '20091220-235525'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0IN2WGL';
var companyName   = 'Welcome+to+Buddhis+World%21';
var htmlTitle	  = '%E8%81%96%E5%9C%B0%E6%96%87%E5%8C%96%E5%87%BA%E7%89%88%E7%A4%BE';
var metaKeywords  = '%E8%81%96%E5%9C%B0%E6%96%87%E5%8C%96%E5%87%BA%E7%89%88%E7%A4%BE%2C%E5%AF%86%E6%B5%B7%E7%87%88%E5%A1%94%2C%E4%BD%9B%E6%95%99%E4%B8%89%E5%AF%B6%E5%8E%9F%E7%90%86%2C%E5%AE%97%E5%96%80%E5%B7%B4%E5%A4%A7%E5%B8%AB%E4%BD%9B%E5%AD%B8%E5%90%8D%E8%91%97%2C%E4%BD%9B%E6%95%99%E8%91%97%E5%90%8D%E7%B6%93%E5%85%B8%E9%81%B8%E6%9E%90%2C%E4%BD%9B%E6%95%99%E7%90%86%E8%AB%96%E6%A1%86%E6%9E%B6%2C%E8%97%8F%E5%AD%B8%E7%A0%94%E7%A9%B6%E7%94%98%E9%9C%B2%2C%E5%A4%A7%E5%A8%81%E5%BE%B7%E4%B9%8B%E5%85%89+%E2%80%93+%E5%AF%86%E5%AE%97%E5%A4%A7%E5%B8%AB%E7%86%B1%E7%BE%85%E5%82%B3%E8%A8%98%2C%E8%97%8F%E5%82%B3%E4%BD%9B%E6%95%99%E7%96%91%E5%95%8F%E8%A7%A3%E7%AD%94120%E9%A1%8C%2C%E5%AF%86%E5%AE%97%2C%E5%AF%86%E6%B3%95%2C%E4%BD%9B%E6%95%99%2C%E8%97%8F%E5%82%B3%E4%BD%9B%E6%95%99%2C%E4%BD%9B%E9%99%80%2C%E4%BD%9B%E7%A5%96%2C%E5%AE%97%E5%96%80%E5%B7%B4%2C%E8%98%AD%E4%BB%81%E5%B7%B4%2C%E8%B2%A2%E5%94%90%E5%80%89%E4%BB%81%E6%B3%A2%E5%88%87%2C%E9%BB%83%E6%95%99%2C%E6%A0%BC%E9%AD%AF%E6%B4%BE%2C%E5%AF%82%E5%A4%A9%E8%8F%A9%E8%96%A9%2C%E5%A4%9A%E8%AD%98%E4%BB%81%E6%B3%A2%E5%88%87%2C%E6%A8%82%E7%A9%BA%E4%B8%8D%E4%BA%8C%2C%E8%BC%AA%E5%9B%9E%2C%E5%AE%97%E6%95%99%2C%E5%BF%83%E7%B6%93%2C%E8%88%AC%E8%8B%A5%E6%B3%A2%E7%BE%85%E8%9C%9C%E5%A4%9A%E5%BF%83%E7%B6%93%2C%E9%87%91%E5%89%9B%E7%B6%93%2C%E8%83%BD%E6%96%B7%E9%87%91%E5%89%9B%E8%88%AC%E8%8B%A5%E6%B3%A2%E7%BE%85%E8%9C%9C%E5%A4%9A%E5%BF%83%E7%B6%93%2C%E4%BD%9B%E6%B3%95%E4%B8%89%E6%A0%B9%E6%9C%AC%2C%E4%BD%9B%E6%B3%95%E5%83%A7%2C%E7%B7%A3%E8%B5%B7%2C%E6%80%A7%E7%A9%BA%2C%E4%B8%AD%E8%A7%80%2C%E7%B7%A3%E8%B5%B7%E7%90%86%E8%B4%8A%2C%E7%9A%88%E4%BE%9D%2C%E7%9A%88%E4%BE%9D%E6%B3%95%2C%E6%99%BA%E6%85%A7%2C%E5%9B%9B%E8%81%96%E8%AB%A6%2C%E5%96%9C%E9%A6%AC%E6%8B%89%E9%9B%85%E5%B1%B1%E7%9A%84%E6%99%BA%E6%85%A7+';
var metaContents  = '%E8%81%96%E5%9C%B0%E6%96%87%E5%8C%96%E5%87%BA%E7%89%88%E7%A4%BE';
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();
};

