/* [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','501',jdecode('Home'),jdecode(''),'/501.html','true',[],''],
	['PAGE','29601',jdecode('About+us'),jdecode(''),'/29601/index.html','true',[ 
		['PAGE','29622',jdecode('Commission+Members'),jdecode(''),'/29601/29622.html','true',[],''],
		['PAGE','31401',jdecode('Staff+%26+Contact+Information'),jdecode(''),'/29601/31401.html','true',[],''],
		['PAGE','29706',jdecode('Jurisdictions'),jdecode(''),'/29601/29706.html','true',[],''],
		['PAGE','35301',jdecode('Virginia+Legislators'),jdecode(''),'/29601/35301.html','true',[],''],
		['PAGE','48271',jdecode('Newsletter'),jdecode(''),'/29601/48271.html','true',[],''],
		['PAGE','48351',jdecode('Meeting+Schedule'),jdecode(''),'/29601/48351.html','true',[],'']
	],''],
	['PAGE','29643',jdecode('What+we+do'),jdecode(''),'/29643/index.html','true',[ 
		['PAGE','29664',jdecode('Regional+Planning'),jdecode(''),'/29643/29664.html','true',[],''],
		['PAGE','29685',jdecode('Transportation+Planning'),jdecode(''),'/29643/29685.html','true',[],''],
		['PAGE','48225',jdecode('GIS%2C+DATA+AND+MAPS'),jdecode(''),'/29643/48225.html','true',[],''],
		['PAGE','46901',jdecode('Community+Development'),jdecode(''),'/29643/46901.html','true',[],''],
		['PAGE','48137',jdecode('Natural+Resources'),jdecode(''),'/29643/48137.html','true',[],''],
		['PAGE','48568',jdecode('SHENAIR'),jdecode(''),'/29643/48568.html','true',[],''],
		['PAGE','48757',jdecode('AIR+Resources+%26+Reports'),jdecode(''),'/29643/48757.html','true',[],'']
	],''],
	['PAGE','29727',jdecode('Jobs'),jdecode(''),'/29727.html','true',[],''],
	['PAGE','33501',jdecode('Map+%26+Directions'),jdecode(''),'/33501.html','true',[],''],
	['PAGE','34601',jdecode('Links'),jdecode(''),'/34601.html','true',[],''],
	['PAGE','49145',jdecode('TDR+Workshop'),jdecode(''),'/49145.html','true',[],'']];
var siteelementCount=20;
theSitetree.topTemplateName='Contrast';
theSitetree.paletteFamily='3F7928';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='16628';
theSitetree.graphicsetId='12214';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Contrast',
				paletteFamily: 	'3F7928',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'16628',
				graphicsetId: 	'12214',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				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:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '33501',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:false;'
};
webappMappings['1501']=webappMappings['1501-13577558']={
webappId:    '1501',
documentId:  '501',
internalId:  '13577558',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20091116-154604'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29727',
internalId:  '',
customField: '20091106-171950'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29601',
internalId:  '',
customField: '20080215-110113'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29622',
internalId:  '',
customField: '20081117-102339'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31401',
internalId:  '',
customField: '20090916-115002'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29706',
internalId:  '',
customField: '20081117-140211'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35301',
internalId:  '',
customField: '20091116-154943'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '48137',
internalId:  '',
customField: '20090824-144212'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29643',
internalId:  '',
customField: '20091020-140840'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29664',
internalId:  '',
customField: '20080212-105540'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29685',
internalId:  '',
customField: '20091006-155347'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '48271',
internalId:  '',
customField: '20090916-115422'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46901',
internalId:  '',
customField: '20091020-141726'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '33501',
internalId:  '',
customField: '20091001-113437'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34601',
internalId:  '',
customField: '20080212-105746'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '48225',
internalId:  '',
customField: '20090916-120638'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '48351',
internalId:  '',
customField: '20081117-155734'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '48568',
internalId:  '',
customField: '20090831-161148'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '48757',
internalId:  '',
customField: '20090831-163432'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '49145',
internalId:  '',
customField: '20090521-150738'
};
var canonHostname = 'cmworker01.yourhostingaccount.com';
var accountId     = 'AENDU0INEO0G';
var companyName   = 'Northern+Shenandoah+Valley%2C+Virginia++++++++++++++++++++';
var htmlTitle	  = 'Northern+Shenandoah+Valley+Regional+Commission';
var metaKeywords  = 'northern+shenandoah+valley+regional+commission+gis+win-fred+mpo+front+royal+virginia+transportation+planning+water+supply+planning+home+community+development+ridesharing+';
var metaContents  = 'The+Northern+Shenandoah+Valley+Regional+Commission+is+located+in+Front+Royal%2C+Virginia.++Serving+the+Counties+of+Warren%2C+Page%2C+Shenandoah%2C+Frederick%2C+Clarke+and+the+City+of+Winchester.';
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();
};
