/* [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','2801',jdecode('Home'),jdecode(''),'/2801.html','true',[],'',''],
	['PAGE','2852',jdecode('about+me'),jdecode(''),'/2852.html','true',[],'',''],
	['PAGE','2878',jdecode('artwork'),jdecode(''),'/2878.html','true',[],'',''],
	['PAGE','3101',jdecode('teaching'),jdecode(''),'/3101/index.html','true',[ 
		['PAGE','3127',jdecode('classes+%26+workshops'),jdecode(''),'/3101/3127.html','true',[],'',''],
		['PAGE','3153',jdecode('documents'),jdecode(''),'/3101/3153.html','true',[],'','']
	],'',''],
	['PAGE','2930',jdecode('contact'),jdecode(''),'/2930.html','true',[],'','']];
var siteelementCount=7;
theSitetree.topTemplateName='Delphi';
theSitetree.paletteFamily='59381F';
theSitetree.keyvisualId='7563';
theSitetree.keyvisualName='kv_7563.jpg';
theSitetree.fontsetId='16661';
theSitetree.graphicsetId='12225';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='818181';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Delphi',
				paletteFamily: 	'59381F',
				keyvisualId: 	'7563',
				keyvisualName: 	'kv_7563.jpg',
				fontsetId: 		'16661',
				graphicsetId: 	'12225',
				contentColor: 	'FFFFFF',
				contentBGColor: '818181',
				a_color: 		'424242',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3101',
internalId:  '',
customField: '20100301-145023'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2801',
internalId:  '',
customField: '20100610-100701'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2878',
internalId:  '',
customField: '20100523-133405'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2852',
internalId:  '',
customField: '20100610-095517'
};
webappMappings['7060']=webappMappings['7060-630ecdb9b986d16edf99b417176f91af']={
webappId:    '7060',
documentId:  '2878',
internalId:  '630ecdb9b986d16edf99b417176f91af',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3127',
internalId:  '',
customField: '20100610-101514'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3153',
internalId:  '',
customField: '20100610-100631'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2930',
internalId:  '',
customField: '20100610-100819'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT30IN37ZP';
var companyName   = 'tony+mosley+-+artist+%26+art+tutor';
var htmlTitle	  = '';
var metaKeywords  = 'art%2C+artist%2C++art+tutor%2C+teaching+art%2C+york%2C+fine+art%2C+watercolour%2C+watercolor%2C+oil+painting%2C+acrylic%2C+sketching%2C+drawing%2C+foundation+skills%2C+perspective%2C+technique%2C+portrait%2C+';
var metaContents  = 'artist+and+art+tutor+based+in+York';
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();
};
