/* [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','12412',jdecode('Home'),jdecode(''),'/12412.html','true',[],''],
	['PAGE','12463',jdecode('Organic+Mattresses'),jdecode(''),'/12463/index.html','true',[ 
		['PAGE','31512',jdecode('WJ+Southard'),jdecode(''),'/12463/31512.html','true',[],''],
		['PAGE','13012',jdecode('Land+and+Sky'),jdecode(''),'/12463/13012.html','true',[],'']
	],''],
	['PAGE','27312',jdecode('Royal-Pedic'),jdecode(''),'/27312/index.html','true',[ 
		['PAGE','27912',jdecode('All+Cotton+Mattress'),jdecode(''),'/27312/27912.html','true',[],''],
		['PAGE','27933',jdecode('Quilt+Top'),jdecode(''),'/27312/27933.html','true',[],''],
		['PAGE','27954',jdecode('Royal+Cloud'),jdecode(''),'/27312/27954.html','true',[],'']
	],''],
	['PAGE','12712',jdecode('Simmons+Beautyrest'),jdecode(''),'/12712.html','true',[],''],
	['PAGE','34012',jdecode('ComforPedic+'),jdecode(''),'/34012.html','true',[],''],
	['PAGE','32712',jdecode('Wood+Platform+Beds'),jdecode(''),'/32712.html','true',[],''],
	['PAGE','12733',jdecode('Crib+Mattresses'),jdecode(''),'/12733.html','true',[],''],
	['PAGE','12754',jdecode('Iron+Beds'),jdecode(''),'/12754.html','true',[],''],
	['PAGE','17312',jdecode('Contact+Info'),jdecode(''),'/17312.html','true',[],''],
	['PAGE','17912',jdecode('Special+Offers%21'),jdecode(''),'/17912.html','true',[],'']];
var siteelementCount=15;
theSitetree.topTemplateName='Commander';
theSitetree.paletteFamily='87700';
theSitetree.keyvisualId='2375';
theSitetree.keyvisualName='autobruecke.jpg';
theSitetree.fontsetId='391';
theSitetree.graphicsetId='440';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='E0E0E0';
var theTemplate={
				name: 			'Commander',
				paletteFamily: 	'87700',
				keyvisualId: 	'2375',
				keyvisualName: 	'autobruecke.jpg',
				fontsetId: 		'391',
				graphicsetId: 	'440',
				contentColor: 	'000000',
				contentBGColor: 'E0E0E0',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'E0E0E0',
				b_color: 		'54601',
				c_color: 		'43A53C',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12412',
internalId:  '',
customField: '20100130-112035'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12463',
internalId:  '',
customField: '20100127-135657'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13012',
internalId:  '',
customField: '20100130-112107'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12712',
internalId:  '',
customField: '20090506-172741'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12733',
internalId:  '',
customField: '20090810-123428'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12754',
internalId:  '',
customField: '20090506-155308'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17312',
internalId:  '',
customField: '20090418-101738'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17912',
internalId:  '',
customField: '20100226-102749'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27312',
internalId:  '',
customField: '20090617-124537'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27912',
internalId:  '',
customField: '20090905-102425'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27933',
internalId:  '',
customField: '20090617-125638'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27954',
internalId:  '',
customField: '20090617-125744'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '12412',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31512',
internalId:  '',
customField: '20100130-111639'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32712',
internalId:  '',
customField: '20090927-143642'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34012',
internalId:  '',
customField: '20091031-121146'
};
var canonHostname = 'wsc-worker04.chi.us.siteprotect.com';
var accountId     = 'AHW050INLJ3S';
var companyName   = 'North+Shore+Bedding';
var htmlTitle	  = 'Organic+Mattresses+Chicago+-+Royal-Pedic+-+North+Shore+Bedding';
var metaKeywords  = 'organic+mattress%2C++simmons+beautyrest%2C+chicago%2C+latex%2C+natural+mattress%2C+latex+mattress%2C+natural+latex%2C+chicago%2C+highland+park%2C+illinois%2C+ill%2C+60035%2C+mattresses%2C+beds%2C+foam+beds%2C+foam+mattress%2C+royal-pedic%2C+royalpedic%2C+royal+pedic';
var metaContents  = 'Chicagolands+leader+in+Organic+Mattresses.++Best+Selection+and+Prices%21++Royal-Pedic%2C+Simmons+Beautyrest+and+Wesley+Allen%2C+too%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();
};
