/* [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','301',jdecode('Home'),jdecode(''),'/301.html','true',[],'',''],
	['PAGE','108801',jdecode('Vote'),jdecode(''),'/108801.html','false',[],'',''],
	['PAGE','6501',jdecode('News'),jdecode(''),'/6501.html','true',[],'',''],
	['PAGE','47901',jdecode('Fixtures+'),jdecode(''),'/47901/index.html','true',[ 
		['PAGE','47922',jdecode('Ardencaple+XI+2010'),jdecode(''),'/47901/47922.html','true',[],'',''],
		['PAGE','47943',jdecode('Sunday+League+2010'),jdecode(''),'/47901/47943.html','true',[],'','']
	],'',''],
	['PAGE','111601',jdecode('Player+profiles++**NEW**'),jdecode(''),'/111601/index.html','true',[ 
		['PAGE','111801',jdecode('A+N+Other'),jdecode(''),'/111601/111801.html','false',[],'','']
	],'',''],
	['PAGE','22801',jdecode('Social+Diary'),jdecode(''),'/22801.html','true',[],'',''],
	['PAGE','7901',jdecode('Junior+Section'),jdecode(''),'/7901.html','true',[],'',''],
	['PAGE','4985',jdecode('Merchandise'),jdecode(''),'/4985.html','true',[],'',''],
	['PAGE','84101',jdecode('SCU+Trophy+2008'),jdecode(''),'/84101.html','true',[],'',''],
	['PAGE','36701',jdecode('Photos'),jdecode(''),'/36701.html','true',[],'',''],
	['PAGE','5006',jdecode('Sponsors'),jdecode(''),'/5006.html','true',[],'',''],
	['PAGE','5027',jdecode('Location'),jdecode(''),'/5027.html','true',[],'',''],
	['PAGE','5048',jdecode('Links'),jdecode(''),'/5048.html','true',[],'',''],
	['PAGE','5069',jdecode('Contact'),jdecode(''),'/5069.html','true',[],'',''],
	['PAGE','6770',jdecode('Guestbook'),jdecode(''),'/6770.html','true',[],'','']];
var siteelementCount=18;
theSitetree.topTemplateName='Alpha';
theSitetree.paletteFamily='479949';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10461';
theSitetree.graphicsetId='10895';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Alpha',
				paletteFamily: 	'479949',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10461',
				graphicsetId: 	'10895',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'479949',
				e_color: 		'479949',
				f_color: 		'479949',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '301',
internalId:  '1006',
customField: '1006'
};
webappMappings['1002']=webappMappings['1002-6770anbt10inxh9x']={
webappId:    '1002',
documentId:  '6770',
internalId:  '6770anbt10inxh9x',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '111601',
internalId:  '',
customField: '20100209-104319'
};
webappMappings['1501']=webappMappings['1501-1717393']={
webappId:    '1501',
documentId:  '301',
internalId:  '1717393',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '301',
internalId:  '',
customField: '20100707-093420'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22801',
internalId:  '',
customField: '20100708-152426'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6501',
internalId:  '',
customField: '20100705-151033'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '84101',
internalId:  '',
customField: '20090427-210024'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '111801',
internalId:  '',
customField: '20100209-105734'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7901',
internalId:  '',
customField: '20080917-123157'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4985',
internalId:  '',
customField: '20081003-203022'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5006',
internalId:  '',
customField: '20090427-135022'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5027',
internalId:  '',
customField: '20080605-115222'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5048',
internalId:  '',
customField: '20091204-165649'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5069',
internalId:  '',
customField: '20100209-101531'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6770',
internalId:  '',
customField: '20070502-135005'
};
webappMappings['7060']=webappMappings['7060-c323aec8171920492f32520524259097']={
webappId:    '7060',
documentId:  '36701',
internalId:  'c323aec8171920492f32520524259097',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36701',
internalId:  '',
customField: '20071227-110410'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '47901',
internalId:  '',
customField: '20091208-133912'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '47922',
internalId:  '',
customField: '20091208-134006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '47943',
internalId:  '',
customField: '20080128-124420'
};
webappMappings['7005']=webappMappings['7005-179']={
webappId:    '7005',
documentId:  '108801',
internalId:  '179',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '108801',
internalId:  '',
customField: '20091204-164405'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10INXH9X';
var companyName   = 'Helensburgh+Cricket+Club';
var htmlTitle	  = 'Helensburgh+Cricket+Club';
var metaKeywords  = 'Helensburgh+cricket+club+CC+ardencaple';
var metaContents  = 'Helensburgh+Cricket+Club+CC+Ardencaple';
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();
};
