/* [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(''), jdecode('%2F401.html'), 'true',[],'',''],
	['PAGE','24001',jdecode('The+Adventure'),jdecode(''), jdecode('%2F24001.html'), 'true',[],'',''],
	['PAGE','6101',jdecode('The+Books'),jdecode(''), jdecode('%2F6101%2Findex.html'), 'true',[ 
		['PAGE','9601',jdecode('Publisher%26%23x27%3Bs+blurbs'),jdecode(''), jdecode('%2F6101%2F9601.html'), 'true',[],'',''],
		['PAGE','8901',jdecode('Extract'),jdecode(''), jdecode('%2F6101%2F8901.html'), 'true',[],'',''],
		['PAGE','11601',jdecode('Order+online'),jdecode(''), jdecode('%2F6101%2F11601.html'), 'true',[],'','']
	],'',''],
	['PAGE','6122',jdecode('The+Column'),jdecode(''), jdecode('%2F6122%2Findex.html'), 'true',[ 
		['PAGE','35501',jdecode('Corrections'),jdecode(''), jdecode('%2F6122%2F35501.html'), 'true',[],'','']
	],'',''],
	['PAGE','6143',jdecode('The+Author'),jdecode(''), jdecode('%2F6143.html'), 'true',[],'',''],
	['PAGE','6164',jdecode('The+House'),jdecode(''), jdecode('%2F6164.html'), 'true',[],'',''],
	['PAGE','6185',jdecode('The+Animals'),jdecode(''), jdecode('%2F6185%2Findex.html'), 'true',[ 
		['PAGE','8922',jdecode('Cat'),jdecode(''), jdecode('%2F6185%2F8922.html'), 'true',[],'',''],
		['PAGE','8943',jdecode('Chickens'),jdecode(''), jdecode('%2F6185%2F8943.html'), 'true',[],'',''],
		['PAGE','8964',jdecode('Sheep'),jdecode(''), jdecode('%2F6185%2F8964.html'), 'true',[],'',''],
		['PAGE','8985',jdecode('Fish'),jdecode(''), jdecode('%2F6185%2F8985.html'), 'true',[],'',''],
		['PAGE','9006',jdecode('Dog'),jdecode(''), jdecode('%2F6185%2F9006.html'), 'true',[],'','']
	],'',''],
	['PAGE','6206',jdecode('The+Plane'),jdecode(''), jdecode('%2F6206.html'), 'true',[],'',''],
	['PAGE','6227',jdecode('FAQs'),jdecode(''), jdecode('%2F6227.html'), 'true',[],'',''],
	['PAGE','14801',jdecode('Contact'),jdecode(''), jdecode('%2F14801.html'), 'true',[],'',''],
	['PAGE','22301',jdecode('Links'),jdecode(''), jdecode('%2F22301.html'), 'true',[],'',''],
	['PAGE','6269',jdecode('Reader+forum'),jdecode(''), jdecode('%2F6269.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 prodDef={
  wl_name: 'easily_co_uk',
  product: 'WSCSYSSSSLY0XVDH'
};
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: '20111112-092034'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6101',
internalId:  '',
customField: '20110505-111619'
};
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: '20110505-112619'
};
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: '20100706-151140'
};
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: '20100706-152636'
};
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 webAppHostname = 'cgi.easily.co.uk:80';
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();
};

