/* [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 theSitetree=[ 
	['PAGE','1801',jdecode('BagButton'),jdecode(''),'/1801.html','true',[],''],
	['PAGE','2201',jdecode('Before+%26+After'),jdecode(''),'/2201.html','true',[],''],
	['PAGE','2222',jdecode('Testimonials'),jdecode(''),'/2222.html','true',[],''],
	['PAGE','2243',jdecode('Tips+and+Hints'),jdecode(''),'/2243.html','true',[],''],
	['PAGE','2264',jdecode('BB+Commercials'),jdecode(''),'/2264.html','true',[],''],
	['PAGE','2285',jdecode('BB+Press+%26+News'),jdecode(''),'/2285.html','true',[],''],
	['PAGE','2306',jdecode('Buy+Now+online'),jdecode(''),'/2306.html','true',[],''],
	['PAGE','2327',jdecode('About+BagButton'),jdecode(''),'/2327.html','true',[],''],
	['PAGE','2348',jdecode('Contact+US'),jdecode(''),'/2348.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Bigcity_Space';
theSitetree.paletteFamily='418980';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='21075';
theSitetree.graphicsetId='13167';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='418980';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Bigcity_Space',
				paletteFamily: 	'418980',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'21075',
				graphicsetId: 	'13167',
				contentColor: 	'FFFFFF',
				contentBGColor: '418980',
				hasFlashNavigation: 'true',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				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:  '1801',
internalId:  '',
customField: '20100317-182828'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2201',
internalId:  '',
customField: '20091006-131342'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2222',
internalId:  '',
customField: '20091006-131504'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2243',
internalId:  '',
customField: '20091006-131716'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2264',
internalId:  '',
customField: '20090704-174333'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2285',
internalId:  '',
customField: '20100317-183254'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2306',
internalId:  '',
customField: '20091007-050046'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2327',
internalId:  '',
customField: '20091006-134708'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2348',
internalId:  '',
customField: '20091006-134847'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0IN32CR';
var companyName   = '+BagButton.co.uk';
var htmlTitle	  = 'Space+BagButton%2C+Vacuum+Space+Bags+for+a+few+Pence';
var metaKeywords  = 'Space+bag%2Cspace+bags%2Cvacuum+space+bags%2Cvacuum+storage+bags%2Chome+storage%2CSpace+BagButton%2Cstorage+bags%2Cbin+bags%2Cspace+saver+bags%2Cspace+saving+bags%2Cspace+savers%2Chome+storage+bags%2Chome+and+garden%2C+buy+space+bags%2Cvacuum+space+saver%2Ccompression+bag%2C+compression+bags%2Cvacuum+bags%2CStorage+system%2C+Storage+systems%2C+plastic+bags%2C+garbage+bags%2C+trash+bags%2C+seen+on+TV%2C+as+seen+on+TV%2C+packmate%2C+pack+mate%2C+pack+mate+bags%2C+food+saver+bags';
var metaContents  = 'BagButton+Vacuum+Storage+Space+bags+for+pennies.+Spacebags+for+the+price+of+a+plastic+bag.+Dustbin%2FGarbage+bags+are+the+original+space+bag%21';
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();
};
