/* [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','501',jdecode('Home'),jdecode(''), jdecode('%2F501.html'), 'true',[],'','']];
var siteelementCount=1;
theSitetree.topTemplateName='Display';
theSitetree.paletteFamily='222222';
theSitetree.keyvisualId='11372';
theSitetree.keyvisualName='kv_11372.jpg';
theSitetree.fontsetId='31963';
theSitetree.graphicsetId='13802';
theSitetree.contentColor='1B1B1B';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'wl_enom',
  product: 'WSCENOSSSLYTC21A'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Display',
				paletteFamily: 	'222222',
				keyvisualId: 	'11372',
				keyvisualName: 	'kv_11372.jpg',
				fontsetId: 		'31963',
				graphicsetId: 	'13802',
				contentColor: 	'1B1B1B',
				contentBGColor: 'FFFFFF',
				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:  '501',
internalId:  '',
customField: '20120203-163307'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '501',
internalId:  '',
customField: 'language:en;country:US;'
};
var webAppHostname = 'wsc.ehost-services.com:80';
var canonHostname = 'wscwrk01.ehost-services.com';
var accountId     = 'AEN010IN3MJT';
var companyName   = 'Best10+Restaurants+in+Chicago';
var htmlTitle	  = 'CHICAGO%27S+BEST+RESTAURANTS+TOP+10';
var metaKeywords  = 'best+restaurants+in+chicago%2C+chicago+best+restaurants%2C+best+of+chicago+restaurants%2C+chicago+restaurants+best%2C+best+chicago+restaurants%2C+the+best+restaurants+in+chicago%2C+best+restaurants+of+chicago.restaurants+chicago+best%2C+what+are+the+best+restaurants+in+chicago%0D%0Athe+best+chicago+restaurants%2C+best+restaurants+in+downtown+chicago%2C+best+restaurants+in%2C+chicago+downtown%2C+chicago+best+restaurants+downtown%2C+best+restaurants+downtown+chicago%0D%0Abest+chicago+restaurants+downtown%2C+best+downtown+chicago+restaurants%2C+best+restaurants+chicago%C2%A0downtown%2C+best+chicago+downtown+restaurants%2C+downtown+chicago+best+restaurants%0D%0Abest+italian+restaurants+chicago%2C+best+italian+restaurants+in+chicago%2C+10%C2%A0best+restaurants+chicago%0D%0Abest+restaurants+in+chicago+2011.+best+chicago+italian+restaurants.+chicago+best%2C+Italian+Restaurany+Italian+%2CRestaurants+10+best+restaurants+in+chicago%2C+best+chicago+restaurants+2011%2C%0D%0A10+best+chicago+restaurants%0D%0Achicago+best+restaurants+2011%0D%0Achicago+s+best+restaurants%0D%0Atop+10+best+restaurants+in+chicago%0D%0Abest+steak+restaurants+in+chicago%0D%0Abest+steak+restaurants+chicago%0D%0Abest+chicago+steak+restaurants%0D%0Abest+new+restaurants+chicago%0D%0Abest+new+restaurants+in+chicago%0D%0Abest+new+chicago+restaurants%0D%0Achicago+best+new+restaurants%0D%0Abest+pizza+restaurants+in+chicago%0D%0Abest+chicago+pizza+restaurants%0D%0Abest+romantic+restaurants+chicago%0D%0Abest+romantic+restaurants+in+chicago%0D%0Abest+seafood+restaurants+in+chicago%0D%0Abest+rated+restaurants+in+chicago%0D%0Abest+seafood+restaurants+chicago%0D%0Abest+chicago+seafood+restaurants%0D%0Abest+restaurants+in+chicago+suburbs%0D%0Abest+mexican+restaurants+in+chicago%0D%0Abest+restaurants+in+chicago+il%0D%0Abest+restaurants+chicago%C2%A0il%0D%0A';
var metaContents  = '+Chicago%E2%80%99s+Restaurant+Guide+to++Best+Top+10%2C+Restaurant+Guide%2C+Chicago%2C+Suburbs%2C+Northwest+Subarbs+Illinois+%2C+Western+Suburbs+Illinois%2C++Good%7C+cafes%2C+diner%2C+drink%2C+cafe%2C+gourmet%2C+cuisine%2C+bars%2C+guide%2C+meal%2C+eat%2C+chef%2C+cook%2C+brunch%2C+lunch%2C+dinner%2C+breakfast%2C++vegetarian%2C+Italian%2C+Asian%2C+American%2C+Mexican%2C+Chinese%2C+Thai%2C+Japanese%2C+steakhouse%2C+burgers%2C+BBQ%2C+sushi%2C+barbecue%2C+chicken%2C+Italian%2CO%27Hare+Airport+%7C+Best+Stek+In+Chicago+%7C+Western+Suburbs+%7C+Northwest+Suburbs+%7C';
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();
};

