/* [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','11101',jdecode('Knowing+Jasper'),jdecode(''), jdecode('%2F11101.html'), 'true',[],'',''],
	['PAGE','15501',jdecode('Understanding+Jasper'),jdecode(''), jdecode('%2F15501.html'), 'true',[],'',''],
	['PAGE','16501',jdecode('The+Etheric+Earth+Council'),jdecode(''), jdecode('%2F16501.html'), 'true',[],'',''],
	['PAGE','15527',jdecode('About+Lillie+Whittle'),jdecode(''), jdecode('%2F15527.html'), 'true',[],'',''],
	['PAGE','15605',jdecode('Galar%26%23x27%3Bs+Alliance'),jdecode(''), jdecode('%2F15605.html'), 'true',[],'',''],
	['PAGE','15631',jdecode('OMMAEHHA+'),jdecode(''), jdecode('%2F15631.html'), 'true',[],'',''],
	['PAGE','15579',jdecode('Who+Stole+My+Memories'),jdecode(''), jdecode('%2F15579.html'), 'true',[],'',''],
	['PAGE','22401',jdecode('Jasper+onTwitter'),jdecode(''), jdecode('%2F22401.html'), 'true',[],'',''],
	['PAGE','39601',jdecode('Lillie+on+Twitter'),jdecode(''), jdecode('%2F39601.html'), 'true',[],'',''],
	['PAGE','41401',jdecode('amazon'),jdecode(''), jdecode('%2F41401.html'), 'true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Riga';
theSitetree.paletteFamily='917F41';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='11222';
theSitetree.graphicsetId='12046';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='917F41';
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: 			'Riga',
				paletteFamily: 	'917F41',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'11222',
				graphicsetId: 	'12046',
				contentColor: 	'000000',
				contentBGColor: '917F41',
				a_color: 		'000000',
				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:  '39601',
internalId:  '',
customField: '20120119-090957'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11101',
internalId:  '',
customField: '20120120-103420'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15501',
internalId:  '',
customField: '20120120-103511'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15527',
internalId:  '',
customField: '20120118-180604'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15579',
internalId:  '',
customField: '20120118-180803'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15605',
internalId:  '',
customField: '20120119-085332'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15631',
internalId:  '',
customField: '20120118-175126'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22401',
internalId:  '',
customField: '20120119-090910'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16501',
internalId:  '',
customField: '20120118-171744'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41401',
internalId:  '',
customField: '20120120-123546'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '11101',
internalId:  '1006',
customField: '1006'
};
var webAppHostname = 'cgi.easily.co.uk:80';
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT30INV11T';
var companyName   = '+Knowing+Jasper+';
var htmlTitle	  = '';
var metaKeywords  = 'Lillie+Whittle%2C+Knowing+Jasper%2C+Understanding+Jasper%2C+Earth+Council%2C+Knowing+Jasper+Series%2C';
var metaContents  = 'IT%27S+TIME+FOR+THE+SCIENCE+OF+TRUTH.+Official+Website+of+Jasper+and+Lillie+Whittle.+';
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();
};

