/* [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','4601',jdecode('Home'),jdecode(''), jdecode('%2F4601.html'), 'true',[],'',''],
	['PAGE','6401',jdecode('EYFS+AND+F.S.'),jdecode(''), jdecode('%2F6401.html'), 'true',[],'',''],
	['PAGE','7101',jdecode('K.S.+1'),jdecode(''), jdecode('%2F7101.html'), 'true',[],'',''],
	['PAGE','7127',jdecode('K.S.+2'),jdecode(''), jdecode('%2F7127.html'), 'true',[],'',''],
	['PAGE','7201',jdecode('CONFERENCES'),jdecode(''), jdecode('%2F7201.html'), 'true',[],'',''],
	['PAGE','7227',jdecode('REVIEWS'),jdecode(''), jdecode('%2F7227.html'), 'true',[],'',''],
	['PAGE','7253',jdecode('DATES+and+FEES'),jdecode(''), jdecode('%2F7253.html'), 'true',[],'',''],
	['PAGE','7305',jdecode('SHOP'),jdecode(''), jdecode('%2F7305.html'), 'true',[],'',''],
	['PAGE','7279',jdecode('DOWNLOADS'),jdecode(''), jdecode('%2F7279.html'), 'true',[],'',''],
	['PAGE','9601',jdecode('FOLK+MUSIC'),jdecode(''), jdecode('%2F9601.html'), 'true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Current';
theSitetree.paletteFamily='6866BD';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10397';
theSitetree.graphicsetId='10596';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='6866BD';
var localeDef={
  language: 'en',
  country: 'GB'
};
var prodDef={
  wl_name: 'easily_co_uk',
  product: 'WSCSYSSSSLY0XVD7'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Current',
				paletteFamily: 	'6866BD',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10397',
				graphicsetId: 	'10596',
				contentColor: 	'FFFFFF',
				contentBGColor: '6866BD',
				a_color: 		'6866BD',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'C8C8C8',
				e_color: 		'8C8B8B',
				f_color: 		'8C8B8B',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4601',
internalId:  '',
customField: '20120131-123447'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4601',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7201',
internalId:  '',
customField: '20091123-162449'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6401',
internalId:  '',
customField: '20091124-144516'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7101',
internalId:  '',
customField: '20091123-162400'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7127',
internalId:  '',
customField: '20110710-160431'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7227',
internalId:  '',
customField: '20120131-122026'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7253',
internalId:  '',
customField: '20120131-124502'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7305',
internalId:  '',
customField: '20120203-133714'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7279',
internalId:  '',
customField: '20110710-171907'
};
webappMappings['1501']=webappMappings['1501-12634981']={
webappId:    '1501',
documentId:  '4601',
internalId:  '12634981',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9601',
internalId:  '',
customField: '20110710-171952'
};
webappMappings['4001']=webappMappings['4001-10801888']={
webappId:    '4001',
documentId:  '7305',
internalId:  '10801888',
customField: 'language:en;country:GB;'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN34ZL';
var companyName   = 'TONY+WILSON++++++STORYTELLER';
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();
};

