/* [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','3001',jdecode('CMC+Home'),jdecode(''),'/3001.html','true',[],'',''],
	['PAGE','18201',jdecode('Child+Care'),jdecode(''),'/18201.html','true',[],'',''],
	['PAGE','7885',jdecode('Preschool'),jdecode(''),'/7885.html','true',[],'',''],
	['PAGE','36901',jdecode('New+Buildiing'),jdecode(''),'/36901.html','true',[],'',''],
	['PAGE','60271',jdecode('Contact+Us'),jdecode(''),'/60271.html','true',[],'',''],
	['PAGE','7927',jdecode('Directions'),jdecode(''),'/7927.html','true',[],'',''],
	['PAGE','7948',jdecode('Staff'),jdecode(''),'/7948.html','true',[],'',''],
	['PAGE','7906',jdecode('Calendar'),jdecode(''),'/7906.html','true',[],'',''],
	['PAGE','7843',jdecode('Children%26%23x27%3Bs+Ministry'),jdecode(''),'/7843.html','true',[],'',''],
	['PAGE','35301',jdecode('Youth+Fellowship'),jdecode(''),'/35301.html','true',[],'',''],
	['PAGE','94671',jdecode('Adult+Fellowships'),jdecode(''),'/94671.html','true',[],'',''],
	['PAGE','7801',jdecode('Christian+Education'),jdecode(''),'/7801.html','true',[],'',''],
	['PAGE','7822',jdecode('Music+Ministry'),jdecode(''),'/7822.html','true',[],'',''],
	['PAGE','7864',jdecode('Outreach'),jdecode(''),'/7864.html','true',[],'',''],
	['PAGE','14501',jdecode('Crafts'),jdecode(''),'/14501.html','true',[],'',''],
	['PAGE','14001',jdecode('History'),jdecode(''),'/14001.html','true',[],'',''],
	['PAGE','14022',jdecode('Web+Links'),jdecode(''),'/14022/index.html','true',[ 
		['PAGE','18401',jdecode('DCE+Blog'),jdecode(''),'/14022/18401.html','false',[],'','']
	],'','']];
var siteelementCount=18;
theSitetree.topTemplateName='Triangle';
theSitetree.paletteFamily='000000';
theSitetree.keyvisualId='12001';
theSitetree.keyvisualName='kv_12001.jpg';
theSitetree.fontsetId='33260';
theSitetree.graphicsetId='14139';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='000000';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Triangle',
				paletteFamily: 	'000000',
				keyvisualId: 	'12001',
				keyvisualName: 	'kv_12001.jpg',
				fontsetId: 		'33260',
				graphicsetId: 	'14139',
				contentColor: 	'FFFFFF',
				contentBGColor: '000000',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3001',
internalId:  '',
customField: '20100902-170915'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7801',
internalId:  '',
customField: '20100720-110741'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7822',
internalId:  '',
customField: '20100825-152839'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7843',
internalId:  '',
customField: '20100824-154745'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7864',
internalId:  '',
customField: '20100812-110436'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7885',
internalId:  '',
customField: '20100902-150252'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7906',
internalId:  '',
customField: '20100902-145436'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7927',
internalId:  '',
customField: '20100720-111206'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7948',
internalId:  '',
customField: '20100819-091442'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14001',
internalId:  '',
customField: '20100812-094834'
};
webappMappings['7050']=webappMappings['7050-937']={
webappId:    '7050',
documentId:  '18401',
internalId:  '937',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18401',
internalId:  '',
customField: '20080330-130255'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '60271',
internalId:  '',
customField: '20100819-120919'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36901',
internalId:  '',
customField: '20100819-122047'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35301',
internalId:  '',
customField: '20100826-095251'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '3001',
internalId:  '1006',
customField: '1006'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '7927',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18201',
internalId:  '',
customField: '20100902-150322'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14022',
internalId:  '',
customField: '20100815-133042'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '94671',
internalId:  '',
customField: '20100812-110457'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14501',
internalId:  '',
customField: '20100819-123353'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0IN2ARB';
var companyName   = 'Clemmons+Moravian+Church';
var htmlTitle	  = 'Clemmons+Moravian+Church';
var metaKeywords  = 'church%2C+churches%2C+moravian%2C+moravian+churches%2C+clemmons%2C+NC%2C+preschool%2C+child+care%2C+daycare+sunday+school%2C+music%2C+worship%2C+lovefeast%2C+vacation+bible+school%2C+youth';
var metaContents  = 'Clemmons+Moravian+Church%2C+Clemmons%2C+NC';
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();
};
