/* [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','801',jdecode('Home'),jdecode(''),'/801.html','true',[],''],
	['PAGE','852',jdecode('About+Us'),jdecode(''),'/852/index.html','true',[ 
		['PAGE','43201',jdecode('We+are+Foursquare'),jdecode(''),'/852/43201.html','true',[],''],
		['PAGE','3001',jdecode('Adult+Ministry'),jdecode(''),'/852/3001.html','true',[],''],
		['PAGE','3022',jdecode('Children%26%23x27%3Bs+Ministry'),jdecode(''),'/852/3022.html','true',[],''],
		['PAGE','3043',jdecode('Family+Ministry'),jdecode(''),'/852/3043.html','true',[],''],
		['PAGE','3064',jdecode('Prayer+Ministry'),jdecode(''),'/852/3064.html','true',[],''],
		['PAGE','3085',jdecode('Worship+Ministry'),jdecode(''),'/852/3085.html','true',[],''],
		['PAGE','3106',jdecode('What+We+Believe'),jdecode(''),'/852/3106.html','true',[],''],
		['PAGE','13201',jdecode('Youth+Ministry'),jdecode(''),'/852/13201.html','true',[],''],
		['PAGE','17901',jdecode('Youth+Photos'),jdecode(''),'/852/17901.html','true',[],'']
	],''],
	['PAGE','915',jdecode('Contact+Us'),jdecode(''),'/915/index.html','true',[ 
		['PAGE','10301',jdecode('Location'),jdecode(''),'/915/10301.html','true',[],'']
	],''],
	['PAGE','894',jdecode('Greater+Joy'),jdecode(''),'/894.html','true',[],''],
	['PAGE','8301',jdecode('Service+Times'),jdecode(''),'/8301.html','true',[],''],
	['PAGE','8901',jdecode('Family+Pictures'),jdecode(''),'/8901.html','true',[],''],
	['PAGE','16401',jdecode('Events'),jdecode(''),'/16401.html','true',[],''],
	['PAGE','38001',jdecode('Podcasts'),jdecode(''),'/38001/index.html','true',[ 
		['PAGE','38101',jdecode('Current'),jdecode(''),'/38001/38101.html','true',[],''],
		['PAGE','38122',jdecode('Archive'),jdecode(''),'/38001/38122.html','true',[],'']
	],''],
	['PAGE','40001',jdecode('Test'),jdecode(''),'/40001.html','false',[],''],
	['PAGE','40601',jdecode('Angel+Food'),jdecode(''),'/40601.html','true',[],'']];
var siteelementCount=22;
theSitetree.topTemplateName='Flat';
theSitetree.paletteFamily='669999';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='16706';
theSitetree.graphicsetId='12238';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='9ABABA';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Flat',
				paletteFamily: 	'669999',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'16706',
				graphicsetId: 	'12238',
				contentColor: 	'FFFFFF',
				contentBGColor: '9ABABA',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				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['7060']=webappMappings['7060-64a07959974b65f7bda7662e88ab398f']={
webappId:    '7060',
documentId:  '8901',
internalId:  '64a07959974b65f7bda7662e88ab398f',
customField: 'language:en;country:US;'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '10301',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:false;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '801',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '801',
internalId:  '',
customField: '20090220-153406'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16401',
internalId:  '',
customField: '20090625-170505'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '915',
internalId:  '',
customField: '20090301-030417'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '852',
internalId:  '',
customField: '20080229-144338'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3001',
internalId:  '',
customField: '20080229-144408'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3022',
internalId:  '',
customField: '20080229-144447'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3043',
internalId:  '',
customField: '20080229-144521'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3064',
internalId:  '',
customField: '20090301-013415'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3085',
internalId:  '',
customField: '20080229-142751'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3106',
internalId:  '',
customField: '20080109-131317'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13201',
internalId:  '',
customField: '20090305-163738'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17901',
internalId:  '',
customField: '20090623-011110'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10301',
internalId:  '',
customField: '20070116-171128'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '894',
internalId:  '',
customField: '20080109-131749'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8301',
internalId:  '',
customField: '20090126-003625'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8901',
internalId:  '',
customField: '20070116-170215'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38001',
internalId:  '',
customField: '20081227-143242'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38101',
internalId:  '',
customField: '20081227-223929'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38122',
internalId:  '',
customField: '20081227-151721'
};
webappMappings['7050']=webappMappings['7050-70']={
webappId:    '7050',
documentId:  '40001',
internalId:  '70',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40001',
internalId:  '',
customField: '20081229-030925'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40601',
internalId:  '',
customField: '20090220-160041'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '43201',
internalId:  '',
customField: '20090310-113255'
};
var canonHostname = 'wsc1.brinkster.com';
var accountId     = 'ABRI10INE5TM';
var companyName   = 'Joy+of+Life';
var htmlTitle	  = 'Joy+Of+Life';
var metaKeywords  = 'Foursquare%2C+4sq%2C+Angel+Food%2C+church%2C+Phoenix%2C+family';
var metaContents  = 'Joy+of+Life%2C+a+church+for+families';
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();
};
