/* [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','24001',jdecode('The+Adventure'),jdecode(''),'/24001.html','true',[],'',''],
	['PAGE','6101',jdecode('The+Books'),jdecode(''),'/6101/index.html','true',[ 
		['PAGE','9601',jdecode('Publisher%26%23x27%3Bs+blurbs'),jdecode(''),'/6101/9601.html','true',[],'',''],
		['PAGE','8901',jdecode('Extract'),jdecode(''),'/6101/8901.html','true',[],'',''],
		['PAGE','11601',jdecode('Order+online'),jdecode(''),'/6101/11601.html','true',[],'','']
	],'',''],
	['PAGE','6122',jdecode('The+Column'),jdecode(''),'/6122/index.html','true',[ 
		['PAGE','35501',jdecode('Corrections'),jdecode(''),'/6122/35501.html','true',[],'','']
	],'',''],
	['PAGE','6143',jdecode('The+Author'),jdecode(''),'/6143.html','true',[],'',''],
	['PAGE','6164',jdecode('The+House'),jdecode(''),'/6164.html','true',[],'',''],
	['PAGE','6185',jdecode('The+Animals'),jdecode(''),'/6185/index.html','true',[ 
		['PAGE','8922',jdecode('Cat'),jdecode(''),'/6185/8922.html','true',[],'',''],
		['PAGE','8943',jdecode('Chickens'),jdecode(''),'/6185/8943.html','true',[],'',''],
		['PAGE','8964',jdecode('Sheep'),jdecode(''),'/6185/8964.html','true',[],'',''],
		['PAGE','8985',jdecode('Fish'),jdecode(''),'/6185/8985.html','true',[],'',''],
		['PAGE','9006',jdecode('Dog'),jdecode(''),'/6185/9006.html','true',[],'','']
	],'',''],
	['PAGE','6206',jdecode('The+Plane'),jdecode(''),'/6206.html','true',[],'',''],
	['PAGE','6227',jdecode('FAQs'),jdecode(''),'/6227.html','true',[],'',''],
	['PAGE','14801',jdecode('Contact'),jdecode(''),'/14801.html','true',[],'',''],
	['PAGE','22301',jdecode('Links'),jdecode(''),'/22301.html','true',[],'',''],
	['PAGE','6269',jdecode('Reader+forum'),jdecode(''),'/6269.html','true',[],'','']];
var siteelementCount=21;
theSitetree.topTemplateName='Draft';
theSitetree.paletteFamily='2E5D32';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10619';
theSitetree.graphicsetId='10612';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='2E5D32';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Draft',
				paletteFamily: 	'2E5D32',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10619',
				graphicsetId: 	'10612',
				contentColor: 	'FFFFFF',
				contentBGColor: '2E5D32',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'92BD96',
				e_color: 		'BFA45F',
				f_color: 		'BFA45F',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '401',
internalId:  '',
customField: '20100706-111335'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6101',
internalId:  '',
customField: '20070720-091518'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6269',
internalId:  '',
customField: '20070717-203102'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6227',
internalId:  '',
customField: '20080419-144611'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6206',
internalId:  '',
customField: '20070718-110832'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6185',
internalId:  '',
customField: '20070717-104352'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6164',
internalId:  '',
customField: '20070718-104039'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6143',
internalId:  '',
customField: '20070716-164429'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6122',
internalId:  '',
customField: '20081229-201259'
};
webappMappings['1003']=webappMappings['1003-anbt10in2m1c113cfbd7e26']={
webappId:    '1003',
documentId:  '6269',
internalId:  'anbt10in2m1c113cfbd7e26',
customField: 'en:GB:'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '401',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22301',
internalId:  '',
customField: '20070925-080528'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8901',
internalId:  '',
customField: '20070721-090050'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9601',
internalId:  '',
customField: '20070720-092246'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8964',
internalId:  '',
customField: '20070718-105905'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8922',
internalId:  '',
customField: '20070718-104609'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8943',
internalId:  '',
customField: '20070718-105257'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8985',
internalId:  '',
customField: '20070717-093939'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9006',
internalId:  '',
customField: '20070718-123636'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14801',
internalId:  '',
customField: '20080419-144138'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11601',
internalId:  '',
customField: '20071211-092900'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '24001',
internalId:  '',
customField: '20070720-090817'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35501',
internalId:  '',
customField: '20070814-112628'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN2M1C';
var companyName   = 'C%27est+La+Folie';
var htmlTitle	  = 'Cest+La+Folie';
var metaKeywords  = 'folie%2C+michael%2C+wright%2C+france%2C+french%2C+rural%2C+renovating%2C+property%2C+smallholding%2C+chickens%2C+sheep%2C+cat%2C+flying%2C+jolibois%2C+limousin%2C+books%2C+aeroplane%2C+Luscombe%2C+abroad%2C+alone%2C+adventure%2C+hero%2C+countryside%2C+ouessant%2C+journalist%2C+Daily+Telegraph%2C+La+Folie%2C+self-sufficiency%2C+hobby+farmer%2C+expat%2C+flying+in+France%2C+Ouessant%2C+michael+wright%2C+la+folie%2C+labrador%2C+house%2C+pilot';
var metaContents  = 'The+story+behind+the+book+and+newspaper+column+of+Cest+La+Folie%2C+a+comic+solo+adventure+in+rural+France%2C+in+which+Michael+Wright+struggles+to+turn+himself+from+wimpish+townie+into+rugged+peasant%2C+renovates+an+old+farm+near+Jolibois%2C+searches+for+a+dishy+copine%2C+and+generally+seeks+to+live+a+more+authentic+life+with+sheep%2C+chickens%2C+a+cat+and+a+vintage+aeroplane';
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();
};
