/* [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','7201',jdecode('Home'),jdecode(''), jdecode('%2F7201.html'), 'true',[],'',''],
	['PAGE','10601',jdecode('About+us'),jdecode(''), jdecode('%2F10601.html'), 'true',[],'',''],
	['PAGE','10622',jdecode('Services'),jdecode(''), jdecode('%2F10622.html'), 'true',[],'',''],
	['PAGE','8501',jdecode('Gallery'),jdecode(''), jdecode('%2F8501.html'), 'true',[],'',''],
	['PAGE','10643',jdecode('Contact+us'),jdecode(''), jdecode('%2F10643.html'), 'true',[],'',''],
	['PAGE','17501',jdecode('JOBS'),jdecode(''), jdecode('%2F17501.html'), 'true',[],'',''],
	['PAGE','23601',jdecode('NEWS'),jdecode(''), jdecode('%2F23601.html'), 'true',[],'','']];
var siteelementCount=7;
theSitetree.topTemplateName='Triangle';
theSitetree.paletteFamily='000000';
theSitetree.keyvisualId='12002';
theSitetree.keyvisualName='kv_12002.jpg';
theSitetree.fontsetId='33260';
theSitetree.graphicsetId='14139';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='000000';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'brinkster',
  product: 'WSCSYSSSSLYTCVUR'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Triangle',
				paletteFamily: 	'000000',
				keyvisualId: 	'12002',
				keyvisualName: 	'kv_12002.jpg',
				fontsetId: 		'33260',
				graphicsetId: 	'14139',
				contentColor: 	'FFFFFF',
				contentBGColor: '000000',
				a_color: 		'000000',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7201',
internalId:  '',
customField: '20120106-062936'
};
webappMappings['7060']=webappMappings['7060-4c070461cb6551159dbf436ae7281dd8']={
webappId:    '7060',
documentId:  '8501',
internalId:  '4c070461cb6551159dbf436ae7281dd8',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10601',
internalId:  '',
customField: '20120106-063245'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8501',
internalId:  '',
customField: '20091016-055038'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10643',
internalId:  '',
customField: '20110209-090529'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '7201',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10622',
internalId:  '',
customField: '20120106-065142'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17501',
internalId:  '',
customField: '20111114-111540'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23601',
internalId:  '',
customField: '20120106-080836'
};
var webAppHostname = 'wsc.brinkster.com:80';
var canonHostname = 'wsc1.brinkster.com';
var accountId     = 'ABR330INLLZ0';
var companyName   = 'AG+Precision+%28Sheet+Metal%29+Ltd';
var htmlTitle	  = 'AG+Precision%2C+Sheet+metal%2C+fabrication%2C+work%2C+in%2C+Beds%2C+Herts%2C+Fabrication%2C+Bucks%2C+Essex%2C+Cambridge%2C+MK%2C+Anglia%2C+South+east%2C+Midlands%2C+Luton%2C+Dunstable%2C+Bedford%2C+Milton+Keynes%2C+Northhants%2C+UK%2C+CNC%2C+Punching%2C+Bending%2C+Fine+Limit%2C+CADCAM%2C+CAD%2FCAM+Toolmakers';
var metaKeywords  = 'sheet+metal%2C+work%2C+fabrication%2C+fabricators%2C+Fine+limit%2C+precision%2C+sheetmetal%2C+sheet%2C+metalwork%2C+engineering%2C+fabrication%2C+in%2C+luton%2C+herts%2C+stevenage%2C+hitchin%2C+Dunstable%2C+Leighton%2C++bedford%2C+beds%2C+bedfordshire%2C+hertfordshire%2C+Essex%2C+cambridge%2C+cambridgshire%2C+MK%2C+Milton+Keynes%2C+Bucks%2C+Buckinghamshire%2C+Northants%2C+Northamptonshire%2C+Midlands%2C+Birmingham%2C+Coventry%2C+Leicester%2C+South%2C+East%2C+Anglia%2C++prototype%2C+ISO9001+approved%2C+laser%2C+CNC%2C+C.N.C%2C+punching%2C+bending%2C+folding%2C+cutting%2C+drilling%2C+batch%2C+multishape%2C+';
var metaContents  = 'AG+Precision+Ltd%2C+++Fine+limit+sheet+metal+and+fabricatin+work%2C+in%2C+Herts%2C+Beds%2C+Bucks%2C+Essex%2C+the+south+east%2C+Cambridge%2C+Anglia%2C+Milton+keynes+and+Midlands%2C+bedfordshire%2C+Hertfordshire%2C+MK%2C+Cambridgeshire%2C+Buckinghamshire%2C+Birmimingham';
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();
};

