/* [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','9501',jdecode('Home'),jdecode(''), jdecode('%2F9501.html'), 'true',[],'',''],
	['PAGE','9552',jdecode('About+Us'),jdecode(''), jdecode('%2F9552.html'), 'true',[],'',''],
	['PAGE','9578',jdecode('Interested+In+Fostering'),jdecode(''), jdecode('%2F9578%2Findex.html'), 'true',[ 
		['PAGE','18001',jdecode('Who+can+be+a+foster+carer'),jdecode(''), jdecode('%2F9578%2F18001.html'), 'true',[],'',''],
		['PAGE','18201',jdecode('What+is+foster+care%3F'),jdecode(''), jdecode('%2F9578%2F18201.html'), 'true',[],'',''],
		['PAGE','19401',jdecode('Types+of+fostering'),jdecode(''), jdecode('%2F9578%2F19401.html'), 'true',[],'',''],
		['PAGE','21101',jdecode('Benefits'),jdecode(''), jdecode('%2F9578%2F21101.html'), 'true',[],'','']
	],'',''],
	['PAGE','22801',jdecode('Transferring'),jdecode(''), jdecode('%2F22801.html'), 'true',[],'',''],
	['PAGE','9831',jdecode('Young+People'),jdecode(''), jdecode('%2F9831.html'), 'true',[],'',''],
	['PAGE','9857',jdecode('News+%26+Events'),jdecode(''), jdecode('%2F9857.html'), 'true',[],'',''],
	['PAGE','9883',jdecode('Local+Authorities'),jdecode(''), jdecode('%2F9883.html'), 'true',[],'',''],
	['PAGE','17601',jdecode('Inspection+Report'),jdecode(''), jdecode('%2F17601.html'), 'true',[],'',''],
	['PAGE','9935',jdecode('Training'),jdecode(''), jdecode('%2F9935.html'), 'true',[],'',''],
	['PAGE','9961',jdecode('Job+Vacancies'),jdecode(''), jdecode('%2F9961.html'), 'true',[],'',''],
	['PAGE','9987',jdecode('Contact+Us'),jdecode(''), jdecode('%2F9987%2Findex.html'), 'true',[ 
		['PAGE','10013',jdecode('Enquiries'),jdecode(''), jdecode('%2F9987%2F10013.html'), 'true',[],'',''],
		['PAGE','10039',jdecode('Map'),jdecode(''), jdecode('%2F9987%2F10039.html'), 'true',[],'','']
	],'',''],
	['PAGE','29101',jdecode('Useful+Links'),jdecode(''), jdecode('%2F29101.html'), 'true',[],'',''],
	['PAGE','9604',jdecode(''),jdecode(''), jdecode('%2F9604.html'), 'true',[],'','']];
var siteelementCount=19;
theSitetree.topTemplateName='Angkor';
theSitetree.paletteFamily='879ED6';
theSitetree.keyvisualId='6892';
theSitetree.keyvisualName='kv_6892.jpg';
theSitetree.fontsetId='11211';
theSitetree.graphicsetId='12030';
theSitetree.contentColor='354B86';
theSitetree.contentBGColor='94AAE1';
var localeDef={
  language: 'en',
  country: 'GB'
};
var prodDef={
  wl_name: 'easily_co_uk',
  product: 'WSCSYSSSSLY0XVDH'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Angkor',
				paletteFamily: 	'879ED6',
				keyvisualId: 	'6892',
				keyvisualName: 	'kv_6892.jpg',
				fontsetId: 		'11211',
				graphicsetId: 	'12030',
				contentColor: 	'354B86',
				contentBGColor: '94AAE1',
				a_color: 		'94AAE1',
				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:  '9501',
internalId:  '',
customField: '20110712-102629'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9578',
internalId:  '',
customField: '20110711-111637'
};
webappMappings['7008']=webappMappings['7008-3980']={
webappId:    '7008',
documentId:  '10013',
internalId:  '3980',
customField: 'language:en;country:GB;'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '10039',
internalId:  'location',
customField: 'language:en;country:GB;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9552',
internalId:  '',
customField: '20110712-095151'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22801',
internalId:  '',
customField: '20110512-123852'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9857',
internalId:  '',
customField: '20110512-123941'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9987',
internalId:  '',
customField: '20111129-142757'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10013',
internalId:  '',
customField: '20111129-143829'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10039',
internalId:  '',
customField: '20090220-202258'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9961',
internalId:  '',
customField: '20120113-133032'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18001',
internalId:  '',
customField: '20110712-095755'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18201',
internalId:  '',
customField: '20110712-100617'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21101',
internalId:  '',
customField: '20110512-123818'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '9501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9831',
internalId:  '',
customField: '20090220-202258'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9883',
internalId:  '',
customField: '20110712-101915'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19401',
internalId:  '',
customField: '20110712-101615'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9935',
internalId:  '',
customField: '20110712-102137'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9604',
internalId:  '',
customField: '20090220-192241'
};
webappMappings['1501']=webappMappings['1501-8974332']={
webappId:    '1501',
documentId:  '9501',
internalId:  '8974332',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17601',
internalId:  '',
customField: '20100413-155420'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29101',
internalId:  '',
customField: '20111129-153654'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20INEYXE';
var companyName   = 'Foster+Care+Group+Wales';
var htmlTitle	  = 'Foster+Care+Group+Wales';
var metaKeywords  = 'Foster+Care+Group+Wales%2C+fcgw%2C+fostering%2C+foster+care%2C+Independent+fostering+agency%2C+small+friendly+agency%2C+Respite%2C+Long+term+foster+care%2C+short+term+foster+care%2C+respite+foster+care%2C+Child+care%2C+foster+children%2C+children+in+care.+Fostering+in+wales.+Foster%2C+carers%2C+children+in+care%2C+South+Wales+fostering%2C+';
var metaContents  = 'Foster+Care+Group+Wales%2C+FCGW%2C+Independent+Fostering+agency.+Small+friendly+fostering+agency%2C+24%2F7+support+provided%2C+paid+respite%2C+Training%2C+Excellent+finance+packages%2C+Benefits.+Long+term%2C+short+term+care.';
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();
};

