/* [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','1410',jdecode('Home'),jdecode(''),'/1410.html','true',[],'',''],
	['PAGE','14601',jdecode('Books+and+Articles'),jdecode(''),'/14601.html','true',[],'',''],
	['PAGE','8601',jdecode('LDN+Now+Blog'),jdecode(''),'/8601.html','true',[],'',''],
	['PAGE','17327',jdecode('LDNNow+Day'),jdecode(''),'/17327.html','true',[],'',''],
	['PAGE','21901',jdecode('Useful+Links'),jdecode(''),'/21901.html','true',[],'',''],
	['PAGE','27101',jdecode('List+of+Pharmacies'),jdecode(''),'/27101.html','true',[],'',''],
	['PAGE','1484',jdecode('Guestbook'),jdecode(''),'/1484.html','true',[],'',''],
	['PAGE','1505',jdecode('Contact'),jdecode(''),'/1505.html','true',[],'',''],
	['PAGE','17301',jdecode('List+of+LDN+conditions'),jdecode(''),'/17301.html','true',[],'',''],
	['PAGE','1431',jdecode('About+Us'),jdecode(''),'/1431.html','true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Citadel';
theSitetree.paletteFamily='414E8C';
theSitetree.keyvisualId='8166';
theSitetree.keyvisualName='kv_8166.jpg';
theSitetree.fontsetId='17011';
theSitetree.graphicsetId='12397';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='414E8C';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Citadel',
				paletteFamily: 	'414E8C',
				keyvisualId: 	'8166',
				keyvisualName: 	'kv_8166.jpg',
				fontsetId: 		'17011',
				graphicsetId: 	'12397',
				contentColor: 	'FFFFFF',
				contentBGColor: '414E8C',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8601',
internalId:  '',
customField: '20090501-003138'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14601',
internalId:  '',
customField: '20090916-164304'
};
webappMappings['7002']=webappMappings['7002-1931']={
webappId:    '7002',
documentId:  '1484',
internalId:  '1931',
customField: 'language:en;country:GB;'
};
webappMappings['7008']=webappMappings['7008-4398']={
webappId:    '7008',
documentId:  '1505',
internalId:  '4398',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1410',
internalId:  '',
customField: '20100821-011012'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1431',
internalId:  '',
customField: '20100805-185354'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1410',
internalId:  '1006',
customField: '1006'
};
webappMappings['7050']=webappMappings['7050-2159']={
webappId:    '7050',
documentId:  '8601',
internalId:  '2159',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1484',
internalId:  '',
customField: '20090413-131114'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1505',
internalId:  '',
customField: '20090501-003216'
};
webappMappings['7070']=webappMappings['7070-169']={
webappId:    '7070',
documentId:  '17327',
internalId:  '169',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17301',
internalId:  '',
customField: '20090801-194021'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17327',
internalId:  '',
customField: '20090917-180119'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27101',
internalId:  '',
customField: '20100526-221205'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21901',
internalId:  '',
customField: '20100729-224804'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20INEH9F';
var companyName   = 'LDN+Now';
var htmlTitle	  = 'Low+Dose+Naltrexone';
var metaKeywords  = 'LDN+Cancer+MS+Crohns+Lupus+HIV+AIDS+Naltrexone+Arthritis+Rheumatoid+Autoimmune+Parkinsons+Fybromyalgia+Autism+Lyme+Multiple+Sclerosis+CFS+Syndrome';
var metaContents  = 'LDN+Resources+site';
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();
};
