/* [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','401',jdecode('Home'),jdecode(''),'/401/index.html','true',[ 
		['PAGE','7001',jdecode('About+us'),jdecode(''),'/401/7001.html','true',[],'',''],
		['PAGE','7022',jdecode('History'),jdecode(''),'/401/7022.html','true',[],'',''],
		['PAGE','7043',jdecode('Officers+%26+Trustees'),jdecode(''),'/401/7043.html','true',[],'',''],
		['PAGE','7064',jdecode('Committees'),jdecode(''),'/401/7064.html','true',[],'','']
	],'',''],
	['PAGE','7106',jdecode('Contact'),jdecode(''),'/7106/index.html','true',[ 
		['PAGE','7127',jdecode('Guestbook'),jdecode(''),'/7106/7127.html','true',[],'',''],
		['PAGE','7085',jdecode('Becoming+a+member'),jdecode(''),'/7106/7085.html','true',[],'','']
	],'',''],
	['PAGE','7148',jdecode('Events'),jdecode(''),'/7148.html','false',[],'',''],
	['PAGE','44801',jdecode('Explore+Resources'),jdecode(''),'/44801/index.html','true',[ 
		['PAGE','39401',jdecode('Interactive+Map'),jdecode(''),'/44801/39401.html','true',[],'',''],
		['PAGE','7422',jdecode('Photos'),jdecode(''),'/44801/7422.html','true',[],'',''],
		['PAGE','7443',jdecode('Newsletters'),jdecode(''),'/44801/7443.html','true',[],'',''],
		['PAGE','7464',jdecode('Historical+Books'),jdecode(''),'/44801/7464.html','true',[],'',''],
		['PAGE','46701',jdecode('Books+by+Local+Authors'),jdecode(''),'/44801/46701.html','true',[],'',''],
		['PAGE','34401',jdecode('Daketown+School'),jdecode(''),'/44801/34401.html','true',[],'',''],
		['PAGE','54401',jdecode('King%26%23x27%3Bs+Station+and+Caboose'),jdecode(''),'/44801/54401.html','true',[],'',''],
		['PAGE','7485',jdecode('Links'),jdecode(''),'/44801/7485.html','true',[],'','']
	],'',''],
	['PAGE','7401',jdecode('Explore'),jdecode(''),'/7401.html','false',[],'',''],
	['PAGE','50001',jdecode('Farmer%26%23x27%3Bs+Market'),jdecode(''),'/50001/index.html','true',[ 
		['PAGE','53701',jdecode('June+25+Farmers+Market'),jdecode(''),'/50001/53701.html','true',[],'','']
	],'','']];
var siteelementCount=21;
theSitetree.topTemplateName='Animal';
theSitetree.paletteFamily='519D4A';
theSitetree.keyvisualId='4311';
theSitetree.keyvisualName='kv_4311.jpg';
theSitetree.fontsetId='10791';
theSitetree.graphicsetId='11210';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='D0E3CE';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'aplus',
  product: 'WSCSYSSSSLYTCPLI'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Animal',
				paletteFamily: 	'519D4A',
				keyvisualId: 	'4311',
				keyvisualName: 	'kv_4311.jpg',
				fontsetId: 		'10791',
				graphicsetId: 	'11210',
				contentColor: 	'000000',
				contentBGColor: 'D0E3CE',
				a_color: 		'519D4A',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1002']=webappMappings['1002-7127aaplu0inzwh8']={
webappId:    '1002',
documentId:  '7127',
internalId:  '7127aaplu0inzwh8',
customField: 'icq=false'
};
webappMappings['7060']=webappMappings['7060-e92fc6b9c0c4beb410e51b17d66ab432']={
webappId:    '7060',
documentId:  '7422',
internalId:  'e92fc6b9c0c4beb410e51b17d66ab432',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '401',
internalId:  '',
customField: '20110911-085908'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7001',
internalId:  '',
customField: '20090720-112548'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7022',
internalId:  '',
customField: '20090716-111856'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7043',
internalId:  '',
customField: '20110406-132456'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7064',
internalId:  '',
customField: '20090717-041847'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7085',
internalId:  '',
customField: '20090716-123224'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7106',
internalId:  '',
customField: '20100118-065952'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7127',
internalId:  '',
customField: '20090716-125831'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7148',
internalId:  '',
customField: '20110623-191734'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7401',
internalId:  '',
customField: '20091123-080859'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7422',
internalId:  '',
customField: '20091119-134852'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7443',
internalId:  '',
customField: '20110911-074835'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7464',
internalId:  '',
customField: '20110501-191238'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7485',
internalId:  '',
customField: '20110623-194733'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34401',
internalId:  '',
customField: '20090720-112215'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39401',
internalId:  '',
customField: '20091023-162023'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '44801',
internalId:  '',
customField: '20100211-065455'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46701',
internalId:  '',
customField: '20110501-191317'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '50001',
internalId:  '',
customField: '20110911-083446'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '53701',
internalId:  '',
customField: '20100628-064545'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '54401',
internalId:  '',
customField: '20100628-171803'
};
var webAppHostname = 'cm4all.aplus.net:80';
var canonHostname = 'cm4all01.carrierzone.com';
var accountId     = 'AAPLU0INZWH8';
var companyName   = 'The+Town+of+Greenfield+Historical+Society';
var htmlTitle	  = 'Town+of+Greenfield+Historical+Society';
var metaKeywords  = 'Greenfield+Historical+SocietyGreenfield+HistorySaratoga+HistoryGreenfield+CenterMiddle+GrovePorter+Corners';
var metaContents  = 'Information%2C+Events+and+Resources+for+the+Town+of+Greenfield+Historical+Society%2C+based+in+the+town+of+Greenfield%2C+NY+in+Saratoga+County.+Monthly+meetings+and+general+membership+are+open+to+everyone.';
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();
};

