/* [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 theSitetree=[ 
	['PAGE','4901',jdecode('Home'),jdecode(''),'/4901.html','true',[],''],
	['PAGE','5134',jdecode('Contact'),jdecode(''),'/5134.html','true',[],''],
	['PAGE','4952',jdecode('About+Us'),jdecode(''),'/4952.html','true',[],''],
	['PAGE','4978',jdecode('Commercial+Projects'),jdecode(''),'/4978.html','true',[],''],
	['PAGE','5030',jdecode('Industrial+Projects'),jdecode(''),'/5030.html','true',[],''],
	['PAGE','5056',jdecode('Domestic+Projects'),jdecode(''),'/5056.html','true',[],''],
	['PAGE','46801',jdecode('Heritage+Projects'),jdecode(''),'/46801.html','true',[],''],
	['PAGE','7501',jdecode('Street+Lighting'),jdecode(''),'/7501.html','true',[],''],
	['PAGE','5004',jdecode('Test+%26+Inspection'),jdecode(''),'/5004.html','true',[],''],
	['PAGE','16501',jdecode('Vacancies'),jdecode(''),'/16501.html','true',[],'']];
var siteelementCount=10;
theSitetree.topTemplateName='Global';
theSitetree.paletteFamily='CC3300';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='85';
theSitetree.graphicsetId='107';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				name: 			'Global',
				paletteFamily: 	'CC3300',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'85',
				graphicsetId: 	'107',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'CB1C00',
				b_color: 		'FF9900',
				c_color: 		'000000',
				d_color: 		'EAEAEA',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4901',
internalId:  '',
customField: '20080604-161453'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4901',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-5424351']={
webappId:    '1501',
documentId:  '4901',
internalId:  '5424351',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4952',
internalId:  '',
customField: '20080417-123210'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4978',
internalId:  '',
customField: '20080423-163606'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5004',
internalId:  '',
customField: '20080916-124136'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5030',
internalId:  '',
customField: '20080418-134124'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5056',
internalId:  '',
customField: '20080803-095800'
};
webappMappings['7008']=webappMappings['7008-800']={
webappId:    '7008',
documentId:  '16501',
internalId:  '800',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5134',
internalId:  '',
customField: '20080409-161111'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7501',
internalId:  '',
customField: '20080502-151713'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16501',
internalId:  '',
customField: '20090311-114314'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '46801',
internalId:  '',
customField: '20080418-134734'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20IN2TNM';
var companyName   = 'V%26W+Electrics+Ltd';
var htmlTitle	  = 'VW+Electrics+Ltd';
var metaKeywords  = 'electricians%2Celectrical+contractor%2Cniceic%2Coswestry%2Cshropshire%2Cpowys%2Ccheshire%2Cperiodic%2Cinspection%2Ctesting%2Cfire+alarm%2Cemergency+lighting%2C17th+edition%2Csocket%2Clight%2Cshower%2Celectric%2Cheating%2Cfuse%2Cboard%2Crcd%2Ccable%2Cswa%2Cflex%2Cdesign%2Cinstallation%2Ccommissioning%2Cteay%2Cbasket%2Cdado%2Cconduit%2Ctrunking%2Cmicc%2Cearthing%2Cbonding%2Cequipotential%2Crod%2Cearth%2Cwiring%2Crewire%2Cmcb%2Cswitch%2Cisolator%2Cdistribution%2Cfluorescent%2Cson%2Cfloodlight%2Clamp%2Cstreetlight%2Ccut+out%2Cmegger%2Cinsulation%2Cconductor%2Cvoltage%2Camp%2Cohm%2Cdownlights%2Chealth%2Csafety%2Cspotlights%2Cfrequency%2Cchasing%2Cclipping%2Cfan%2Cventilation%2Cpendant%2Cdin%2Cterminal%2Csparky%2Crelay%2Ctimer%2Cconvector%2Cpir%2Csmoke%2Cheat%2Ccall+point%2Cspur%2C13a%2Cfirst+fix%2Csecond%2Cfix%2Ctelephone%2Cbell%2Csounder%2Cwall+light%2Coffice%2Cfactory%2Cdomestic%2Ccommercial%2Cinductrial%2Cheritage%2Cold%2Crefurbish%2Ccatenary%2Cpower%2Caccessories%2Cplug%2Csockets%2Csox%2Cmercury%2Coverload%2Ccall+out%2Cenclosure%2Cchangeover%2Cgenerator%2Cstorage%2Cquartz%2Celement%2Ctube%2Cbulb%2Celement%2Cmini%2Cmaxi%2Cdry%2Cbox%2Cbend%2Cperimiter%2Caluminium%2Csteel%2Cplastic%2Cupvc%2Ccontainment%2Cpowerpole%2Cdata%2Ccat5%2Ccat6%2Ccat5e%2Ccabling%2Cstructure%2Cschool%2Chouse%2Ccorridor%2Chall%2Cattic%2Ccar%2Cpark%2Csite%2C110v%2C230v%2C400v%2Cthre%2Cphase%2Csingle%2Coutlet%2Ccertificate%2Ccertification%2Cflush%2Csurface%2Cwhite%2Cmetalclad%2Ctwin%2Carmoured%2Cgland%2Ctails%2Chigh%2Clow%2Calarm%2Ccall%2Clive%2Cisolated%2Ctransformer%2Clug%2Ccopper%2Cjoint%2Cstud%2Cthread%2Cbesa%2Cequiment%2Caccess%2Cchas%2Cconstructionline%2Cwem%2Cshrewsbury%2Cbaschurch%2Cwhitchurch%2Cmarket+drayton%2Cludlow%2Cleominster%2Cchurch+stretton%2Ccraven+arms%2Chodnet%2Cprees%2Charlscott%2Cwelshpool%2Cnewtown%2Cchester%2Cwrexham%2Ctelford%2Cbridgenorth%2Cclun%2Cironbridge%2Cbishops+castle%2Cministerley%2Cpontsbury%2Cshawbury%2Cllangollen%2Cchirk%2Cglyn+ceiriog%2Cmalpas%2Cfarndon%2Coverton%2Cellesmere%2Cwelshampton%2Cmontgomery%2Calbrighton%2Cdawley%2Cbroseley%2Ccoalbrookdale%2Cnewport%2C';
var metaContents  = 'electrical+contractor+oswestry+shropshire+niceic+approved';
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();
};

