/* [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','9301',jdecode('Home'),jdecode(''),'/9301.html','true',[],''],
	['PAGE','9352',jdecode('Engineering+Services'),jdecode(''),'/9352.html','true',[],''],
	['PAGE','16401',jdecode('Land+Surveying+Services'),jdecode(''),'/16401.html','true',[],''],
	['PAGE','9394',jdecode('Location'),jdecode(''),'/9394.html','true',[],''],
	['PAGE','9373',jdecode('Representative+Projects'),jdecode(''),'/9373.html','true',[],''],
	['PAGE','9415',jdecode('Contact+Us'),jdecode(''),'/9415/index.html','true',[ 
		['PAGE','9436',jdecode('Our+team'),jdecode(''),'/9415/9436.html','true',[],''],
		['PAGE','9457',jdecode('Contact+Information'),jdecode(''),'/9415/9457.html','true',[],'']
	],''],
	['PAGE','17601',jdecode('Job+Openings'),jdecode(''),'/17601.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Movement';
theSitetree.paletteFamily='333F65';
theSitetree.keyvisualId='1819';
theSitetree.keyvisualName='kv_dummy.jpg';
theSitetree.fontsetId='289';
theSitetree.graphicsetId='355';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='333F65';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Movement',
				paletteFamily: 	'333F65',
				keyvisualId: 	'1819',
				keyvisualName: 	'kv_dummy.jpg',
				fontsetId: 		'289',
				graphicsetId: 	'355',
				contentColor: 	'FFFFFF',
				contentBGColor: '333F65',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'333F65',
				b_color: 		'040507',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9301',
internalId:  '',
customField: '20091124-112459'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '9301',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9352',
internalId:  '',
customField: '20090501-103926'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9373',
internalId:  '',
customField: '20090504-132026'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9394',
internalId:  '',
customField: '20090503-220112'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9415',
internalId:  '',
customField: '20090501-113110'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9436',
internalId:  '',
customField: '20091124-112552'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9457',
internalId:  '',
customField: '20090501-125740'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17601',
internalId:  '',
customField: '20090501-143350'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16401',
internalId:  '',
customField: '20090504-132457'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0IN3R8W';
var companyName   = 'Apgar+Associates';
var htmlTitle	  = 'Apgar+Associates%2C+Land+Surveyor%2C+Civil+Engineers%2C+Somerset+County%2C+Morris+County%2C+Hunterdon+County%2C+Union+County%2C+NJ';
var metaKeywords  = 'professional+engineering++land+surveying+Site+Planning+and+Design+Land+Subdivision+Municipal+Engineering+Environmental+Studies+Soil+Engineering+Drainage+and+Flood+Studies+Streets+and+Highways+Dams+and+Hydraulic+Structures+Recreation+Facilities+Boundary+SURVEY+NJ+Topographic+Surveys+NJ+Construction+Supervision+Inspection+Contract+Administration+Construction+Stakeout+ALTA+SURVEY+SURVEY+MORRIS+COUNTY+SURVEY+SOMERSET+COUNTY+CIVIL+ENGINEERING+MORRIS+COUNTYCIVIL+ENGINEERING+SOMERSET+COUNTY+DAM+INSPECTIONS+NJ+SITE+PLANNER+MORRIS+COUNTY+SITE+PLANNER+SOMERSET+COUNTY+LAND+SURVEY+MORRIS+COUNTY+LAND+SURVEY+SOMERSET+COUNTY+SURVEY+HUNTERDON+COUNTY+SURVEY+UNION+COUNTY+CIVIL+ENGINEER+HUNTERDON+COUNTY+CIVIL+ENGINEER+UNION+COUNTY+CIVIL+ENGINEER+NJ+LAND+SURVEY+NJ';
var metaContents  = 'Apgar+Associates+is+a+professional+engineering+and+land+surveying+organization+that+has+served+northern+and+central+New+Jersey+since+1960.++Prior+to+that+time+the+firm+was+the+sole+proprietorship+of+Leslie+M.+Apgar%2C+P.E.+and+L.S.%2C+who+practiced+engineering+and+land+surveying+in+the+Somerset+Hills+area+since+1939.+Apgar+Associates+has+grown+to+become+quite+diversified+since+its+inception';
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();
};
