/* [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','501',jdecode('Home'),jdecode(''),'/501.html','true',[],'',''],
	['PAGE','1701',jdecode('Bear+Talk'),jdecode(''),'/1701.html','true',[],'',''],
	['PAGE','1722',jdecode('SPL+Stuff'),jdecode(''),'/1722.html','true',[],'',''],
	['PAGE','1743',jdecode('90+Minutes'),jdecode(''),'/1743.html','true',[],'',''],
	['PAGE','1764',jdecode('Legends+in+Blue'),jdecode(''),'/1764.html','true',[],'',''],
	['PAGE','1785',jdecode('A+Time+to+Remember'),jdecode(''),'/1785.html','true',[],'',''],
	['PAGE','1806',jdecode('Order+of+the+Prat'),jdecode(''),'/1806.html','true',[],'',''],
	['PAGE','22301',jdecode('It%26%23x27%3Bs+a+Fact'),jdecode(''),'/22301.html','true',[],'',''],
	['PAGE','3006',jdecode('Guestbook'),jdecode(''),'/3006/index.html','true',[ 
		['PAGE','3001',jdecode('Read+Guestbook'),jdecode(''),'/3006/3001.html','false',[],'','']
	],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Checkered';
theSitetree.paletteFamily='414883';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='11076';
theSitetree.graphicsetId='11849';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='888787';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Checkered',
				paletteFamily: 	'414883',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'11076',
				graphicsetId: 	'11849',
				contentColor: 	'FFFFFF',
				contentBGColor: '888787',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['1002']=webappMappings['1002-3006anbt10inxhu3']={
webappId:    '1002',
documentId:  '3006',
internalId:  '3006anbt10inxhu3',
customField: 'icq=false'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20090923-165945'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1701',
internalId:  '',
customField: '20100722-141821'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22301',
internalId:  '',
customField: '20100112-130316'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1722',
internalId:  '',
customField: '20100704-142230'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1743',
internalId:  '',
customField: '20100704-143611'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1764',
internalId:  '',
customField: '20090920-170623'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1785',
internalId:  '',
customField: '20090920-170727'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1806',
internalId:  '',
customField: '20100704-143931'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3006',
internalId:  '',
customField: '20070510-151137'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3001',
internalId:  '',
customField: '20070510-151137'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10INXHU3';
var companyName   = 'FRIENDS+OF+RANGERS';
var htmlTitle	  = 'Bob+MacCallum+Friends+of+Glasgow+Rangers+Football';
var metaKeywords  = 'META+name%3Dkeywords+content%3Dglasgow+rangers+football+club%2Crangers+football+team%2Cglasgow+rangers+picture%2Cglasgow+rangers+logo%2Crangers+online%2Crangers+downloads%2Crangers+pictures%2Cglasgow+rangers+players%2Cspl+scores%2Cspl+football%2Cspl+fixtures%2Cspl+forums%2Cscottish+premier+league+results%2Cscottish+football+programmes%2Cscottish+premier+league+football%2Cscottish+football+news%2Cscotland+football+scores%2Cscotland+football+results%2Cscottish+football+scores%2Cscottish+football+fixtures%2Cscottish+football+team%2Cgers+forum%2CFriends+of+Rangers%2CBob+A.+Maccallum%2C+www.friendsofrangers.co.uk';
var metaContents  = 'Information+and+discussion+about+Glasgow+Rangers+football+club+present+and+past';
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();
};
