/* [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','1701',jdecode('Home'),jdecode(''), jdecode('%2F1701.html'), 'true',[],'',''],
	['PAGE','1752',jdecode('About+Graham+Page+Wine'),jdecode(''), jdecode('%2F1752.html'), 'true',[],'',''],
	['PAGE','34901',jdecode('Summer+White+Wine+Case'),jdecode(''), jdecode('%2F34901.html'), 'false',[],'',''],
	['PAGE','32101',jdecode('Summer+Red+Wine+Case'),jdecode(''), jdecode('%2F32101.html'), 'false',[],'',''],
	['PAGE','1804',jdecode('Graham%26%23x27%3Bs+Christmas+Wine+Case'),jdecode(''), jdecode('%2F1804.html'), 'false',[],'',''],
	['PAGE','16401',jdecode('Party+Wine%21'),jdecode(''), jdecode('%2F16401.html'), 'true',[],'',''],
	['PAGE','1830',jdecode('Groote+Post'),jdecode(''), jdecode('%2F1830.html'), 'true',[],'',''],
	['PAGE','7927',jdecode('Ch%C3%A2teau+Le+Bourdieu+'),jdecode(''), jdecode('%2F7927.html'), 'true',[],'',''],
	['PAGE','7953',jdecode('Charles+Gardet'),jdecode(''), jdecode('%2F7953.html'), 'true',[],'',''],
	['PAGE','8005',jdecode('Michael+Schafer'),jdecode(''), jdecode('%2F8005.html'), 'true',[],'',''],
	['PAGE','8031',jdecode('Trenel'),jdecode(''), jdecode('%2F8031.html'), 'true',[],'',''],
	['PAGE','8057',jdecode('Maison+Simonnet-Febvre'),jdecode(''), jdecode('%2F8057.html'), 'true',[],'',''],
	['PAGE','19401',jdecode('Selaks'),jdecode(''), jdecode('%2F19401.html'), 'true',[],'',''],
	['PAGE','20701',jdecode('Kumeu+River+Wines'),jdecode(''), jdecode('%2F20701.html'), 'true',[],'',''],
	['PAGE','25601',jdecode('Domaine+Bouvachon'),jdecode(''), jdecode('%2F25601.html'), 'true',[],'',''],
	['PAGE','1856',jdecode('Contact'),jdecode(''), jdecode('%2F1856.html'), 'true',[],'',''],
	['PAGE','27301',jdecode('Price+List+%2FOrders'),jdecode(''), jdecode('%2F27301.html'), 'false',[],'','']];
var siteelementCount=17;
theSitetree.topTemplateName='Aliment';
theSitetree.paletteFamily='BD1A27';
theSitetree.keyvisualId='8106';
theSitetree.keyvisualName='kv_8106.jpg';
theSitetree.fontsetId='16993';
theSitetree.graphicsetId='12387';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='f3f2f2';
var localeDef={
  language: 'en',
  country: 'GB'
};
var prodDef={
  wl_name: 'easily_co_uk',
  product: 'WSCSYSSSSLY0XVDH'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Aliment',
				paletteFamily: 	'BD1A27',
				keyvisualId: 	'8106',
				keyvisualName: 	'kv_8106.jpg',
				fontsetId: 		'16993',
				graphicsetId: 	'12387',
				contentColor: 	'000000',
				contentBGColor: 'f3f2f2',
				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:  '1701',
internalId:  '',
customField: '20100730-104249'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1701',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-7941802']={
webappId:    '1501',
documentId:  '1701',
internalId:  '7941802',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25601',
internalId:  '',
customField: '20100730-105309'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1752',
internalId:  '',
customField: '20100730-104332'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1804',
internalId:  '',
customField: '20081127-101427'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1830',
internalId:  '',
customField: '20100730-104619'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1856',
internalId:  '',
customField: '20081127-060315'
};
webappMappings['7008']=webappMappings['7008-3215']={
webappId:    '7008',
documentId:  '27301',
internalId:  '3215',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7927',
internalId:  '',
customField: '20100730-104707'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7953',
internalId:  '',
customField: '20100730-104902'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20701',
internalId:  '',
customField: '20100730-105226'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8005',
internalId:  '',
customField: '20100730-105004'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8031',
internalId:  '',
customField: '20100730-105041'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8057',
internalId:  '',
customField: '20100730-105134'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19401',
internalId:  '',
customField: '20100730-105156'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16401',
internalId:  '',
customField: '20100914-101951'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27301',
internalId:  '',
customField: '20090109-085223'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32101',
internalId:  '',
customField: '20090711-102755'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34901',
internalId:  '',
customField: '20090711-103021'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20INEQGW';
var companyName   = 'Graham+Page+Wine';
var htmlTitle	  = 'Graham+Page+Wines';
var metaKeywords  = 'Wine+norwich%2Cred+wine+norwich%2Cwhite+wine+norwich%2Crose+wine+norwich%2C+wine+distributor%2Cwine+retailer%2Cwine+deliveries%2Cport%2C+vintage+port%2C+champagne%2Cvintage+champagne%2Cvintage+wine%2Cchampane%2Cwine+norfolk%2Cport+norfolk%2Cchampagne+norfolk%2Cfree+delivery%2Cchristmas+wine%2Cfrench+wine%2Csouth+african+wine%2Crose+wine%2Cbottles+of+wine%2Cbottles+of+port%2Cbottles+of+champagne%2Cchampagne+delivery%2Cchristmas+delivery%2Ccharles+gardet+wine%2C+charles+gardet+champagne%2Cgardet+champagne%2C';
var metaContents  = 'Graham+Page+Wine%2C+wine+importer+and+distributor%2C+based+near+Norwich%2C+Norfolk.+Specialist+red+white+and+rose+wines%2C+champagne+and+port.';
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();
};

