/* [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','1601',jdecode('Home'),jdecode(''), jdecode('%2F1601.html'), 'true',[],'',''],
	['PAGE','18501',jdecode('Schedule+of+Events'),jdecode(''), jdecode('%2F18501.html'), 'true',[],'',''],
	['PAGE','28701',jdecode('Dairy+Princess'),jdecode(''), jdecode('%2F28701.html'), 'true',[],'',''],
	['PAGE','89401',jdecode('Mechanical+Pulling'),jdecode(''), jdecode('%2F89401.html'), 'true',[],'',''],
	['PAGE','89422',jdecode('Woodmans+Day'),jdecode(''), jdecode('%2F89422.html'), 'true',[],'',''],
	['PAGE','93831',jdecode('Animal+Pulling'),jdecode(''), jdecode('%2F93831.html'), 'true',[],'',''],
	['PAGE','7701',jdecode('Fair+Photos'),jdecode(''), jdecode('%2F7701.html'), 'true',[],'',''],
	['PAGE','10301',jdecode('Parade+Photos'),jdecode(''), jdecode('%2F10301.html'), 'true',[],'',''],
	['PAGE','21001',jdecode('Sponsor+Page'),jdecode(''), jdecode('%2F21001.html'), 'false',[],'',''],
	['PAGE','14401',jdecode('Map+%26+Directions'),jdecode(''), jdecode('%2F14401.html'), 'true',[],'',''],
	['PAGE','12001',jdecode('Vendors'),jdecode(''), jdecode('%2F12001%2Findex.html'), 'true',[ 
		['PAGE','16501',jdecode('Vendor+Forms'),jdecode(''), jdecode('%2F12001%2F16501.html'), 'true',[],'','']
	],'',''],
	['PAGE','18522',jdecode('Links'),jdecode(''), jdecode('%2F18522.html'), 'true',[],'',''],
	['PAGE','18543',jdecode('Contact'),jdecode(''), jdecode('%2F18543.html'), 'true',[],'','']];
var siteelementCount=14;
theSitetree.topTemplateName='Drivein';
theSitetree.paletteFamily='B89834';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='16672';
theSitetree.graphicsetId='12231';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='000000';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'fatcow',
  product: 'WSCSYSSSSLY0XRN4'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Drivein',
				paletteFamily: 	'B89834',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'16672',
				graphicsetId: 	'12231',
				contentColor: 	'FFFFFF',
				contentBGColor: '000000',
				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:  '1601',
internalId:  '',
customField: '20120119-210727'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '89422',
internalId:  '',
customField: '20111113-153942'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7701',
internalId:  '',
customField: '20110915-121518'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10301',
internalId:  '',
customField: '20110915-182259'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12001',
internalId:  '',
customField: '20110914-160523'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '14401',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14401',
internalId:  '',
customField: '20110401-072321'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16501',
internalId:  '',
customField: '20110914-180104'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18501',
internalId:  '',
customField: '20111109-090149'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18522',
internalId:  '',
customField: '20120119-194205'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18543',
internalId:  '',
customField: '20120119-194105'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21001',
internalId:  '',
customField: '20110624-082411'
};
webappMappings['7060']=webappMappings['7060-1daa061a0dd26c92e9332983d17b1752']={
webappId:    '7060',
documentId:  '7701',
internalId:  '1daa061a0dd26c92e9332983d17b1752',
customField: 'language:en;country:US;'
};
webappMappings['1501']=webappMappings['1501-44166519']={
webappId:    '1501',
documentId:  '1601',
internalId:  '44166519',
customField: '1501'
};
webappMappings['7060']=webappMappings['7060-1054a91cdd14b03982e1ea93aef808c5']={
webappId:    '7060',
documentId:  '89401',
internalId:  '1054a91cdd14b03982e1ea93aef808c5',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '89401',
internalId:  '',
customField: '20111110-065132'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '28701',
internalId:  '',
customField: '20111113-155302'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '93831',
internalId:  '',
customField: '20120119-193944'
};
var webAppHostname = 'cgiwsc.enhancedsitebuilder.com:80';
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0INLQXE';
var companyName   = 'Clinton+Lions+Agricultural+Fair';
var htmlTitle	  = '';
var metaKeywords  = 'Clinton+Lions+club+fair+agricultural';
var metaContents  = 'The+Clinton+Lions+Club+Fair';
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();
};

