/* [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','22401',jdecode('+Our+Farm'),jdecode(''),'/22401.html','true',[],'',''],
	['PAGE','31964',jdecode('News'),jdecode(''),'/31964.html','true',[],'',''],
	['PAGE','31985',jdecode('Our+Market+Garden'),jdecode(''),'/31985.html','true',[],'',''],
	['PAGE','32006',jdecode('Highland+Cattle'),jdecode(''),'/32006/index.html','true',[ 
		['PAGE','35615',jdecode('Semen+Sales'),jdecode(''),'/32006/35615.html','true',[],'',''],
		['PAGE','35915',jdecode('History'),jdecode(''),'/32006/35915.html','true',[],'',''],
		['PAGE','36615',jdecode('Highland+Beef'),jdecode(''),'/32006/36615.html','true',[],'','']
	],'',''],
	['PAGE','47966',jdecode('CSA+Boxes'),jdecode(''),'/47966.html','true',[],'',''],
	['PAGE','46366',jdecode('Garlic+Seed'),jdecode(''),'/46366.html','true',[],'',''],
	['PAGE','46466',jdecode('Lauriston+Farm+Blog'),jdecode(''),'/46466.html','true',[],'',''],
	['PAGE','44215',jdecode('SHOP'),jdecode(''),'/44215.html','true',[],'',''],
	['PAGE','43615',jdecode('Farm+Photos'),jdecode(''),'/43615.html','true',[],'',''],
	['PAGE','41315',jdecode('Employment+Opportunities'),jdecode(''),'/41315.html','true',[],'',''],
	['PAGE','41515',jdecode('How+to+find+us'),jdecode(''),'/41515.html','true',[],'',''],
	['PAGE','22501',jdecode('Contact'),jdecode(''),'/22501.html','true',[],'','']];
var siteelementCount=15;
theSitetree.topTemplateName='Favor';
theSitetree.paletteFamily='D2BD84';
theSitetree.keyvisualId='7344';
theSitetree.keyvisualName='kv_7344.jpg';
theSitetree.fontsetId='16468';
theSitetree.graphicsetId='12160';
theSitetree.contentColor='323232';
theSitetree.contentBGColor='F1EEDB';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Favor',
				paletteFamily: 	'D2BD84',
				keyvisualId: 	'7344',
				keyvisualName: 	'kv_7344.jpg',
				fontsetId: 		'16468',
				graphicsetId: 	'12160',
				contentColor: 	'323232',
				contentBGColor: 'F1EEDB',
				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['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22401',
internalId:  '',
customField: '20100215-042702'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41315',
internalId:  '',
customField: '20100221-110217'
};
webappMappings['2002']=webappMappings['2002-routing']={
webappId:    '2002',
documentId:  '41515',
internalId:  'routing',
customField: 'en_US'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '22401',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32006',
internalId:  '',
customField: '20100216-140115'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35615',
internalId:  '',
customField: '20100221-130956'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35915',
internalId:  '',
customField: '20100214-081525'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36615',
internalId:  '',
customField: '20100221-130325'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22501',
internalId:  '',
customField: '20100221-154232'
};
webappMappings['7008']=webappMappings['7008-2097']={
webappId:    '7008',
documentId:  '22501',
internalId:  '2097',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31985',
internalId:  '',
customField: '20100225-120009'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41515',
internalId:  '',
customField: '20100221-110803'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31964',
internalId:  '',
customField: '20100209-075434'
};
webappMappings['7060']=webappMappings['7060-fe6d7418e36da982a93c78b70a18eb1d']={
webappId:    '7060',
documentId:  '43615',
internalId:  'fe6d7418e36da982a93c78b70a18eb1d',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '43615',
internalId:  '',
customField: '20100225-121424'
};
webappMappings['4001']=webappMappings['4001-9447557']={
webappId:    '4001',
documentId:  '44215',
internalId:  '9447557',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '44215',
internalId:  '',
customField: '20100226-103917'
};
webappMappings['7050']=webappMappings['7050-276']={
webappId:    '7050',
documentId:  '46466',
internalId:  '276',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46366',
internalId:  '',
customField: '20110228-144842'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46466',
internalId:  '',
customField: '20110228-150417'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '47966',
internalId:  '',
customField: '20110426-163232'
};
var canonHostname = 'localhost';
var accountId     = 'ANFI20IN2KN8';
var companyName   = 'LAURISTON+FARM';
var htmlTitle	  = 'Lauriston+Farm+Market+Garden+and+Highland+Cattle+';
var metaKeywords  = 'Lauriston+Farm%2C+Highland+Cattle%2C+Highland+semen%2C+Lauriston+Angelo%2C+Certified+Naturally+Grown%2C+Highland+beef%2C+Market+Garden%2C+Bulkley+Valley+Farmers+Market.';
var metaContents  = 'Lauriston+Farm+Certified+Naturally+Grown+market+garden+and+Highland+Cattle+and+beef';
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();
};

