/* [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','2901',jdecode('Home'),jdecode(''), jdecode('%2F2901.html'), 'true',[],'',''],
	['PAGE','2952',jdecode('Contact'),jdecode(''), jdecode('%2F2952.html'), 'true',[],'','']];
var siteelementCount=2;
theSitetree.topTemplateName='Axis';
theSitetree.paletteFamily='C2C99B';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10467';
theSitetree.graphicsetId='10917';
theSitetree.contentColor='003366';
theSitetree.contentBGColor='DBDFC0';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'wl_enom',
  product: 'WSCENOSSSLYTC21A'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Axis',
				paletteFamily: 	'C2C99B',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10467',
				graphicsetId: 	'10917',
				contentColor: 	'003366',
				contentBGColor: 'DBDFC0',
				a_color: 		'EFF2DD',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'606638',
				e_color: 		'606638',
				f_color: 		'606638',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2901',
internalId:  '',
customField: '20111214-064712'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2952',
internalId:  '',
customField: '20111212-043157'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2901',
internalId:  '1006',
customField: '1006'
};
var webAppHostname = 'wsc.ehost-services.com:80';
var canonHostname = 'wscwrk01.ehost-services.com';
var accountId     = 'AEN340INPU3L';
var companyName   = '++++++++++++++++++RUGBY+PLUMBING+%26+HEATING+ENGINEER';
var htmlTitle	  = 'RUGBY+PLUMBING+%26+HEATING+07887775869';
var metaKeywords  = 'plumber+in+rugby%2C+emergency+plumber+in+rugby%2C++rugby+plumbing%2C+rugby+plummer%2C+plumber%2C+water+leak%2C+burst+pipes%2C+local+tradesman%2C++plumber%2CRugby%2CRegistered%2Cemergency%2Cplumber%2Cshower%2Ctoilet%2Cbathroom%2Cheating%2Cplumbing%2Cpipe%2Crepair%2Ccylinders%2Csinks%2Ctanks%2C+Repairs%2Cball+valves%2Ctaps%2Cpipework%2Cwashing+machines%2Cpumps%2Cradiators%2Cgeneral+plumbing+repairs%2Crapid+emergency+response%2CRepairs%2CUnblock%2CUnblock%2Ctoilets%2CReline%2CUndertake+insurance+work%2Ccentral+heating%2CSupply+and+Install%2Cinstallation+only%2Cfree+quotations%2CBurst+pipes%2CLeaks%2CLead%2CCopper%2CPVC%2CPipe+Work+Repair%2CMaintenance%2CSiphons%2CCisterns%2CBall+Cocks%2CBall-O-Fix%2CGate+Valves%2COverhaul%2CReplace%2CImmersion+Elements%2CThermostats%2CMains+Cold+Water+Supplies%2CCold+Water+Storage+Tanks%2CFeed+Tanks%2CExpansion+Tanks%2CIndirect%2CDirect%2CHot+Water+Cylinders%2CExpansion+Vessels%2CUnVented+Systems%2CBathroom+Refurbishments%2CWashing+Machine+Installations%2CDishwasher+Installations%2CRugby%2C+Lutterworth%2C+Daventry%2C+Hinckley%2C+Leamington+Spa%2C+Northampton%2C+Southam%2C+Hillmorton%2C+Overslade%2C+Brownsover%2C+Bilton%2C+New+Bilton%2C+Newbold%2C+Clifton-upon-Dunsmore%2C+Cawston%2C+Dunchurch%2C+Long+Lawford%2C+Newton%2C+';
var metaContents  = 'RUGBY+LOCAL+REGISTERED+PLUMBER+EMERGENCY+SERVICE+NO+CALL+OUT+CHARGE+07887775869';
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();
};

