/* [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','1701',jdecode('Home'),jdecode(''),'/1701.html','true',[],''],
	['PAGE','1801',jdecode('About+us'),jdecode(''),'/1801.html','true',[],''],
	['PAGE','1822',jdecode('Service'),jdecode(''),'/1822.html','true',[],''],
	['PAGE','7901',jdecode('Management+Team'),jdecode(''),'/7901.html','true',[],''],
	['PAGE','5501',jdecode('Client+Accolades'),jdecode(''),'/5501.html','true',[],''],
	['PAGE','1885',jdecode('Contact+Request'),jdecode(''),'/1885.html','true',[],''],
	['PAGE','1864',jdecode('Location'),jdecode(''),'/1864.html','true',[],'']];
var siteelementCount=7;
theSitetree.topTemplateName='Scenery';
theSitetree.paletteFamily='6585B8';
theSitetree.keyvisualId='6943';
theSitetree.keyvisualName='kv_6943.jpg';
theSitetree.fontsetId='11227';
theSitetree.graphicsetId='12047';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='8AA6D2';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Scenery',
				paletteFamily: 	'6585B8',
				keyvisualId: 	'6943',
				keyvisualName: 	'kv_6943.jpg',
				fontsetId: 		'11227',
				graphicsetId: 	'12047',
				contentColor: 	'FFFFFF',
				contentBGColor: '8AA6D2',
				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: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['7008']=webappMappings['7008-14442']={
webappId:    '7008',
documentId:  '1885',
internalId:  '14442',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1701',
internalId:  '',
customField: '20100512-142054'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1801',
internalId:  '',
customField: '20100512-141553'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1822',
internalId:  '',
customField: '20090310-163912'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1864',
internalId:  '',
customField: '20090311-143052'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1885',
internalId:  '',
customField: '20100512-141432'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5501',
internalId:  '',
customField: '20090310-160951'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7901',
internalId:  '',
customField: '20090819-104325'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0IN3M9W';
var companyName   = 'Casco+Bay+Home+Care';
var htmlTitle	  = 'Casco+Bay+Home+Care+%2F%2F+Home+Care+Services+%2F%2F+Cumberland+County%2C+ME';
var metaKeywords  = 'home+health+care+yarmouth%2C+ME+home+care+Yarmouth%2C+ME+homecare+Yarmouth%2C+ME+in+home+care+Yarmouth%2C+ME+senior+services+Yarmouth%2C+ME+Home+care+aids+Home+health+aids+homehealth+Portland%2C+ME+Home+nursing+care+Portland%2C+ME+South+Portland%2C+ME+Home+care+Portland%2C+ME+Home+care+South+Portland%2C+ME+in+home+care+Yarmouth%2C+ME+Long+term+care+insurance+Yarmouth%2C+ME+Long+term+care+insurance+Portland%2C+ME+Home+health+care+Falmouth%2C+ME+Home+care+Falmouth%2C+ME+in+home+care+Falmouth%2C+ME+elderly+services+Yarmouth%2C+ME+Elderly+services%2C+Portland%2C+ME+Elderly+services%2C+Falmouth%2C+ME+Medication+Management%2C+Yarmouth%2C+ME+Medication+management%2C+Portland%2C+ME+Home+health+care+southern+Maine';
var metaContents  = 'Home+Health+Care+Yarmouth%2C+ME+%2F%2F+Serving+Cumberland+County+%2F%2F+Companionship+and+Personal+Hygiene+Services+including%3A++Companionship%2C+Personal+Hygiene%2C+Meal+Preperation%2C+Safety+Monitoring%2C+Confusion+and+forgetfulness%2C+Light+Housekeeping%2C+Transportation';
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();
};

