/* [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','15201',jdecode('Home'),jdecode(''), jdecode('%2F15201.html'), 'true',[],'',''],
	['PAGE','15252',jdecode('Contact+Us'),jdecode(''), jdecode('%2F15252.html'), 'true',[],'',''],
	['PAGE','18101',jdecode('Housing'),jdecode(''), jdecode('%2F18101.html'), 'true',[],'',''],
	['PAGE','18201',jdecode('Education'),jdecode(''), jdecode('%2F18201.html'), 'true',[],'',''],
	['PAGE','18301',jdecode('Historic+Buildings'),jdecode(''), jdecode('%2F18301.html'), 'true',[],'',''],
	['PAGE','18327',jdecode('Religious+Buildings'),jdecode(''), jdecode('%2F18327.html'), 'true',[],'',''],
	['PAGE','16005',jdecode('Community+Projects'),jdecode(''), jdecode('%2F16005.html'), 'true',[],'',''],
	['PAGE','16031',jdecode('Health+Care+'),jdecode(''), jdecode('%2F16031.html'), 'true',[],'',''],
	['PAGE','16057',jdecode('Retail'),jdecode(''), jdecode('%2F16057.html'), 'true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Valiant';
theSitetree.paletteFamily='5252B6';
theSitetree.keyvisualId='9818';
theSitetree.keyvisualName='kv_9818.jpg';
theSitetree.fontsetId='17630';
theSitetree.graphicsetId='13032';
theSitetree.contentColor='646464';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var prodDef={
  wl_name: 'easily_co_uk',
  product: 'WSCSYSSSSLY0XVDX'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Valiant',
				paletteFamily: 	'5252B6',
				keyvisualId: 	'9818',
				keyvisualName: 	'kv_9818.jpg',
				fontsetId: 		'17630',
				graphicsetId: 	'13032',
				contentColor: 	'646464',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15201',
internalId:  '',
customField: '20100824-113310'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15252',
internalId:  '',
customField: '20100827-113014'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18101',
internalId:  '',
customField: '20100827-113202'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16057',
internalId:  '',
customField: '20100827-115646'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16031',
internalId:  '',
customField: '20100827-152514'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16005',
internalId:  '',
customField: '20100827-121501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18201',
internalId:  '',
customField: '20100827-113337'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18301',
internalId:  '',
customField: '20100827-113517'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18327',
internalId:  '',
customField: '20100827-113624'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT30IN3UK9';
var companyName   = 'MILDRED%2C+HOWELLS+%26+CO.';
var htmlTitle	  = 'Mildred%2C+Howells+%26+Co.+-++Chartered+Quantity+Surveyors';
var metaKeywords  = 'Mildred+Howells%2C+Mildred+Howells+%26+Co%2C+Mildred%2C+Howells%2C+Quantity+Surveyors%2C+Quantity+Surveyors+Bristol%2C+Quantity+Surveyors+Swansea%2C+Quantity+Surveyors+Saltash%2C+Bristol+Quantity+Surveyors%2C+Swansea+Quantity+Surveyors%2C+Saltash+Quantity+Surveyors%2C+Quantity+Surveyors%2C+Quantity%2C+Surveyors%2C+Construction%2C+Construction+Cost+Consultants%2C+Cost+Estimates%2C+Building+Valuations%2C+Cost+Planning%2C+Cost+Advice+Building%2C+Cost+control+building%2C+Building+Surveyor%2C+Construction+Surveyor%2C+Employers+Agents%2C+Quantities%2C+Bill+of+Quantities%2C+Bills+of+Quantities%2C+Schedules+of+Work%2C+Valuations%2C+Estimates%2C+Pricing%2C+Cost+Plans%2C+Final+Account%2C+Measuring';
var metaContents  = 'Mildred%2C+Howells+%26+Co.%2C+Chartered+Quantity+Surveyors%2C+Construction+Cost+Consultants.++Our+services+cover+the+whole+process+of+construction+cost+advice%2C+contract+documentation+and+the+financial+administration+and+cost+control+of+building+and+civil+enginering+projects.';
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();
};

