/* [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','4701',jdecode('Home'),jdecode(''),'/4701.html','true',[],''],
	['PAGE','4752',jdecode('Luxury+Divans'),jdecode(''),'/4752.html','true',[],''],
	['PAGE','53957',jdecode('Buget+Divans'),jdecode(''),'/53957.html','true',[],''],
	['PAGE','23801',jdecode('Mattresses'),jdecode(''),'/23801.html','true',[],''],
	['PAGE','44757',jdecode('Bunk+And+Guest+Beds'),jdecode(''),'/44757.html','true',[],''],
	['PAGE','23822',jdecode('Faux+Leather'),jdecode(''),'/23822.html','true',[],''],
	['PAGE','4773',jdecode('Metal+Frames'),jdecode(''),'/4773.html','true',[],''],
	['PAGE','4794',jdecode('Wooden+Frames'),jdecode(''),'/4794.html','true',[],''],
	['PAGE','29001',jdecode('Fabric+Head+Boards+'),jdecode(''),'/29001.html','true',[],''],
	['PAGE','39957',jdecode('Fabric+Prices'),jdecode(''),'/39957.html','false',[],''],
	['PAGE','38801',jdecode('Faux+Leather+Head+Boards'),jdecode(''),'/38801.html','true',[],''],
	['PAGE','37601',jdecode('Electric+Ajustable+Beds'),jdecode(''),'/37601.html','true',[],''],
	['PAGE','52357',jdecode('Caring+for+your+new+bed'),jdecode(''),'/52357.html','true',[],''],
	['PAGE','40457',jdecode('Where+to+Find+Us'),jdecode(''),'/40457.html','true',[],''],
	['PAGE','41457',jdecode('Email+Us'),jdecode(''),'/41457.html','true',[],'']];
var siteelementCount=15;
theSitetree.topTemplateName='Weekend';
theSitetree.paletteFamily='4A53AF';
theSitetree.keyvisualId='4078';
theSitetree.keyvisualName='kv_4078.jpg';
theSitetree.fontsetId='10539';
theSitetree.graphicsetId='11142';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='5C65C1';
var theTemplate={
				name: 			'Weekend',
				paletteFamily: 	'4A53AF',
				keyvisualId: 	'4078',
				keyvisualName: 	'kv_4078.jpg',
				fontsetId: 		'10539',
				graphicsetId: 	'11142',
				contentColor: 	'000000',
				contentBGColor: '5C65C1',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Times New Roman, Times, serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4701',
internalId:  '',
customField: '20091121-050651'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4752',
internalId:  '',
customField: '20091130-074429'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4773',
internalId:  '',
customField: '20091121-044536'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4794',
internalId:  '',
customField: '20100115-062654'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41457',
internalId:  '',
customField: '20091117-070604'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4701',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23822',
internalId:  '',
customField: '20091130-101601'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23801',
internalId:  '',
customField: '20091118-062048'
};
webappMappings['1501']=webappMappings['1501-5897352']={
webappId:    '1501',
documentId:  '4701',
internalId:  '5897352',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '29001',
internalId:  '',
customField: '20091117-104801'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '37601',
internalId:  '',
customField: '20091117-105021'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38801',
internalId:  '',
customField: '20091117-104904'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39957',
internalId:  '',
customField: '20091117-034938'
};
webappMappings['7008']=webappMappings['7008-5540']={
webappId:    '7008',
documentId:  '41457',
internalId:  '5540',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40457',
internalId:  '',
customField: '20091117-105121'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '44757',
internalId:  '',
customField: '20100120-084211'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '52357',
internalId:  '',
customField: '20100115-072741'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '53957',
internalId:  '',
customField: '20100118-114028'
};
var canonHostname = 'wsc-worker04.chi.us.siteprotect.com';
var accountId     = 'AHW050IN3NH8';
var companyName   = 'Beds+For+Everyone+';
var htmlTitle	  = 'Divans+Beds%2C++Mattresses%2CHead+Boards%2C+Metal+Frames%2CRacing+Car+Bed%2C+Pine+Frames%2CHead+Boards%2C+Fast+Delivery%2C+Leeds+and+Bradford+';
var metaKeywords  = '4ft+bedsadjustable+bedsairsprung+bedsairsprung+mattressbargain+bedsbed+framebed+framesbed+headboardsbed+mattressesbedsbeds+and+mattressesbeds+for+salebeds+mattressesbedsteadbedsteadsbunk+bedbunk+bedsbuy+bedscheap+divan+bedsdivandivan+bedsdivansdouble+bed+framesdouble+bedsdouble+mattressdouble+mattresseskids+bedkingsize+bedsleather+bedsluxury+mattressmattressmattress+next+day+deliverymattressesmemory+foam+bedsmetal+bedmetal+bed+framesmetal+bedsorthopaedic+bedsorthopaedic+mattresspine+bedpine+bedssealy+bedssingle+bed+framessingle+bedssleepeezee+bedssmall+double+bedssprung+mattressstorage+bedssuper+king+bedswhite+bedswooden+bed+frameswooden+beds';
var metaContents  = 'Leeds+Based+Bed+Retailer+Established+30+Years+Selling+Divans%2C+Mattresses%2C+Pine+and+Metal+Frames%2CFaux+Leather+and+Real+Leather+Frames+All+Types+of+Head+Boards+Offering+Fast+Local+Delivery++';
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();
};
