/* [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','1401',jdecode('Home'),jdecode(''),'/1401.html','true',[],''],
	['PAGE','7378',jdecode('Regular+Events'),jdecode(''),'/7378.html','true',[],''],
	['PAGE','2722',jdecode('Church+Calendar'),jdecode(''),'/2722.html','true',[],''],
	['PAGE','46215',jdecode('Building+Restoration'),jdecode(''),'/46215.html','true',[],''],
	['PAGE','6615',jdecode('Photo+Gallery'),jdecode(''),'/6615.html','true',[],''],
	['PAGE','7315',jdecode('About+Us'),jdecode(''),'/7315/index.html','true',[ 
		['PAGE','2343',jdecode('Contact+Info'),jdecode(''),'/7315/2343.html','true',[],''],
		['PAGE','7336',jdecode('Where+We+Are'),jdecode(''),'/7315/7336.html','true',[],''],
		['PAGE','7357',jdecode('Staff'),jdecode(''),'/7315/7357.html','true',[],'']
	],''],
	['PAGE','2301',jdecode('Latest+news'),jdecode(''),'/2301.html','true',[],''],
	['PAGE','7399',jdecode('Meeting+Notes'),jdecode(''),'/7399.html','true',[],''],
	['PAGE','42315',jdecode('Human+Services'),jdecode(''),'/42315.html','true',[],''],
	['PAGE','2364',jdecode('Community+Ministries'),jdecode(''),'/2364.html','true',[],''],
	['PAGE','2322',jdecode('Links'),jdecode(''),'/2322.html','true',[],''],
	['PAGE','14015',jdecode('Office+Email'),jdecode(''),'/14015.html','false',[],''],
	['PAGE','14715',jdecode('Pastor+Email'),jdecode(''),'/14715.html','false',[],'']];
var siteelementCount=16;
theSitetree.topTemplateName='Card';
theSitetree.paletteFamily='990000';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='427';
theSitetree.graphicsetId='479';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Card',
				paletteFamily: 	'990000',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'427',
				graphicsetId: 	'479',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'FFFFFF',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1401',
internalId:  '',
customField: '20100115-104017'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2301',
internalId:  '',
customField: '20091209-175302'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2343',
internalId:  '',
customField: '20100106-223946'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2322',
internalId:  '',
customField: '20091124-164759'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2364',
internalId:  '',
customField: '20091123-221908'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6615',
internalId:  '',
customField: '20091209-174914'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2722',
internalId:  '',
customField: '20100106-211251'
};
webappMappings['7060']=webappMappings['7060-d01a590d59b650009e196e460f67e2c3']={
webappId:    '7060',
documentId:  '6615',
internalId:  'd01a590d59b650009e196e460f67e2c3',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7399',
internalId:  '',
customField: '20100106-224130'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7315',
internalId:  '',
customField: '20100114-095356'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7336',
internalId:  '',
customField: '20091209-175215'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7357',
internalId:  '',
customField: '20091207-203844'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7378',
internalId:  '',
customField: '20091209-192956'
};
webappMappings['7008']=webappMappings['7008-23543']={
webappId:    '7008',
documentId:  '14015',
internalId:  '23543',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14015',
internalId:  '',
customField: '20091126-195940'
};
webappMappings['7008']=webappMappings['7008-23548']={
webappId:    '7008',
documentId:  '14715',
internalId:  '23548',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14715',
internalId:  '',
customField: '20091127-001038'
};
webappMappings['7050']=webappMappings['7050-13631']={
webappId:    '7050',
documentId:  '2301',
internalId:  '13631',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '42315',
internalId:  '',
customField: '20091211-124904'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1401',
internalId:  '1006',
customField: '1006'
};
webappMappings['7060']=webappMappings['7060-c0a81432e51566554ddda7779b7e7422']={
webappId:    '7060',
documentId:  '46215',
internalId:  'c0a81432e51566554ddda7779b7e7422',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46215',
internalId:  '',
customField: '20091225-233744'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0INVIX6';
var companyName   = 'Johnstown+First+United+Methodist+Church';
var htmlTitle	  = 'Johnstown+First+UMC';
var metaKeywords  = '';
var metaContents  = 'The+homepage+of+Johnstown+First+United+Methodist+Church%2C+Johnstown+PA';
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();
};
