/* [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','5001',jdecode('Home'),jdecode(''),'/5001.html','true',[],'',''],
	['PAGE','5052',jdecode('Meet+the+team'),jdecode(''),'/5052.html','true',[],'',''],
	['PAGE','5078',jdecode('Contact+Us'),jdecode(''),'/5078.html','true',[],'',''],
	['PAGE','5234',jdecode('How+We+Work'),jdecode(''),'/5234.html','true',[],'',''],
	['PAGE','10701',jdecode('Market+commentary'),jdecode(''),'/10701.html','true',[],'',''],
	['PAGE','9301',jdecode('Estate+Planning+%26+Wills'),jdecode(''),'/9301.html','true',[],'',''],
	['PAGE','9701',jdecode('Mortgages'),jdecode(''),'/9701.html','true',[],'',''],
	['PAGE','38601',jdecode('Mortgage+commentary'),jdecode(''),'/38601/index.html','true',[ 
		['PAGE','9327',jdecode('ISA%26%23x27%3Bs'),jdecode(''),'/38601/9327.html','false',[],'',''],
		['PAGE','9353',jdecode('Guaranteed+Products'),jdecode(''),'/38601/9353.html','false',[],'','']
	],'',''],
	['PAGE','5156',jdecode('Pensions'),jdecode(''),'/5156/index.html','true',[ 
		['PAGE','5182',jdecode('Personal+Accounts'),jdecode(''),'/5156/5182.html','false',[],'',''],
		['PAGE','5208',jdecode('The+State+Pensions'),jdecode(''),'/5156/5208.html','false',[],'','']
	],'',''],
	['PAGE','5260',jdecode('Protection'),jdecode(''),'/5260/index.html','true',[ 
		['PAGE','8101',jdecode('-+for+the+family'),jdecode(''),'/5260/8101.html','true',[],'',''],
		['PAGE','8127',jdecode('-+for+your+business'),jdecode(''),'/5260/8127.html','true',[],'',''],
		['PAGE','8401',jdecode('-+for+your+income'),jdecode(''),'/5260/8401.html','true',[],'','']
	],'',''],
	['PAGE','17101',jdecode('General+Insurance'),jdecode(''),'/17101.html','true',[],'',''],
	['PAGE','5286',jdecode('Savings+%26+Investments'),jdecode(''),'/5286.html','true',[],'',''],
	['PAGE','12701',jdecode('Structured+Products'),jdecode(''),'/12701.html','true',[],'',''],
	['PAGE','9379',jdecode('Useful+Links'),jdecode(''),'/9379.html','true',[],'',''],
	['PAGE','5312',jdecode('Testimonials'),jdecode(''),'/5312.html','true',[],'','']];
var siteelementCount=22;
theSitetree.topTemplateName='Movement';
theSitetree.paletteFamily='003390';
theSitetree.keyvisualId='1819';
theSitetree.keyvisualName='kv_dummy.jpg';
theSitetree.fontsetId='289';
theSitetree.graphicsetId='353';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='003390';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Movement',
				paletteFamily: 	'003390',
				keyvisualId: 	'1819',
				keyvisualName: 	'kv_dummy.jpg',
				fontsetId: 		'289',
				graphicsetId: 	'353',
				contentColor: 	'FFFFFF',
				contentBGColor: '003390',
				a_color: 		'003390',
				b_color: 		'000000',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5001',
internalId:  '',
customField: '20100803-163807'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5052',
internalId:  '',
customField: '20100223-151250'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5078',
internalId:  '',
customField: '20100203-125855'
};
webappMappings['7008']=webappMappings['7008-4255']={
webappId:    '7008',
documentId:  '5078',
internalId:  '4255',
customField: 'language:en;country:GB;'
};
webappMappings['1501']=webappMappings['1501-9223032']={
webappId:    '1501',
documentId:  '5001',
internalId:  '9223032',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10701',
internalId:  '',
customField: '20100813-084414'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38601',
internalId:  '',
customField: '20100818-112517'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5156',
internalId:  '',
customField: '20090511-100256'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5182',
internalId:  '',
customField: '20090324-065417'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5208',
internalId:  '',
customField: '20090324-065417'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5234',
internalId:  '',
customField: '20090511-100018'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5260',
internalId:  '',
customField: '20090511-100355'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5286',
internalId:  '',
customField: '20090324-164224'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5312',
internalId:  '',
customField: '20090511-100438'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17101',
internalId:  '',
customField: '20090505-174217'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8101',
internalId:  '',
customField: '20090324-140514'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8127',
internalId:  '',
customField: '20090324-140832'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8401',
internalId:  '',
customField: '20090324-141123'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9379',
internalId:  '',
customField: '20100818-174608'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9701',
internalId:  '',
customField: '20090511-100215'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9301',
internalId:  '',
customField: '20090521-081809'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9327',
internalId:  '',
customField: '20090324-164906'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9353',
internalId:  '',
customField: '20090324-164906'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12701',
internalId:  '',
customField: '20091208-151212'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20INEPW2';
var companyName   = 'The+FG+%28IFA%29+Ltd';
var htmlTitle	  = '';
var metaKeywords  = 'HEADBenfleet%2CFinancial%2CTheFG%2CBasildon%2CCanvey%2CIsland%2CIndependent%2CStructured%2CProducts%2FHEAD';
var metaContents  = 'HEADIndividual++and+Corporate+Independent+Financial+Advice%2FHEAD';
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();
};
