/* [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','1312',jdecode('Home'),jdecode(''),'/1312.html','true',[],'',''],
	['PAGE','19101',jdecode('Club+News+2010'),jdecode(''),'/19101.html','true',[],'',''],
	['PAGE','25301',jdecode('League+Reports+2010'),jdecode(''),'/25301.html','true',[],'',''],
	['PAGE','25327',jdecode('Club+Competitions+2010'),jdecode(''),'/25327.html','true',[],'',''],
	['PAGE','1354',jdecode('Bowling+Gallery'),jdecode(''),'/1354.html','true',[],'',''],
	['PAGE','1386',jdecode('Club+History'),jdecode(''),'/1386.html','true',[],'',''],
	['PAGE','16301',jdecode('Club+Champions+2010'),jdecode(''),'/16301.html','true',[],'',''],
	['PAGE','1333',jdecode('Archived+News'),jdecode(''),'/1333.html','true',[],'',''],
	['PAGE','16601',jdecode('150th+Anniversary+Dinner'),jdecode(''),'/16601.html','true',[],'',''],
	['PAGE','14601',jdecode('Club+Sponsors'),jdecode(''),'/14601.html','true',[],'',''],
	['PAGE','7404',jdecode('Guestbook'),jdecode(''),'/7404.html','true',[],'',''],
	['PAGE','1407',jdecode('Office+Bearers+2010'),jdecode(''),'/1407.html','true',[],'',''],
	['PAGE','7430',jdecode('Contact'),jdecode(''),'/7430.html','true',[],'',''],
	['PAGE','20201',jdecode('Find+Us'),jdecode(''),'/20201.html','true',[],'','']];
var siteelementCount=14;
theSitetree.topTemplateName='Sportfan2';
theSitetree.paletteFamily='D8D5FD';
theSitetree.keyvisualId='10135';
theSitetree.keyvisualName='kv_10135.jpg';
theSitetree.fontsetId='21089';
theSitetree.graphicsetId='13185';
theSitetree.contentColor='291EBB';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Sportfan2',
				paletteFamily: 	'D8D5FD',
				keyvisualId: 	'10135',
				keyvisualName: 	'kv_10135.jpg',
				fontsetId: 		'21089',
				graphicsetId: 	'13185',
				contentColor: 	'291EBB',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['7060']=webappMappings['7060-8e5277a4bf857abafe6677ab1d18335f']={
webappId:    '7060',
documentId:  '1354',
internalId:  '8e5277a4bf857abafe6677ab1d18335f',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7404',
internalId:  '',
customField: '20090623-231201'
};
webappMappings['7008']=webappMappings['7008-4988']={
webappId:    '7008',
documentId:  '7430',
internalId:  '4988',
customField: 'language:en;country:GB;'
};
webappMappings['7002']=webappMappings['7002-2274']={
webappId:    '7002',
documentId:  '7404',
internalId:  '2274',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1312',
internalId:  '',
customField: '20100701-230158'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1333',
internalId:  '',
customField: '20090917-123705'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1354',
internalId:  '',
customField: '20090623-231340'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1312',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1386',
internalId:  '',
customField: '20100503-212443'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1407',
internalId:  '',
customField: '20100331-215608'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7430',
internalId:  '',
customField: '20100503-212123'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14601',
internalId:  '',
customField: '20100615-231656'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16301',
internalId:  '',
customField: '20100615-230801'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16601',
internalId:  '',
customField: '20090917-133848'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19101',
internalId:  '',
customField: '20100615-230538'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '20201',
internalId:  'location',
customField: 'language:en;country:GB;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20201',
internalId:  '',
customField: '20100402-211601'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25301',
internalId:  '',
customField: '20100701-230013'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25327',
internalId:  '',
customField: '20100615-230240'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN3KGC';
var companyName   = 'Welcome+To+The+Jedburgh+Bowling+Club+Website%21';
var htmlTitle	  = 'The+Jedburgh+Bowling+Club+Website%21+Is+Online%21';
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();
};
