/* [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','21001',jdecode('NL+Inspection'),jdecode(''),'/21001.html','true',[],''],
	['PAGE','103801',jdecode('BS+EN+ISO%3A+9001'),jdecode(''),'/103801.html','true',[],''],
	['PAGE','4978',jdecode('Our+Services'),jdecode(''),'/4978.html','true',[],''],
	['PAGE','5004',jdecode('Contact+Us'),jdecode(''),'/5004.html','true',[],''],
	['PAGE','10201',jdecode('Enquiries'),jdecode(''),'/10201.html','true',[],''],
	['PAGE','104501',jdecode('Customer+Survey'),jdecode(''),'/104501.html','false',[],''],
	['PAGE','11001',jdecode('Gallery'),jdecode(''),'/11001.html','true',[],''],
	['PAGE','116401',jdecode('Clients'),jdecode(''),'/116401.html','true',[],''],
	['PAGE','24301',jdecode('Welder+Quals'),jdecode(''),'/24301.html','true',[],'']];
var siteelementCount=10;
theSitetree.topTemplateName='Delphi';
theSitetree.paletteFamily='2B3559';
theSitetree.keyvisualId='7542';
theSitetree.keyvisualName='kv_7542.jpg';
theSitetree.fontsetId='16657';
theSitetree.graphicsetId='12222';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='818181';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				name: 			'Delphi',
				paletteFamily: 	'2B3559',
				keyvisualId: 	'7542',
				keyvisualName: 	'kv_7542.jpg',
				fontsetId: 		'16657',
				graphicsetId: 	'12222',
				contentColor: 	'FFFFFF',
				contentBGColor: '818181',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'424242',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4901',
internalId:  '',
customField: '20090622-212429'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4978',
internalId:  '',
customField: '20090519-124640'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5004',
internalId:  '',
customField: '20090729-131629'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4901',
internalId:  '1006',
customField: '1006'
};
webappMappings['7008']=webappMappings['7008-4699']={
webappId:    '7008',
documentId:  '10201',
internalId:  '4699',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4901',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '103801',
internalId:  '',
customField: '20090924-091708'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4978',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '5004',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '10201',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10201',
internalId:  '',
customField: '20090518-204854'
};
webappMappings['7060']=webappMappings['7060-931eda10470dfdbf833378dc6fdf9a07']={
webappId:    '7060',
documentId:  '11001',
internalId:  '931eda10470dfdbf833378dc6fdf9a07',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '11001',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11001',
internalId:  '',
customField: '20090526-193426'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '21001',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21001',
internalId:  '',
customField: '20091008-112104'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '24301',
internalId:  '',
customField: '20090924-092033'
};
webappMappings['7008']=webappMappings['7008-5199']={
webappId:    '7008',
documentId:  '104501',
internalId:  '5199',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '104501',
internalId:  '',
customField: '20090722-154236'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '116401',
internalId:  '',
customField: '20091008-113436'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN3C8N';
var companyName   = 'Specialist+Welding+%26+Engineering+Ltd';
var htmlTitle	  = 'Specialist+Welding+%26+Engineering+Ltd';
var metaKeywords  = 'Specialist%2CWelding%2CEngineering%2CWelding%2CFabrication%2CSWEL%2Cexotics%2Csuper%2Cduplex%2Cmachining%2CNDT%2CMPI%2CDPI%2CConsultancy%2CSubsea%2COffshore%2CAerospace%2CDefense';
var metaContents  = 'Specialist+Welding++Engineering+Ltd%2Cwelding%2Cfabrication%2CInspection%2CNDT%2CMPI%2CDPI%2CConsultancy%2CSubsea%2COffshore%2CAerospace%2CDefense';
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();
};
