/* [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','6143',jdecode('Home'),jdecode(''),'/6143.html','true',[],'',''],
	['PAGE','6194',jdecode('Online+Catalog'),jdecode(''),'/6194.html','true',[],'',''],
	['PAGE','6236',jdecode('New+Books+%26+DVDs'),jdecode(''),'/6236.html','true',[],'',''],
	['PAGE','6320',jdecode('Databases'),jdecode(''),'/6320.html','true',[],'',''],
	['PAGE','6215',jdecode('Calendar'),jdecode(''),'/6215.html','true',[],'',''],
	['PAGE','6362',jdecode('Links'),jdecode(''),'/6362.html','true',[],'',''],
	['PAGE','6278',jdecode('FAQS'),jdecode(''),'/6278.html','false',[],'',''],
	['PAGE','6299',jdecode('Blog'),jdecode(''),'/6299.html','true',[],'',''],
	['PAGE','6383',jdecode('Teens'),jdecode(''),'/6383.html','true',[],'',''],
	['PAGE','6404',jdecode('Children'),jdecode(''),'/6404.html','false',[],'',''],
	['PAGE','6341',jdecode('Genealogy'),jdecode(''),'/6341.html','true',[],'',''],
	['PAGE','6257',jdecode('Contact+us'),jdecode(''),'/6257.html','true',[],'',''],
	['PAGE','31864',jdecode('Media+album'),jdecode(''),'/31864.html','false',[],'',''],
	['PAGE','50564',jdecode('Authors'),jdecode(''),'/50564.html','true',[],'',''],
	['PAGE','62164',jdecode('Best-Sellers+%26+Awards'),jdecode(''),'/62164.html','true',[],'','']];
var siteelementCount=15;
theSitetree.topTemplateName='Seasons_spring';
theSitetree.paletteFamily='FFFFFF';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='21090';
theSitetree.graphicsetId='13190';
theSitetree.contentColor='2E2E2E';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'true',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				name: 			'Seasons_spring',
				paletteFamily: 	'FFFFFF',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'21090',
				graphicsetId: 	'13190',
				contentColor: 	'2E2E2E',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6143',
internalId:  '',
customField: '20100728-160847'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6194',
internalId:  '',
customField: '20091014-163148'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6215',
internalId:  '',
customField: '20100708-151841'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6383',
internalId:  '',
customField: '20100610-122816'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6236',
internalId:  '',
customField: '20100728-162148'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6299',
internalId:  '',
customField: '20091014-194614'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '50564',
internalId:  '',
customField: '20100429-134139'
};
webappMappings['7050']=webappMappings['7050-3006']={
webappId:    '7050',
documentId:  '6299',
internalId:  '3006',
customField: 'language:en;country:US;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '6143',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6362',
internalId:  '',
customField: '20100324-111624'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6257',
internalId:  '',
customField: '20100225-183835'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6278',
internalId:  '',
customField: '20090916-201436'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6320',
internalId:  '',
customField: '20091014-163616'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6341',
internalId:  '',
customField: '20091014-135823'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6404',
internalId:  '',
customField: '20090916-201436'
};
webappMappings['1501']=webappMappings['1501-14620477']={
webappId:    '1501',
documentId:  '6143',
internalId:  '14620477',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31864',
internalId:  '',
customField: '20091209-095326'
};
webappMappings['7060']=webappMappings['7060-3d46e05c85c71df2839693dd80b2eb6b']={
webappId:    '7060',
documentId:  '31864',
internalId:  '3d46e05c85c71df2839693dd80b2eb6b',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '62164',
internalId:  '',
customField: '20100524-115620'
};
var canonHostname = 'diywk00.verio.stngva01.us.diy-servers.net';
var accountId     = 'AVFL30INHUX3';
var companyName   = '+Madisonville%2C+TN+Public+Library';
var htmlTitle	  = '';
var metaKeywords  = '';
var metaContents  = '';
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();
};
