/* [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','1801',jdecode('Home'),jdecode(''),'/1801.html','true',[],'',''],
	['PAGE','13901',jdecode('Trust+News+'),jdecode(''),'/13901.html','true',[],'',''],
	['PAGE','1852',jdecode('About+us'),jdecode(''),'/1852.html','true',[],'',''],
	['PAGE','28601',jdecode('Corporate+Members'),jdecode(''),'/28601.html','true',[],'',''],
	['PAGE','4601',jdecode('Current+Members'),jdecode(''),'/4601.html','true',[],'',''],
	['PAGE','1878',jdecode('Committee+Members'),jdecode(''),'/1878.html','true',[],'',''],
	['PAGE','1904',jdecode('Become+a+Member'),jdecode(''),'/1904.html','true',[],'',''],
	['PAGE','21601',jdecode('Trust+Downloads'),jdecode(''),'/21601.html','true',[],'',''],
	['PAGE','1930',jdecode('Links'),jdecode(''),'/1930.html','true',[],'',''],
	['PAGE','1956',jdecode('Contact+Us'),jdecode(''),'/1956.html','true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Lifecycle';
theSitetree.paletteFamily='EF9043';
theSitetree.keyvisualId='4460';
theSitetree.keyvisualName='kv_4460.jpg';
theSitetree.fontsetId='10815';
theSitetree.graphicsetId='11260';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='7F7F7F';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Lifecycle',
				paletteFamily: 	'EF9043',
				keyvisualId: 	'4460',
				keyvisualName: 	'kv_4460.jpg',
				fontsetId: 		'10815',
				graphicsetId: 	'11260',
				contentColor: 	'FFFFFF',
				contentBGColor: '7F7F7F',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1801',
internalId:  '',
customField: '20091213-204316'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1904',
internalId:  '',
customField: '20090318-210243'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1878',
internalId:  '',
customField: '20090805-095919'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1956',
internalId:  '',
customField: '20090116-145638'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1930',
internalId:  '',
customField: '20090210-210257'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1801',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1852',
internalId:  '',
customField: '20090110-162205'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4601',
internalId:  '',
customField: '20090818-211011'
};
webappMappings['1501']=webappMappings['1501-8510499']={
webappId:    '1501',
documentId:  '1801',
internalId:  '8510499',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13901',
internalId:  '',
customField: '20091213-205546'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21601',
internalId:  '',
customField: '20090308-211040'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '28601',
internalId:  '',
customField: '20090626-213147'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20INERTG';
var companyName   = 'Newport+County+afc+Supporters+Trust';
var htmlTitle	  = 'Newport+County+AFC+Supporters+Trust';
var metaKeywords  = 'Newport+County+Supporters+Trust+Football+South+Wales+Exiles+Ironsides+south+wales+soccer+';
var metaContents  = 'Newport+County+AFC+Supporters+Trust+++was+originally+formed+in+2001+but+has+had+a+makeover+this+year+with++new+members+and+fresh+input+from+supporters+from+all+walks+of+life.++While+the+Trust+hopes+to+provide+a+voice+for+supporters+within+our+Football+Club+it+is+also+looking+to+actively+support+the+club+at+grass+roots+and+community+levels';
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();
};
