/* [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','11301',jdecode('Home'),jdecode(''),'/11301.html','true',[],'',''],
	['PAGE','11352',jdecode('The+Excuse-eator'),jdecode(''),'/11352/index.html','true',[ 
		['PAGE','11508',jdecode('Training+undertaken'),jdecode(''),'/11352/11508.html','true',[],'','']
	],'',''],
	['PAGE','11378',jdecode('Organisations'),jdecode(''),'/11378/index.html','true',[ 
		['PAGE','39201',jdecode('Leaving+Care'),jdecode(''),'/11378/39201.html','true',[],'',''],
		['PAGE','39227',jdecode('Youth+Offending'),jdecode(''),'/11378/39227.html','true',[],'',''],
		['PAGE','39253',jdecode('Charities'),jdecode(''),'/11378/39253.html','true',[],'','']
	],'',''],
	['PAGE','29601',jdecode('Parents'),jdecode(''),'/29601/index.html','true',[ 
		['PAGE','29627',jdecode('121+at+home+'),jdecode(''),'/29601/29627.html','true',[],'',''],
		['PAGE','29653',jdecode('121+phone+coaching'),jdecode(''),'/29601/29653.html','true',[],'',''],
		['PAGE','30101',jdecode('How+coaching+works'),jdecode(''),'/29601/30101.html','true',[],'',''],
		['PAGE','37801',jdecode('How+to+pay'),jdecode(''),'/29601/37801.html','false',[],'','']
	],'',''],
	['PAGE','11560',jdecode('What+people+say'),jdecode(''),'/11560.html','true',[],'',''],
	['PAGE','11801',jdecode('Guest+book'),jdecode(''),'/11801.html','true',[],'',''],
	['PAGE','37827',jdecode('Community'),jdecode(''),'/37827.html','true',[],'',''],
	['PAGE','11534',jdecode('My+blog'),jdecode(''),'/11534.html','true',[],'',''],
	['PAGE','37701',jdecode('Search+website'),jdecode(''),'/37701.html','true',[],'',''],
	['PAGE','13401',jdecode('Useful+links'),jdecode(''),'/13401.html','true',[],'',''],
	['PAGE','11586',jdecode('Contact'),jdecode(''),'/11586/index.html','true',[ 
		['PAGE','27101',jdecode('Quick+Links'),jdecode(''),'/11586/27101.html','true',[],'','']
	],'','']];
var siteelementCount=20;
theSitetree.topTemplateName='Comedy';
theSitetree.paletteFamily='7F64A5';
theSitetree.keyvisualId='2805';
theSitetree.keyvisualName='blanko.jpg';
theSitetree.fontsetId='10422';
theSitetree.graphicsetId='10723';
theSitetree.contentColor='F1EEF5';
theSitetree.contentBGColor='957FB5';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Comedy',
				paletteFamily: 	'7F64A5',
				keyvisualId: 	'2805',
				keyvisualName: 	'blanko.jpg',
				fontsetId: 		'10422',
				graphicsetId: 	'10723',
				contentColor: 	'F1EEF5',
				contentBGColor: '957FB5',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'644D85',
				e_color: 		'644D85',
				f_color: 		'644D85',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29653',
internalId:  '',
customField: '20100201-102832'
};
webappMappings['7050']=webappMappings['7050-3524']={
webappId:    '7050',
documentId:  '11534',
internalId:  '3524',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11301',
internalId:  '',
customField: '20100129-132142'
};
webappMappings['1002']=webappMappings['1002-11801anbt10in3qp6']={
webappId:    '1002',
documentId:  '11801',
internalId:  '11801anbt10in3qp6',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11378',
internalId:  '',
customField: '20100201-104427'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30101',
internalId:  '',
customField: '20100201-103024'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29601',
internalId:  '',
customField: '20100201-104527'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11352',
internalId:  '',
customField: '20100201-152207'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11560',
internalId:  '',
customField: '20100201-103101'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11508',
internalId:  '',
customField: '20100201-104337'
};
webappMappings['8002']=webappMappings['8002-search']={
webappId:    '8002',
documentId:  '37701',
internalId:  'search',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29627',
internalId:  '',
customField: '20100201-104624'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11534',
internalId:  '',
customField: '20100129-202141'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11801',
internalId:  '',
customField: '20100129-202117'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11586',
internalId:  '',
customField: '20100201-110118'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13401',
internalId:  '',
customField: '20100201-104726'
};
webappMappings['7008']=webappMappings['7008-6603']={
webappId:    '7008',
documentId:  '11586',
internalId:  '6603',
customField: 'language:en;country:GB;'
};
webappMappings['1501']=webappMappings['1501-11120631']={
webappId:    '1501',
documentId:  '11301',
internalId:  '11120631',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27101',
internalId:  '',
customField: '20100201-104036'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '37701',
internalId:  '',
customField: '20100201-110555'
};
webappMappings['4001']=webappMappings['4001-11129743']={
webappId:    '4001',
documentId:  '37801',
internalId:  '11129743',
customField: 'language:en;country:GB;'
};
webappMappings['1003']=webappMappings['1003-anbt10in3qp612689451eec']={
webappId:    '1003',
documentId:  '37827',
internalId:  'anbt10in3qp612689451eec',
customField: 'en:GB'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '37801',
internalId:  '',
customField: '20100201-145330'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '37827',
internalId:  '',
customField: '20100201-112313'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39201',
internalId:  '',
customField: '20100201-151859'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39227',
internalId:  '',
customField: '20100201-152341'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39253',
internalId:  '',
customField: '20100201-152657'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN3QP6';
var companyName   = '+The+Excuse-eator+No+More+Excuses';
var htmlTitle	  = '';
var metaKeywords  = '';
var metaContents  = '';
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();
};
