/* [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','3201',jdecode('Weight+Loss+Challenge'),jdecode(''), jdecode('%2F3201.html'), 'true',[],'',''],
	['PAGE','71812',jdecode('PUBLIC+MOBILE+WLC'),jdecode(''), jdecode('%2F71812.html'), 'true',[],'',''],
	['PAGE','24701',jdecode('Locations'),jdecode(''), jdecode('%2F24701.html'), 'true',[],'',''],
	['PAGE','3252',jdecode('NEWS+%21'),jdecode(''), jdecode('%2F3252.html'), 'true',[],'',''],
	['PAGE','53012',jdecode('WLC+for+your+Office'),jdecode(''), jdecode('%2F53012.html'), 'true',[],'',''],
	['PAGE','34501',jdecode('Our+Weekly+Program'),jdecode(''), jdecode('%2F34501.html'), 'true',[],'',''],
	['PAGE','3336',jdecode('Join+the+Challenge%21'),jdecode(''), jdecode('%2F3336.html'), 'true',[],'',''],
	['PAGE','47612',jdecode('About+WLC+'),jdecode(''), jdecode('%2F47612.html'), 'true',[],'',''],
	['PAGE','3315',jdecode('Contact+Us'),jdecode(''), jdecode('%2F3315.html'), 'true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Comic';
theSitetree.paletteFamily='071A5E';
theSitetree.keyvisualId='9982';
theSitetree.keyvisualName='kv1.swf';
theSitetree.fontsetId='17761';
theSitetree.graphicsetId='13130';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'endurance',
  product: 'WSCSYSSSSLY0XRNC'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				name: 			'Comic',
				paletteFamily: 	'071A5E',
				keyvisualId: 	'9982',
				keyvisualName: 	'kv1.swf',
				fontsetId: 		'17761',
				graphicsetId: 	'13130',
				contentColor: 	'000000',
				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:     'true'
			  };
var webappMappings = {};
webappMappings['7008']=webappMappings['7008-16258']={
webappId:    '7008',
documentId:  '3336',
internalId:  '16258',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3315',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3201',
internalId:  '',
customField: '20120123-180123'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3201',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '3201',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '47612',
internalId:  '',
customField: '20120203-174605'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '24701',
internalId:  '',
customField: '20120203-175134'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3252',
internalId:  '',
customField: '20110329-222211'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3336',
internalId:  '',
customField: '20101207-115943'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3252',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '24701',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3315',
internalId:  '',
customField: '20110720-110551'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3336',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34501',
internalId:  '',
customField: '20110831-174853'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '53012',
internalId:  '',
customField: '20101220-204818'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '34501',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '47612',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '53012',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '71812',
internalId:  '',
customField: '20110903-113155'
};
webappMappings['7008']=webappMappings['7008-33962']={
webappId:    '7008',
documentId:  '71812',
internalId:  '33962',
customField: 'language:en;country:US;'
};
var webAppHostname = 'cgiwsc.enhancedsitebuilder.com:80';
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0IN37W6';
var companyName   = 'Weight+Loss+Challenge';
var htmlTitle	  = 'Toronto+Weight+Loss+Challenge';
var metaKeywords  = 'weight+loss+challenge+protein+sport+sexy+body+slim+fit+management+contest+Toronto+Canada+nutrition+sport+food+label+win+cash+money+contact+coach+richmond+hill+North+York+Mississauga+brampton+thornhill+newmarket+locations+ask+me+how+supplements%2C+herbalife%2C+office+weight+loss%2C+office+challenge%2C+workplace+challenge%2C+employee+challenge%2C+simple+challenge%2C+weight%2C+loss%2C+keep+weight+off%2C+energy%2C+fitness%2C+diabetes%2C+cholesterol%2C+bloodpressure%2C+weight+loss%2C+cash+prize%2C+cash+money%2C+200%2C+challenge+at+work%2C+challenge+with+employees%2C+boss+lose+weight.+Beaches+weight+loss+challenge%2C+NOrth+York%2C+Richmond+Hill%2C+Thornhill%2C+Riverdale%2C+Leslieville%2C+Leaside%2C+Niagara+Weight+Loss+Challenge%2C+downtown+weight+loss+challenge%2C+newmarket+weight+loss+challenge%2C+barrie+weight+loss.+office+challenge%2C+office+wellness+program%2C+employee%2C+health+program%2C+lunch+and+learn.+';
var metaContents  = 'Congratulations+on+your+decision+to+get+serious+about+weight+loss.+On+this+website%2C+you+will+find+all+the+tools+you+need+to+help+guide+you+through+the+Weight+Loss+Challenge.';
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();
};

