/* [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','401',jdecode('Home'),jdecode(''),'/401.html','true',[],'',''],
	['PAGE','452',jdecode('Rooms+and+Rates'),jdecode(''),'/452.html','true',[],'',''],
	['PAGE','32601',jdecode('Facilities'),jdecode(''),'/32601.html','true',[],'',''],
	['PAGE','68212',jdecode('Views+of+The+Brownlow'),jdecode(''),'/68212.html','true',[],'',''],
	['PAGE','473',jdecode('Ivinghoe'),jdecode(''),'/473.html','true',[],'',''],
	['PAGE','515',jdecode('Local+Attractions'),jdecode(''),'/515.html','true',[],'',''],
	['PAGE','50801',jdecode('Where+to+find+us.....'),jdecode(''),'/50801.html','true',[],'',''],
	['PAGE','557',jdecode('Booking'),jdecode(''),'/557.html','true',[],'',''],
	['PAGE','494',jdecode('Why+Us%3F'),jdecode(''),'/494.html','true',[],'',''],
	['PAGE','578',jdecode('Contact+Us'),jdecode(''),'/578.html','true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Angkor';
theSitetree.paletteFamily='A5B351';
theSitetree.keyvisualId='6901';
theSitetree.keyvisualName='kv_6901.jpg';
theSitetree.fontsetId='11212';
theSitetree.graphicsetId='12031';
theSitetree.contentColor='657025';
theSitetree.contentBGColor='C1CF70';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Angkor',
				paletteFamily: 	'A5B351',
				keyvisualId: 	'6901',
				keyvisualName: 	'kv_6901.jpg',
				fontsetId: 		'11212',
				graphicsetId: 	'12031',
				contentColor: 	'657025',
				contentBGColor: 'C1CF70',
				a_color: 		'C1CF70',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '401',
internalId:  '',
customField: '20091206-185051'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '452',
internalId:  '',
customField: '20100108-152159'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '473',
internalId:  '',
customField: '20080430-114247'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '557',
internalId:  '',
customField: '20071102-101835'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '494',
internalId:  '',
customField: '20071118-140702'
};
webappMappings['7008']=webappMappings['7008-226']={
webappId:    '7008',
documentId:  '557',
internalId:  '226',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '515',
internalId:  '',
customField: '20071118-183652'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '401',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '578',
internalId:  '',
customField: '20071115-225930'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '50801',
internalId:  '',
customField: '20071110-192149'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32601',
internalId:  '',
customField: '20091022-180303'
};
webappMappings['7060']=webappMappings['7060-2eacf70ba7f51c72867d06a37a60d59a']={
webappId:    '7060',
documentId:  '68212',
internalId:  '2eacf70ba7f51c72867d06a37a60d59a',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '68212',
internalId:  '',
customField: '20080502-160811'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN2JVB';
var companyName   = 'The+Brownlow+Guest+Accommodation';
var htmlTitle	  = 'www.thebrownlow.com';
var metaKeywords  = 'bedfordshire+bed+and+breakfast%2Caccommodation+place+bedford+uk%2Cbedford+guest+houses%2Cbed+and+breakfast+bedford%2Cbed++breakfast+ivinghoe%2Cbedfordshire+self+catering+accommodation%2Cbedford+accommodation%2Cbed+and+breakfast+ivinghoe%2Cbedfordshire+holiday+cottages%2Cbuckingham+guest+house%2Cbuckinghamshire+holiday+cottages%2Cbuckinghamshire+bed+and+breakfast%2Cbuckinghamshire+holiday+accommodation%2Cbuckinghamshire+family+holiday%2Ccambridgeshire+holiday+cottages%2Cnorthampton+bed+and+breakfast%2Cnorthampton+accommodation%2Chertfordshire+bed+and+breakfast%2Cnorthamptonshire+holiday+cottages%2Chertfordshire+self+catering+accommodation%2Chertfordshire+holiday+cottages%2Caccommodation+in+cambridge+uk%2Chertford+guest+house%2Chertford+accommodation%2Cnorthamptonshire+self+catering+accommodation%2Ccambridgeshire+self+catering+accommodation%2C+www.thebrownlow.com%2Caccommodation%2Cbed+and+breakfast%2Cexecutive%2Cbreakfast%2Cgolf%2Cmentmore%2Cwoburn%2C+luton+airport%2Cashridge+golf+club%2Cashridge+business+school%2Cgoodrich%2Cbellows+mill%2Ctring%2Cwendover%2Caylesbury%2Cbuckinghamshire%2Cbedfordshire%2Chertfordshire%2C+whipsnade%2Csouth+east+tourism%2CAA+accommodation%2Cprivate+location%2C';
var metaContents  = 'The+Brownlow+Bed+and+Breakfast%2CIvinghoe+Bucks%2Cnr+Tring%2CBerkhamsted%2CLeighton+Buzzard%2CWendover%2Cluxury+bed+and+breakfast%2Cprivate+location%2Cfronting+onto+Grand+Union+Canal%2Csecluded%2Cpicturesque%2C';
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();
};
