/* [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','401',jdecode('Home'),jdecode(''),'/401.html','true',[],'',''],
	['PAGE','536',jdecode('News+And+New+Products'),jdecode(''),'/536.html','true',[],'',''],
	['PAGE','452',jdecode('Products+And+Price+List'),jdecode(''),'/452.html','true',[],'',''],
	['PAGE','43401',jdecode('Other+Things+We+Sell'),jdecode(''),'/43401.html','true',[],'',''],
	['PAGE','41901',jdecode('The+New+Blue+Loo+Co'),jdecode(''),'/41901.html','true',[],'',''],
	['PAGE','473',jdecode('Where+Are+We+Now%3F'),jdecode(''),'/473.html','true',[],'',''],
	['PAGE','494',jdecode('Dates+For+Your+Diary'),jdecode(''),'/494.html','true',[],'',''],
	['PAGE','49601',jdecode('Folly+Pub+Napton'),jdecode(''),'/49601.html','true',[],'',''],
	['PAGE','515',jdecode('Contact+Us'),jdecode(''),'/515.html','true',[],'',''],
	['PAGE','578',jdecode('Links+Page'),jdecode(''),'/578.html','true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Valiant';
theSitetree.paletteFamily='25882F';
theSitetree.keyvisualId='9820';
theSitetree.keyvisualName='kv_9820.jpg';
theSitetree.fontsetId='17631';
theSitetree.graphicsetId='13033';
theSitetree.contentColor='25882F';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Valiant',
				paletteFamily: 	'25882F',
				keyvisualId: 	'9820',
				keyvisualName: 	'kv_9820.jpg',
				fontsetId: 		'17631',
				graphicsetId: 	'13033',
				contentColor: 	'25882F',
				contentBGColor: 'FFFFFF',
				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:  '401',
internalId:  '',
customField: '20100609-215249'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '452',
internalId:  '',
customField: '20100321-231109'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '401',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '473',
internalId:  '',
customField: '20100702-171608'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '494',
internalId:  '',
customField: '20100609-215717'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '515',
internalId:  '',
customField: '20100322-124528'
};
webappMappings['7008']=webappMappings['7008-1111']={
webappId:    '7008',
documentId:  '515',
internalId:  '1111',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '536',
internalId:  '',
customField: '20100406-195504'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41901',
internalId:  '',
customField: '20100406-210139'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '43401',
internalId:  '',
customField: '20100702-171715'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '578',
internalId:  '',
customField: '20100406-200543'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '49601',
internalId:  '',
customField: '20100406-200256'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT10IN25KK';
var companyName   = 'Environmentally+Responsible+Products';
var htmlTitle	  = 'Tia+Environmentally+Responsible+Products';
var metaKeywords  = 'Tia%2C+green%2C+environmentally%2C+responsible%2C+eco-friendly%2C+Ecover%2C+EcoBalls%2C+phosphate-free%2C+phosphates%2C+BioD%2C+Suma%2C+Refills%2C+Canals%2C+Inland+Waterways%2C+Napton%2C+Braunston%2C+DEFRA%2C+British+Waterways%2C+Department+of+the+environment+food+and+rural+affairs%2C+budget+cuts%2C+funding+cuts%2C+Bio+Magic%2C+Crick%2C+Boatshow%2C+Southam%2C+Stoke+Bruerne%2C+Foxton%2C+Watford%2C+tiacares%2C+Narrowboat%2C+Washing+up+liquid%2C+Hand+soap%2C+Disinfectant%2C+shower+gel%2C+soap%2C+clean%2C+laundry%2C+washing+powder%2C+boat+wash%2C+bacteria%2C+Escherichia+Coli%2C+Staphylococcus+Aureus%2C+enzymes%2C+detergent%2C+hypoallergenic%2C+sensitive%2C+skins%2C+sensitivities%2C+natural+products%2C+nature%2C+';
var metaContents  = 'Environmentally+responsible+products+sold+from+our+narrowboat+Tia+to+boat+owners+in+the+south+midlands+of+England.+We+believe+that+all+boat+owners+should+use+green+products+when+cleaning+their+boats+or+themselves+to+prevent+pollution+to+the+canals.';
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();
};
