/* [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','2701',jdecode('HOME'),jdecode(''),'/2701.html','true',[],''],
	['PAGE','15601',jdecode('BED+%26+BREAKFAST+SUITES+AVAILABLE'),jdecode(''),'/15601.html','true',[],''],
	['PAGE','15701',jdecode('RATES'),jdecode(''),'/15701.html','true',[],''],
	['PAGE','34301',jdecode('GOURMET+BREAKFASTS'),jdecode(''),'/34301.html','true',[],''],
	['PAGE','15722',jdecode('WILDERNESS+TREATMENT+CENTER'),jdecode(''),'/15722.html','true',[],''],
	['PAGE','20922',jdecode('MONTANA+ACADEMY+LODGING'),jdecode(''),'/20922.html','true',[],''],
	['PAGE','17701',jdecode('EVENTS+AT+THE+LAKE'),jdecode(''),'/17701.html','true',[],''],
	['PAGE','15743',jdecode('LOCAL+ATTRACTIONS'),jdecode(''),'/15743.html','true',[],''],
	['PAGE','31101',jdecode('SPECIALTY+ITEMS'),jdecode(''),'/31101.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='View';
theSitetree.paletteFamily='236A8C';
theSitetree.keyvisualId='11410';
theSitetree.keyvisualName='kv_11410.jpg';
theSitetree.fontsetId='32029';
theSitetree.graphicsetId='13853';
theSitetree.contentColor='2F2F2F';
theSitetree.contentBGColor='236A8C';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'View',
				paletteFamily: 	'236A8C',
				keyvisualId: 	'11410',
				keyvisualName: 	'kv_11410.jpg',
				fontsetId: 		'32029',
				graphicsetId: 	'13853',
				contentColor: 	'2F2F2F',
				contentBGColor: '236A8C',
				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:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2701',
internalId:  '',
customField: '20090502-131350'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2701',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-16786895']={
webappId:    '1501',
documentId:  '2701',
internalId:  '16786895',
customField: '1501'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '15722',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15743',
internalId:  '',
customField: '20090714-130626'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15601',
internalId:  '',
customField: '20090521-095634'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15701',
internalId:  '',
customField: '20090502-151934'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15722',
internalId:  '',
customField: '20090503-223915'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34301',
internalId:  '',
customField: '20090503-234918'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17701',
internalId:  '',
customField: '20090512-111331'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20922',
internalId:  '',
customField: '20090521-100107'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31101',
internalId:  '',
customField: '20090517-200626'
};
var canonHostname = 'cmworker01.yourhostingaccount.com';
var accountId     = 'AENDU0IN3D3O';
var companyName   = 'At+The+Lake+B%26B+%28406%29+858-2456+';
var htmlTitle	  = 'AT+THE+LAKE+BED+AND+BREAKFAST%2C+McGREGOR+LAKE%2C+MARION%2C+MONTANA';
var metaKeywords  = 'at+the+lake+bed+and+breakfast%3B+atthelake%3Bwww.atthelakebb.com%2C+McGregor+Lake+Marion%2C+Montana%2C+MONTANA%2C+Marion%2C+MT+lodging%2C+McGregor+Lake+Lodge%2C+McGregor+Lake+Lodging%2C+Glacier+National+Park%2CGlacier+Country%2Cfishing%2Cswimming%2Cboating%2Ccanoeing%2C+lakefront+weddings%2Cpirate+party%2Cice+golf%2Cskiing%2Cgol+f+party+at+the+lake+bb%2C+N.+Murr+Creek+road%2C+breakfast%2C+Marion%2C+Montana+Lodging%2C+Wilderness+Treatment+Center%2C+WTC%2C+Montana+Academy%2C+MTA%2C+Paula+Bundrock%2C+Deja+Page%2C+waterfront+rooms%2C+trout+fishing%2C+smores%2C+lake+shore+lodging%2C+lake+shore+bed+and+breakfast%2C+bnb+bb%2Csunrise+suite%2C++MTBBA+Inn%2C+huckleberry+french+toast';
var metaContents  = 'AT+THE+LAKE+BED+AND+BREAKFAST-+MCGREGOR+LAKE%2C+MARION%2C+MONTANA+We+offer+the+magic+of+the+real+MONTANA%2C+a+great+life+At+The+Lake+with+just+the+right+touch+of+civilization.+Many+people+pass+through+Glacier+Country%2C+but+our+Inn+offers+its+guests+something+rare+and+wonderful.+Call+to+make+reservations%3A++%28406%29+858-2456.';
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();
};
