/* [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','33',jdecode('Home'),jdecode(''),'/33.html','true',[],''],
	['PAGE','3180',jdecode('About+us'),jdecode(''),'/3180.html','true',[],''],
	['PAGE','3189',jdecode('Cedar+vs.+Pine'),jdecode(''),'/3189.html','true',[],''],
	['PAGE','3198',jdecode('Construction+Details'),jdecode(''),'/3198.html','true',[],''],
	['PAGE','1536',jdecode('Pictures'),jdecode(''),'/1536.html','true',[],''],
	['PAGE','1993',jdecode('Testimonials'),jdecode(''),'/1993.html','true',[],''],
	['PAGE','1681',jdecode('Resources%2Finfo%2Fplans'),jdecode(''),'/1681.html','true',[],'']];
var siteelementCount=7;
theSitetree.topTemplateName='Avocation';
theSitetree.paletteFamily='BD4A52';
theSitetree.keyvisualId='4561';
theSitetree.keyvisualName='kv_4561.jpg';
theSitetree.fontsetId='10825';
theSitetree.graphicsetId='11278';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='BD4A52';
var theTemplate={
				name: 			'Avocation',
				paletteFamily: 	'BD4A52',
				keyvisualId: 	'4561',
				keyvisualName: 	'kv_4561.jpg',
				fontsetId: 		'10825',
				graphicsetId: 	'11278',
				contentColor: 	'FFFFFF',
				contentBGColor: 'BD4A52',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'BD4A52',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'64181D',
				e_color: 		'64181D',
				f_color: 		'64181D',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '33',
internalId:  '1006',
customField: '1006'
};
webappMappings['7060']=webappMappings['7060-f04c862bf963ff35de454b7ce91cd0e3']={
webappId:    '7060',
documentId:  '1536',
internalId:  'f04c862bf963ff35de454b7ce91cd0e3',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-876']={
webappId:    '7008',
documentId:  '1681',
internalId:  '876',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '33',
internalId:  '',
customField: '20091013-045611'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3180',
internalId:  '',
customField: '20081213-063741'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3189',
internalId:  '',
customField: '20071202-144312'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3198',
internalId:  '',
customField: '20071202-230521'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1536',
internalId:  '',
customField: '20081213-074007'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1993',
internalId:  '',
customField: '20071202-144424'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1681',
internalId:  '',
customField: '20090201-085353'
};
var canonHostname = 'wsc-worker01.chi.us.siteprotect.com';
var accountId     = 'AHW050INV9OH';
var companyName   = 'Lakeside+Log+Homes';
var htmlTitle	  = 'Lakeside+Log+Homes+Williamstown+New+Jersey';
var metaKeywords  = 'logs%2Ccedar%2Clogcabins%2Cpine%2Cnewjersey%2Csouthjersey%2Ccamps%2Csiding%2Cbuilders%2Cplans%2Cfloorplans%2Ckatahdin%2Cthebest%2Cstain%2Cpurlin%2Clograils%2Clogsteps%2Ccheap%2Cexpensive%2Cfast%2Ccustom';
var metaContents  = 'Lakeside+Log+Homes%2C+custom+cedar+and+pine+log+homes+and+cabins.+Cedar+for+the+price+of+pine%21+The+industry+leader+in+log+homes+and+cabins.';
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();
};
