/* [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','5101',jdecode('Home'),jdecode(''),'/5101.html','true',[],''],
	['PAGE','5301',jdecode('Resources'),jdecode(''),'/5301.html','true',[],''],
	['PAGE','5322',jdecode('Dr.+Woodard%2C+Author'),jdecode(''),'/5322.html','true',[],''],
	['PAGE','5343',jdecode('Sample%2C+Slide+26'),jdecode(''),'/5343.html','true',[],''],
	['PAGE','5364',jdecode('Sample%2C+Slide+82'),jdecode(''),'/5364.html','true',[],''],
	['PAGE','5385',jdecode('E-Book+1%2C+Prevent+Dementia'),jdecode(''),'/5385.html','true',[],''],
	['PAGE','5406',jdecode('E-Book+2%2C..Atlas..Neuropatho'),jdecode(''),'/5406.html','true',[],'']];
var siteelementCount=7;
theSitetree.topTemplateName='Movement';
theSitetree.paletteFamily='003390';
theSitetree.keyvisualId='1819';
theSitetree.keyvisualName='kv_dummy.jpg';
theSitetree.fontsetId='289';
theSitetree.graphicsetId='353';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='003390';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Movement',
				paletteFamily: 	'003390',
				keyvisualId: 	'1819',
				keyvisualName: 	'kv_dummy.jpg',
				fontsetId: 		'289',
				graphicsetId: 	'353',
				contentColor: 	'FFFFFF',
				contentBGColor: '003390',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'003390',
				b_color: 		'000000',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5101',
internalId:  '',
customField: '20100118-163028'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5322',
internalId:  '',
customField: '20090816-195759'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5301',
internalId:  '',
customField: '20090816-191904'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5343',
internalId:  '',
customField: '20100101-152139'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5364',
internalId:  '',
customField: '20090816-192152'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5385',
internalId:  '',
customField: '20091114-142223'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5406',
internalId:  '',
customField: '20100118-162849'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '5101',
internalId:  '1006',
customField: '1006'
};
var canonHostname = 'cmworker01.yourhostingaccount.com';
var accountId     = 'AENDU0IN3HIY';
var companyName   = 'California+Medical+Publications';
var htmlTitle	  = 'Prevent+Dementia%2C+E-books%2C+Alzheimer%27s+disease%2C+alcohol+related+disorders%2C+human+brains';
var metaKeywords  = 'dementia+prevention%2C+educational+e-book%2C+alzheimers+disease%2C+Lewy+body+disease%2C+brain+abnormality%2C+memory+loss%2C+dementia+risk%2C+glucose+metabolism%2C+alcoholism%2C+alcoholism+memory+loss%2C+intellectual+impairment%2C+brain+injury%2C+aging+brain%2C+prevent+aging%2C+glucose+metabolism%2C+brain+pathology%2C+dealing+with+dementia%2C+aging%2C+disorientation%2C+forgetfulness%2C+hippocampus%2C+human+brain+photos';
var metaContents  = 'Say+No+To+Dementia%2C+E-Books%2C+Dementia+Prevention%2C+Alzheimers+disease%2C+Lewy+body+disease%2C+memory+loss%2C+forgetfulness%2C+alcoholism%2C+brain+trauma%2C+prevent+aging%2C+aging%2C+disorientation%2C+memory+loss%2C+glucose+matabolism%2C+human+brain%2C+human+brain+photographs%2C+histopathology%2C+neuropathology%2C+educational+ebooks+on+prevention+of+memory+loss';
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();
};
