/* [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('Homepage'),jdecode(''),'/501.html','true',[],'',''],
	['PAGE','4901',jdecode('About+Us'),jdecode(''),'/4901.html','true',[],'',''],
	['PAGE','5048',jdecode('Club+News'),jdecode(''),'/5048/index.html','true',[ 
		['PAGE','113301',jdecode('Maggot%26%23x27%3Bs+Mouth'),jdecode(''),'/5048/113301.html','true',[],'','']
	],'',''],
	['PAGE','4922',jdecode('Race+Diary'),jdecode(''),'/4922.html','true',[],'',''],
	['PAGE','5069',jdecode('Race+Results'),jdecode(''),'/5069.html','true',[],'',''],
	['PAGE','43101',jdecode('Club+Records'),jdecode(''),'/43101.html','true',[],'',''],
	['PAGE','14401',jdecode('Nairn+Half+Marathon'),jdecode(''),'/14401/index.html','true',[ 
		['PAGE','130701',jdecode('2010+Results'),jdecode(''),'/14401/130701.html','true',[],'',''],
		['PAGE','5027',jdecode('Photographs+2009'),jdecode(''),'/14401/5027.html','true',[],'',''],
		['PAGE','67201',jdecode('Photographs+2008'),jdecode(''),'/14401/67201.html','true',[],'',''],
		['PAGE','63501',jdecode('Results+2008'),jdecode(''),'/14401/63501.html','true',[],'','']
	],'',''],
	['PAGE','4964',jdecode('Nairn+10k'),jdecode(''),'/4964/index.html','true',[ 
		['PAGE','119001',jdecode('2010'),jdecode(''),'/4964/119001.html','true',[],'',''],
		['PAGE','87201',jdecode('2009'),jdecode(''),'/4964/87201.html','true',[],'',''],
		['PAGE','49501',jdecode('2008'),jdecode(''),'/4964/49501.html','true',[],'',''],
		['PAGE','4985',jdecode('2007'),jdecode(''),'/4964/4985.html','true',[],'','']
	],'',''],
	['PAGE','109001',jdecode('Turkey+Trot'),jdecode(''),'/109001.html','true',[],'',''],
	['PAGE','5090',jdecode('Photo+Album'),jdecode(''),'/5090/index.html','true',[ 
		['PAGE','27401',jdecode('Half+Marathon+07'),jdecode(''),'/5090/27401.html','true',[],'','']
	],'',''],
	['PAGE','13201',jdecode('Links'),jdecode(''),'/13201.html','true',[],'',''],
	['PAGE','43122',jdecode('Archive'),jdecode(''),'/43122/index.html','true',[ 
		['PAGE','76901',jdecode('2008'),jdecode(''),'/43122/76901.html','true',[],'','']
	],'','']];
var siteelementCount=23;
theSitetree.topTemplateName='Enjoy';
theSitetree.paletteFamily='FF9F21';
theSitetree.keyvisualId='2255';
theSitetree.keyvisualName='reise5.jpg';
theSitetree.fontsetId='366';
theSitetree.graphicsetId='418';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FF9F21';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Enjoy',
				paletteFamily: 	'FF9F21',
				keyvisualId: 	'2255',
				keyvisualName: 	'reise5.jpg',
				fontsetId: 		'366',
				graphicsetId: 	'418',
				contentColor: 	'000000',
				contentBGColor: 'FF9F21',
				a_color: 		'FF9F21',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20100822-131921'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4964',
internalId:  '',
customField: '20100328-120819'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '119001',
internalId:  '',
customField: '20100415-181017'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5027',
internalId:  '',
customField: '20090906-193658'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5090',
internalId:  '',
customField: '20100102-164411'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '76901',
internalId:  '',
customField: '20090226-222405'
};
webappMappings['1501']=webappMappings['1501-2360016']={
webappId:    '1501',
documentId:  '501',
internalId:  '2360016',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4901',
internalId:  '',
customField: '20100415-180559'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4922',
internalId:  '',
customField: '20100807-104036'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '113301',
internalId:  '',
customField: '20100402-193314'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4985',
internalId:  '',
customField: '20070625-224109'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5048',
internalId:  '',
customField: '20100902-222801'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5069',
internalId:  '',
customField: '20100116-190839'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '49501',
internalId:  '',
customField: '20100406-203619'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13201',
internalId:  '',
customField: '20100225-224119'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14401',
internalId:  '',
customField: '20100822-132617'
};
webappMappings['7060']=webappMappings['7060-52e48ce46774086b5bb69143ad7d0076']={
webappId:    '7060',
documentId:  '27401',
internalId:  '52e48ce46774086b5bb69143ad7d0076',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27401',
internalId:  '',
customField: '20070914-183956'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '43101',
internalId:  '',
customField: '20100719-214048'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '43122',
internalId:  '',
customField: '20080127-160431'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '130701',
internalId:  '',
customField: '20100822-135618'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '63501',
internalId:  '',
customField: '20080922-132329'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '67201',
internalId:  '',
customField: '20081017-194407'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '109001',
internalId:  '',
customField: '20100406-205028'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '87201',
internalId:  '',
customField: '20090313-194038'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN2924';
var companyName   = 'Nairn+Road+Runners';
var htmlTitle	  = 'Nairn+Road+Runners';
var metaKeywords  = 'Nairn%2C+road+running%2C+half+marathon%2C+10k%2C+races%2C+road+races%2C+highlands%2C+running+clubs%2C+off-road%2C+cross+country';
var metaContents  = 'Road+running+club+located+in+Nairn';
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();
};
