/* [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','5001',jdecode('Home'),jdecode(''), jdecode('%2F5001.html'), 'true',[],'',''],
	['PAGE','5052',jdecode('Ministries'),jdecode(''), jdecode('%2F5052%2Findex.html'), 'true',[ 
		['PAGE','6301',jdecode('Adult'),jdecode(''), jdecode('%2F5052%2F6301.html'), 'true',[],'',''],
		['PAGE','6322',jdecode('Youth'),jdecode(''), jdecode('%2F5052%2F6322.html'), 'true',[],'',''],
		['PAGE','6343',jdecode('Children'),jdecode(''), jdecode('%2F5052%2F6343.html'), 'true',[],'','']
	],'',''],
	['PAGE','5073',jdecode('About+us'),jdecode(''), jdecode('%2F5073%2Findex.html'), 'true',[ 
		['PAGE','6364',jdecode('Our+Beliefs'),jdecode(''), jdecode('%2F5073%2F6364.html'), 'true',[],'',''],
		['PAGE','6385',jdecode('Our+Mission'),jdecode(''), jdecode('%2F5073%2F6385.html'), 'true',[],'',''],
		['PAGE','6406',jdecode('Our+Associations'),jdecode(''), jdecode('%2F5073%2F6406.html'), 'true',[],'','']
	],'',''],
	['PAGE','5094',jdecode('Event+calendar'),jdecode(''), jdecode('%2F5094.html'), 'true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Enjoy';
theSitetree.paletteFamily='93A6CC';
theSitetree.keyvisualId='2224';
theSitetree.keyvisualName='blanko.jpg';
theSitetree.fontsetId='364';
theSitetree.graphicsetId='415';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='93A6CC';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'qwest',
  product: 'WSCSYSSSSLYTCPH7'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Enjoy',
				paletteFamily: 	'93A6CC',
				keyvisualId: 	'2224',
				keyvisualName: 	'blanko.jpg',
				fontsetId: 		'364',
				graphicsetId: 	'415',
				contentColor: 	'000000',
				contentBGColor: '93A6CC',
				a_color: 		'93A6CC',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5001',
internalId:  '',
customField: '20110827-133155'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5052',
internalId:  '',
customField: '20110416-183939'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5073',
internalId:  '',
customField: '20110416-191451'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5094',
internalId:  '',
customField: '20120107-165125'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6301',
internalId:  '',
customField: '20110830-123042'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6322',
internalId:  '',
customField: '20110527-110916'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6343',
internalId:  '',
customField: '20110827-134801'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6364',
internalId:  '',
customField: '20110416-191627'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6385',
internalId:  '',
customField: '20110416-205550'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6406',
internalId:  '',
customField: '20110625-160803'
};
webappMappings['7008']=webappMappings['7008-11269']={
webappId:    '7008',
documentId:  '6301',
internalId:  '11269',
customField: 'language:en;country:US;'
};
var webAppHostname = 'cgi-wsc.chi.us.siteprotect.com:80';
var canonHostname = 'wsc-worker02.chi.us.siteprotect.com';
var accountId     = 'AHW050INF499';
var companyName   = 'Rainier+Community+Church+of+God';
var htmlTitle	  = 'Rainier+Community+Church+of+God';
var metaKeywords  = 'church+of+god+%0ARainier+Community+Church+of+God%0ARainier+church%0AChurch+of+God+in+Rainier%0AChurch+of+God%0A%0A%0A%0ACommunity+church+of+god%0A%0A%0A%0ARainier+Community+Church+of+God%0A%0AChurch++%0A%0AChurch+Of+God++%0A%0ACommunity+Church+%0A%0AReligious+Organisations+%0A%0A+Religious+Organizations+%0A%0AReligious+Services+%26+Organizations+';
var metaContents  = 'Rainier+Church+of+God%0ARainier+Community+Church+of+God%0ARainier+church%0AChurch+of+God+in+Rainier%0Arainier+church+of+god%0A%0A%0A%0Achurch+of+god+in+rainier%0A%0A%0A%0AChurch+of+God+in+Rainier%0A%0A%0A%0AChurch+of+God%0A%0A%0A%0AChurches+in+Rainier+Oregon%0A%0A%0A%0Achurches%0A%0A%0A%0ARainier+Community+Church+of+God%0A%0AChurch+%0A%0AChurch+Of+God++%0A%0ACommunity+Church+%0A%0AReligious+Organisations+%0A%0A+Religious+Organizations++%0A%0AReligious+Services+%26+Organizations+';
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();
};

