/* [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','1901',jdecode('Welcome'),jdecode(''), jdecode('%2F1901.html'), 'true',[],'',''],
	['PAGE','4901',jdecode('The+Yard'),jdecode(''), jdecode('%2F4901.html'), 'true',[],'',''],
	['PAGE','18501',jdecode('Paddocks+%26+Turn+Out'),jdecode(''), jdecode('%2F18501.html'), 'true',[],'',''],
	['PAGE','1978',jdecode('Livery'),jdecode(''), jdecode('%2F1978.html'), 'true',[],'',''],
	['PAGE','2082',jdecode('Tariff'),jdecode(''), jdecode('%2F2082.html'), 'true',[],'',''],
	['PAGE','19301',jdecode('Further+Information'),jdecode(''), jdecode('%2F19301.html'), 'true',[],'',''],
	['PAGE','2108',jdecode('About+Us'),jdecode(''), jdecode('%2F2108.html'), 'true',[],'',''],
	['PAGE','2160',jdecode('Contact+Hall+Acres'),jdecode(''), jdecode('%2F2160.html'), 'true',[],'',''],
	['PAGE','20101',jdecode('Gallery'),jdecode(''), jdecode('%2F20101.html'), 'true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Alpha';
theSitetree.paletteFamily='555454';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10461';
theSitetree.graphicsetId='10892';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
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: 			'Alpha',
				paletteFamily: 	'555454',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10461',
				graphicsetId: 	'10892',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'555454',
				e_color: 		'555454',
				f_color: 		'555454',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1901',
internalId:  '',
customField: '20110605-184108'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4901',
internalId:  '',
customField: '20110605-185439'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1978',
internalId:  '',
customField: '20110612-212034'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19301',
internalId:  '',
customField: '20120111-114717'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20101',
internalId:  '',
customField: '20110605-191250'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2082',
internalId:  '',
customField: '20110903-124346'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2108',
internalId:  '',
customField: '20110612-212544'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1901',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2160',
internalId:  '',
customField: '20110601-221805'
};
webappMappings['7008']=webappMappings['7008-4346']={
webappId:    '7008',
documentId:  '2160',
internalId:  '4346',
customField: 'language:en;country:GB;'
};
webappMappings['1501']=webappMappings['1501-9317663']={
webappId:    '1501',
documentId:  '1901',
internalId:  '9317663',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18501',
internalId:  '',
customField: '20110605-182316'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20INEP6A';
var companyName   = '';
var htmlTitle	  = 'hallacres%2C+HALL+ACRES%2C+Livery%2C+Racing%2C+Point+to+Point%2C+Convalescence%2C+Stable+Yard%2C+Bradenham%2C+High+Wycombe%2C+Buckinghamshire';
var metaKeywords  = 'META+name%3Dkeywords+content%3Dhorse+care+uk+%2Chorse+respiratory+care+%2Chorse+hoof+care+%2Chorse+livery+buckinghamshire+%2Cequine+joint+care+%2Chorse+joint+health+%2Chorse+health+uk+%2Chorse+rehabilitation+%2Cpoint+to+point+trainers+%2Cpoint+to+point+fixtures+%2Cpoint+to+point+racing+%2Cpoint+to+point+horse+racing+%2Crace+horse+training+%2Crace+horse+trainer+%2Crace+horse+for+sale+%2Chorse+race+fixtures+%2Chorse+transport+uk+%2Chorse+therapy+%2Chorse+vet+%2Chorse+farrier+%2Cenglish+horse+racing+%2Chorse+stall+%2Chorse+racing+trainer+%2Crace+horse+for+sale+%2C+www.hallacres.com%2C+horse%2C+racing%2C+livery+stables%2C+stable+yards%2C+yards%2C+point+to+point%2C+trainers%2C+convalescence%2C+rest++rehabilitation%2C+winners%2C+fences%2C+schooling+grounds%2C+jumps+hire%2C+schooling+ground%2C+livery%2C+grass+livery%2C+horses+at+grass%2C+hall+acres%2C+hallacres%2C+hallacres.com%2C+';
var metaContents  = 'hallacres%2C+Hall+Acres%2C+Livery%2C+Racing%2C+Point+to+Point%2C+Convalescence%2C+stable+yard%2C+bradenham%2C+high+wycombe%2C+buckinghamshire%2C';
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();
};

