/* [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','301',jdecode('Home'),jdecode(''),'/301.html','true',[],''],
	['PAGE','15601',jdecode('This+Page+is+for+the+Birds'),jdecode(''),'/15601.html','true',[],''],
	['PAGE','394',jdecode('Produce'),jdecode(''),'/394.html','true',[],''],
	['PAGE','373',jdecode('Honey'),jdecode(''),'/373.html','true',[],''],
	['PAGE','17101',jdecode('Honey+Info'),jdecode(''),'/17101.html','true',[],''],
	['PAGE','19601',jdecode('Pollen+Info'),jdecode(''),'/19601.html','true',[],''],
	['PAGE','19622',jdecode('Recipes'),jdecode(''),'/19622.html','true',[],''],
	['PAGE','415',jdecode('Contact%2FLocation'),jdecode(''),'/415.html','true',[],''],
	['PAGE','3701',jdecode('Guestbook'),jdecode(''),'/3701.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Porthole';
theSitetree.paletteFamily='064B91';
theSitetree.keyvisualId='6714';
theSitetree.keyvisualName='kv_6714.jpg';
theSitetree.fontsetId='11202';
theSitetree.graphicsetId='12013';
theSitetree.contentColor='215991';
theSitetree.contentBGColor='E9F3FF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Porthole',
				paletteFamily: 	'064B91',
				keyvisualId: 	'6714',
				keyvisualName: 	'kv_6714.jpg',
				fontsetId: 		'11202',
				graphicsetId: 	'12013',
				contentColor: 	'215991',
				contentBGColor: 'E9F3FF',
				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: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '301',
internalId:  '1006',
customField: '1006'
};
webappMappings['7005']=webappMappings['7005-128']={
webappId:    '7005',
documentId:  '373',
internalId:  '128',
customField: 'language:en;country:US;'
};
webappMappings['1501']=webappMappings['1501-1616801']={
webappId:    '1501',
documentId:  '301',
internalId:  '1616801',
customField: '1501'
};
webappMappings['7008']=webappMappings['7008-1105']={
webappId:    '7008',
documentId:  '415',
internalId:  '1105',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '301',
internalId:  '',
customField: '20091106-102004'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '394',
internalId:  '',
customField: '20091106-103421'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '415',
internalId:  '',
customField: '20081112-100024'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19622',
internalId:  '',
customField: '20080318-193722'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '373',
internalId:  '',
customField: '20081122-224714'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15601',
internalId:  '',
customField: '20091106-103627'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17101',
internalId:  '',
customField: '20080318-174031'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19601',
internalId:  '',
customField: '20080318-174434'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3701',
internalId:  '',
customField: '20081112-095849'
};
webappMappings['1002']=webappMappings['1002-3701aendu0inxvr5']={
webappId:    '1002',
documentId:  '3701',
internalId:  '3701aendu0inxvr5',
customField: 'icq=false'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0INXVR5';
var companyName   = 'Riverwood+Produce+Farm';
var htmlTitle	  = 'Riverwood+Produce+Farm';
var metaKeywords  = 'produce%2C+honey%2C+local+honey%2C+local+produce%2C+vegetables%2C+fresh+vegetables%2C+fresh+produce%2C+Kenosha%2C+riverwood%2C+farm%2C+riverwoodfarm%2C+riverwoodproducefarm%2C+riverwoodhoney';
var metaContents  = 'Riverwood+Produce+Farm+Kenosha%2C+WI+53140+Mike+Toboyek+262-552-8830';
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();
};
