/* [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','301',jdecode('Home'),jdecode(''),'/301.html','true',[],'',''],
	['PAGE','46301',jdecode('Adult+Residential'),jdecode(''),'/46301/index.html','true',[ 
		['PAGE','59801',jdecode('Services'),jdecode(''),'/46301/59801.html','true',[],'','']
	],'',''],
	['PAGE','46322',jdecode('Community+Living'),jdecode(''),'/46322.html','true',[],'',''],
	['PAGE','46343',jdecode('Childrens+Services'),jdecode(''),'/46343/index.html','true',[ 
		['PAGE','59843',jdecode('Chilren%26%23x27%3Bs+Respite'),jdecode(''),'/46343/59843.html','true',[],'',''],
		['PAGE','59864',jdecode('In-Home+Services'),jdecode(''),'/46343/59864.html','true',[],'',''],
		['PAGE','46364',jdecode('Community+Respite+Supports'),jdecode(''),'/46343/46364.html','true',[],'','']
	],'',''],
	['PAGE','57901',jdecode('Vocational+Services'),jdecode(''),'/57901/index.html','true',[ 
		['PAGE','73201',jdecode('Giving+Tree+Farm'),jdecode(''),'/57901/73201.html','true',[],'','']
	],'',''],
	['PAGE','58301',jdecode('Consulting'),jdecode(''),'/58301.html','true',[],'',''],
	['PAGE','22922',jdecode('Professional+Staff'),jdecode(''),'/22922.html','true',[],'',''],
	['PAGE','23111',jdecode('Contact+Us'),jdecode(''),'/23111/index.html','true',[ 
		['PAGE','84701',jdecode('Main+Office+Location'),jdecode(''),'/23111/84701.html','true',[],'','']
	],'',''],
	['PAGE','23090',jdecode('Careers'),jdecode(''),'/23090.html','true',[],'',''],
	['PAGE','80101',jdecode('Staff+Access'),jdecode(''),'/80101.html','true',[],'','']];
var siteelementCount=16;
theSitetree.topTemplateName='Basic';
theSitetree.paletteFamily='823333';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10828';
theSitetree.graphicsetId='11284';
theSitetree.contentColor='333333';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Basic',
				paletteFamily: 	'823333',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10828',
				graphicsetId: 	'11284',
				contentColor: 	'333333',
				contentBGColor: 'FFFFFF',
				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:  '301',
internalId:  '',
customField: '20090319-204352'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '301',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23090',
internalId:  '',
customField: '20100623-161454'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23111',
internalId:  '',
customField: '20100618-205000'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '59801',
internalId:  '',
customField: '20090226-170408'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '73201',
internalId:  '',
customField: '20090306-120834'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '57901',
internalId:  '',
customField: '20090306-120258'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '58301',
internalId:  '',
customField: '20090402-094958'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46343',
internalId:  '',
customField: '20090213-124159'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46301',
internalId:  '',
customField: '20090226-170844'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46322',
internalId:  '',
customField: '20090226-170917'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22922',
internalId:  '',
customField: '20100618-204953'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46364',
internalId:  '',
customField: '20090806-090736'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '59843',
internalId:  '',
customField: '20090226-170947'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '59864',
internalId:  '',
customField: '20100623-161406'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '84701',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '84701',
internalId:  '',
customField: '20090306-120017'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '80101',
internalId:  '',
customField: '20100618-205337'
};
webappMappings['7008']=webappMappings['7008-1931']={
webappId:    '7008',
documentId:  '23111',
internalId:  '1931',
customField: 'language:en;country:US;'
};
var canonHostname = 'wsc-worker03.chi.us.siteprotect.com';
var accountId     = 'AHW050INXSS3';
var companyName   = 'CBI+Rehabilitation+Services%2C+Inc.';
var htmlTitle	  = 'CBI+Rehabilitation+Services%2C+Inc.';
var metaKeywords  = 'behavioral+modification%2C+brain+injury%2C+tbi%2C+autism%2C+applied+behavior+management%2C+respite%2C+adult+foster+care%2C+supported+living%2Fteen+suicide%2Fadult+behavior+support';
var metaContents  = '%2Fautism%2Ftraumatic+brain+injury%2Fvocational+rehabilitation%2Forganic+farming%2Frespite+care%2Fin+home+care%2Femotional+disturbances%2Fdevelopmental+disabilities%2Fchildren+waiver+program%2Fclosed+head+injury%2Fvocational%2Ftbi+resources%2Faspergers%2Ftramtic+brain+injury%2Fresidential+services%2Fafc%2Fchild+caring+institution%2Fchild+and+adult+licensed+facilities%2Farp';
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();
};
