/* [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','2601',jdecode('HOME'),jdecode(''), jdecode('%2F2601.html'), 'true',[],'',''],
	['PAGE','2652',jdecode('STYLES'),jdecode(''), jdecode('%2F2652.html'), 'false',[],'',''],
	['PAGE','2673',jdecode('CONFIGURATIONS'),jdecode(''), jdecode('%2F2673.html'), 'false',[],'',''],
	['PAGE','2694',jdecode('FABRICS+%26+LEATHERS'),jdecode(''), jdecode('%2F2694.html'), 'false',[],'',''],
	['PAGE','2715',jdecode('QUALITY'),jdecode(''), jdecode('%2F2715.html'), 'false',[],'',''],
	['PAGE','2799',jdecode('CONTACT'),jdecode(''), jdecode('%2F2799%2Findex.html'), 'false',[ 
		['PAGE','40644',jdecode('Los+Angeles%2C+CA'),jdecode(''), jdecode('%2F2799%2F40644.html'), 'true',[],'',''],
		['PAGE','40623',jdecode('Orange+County%2C+CA'),jdecode(''), jdecode('%2F2799%2F40623.html'), 'true',[],'',''],
		['PAGE','40665',jdecode('S.F.+Bay+Area%2C+CA'),jdecode(''), jdecode('%2F2799%2F40665.html'), 'true',[],'',''],
		['PAGE','40686',jdecode('Dallas%2C+TX'),jdecode(''), jdecode('%2F2799%2F40686.html'), 'true',[],'','']
	],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Alpha';
theSitetree.paletteFamily='555454';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10461';
theSitetree.graphicsetId='10892';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'hostway_generic',
  product: 'WSCSYSSSSLYTC245'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Alpha',
				paletteFamily: 	'555454',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10461',
				graphicsetId: 	'10892',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'555454',
				e_color: 		'555454',
				f_color: 		'555454',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2601',
internalId:  '',
customField: '20110827-135028'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40665',
internalId:  '',
customField: '20110525-202827'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2799',
internalId:  '',
customField: '20110525-202128'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2652',
internalId:  '',
customField: '20110413-125954'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2673',
internalId:  '',
customField: '20110201-152425'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2694',
internalId:  '',
customField: '20110202-182347'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2715',
internalId:  '',
customField: '20110201-152440'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40644',
internalId:  '',
customField: '20110525-202700'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40623',
internalId:  '',
customField: '20110525-202739'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2601',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '40686',
internalId:  '',
customField: '20110525-202909'
};
var webAppHostname = 'cgi-wsc.chi.us.siteprotect.com:80';
var canonHostname = 'wsc-worker03.chi.us.siteprotect.com';
var accountId     = 'AHW050INZUUK';
var companyName   = '';
var htmlTitle	  = 'Sofa+Craft+%7C+Quality+Custom+Sofas';
var metaKeywords  = 'affordable+custom+sofa+%2C+upholstered+custom+sofa+%2C+slipcovered+custom+sofa+%2C+hand+made+custom+sofa+%2C+contemporary+custom+sofa+%2C+modern+custom+sofa+%2C+transitional+custom+sofa+%2C+beautiful+custom+sofa+%2C+comfortable+custom+sofa+%2C+orange+county+custom+sofa+%2C+affordable+custom+sectional+%2C+upholstered+custom+sectional+%2C+slipcovered+custom+sectional+%2C+hand+made+custom+sectional+%2C+contemporary+custom+sectional+%2C+modern+custom+sectional+%2C+transitional+custom+sectional+%2C+beautiful+custom+sectional+%2C+comfortable+custom+sectional+%2C+orange+county+custom+sectional+%2C+affordable+custom+couch+%2C+upholstered+custom+couch+%2C+slipcovered+custom+couch+%2C+hand+made+custom+couch+%2C+contemporary+custom+couch+%2C+modern+custom+couch+%2C+transitional+custom+couch+%2C+beautiful+custom+couch+%2C+comfortable+custom+couch+%2C+orange+county+custom+couch';
var metaContents  = 'SOFA+CRAFT+HAS+CUSTOM+SOFAS++CUSTOM+SECTIONALS++CUSTOM+COUCHES+AT+THE+LOWEST+PRICES+GUARANTEED%21+A+CUSTOM+SECTIONAL+CUSTOM+SOFA+OR+CUSTOM+COUCH+IS+OUR+SPECIALTY.+SOFA+CRAFTS+CUSTOM+SOFA++CUSTOM+SECTIONAL++CUSTOM+COUCH+SHOWROOM+SHIPS+NATIONWIDE.+EVERY+CUSTOM+SOFA++CUSTOM+SECTIONAL++CUSTOM+COUCH+IS+HAND+MADE+BY+EXPERT+CRAFTSMEN.+COME+VISIT+OUR+CUSTOM+SOFA++CUSTOM+SECTIONAL++CUSTOM+COUCH+SHOWROOM+TODAY.';
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();
};

