/* [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','1431',jdecode('Primary+Care+Mental+Health'),jdecode(''), jdecode('%2F1431.html'), 'true',[],'',''],
	['PAGE','20201',jdecode('Cognitive+linguistics+and+CBT'),jdecode(''), jdecode('%2F20201.html'), 'true',[],'',''],
	['PAGE','20227',jdecode('General+Practice'),jdecode(''), jdecode('%2F20227.html'), 'true',[],'',''],
	['PAGE','23001',jdecode('Publications'),jdecode(''), jdecode('%2F23001.html'), 'true',[],'',''],
	['PAGE','20253',jdecode('Harps%2C+folk+music%2C+community+radio+'),jdecode(''), jdecode('%2F20253.html'), 'true',[],'',''],
	['PAGE','26101',jdecode('Tales+for+our+times'),jdecode(''), jdecode('%2F26101%2Findex.html'), 'true',[ 
		['PAGE','26401',jdecode('The+Snake+and+the+King%26%23x27%3Bs+Dream'),jdecode(''), jdecode('%2F26101%2F26401.html'), 'true',[],'','']
	],'',''],
	['PAGE','20279',jdecode('Terri+Eynon%26%23x27%3Bs+Blog'),jdecode(''), jdecode('%2F20279.html'), 'true',[],'',''],
	['PAGE','20305',jdecode('Alderoak'),jdecode(''), jdecode('%2F20305.html'), 'true',[],'',''],
	['PAGE','20331',jdecode('Contact'),jdecode(''), jdecode('%2F20331.html'), 'true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Valiant';
theSitetree.paletteFamily='D43F3F';
theSitetree.keyvisualId='9810';
theSitetree.keyvisualName='kv_9810.jpg';
theSitetree.fontsetId='17626';
theSitetree.graphicsetId='13031';
theSitetree.contentColor='646464';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var prodDef={
  wl_name: 'easily_co_uk_ce',
  product: 'WSCSYSSSSLY0XKQS'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Valiant',
				paletteFamily: 	'D43F3F',
				keyvisualId: 	'9810',
				keyvisualName: 	'kv_9810.jpg',
				fontsetId: 		'17626',
				graphicsetId: 	'13031',
				contentColor: 	'646464',
				contentBGColor: 'FFFFFF',
				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:  '20279',
internalId:  '',
customField: '20110807-212328'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1431',
internalId:  '',
customField: '20101012-101329'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20227',
internalId:  '',
customField: '20120116-170449'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20253',
internalId:  '',
customField: '20101012-150446'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20201',
internalId:  '',
customField: '20101012-113805'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1431',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-6341899']={
webappId:    '1501',
documentId:  '1431',
internalId:  '6341899',
customField: '1501'
};
webappMappings['7050']=webappMappings['7050-4299']={
webappId:    '7050',
documentId:  '20279',
internalId:  '4299',
customField: 'language:en;country:GB;'
};
webappMappings['7002']=webappMappings['7002-3989']={
webappId:    '7002',
documentId:  '20305',
internalId:  '3989',
customField: 'language:en;country:GB;'
};
webappMappings['7008']=webappMappings['7008-7975']={
webappId:    '7008',
documentId:  '20331',
internalId:  '7975',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20305',
internalId:  '',
customField: '20101212-172417'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20331',
internalId:  '',
customField: '20110807-211922'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23001',
internalId:  '',
customField: '20120116-171000'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '26101',
internalId:  '',
customField: '20110809-112550'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '26401',
internalId:  '',
customField: '20110809-113149'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20IN2LBX';
var companyName   = 'Dr.+Terri+Eynon+MBChB+MRCPsych+DFFP+MRCGP+';
var htmlTitle	  = 'Dr+Theresa+Eynon+MB+ChB+MRCPsych+DFFP+MRCGP';
var metaKeywords  = 'Leicester+County+Rutland+primary+care+trust+alderoak+Terri+Eynon+Theresa%0D%0Acognitive+linguistics%2C+embodiment+theory%2C+cognitive+behaviour+therapy%2C+IAPT%2C+Good+Thinking+Therapy+Service%2C+general+practice%2C+undifferentiated+consultation+model+biopsychosocial+';
var metaContents  = 'Dr.+Terri+Eynon+is+a+GP+with+a+special+interest+in+promoting+the+use+of+cognitive+behavioural+models+in+the+undifferentiated+primary+care+consultation.+';
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();
};

