/* [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','601',jdecode('Home'),jdecode(''), jdecode('%2F601.html'), 'true',[],'',''],
	['PAGE','52127',jdecode('+CONTACT%2FDETAILS'),jdecode(''), jdecode('%2F52127.html'), 'true',[],'',''],
	['PAGE','20201',jdecode('DIARY+2012'),jdecode(''), jdecode('%2F20201.html'), 'true',[],'',''],
	['PAGE','14701',jdecode('CURRENT+NEWS'),jdecode(''), jdecode('%2F14701.html'), 'true',[],'',''],
	['PAGE','106101',jdecode('+COLLEGE+OF+ART'),jdecode(''), jdecode('%2F106101.html'), 'true',[],'',''],
	['PAGE','32001',jdecode('CHOIR+OFFICIALS'),jdecode(''), jdecode('%2F32001.html'), 'true',[],'',''],
	['PAGE','652',jdecode('CHOIR+HISTORY'),jdecode(''), jdecode('%2F652.html'), 'true',[],'',''],
	['PAGE','52101',jdecode('+2011+CONCERT'),jdecode(''), jdecode('%2F52101.html'), 'true',[],'',''],
	['PAGE','29201',jdecode('WEDDING+PHOTOS'),jdecode(''), jdecode('%2F29201.html'), 'true',[],'',''],
	['PAGE','24301',jdecode('VICE+PRESIDENTS'),jdecode(''), jdecode('%2F24301.html'), 'true',[],'',''],
	['PAGE','101901',jdecode('SPONSORS+LINK'),jdecode(''), jdecode('%2F101901.html'), 'true',[],'',''],
	['PAGE','52153',jdecode('+GRAVELLS+GARAGE'),jdecode(''), jdecode('%2F52153.html'), 'true',[],'',''],
	['PAGE','57401',jdecode('35TH+ANNIVERSARY'),jdecode(''), jdecode('%2F57401.html'), 'true',[],'',''],
	['PAGE','31527',jdecode('KIDWELLY+CASTLE+'),jdecode(''), jdecode('%2F31527.html'), 'true',[],'',''],
	['PAGE','31501',jdecode('IRISH+%2F+WELSH+NIGHT'),jdecode(''), jdecode('%2F31501.html'), 'true',[],'',''],
	['PAGE','15801',jdecode('PRESENTATION'),jdecode(''), jdecode('%2F15801.html'), 'true',[],'',''],
	['PAGE','52179',jdecode('GUEST+PAGE'),jdecode(''), jdecode('%2F52179.html'), 'true',[],'',''],
	['PAGE','85501',jdecode('E_MAIL+CONTACT'),jdecode(''), jdecode('%2F85501.html'), 'true',[],'',''],
	['PAGE','92901',jdecode('MUSIC'),jdecode(''), jdecode('%2F92901.html'), 'true',[],'','']];
var siteelementCount=19;
theSitetree.topTemplateName='Instrument';
theSitetree.paletteFamily='4E56CA';
theSitetree.keyvisualId='6152';
theSitetree.keyvisualName='kv_6152.jpg';
theSitetree.fontsetId='11134';
theSitetree.graphicsetId='11933';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='DFDFE2';
var localeDef={
  language: 'en',
  country: 'GB'
};
var prodDef={
  wl_name: 'easily_co_uk',
  product: 'WSCSYSSSSLY0XVDH'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Instrument',
				paletteFamily: 	'4E56CA',
				keyvisualId: 	'6152',
				keyvisualName: 	'kv_6152.jpg',
				fontsetId: 		'11134',
				graphicsetId: 	'11933',
				contentColor: 	'000000',
				contentBGColor: 'DFDFE2',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'16226A',
				e_color: 		'16226A',
				f_color: 		'16226A',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '601',
internalId:  '',
customField: '20120131-163123'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '652',
internalId:  '',
customField: '20100105-112901'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20201',
internalId:  '',
customField: '20120131-120218'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31501',
internalId:  '',
customField: '20101213-145559'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31527',
internalId:  '',
customField: '20111025-154355'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29201',
internalId:  '',
customField: '20111025-152604'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '601',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32001',
internalId:  '',
customField: '20120108-190145'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15801',
internalId:  '',
customField: '20111122-140441'
};
webappMappings['1002']=webappMappings['1002-52179anbt10in2nk8']={
webappId:    '1002',
documentId:  '52179',
internalId:  '52179anbt10in2nk8',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '24301',
internalId:  '',
customField: '20110414-213055'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '101901',
internalId:  '',
customField: '20111222-152743'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14701',
internalId:  '',
customField: '20120116-113710'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '52101',
internalId:  '',
customField: '20110728-064731'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '52127',
internalId:  '',
customField: '20110420-210733'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '52153',
internalId:  '',
customField: '20101213-143627'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '52179',
internalId:  '',
customField: '20100723-220616'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '57401',
internalId:  '',
customField: '20100624-153536'
};
webappMappings['7008']=webappMappings['7008-8380']={
webappId:    '7008',
documentId:  '85501',
internalId:  '8380',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '85501',
internalId:  '',
customField: '20110124-222409'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '92901',
internalId:  '',
customField: '20110421-064731'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '106101',
internalId:  '',
customField: '20120131-163428'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN2NK8';
var companyName   = 'C%C3%B4r+Meibion+Dyffryn+Tywi';
var htmlTitle	  = 'WWW.CORMEIBIONDYFFRYNTYWI.CO.UK';
var metaKeywords  = 'WELSH+MALE+VOICE+CHOIRS';
var metaContents  = 'COR+MEIBION+DYFFRYN+TYWI+';
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();
};

