/* [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','2501',jdecode('Chasing+Beauty'),jdecode(''),'/2501.html','true',[],''],
	['PAGE','7001',jdecode('About+Chasing+Beauty'),jdecode(''),'/7001.html','true',[],''],
	['PAGE','4301',jdecode('Table+of+Contents'),jdecode(''),'/4301.html','true',[],''],
	['PAGE','38001',jdecode('Foreword'),jdecode(''),'/38001.html','true',[],''],
	['PAGE','2552',jdecode('Prologue'),jdecode(''),'/2552.html','true',[],''],
	['PAGE','2573',jdecode('Author+%2F+Contact'),jdecode(''),'/2573.html','true',[],''],
	['PAGE','31601',jdecode('Blog'),jdecode(''),'/31601.html','true',[],'']];
var siteelementCount=7;
theSitetree.topTemplateName='Applicant';
theSitetree.paletteFamily='EEBE79';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='26568';
theSitetree.graphicsetId='13381';
theSitetree.contentColor='835e29';
theSitetree.contentBGColor='fce7ca';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Applicant',
				paletteFamily: 	'EEBE79',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'26568',
				graphicsetId: 	'13381',
				contentColor: 	'835e29',
				contentBGColor: 'fce7ca',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'EEBE79',
				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:  '2501',
internalId:  '',
customField: '20100614-091422'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38001',
internalId:  '',
customField: '20091123-194748'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2552',
internalId:  '',
customField: '20080725-125201'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4301',
internalId:  '',
customField: '20080724-145230'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2573',
internalId:  '',
customField: '20100327-182051'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '38001',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31601',
internalId:  '',
customField: '20090719-075942'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7001',
internalId:  '',
customField: '20100322-063502'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2501',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '7001',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4301',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2552',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2573',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '31601',
internalId:  '',
customField: 'language:en;country:US;'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0IN2PRL';
var companyName   = 'CHASING+BEAUTY%3A+My+Cosmetic+Surgery+Takeover';
var htmlTitle	  = 'CHASING+BEAUTY%3A+My+Cosmetic+Surgery+Takeover';
var metaKeywords  = 'TODAY+show%2C+Fox+News%2C+Fox+and+Friends%2C+NBC+New+York%2C+Too+Much+Nip%2FTuck%2C+Beauty%2C+Chasing+Beauty%2C+Plastic+Surgery+Addiction%2C+Writers+Guild%2C+WGA+West+registered%2C+www.chasingbeauty.com%2C+KINDLE%2C+WOCM-FM+98.1+The+Rude+Awakening+Show%3A+http%3A%2F%2Firieradio.com%2Fpodcast%2FRudeAwakening.rss%2C+www.chasingbeauty.com%2C+Cosmetic%2C+Cosmetic+Surgery%2C+Plastic+Surgery%2C+Amazon%2C+Barnes+and+Noble%2C+BN.com%2C+amazon.com%2C+Jamieson+Dale%2C+Dr.+Michael+Yaremchuk%2C+beauty+Book%2C+Cosmetic+Surgery%2C++Book%2C+Plastic+Surgery+Book%2C+Beauty+Memoir%2C+Cosmetic+Surgery+Memoir%2C+Plastic+Surgery+Memoir%2C+Bad+Plastic+Surgery%2C+Good+Plastic+Surgery%2C+Boston+Plastic+Surgery%2C+Boston+Cosmetic+Surgery%2C+fabulously40.com%2C+Lois+W.+Stern%2C+Sex+Lies+and+Cosmetic+Surgery%2C+Kerry+Cohen%2C+Loose+Girl%2C+amazon%2C+kindle%2C+myspace%2C+facebook%2C+twitter%2C+stumble%2C+FlashNews%2C+Woman+Alters+Entire+Face+With+15+Surgeries%2C+KING5+News';
var metaContents  = 'Chasing+Beauty%3A+My+Cosmetic+Surgery+Takeover+by+author+Jamieson+Dale%2C+Foreword+by+Dr.+Michael+Yaremchuk+of+Massachusetts+General+Hospital+and+Harvard+Medical+School.+TODAY+show+features+Chasing+Beauty+in+Woman+Addicted+to+Plastic+Surgery.';
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();
};
