/* [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','5201',jdecode('home'),jdecode(''),'/5201.html','true',[],'',''],
	['PAGE','2301',jdecode('about+mango+homes'),jdecode(''),'/2301/index.html','true',[ 
		['PAGE','2352',jdecode('about+phil+bradby'),jdecode(''),'/2301/2352.html','true',[],'','']
	],'',''],
	['PAGE','2378',jdecode('abbey+warehouse%2C+penzance'),jdecode(''),'/2378/index.html','true',[ 
		['PAGE','2404',jdecode('the+sail'),jdecode(''),'/2378/2404.html','true',[],'','']
	],'',''],
	['PAGE','2430',jdecode('berlin%2C+germany'),jdecode(''),'/2430.html','true',[],'',''],
	['PAGE','2456',jdecode('ashley+house%2C+ripon'),jdecode(''),'/2456.html','true',[],'',''],
	['PAGE','2482',jdecode('mayroyd+mill%2C+hebden+bridge'),jdecode(''),'/2482/index.html','true',[ 
		['PAGE','5252',jdecode('show+house'),jdecode(''),'/2482/5252.html','true',[],'','']
	],'',''],
	['PAGE','2508',jdecode('melbourne+mill%2C+hebden+bridge'),jdecode(''),'/2508/index.html','true',[ 
		['PAGE','5278',jdecode('show+flat'),jdecode(''),'/2508/5278.html','true',[],'','']
	],'',''],
	['PAGE','2534',jdecode('pecket+well+mill%2C+hebden+bridge'),jdecode(''),'/2534/index.html','true',[ 
		['PAGE','2560',jdecode('bobbin+cottage'),jdecode(''),'/2534/2560.html','true',[],'',''],
		['PAGE','2586',jdecode('show+apartment'),jdecode(''),'/2534/2586.html','true',[],'',''],
		['PAGE','5304',jdecode('steve+morgan+pictures'),jdecode(''),'/2534/5304.html','true',[],'','']
	],'',''],
	['PAGE','2612',jdecode('south+sea+cottage%2C+polperro'),jdecode(''),'/2612.html','true',[],'',''],
	['PAGE','2638',jdecode('trowan%2C+st+ives'),jdecode(''),'/2638/index.html','true',[ 
		['PAGE','5330',jdecode('quick%26%23x27%3Bs+cottage'),jdecode(''),'/2638/5330.html','true',[],'','']
	],'',''],
	['PAGE','4301',jdecode('press+articles'),jdecode(''),'/4301.html','true',[],'',''],
	['PAGE','3901',jdecode('contact+mango+homes'),jdecode(''),'/3901.html','true',[],'','']];
var siteelementCount=20;
theSitetree.topTemplateName='Alpha';
theSitetree.paletteFamily='555454';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10461';
theSitetree.graphicsetId='10892';
theSitetree.contentColor='0000A0';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Alpha',
				paletteFamily: 	'555454',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10461',
				graphicsetId: 	'10892',
				contentColor: 	'0000A0',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'555454',
				e_color: 		'555454',
				f_color: 		'555454',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2301',
internalId:  '',
customField: '20100305-114512'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2352',
internalId:  '',
customField: '20100305-115453'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2378',
internalId:  '',
customField: '20100305-120813'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2638',
internalId:  '',
customField: '20100305-123728'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2612',
internalId:  '',
customField: '20100305-123228'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2456',
internalId:  '',
customField: '20100305-115650'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2430',
internalId:  '',
customField: '20100305-065515'
};
webappMappings['7008']=webappMappings['7008-6898']={
webappId:    '7008',
documentId:  '3901',
internalId:  '6898',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3901',
internalId:  '',
customField: '20100305-125033'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4301',
internalId:  '',
customField: '20100305-123502'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2404',
internalId:  '',
customField: '20100305-062134'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2482',
internalId:  '',
customField: '20100305-120930'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2508',
internalId:  '',
customField: '20100305-062134'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2534',
internalId:  '',
customField: '20100305-062134'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2560',
internalId:  '',
customField: '20100305-122010'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2586',
internalId:  '',
customField: '20100305-121753'
};
webappMappings['1501']=webappMappings['1501-1501']={
webappId:    '1501',
documentId:  '5201',
internalId:  '1501',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5201',
internalId:  '',
customField: '20100305-105631'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5252',
internalId:  '',
customField: '20100305-121413'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5278',
internalId:  '',
customField: '20100305-102223'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5304',
internalId:  '',
customField: '20100305-102223'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5330',
internalId:  '',
customField: '20100305-102223'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT30IN3R0T';
var companyName   = '';
var htmlTitle	  = 'mango+homes%2C+philip+bradby';
var metaKeywords  = 'Mango+Homes%2C+Phil+Bradby%2C+specialist+historic+buildings%2C+Abbey+Warehouse+Penzance%2C+Trowan+St+Ives%2C+South+Sea+Cottage%2C+Gaudy+Strasse%2C+Auer+Strasse%2C+Sonntag+Strasse%2C+Berlin%2C+Mayroyd+Mill%2C+Melbourne+Mill%2C+Pecket+Well+Mill%2C+Hebden+Bridge%2C+Ashley+House+Ripon%2C+P+M+Bradby%2C+Mango-Homes%2C+Philip+Bradby';
var metaContents  = 'Welcome+to+the+web+site+for+the+award+winning+historic+buildings+specialsist+Mango+Homes+working+with+beautiful+buildings+in+the+UK+and+Germany.';
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();
};
