/* [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','501',jdecode('Home'),jdecode(''), jdecode('%2F501.html'), 'true',[],'',''],
	['PAGE','552',jdecode('About+us'),jdecode(''), jdecode('%2F552.html'), 'true',[],'',''],
	['PAGE','573',jdecode('Board+Members'),jdecode(''), jdecode('%2F573.html'), 'true',[],'',''],
	['PAGE','594',jdecode('Wear+our+Apparel%21'),jdecode(''), jdecode('%2F594.html'), 'true',[],'',''],
	['PAGE','19301',jdecode('Our+Unity+Houses'),jdecode(''), jdecode('%2F19301.html'), 'true',[],'',''],
	['PAGE','615',jdecode('Support+and+donations'),jdecode(''), jdecode('%2F615.html'), 'true',[],'',''],
	['PAGE','636',jdecode('Newsletter'),jdecode(''), jdecode('%2F636.html'), 'true',[],'',''],
	['PAGE','678',jdecode('Thanks+to+our+Sponsors'),jdecode(''), jdecode('%2F678.html'), 'true',[],'',''],
	['PAGE','699',jdecode('Links'),jdecode(''), jdecode('%2F699.html'), 'true',[],'',''],
	['PAGE','720',jdecode('Contact+Us'),jdecode(''), jdecode('%2F720.html'), 'true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Stone';
theSitetree.paletteFamily='383691';
theSitetree.keyvisualId='4415';
theSitetree.keyvisualName='kv_4415.jpg';
theSitetree.fontsetId='10804';
theSitetree.graphicsetId='11239';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='9C9B9B';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'wsc-whgeneric',
  product: 'WSCSYSSSSLYTC2VW'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Stone',
				paletteFamily: 	'383691',
				keyvisualId: 	'4415',
				keyvisualName: 	'kv_4415.jpg',
				fontsetId: 		'10804',
				graphicsetId: 	'11239',
				contentColor: 	'000000',
				contentBGColor: '9C9B9B',
				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:     'true'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20110601-153042'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '552',
internalId:  '',
customField: '20110201-195123'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '573',
internalId:  '',
customField: '20110308-191453'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '594',
internalId:  '',
customField: '20100903-152737'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '615',
internalId:  '',
customField: '20110201-194228'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '636',
internalId:  '',
customField: '20100903-141304'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '678',
internalId:  '',
customField: '20100819-185603'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '699',
internalId:  '',
customField: '20100907-141455'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '720',
internalId:  '',
customField: '20110308-191906'
};
webappMappings['7060']=webappMappings['7060-2c5f7363a221f2b270878249ccd3cdc7']={
webappId:    '7060',
documentId:  '19301',
internalId:  '2c5f7363a221f2b270878249ccd3cdc7',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19301',
internalId:  '',
customField: '20090408-163711'
};
webappMappings['7008']=webappMappings['7008-262']={
webappId:    '7008',
documentId:  '615',
internalId:  '262',
customField: 'language:en;country:US;'
};
var webAppHostname = 'cgicm4all.west-datacenter.net:80';
var canonHostname = 'cm4all01.west-datacenter.net';
var accountId     = 'AWH020IN2AE2';
var companyName   = 'Unity+in+Recovery';
var htmlTitle	  = 'Unity+in+Recovery-+Supporting+Clean+and+Sober+Living+in+Glenn+County%2C+California';
var metaKeywords  = 'drug+recovery%2C+alcohol+recovery%2C+Orland+california%2C+sober+living%2C+clean+living%2C+drug+free%2C+drug-free%2C+alcohol-free%2C+alcohol+free%2C+anti-drug%2C+addiction%2C+alcoholic%2C+alcoholics+anonymous%2C+narcotics+anonymous%2C+drug+treatment%2C+housing+for+addicts%2C+alcoholism%2C+AA%2C+NA%2C+addiction+counseling%2C+alcoholism+counseling%2C+clean+and+sober+living%2C+northern+california%2C+chico%2C+willows%2C+corning%2C+glenn+county%2C+tehama+county%2C+butte+county%2C+binge+drinking%2C+metamphetamine%2C+crack%2C+cocaine%2C+crystal+meth%2C+meth%2C+not+in+our+town+glenn+county%2C+Unity+House%2C+Glenn+County+California';
var metaContents  = 'Unity+in+Recovery+is+a+drug+and+alcohol+support+group+for+graduates+of+California+Prop+36+and+Glenn+County+Drug+Court.++We+are+currently+sponsoring+Unity+House%2C+a+clean+and+sober+living+house+for+women+in+Orland%2C+California.++Opening+date+was+June+1%2C+2008.++All+advocates+for+Clean+and+Sober+Living+as+well+as+those+in+Recovery+are+welcome+to+join+us+in+this+mission.';
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();
};

