/* [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','4001',jdecode('Home'),jdecode(''),'/4001.html','true',[],''],
	['PAGE','4094',jdecode('Beers+Just+In'),jdecode(''),'/4094.html','true',[],''],
	['PAGE','6901',jdecode('Upcoming+Tastings'),jdecode(''),'/6901.html','true',[],''],
	['PAGE','4052',jdecode('Special+Orders'),jdecode(''),'/4052.html','true',[],''],
	['PAGE','6922',jdecode('News+%26+Lottery'),jdecode(''),'/6922.html','true',[],''],
	['PAGE','4073',jdecode('Links'),jdecode(''),'/4073.html','true',[],''],
	['PAGE','8501',jdecode('Directions'),jdecode(''),'/8501.html','true',[],''],
	['PAGE','4178',jdecode('Hours'),jdecode(''),'/4178.html','true',[],''],
	['PAGE','22601',jdecode('cookie'),jdecode(''),'/22601.html','false',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Grace';
theSitetree.paletteFamily='CECDD0';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='32047';
theSitetree.graphicsetId='13873';
theSitetree.contentColor='484848';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Grace',
				paletteFamily: 	'CECDD0',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'32047',
				graphicsetId: 	'13873',
				contentColor: 	'484848',
				contentBGColor: 'FFFFFF',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4001',
internalId:  '',
customField: '20100719-132127'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4094',
internalId:  '',
customField: '20100719-131711'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4052',
internalId:  '',
customField: '20090917-002123'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4073',
internalId:  '',
customField: '20090917-002738'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4001',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6922',
internalId:  '',
customField: '20090916-234520'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4094',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4178',
internalId:  '',
customField: '20090917-001734'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4001',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6901',
internalId:  '',
customField: '20100722-171114'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '6901',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4052',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '6922',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4073',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4178',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-20960']={
webappId:    '7008',
documentId:  '4052',
internalId:  '20960',
customField: 'language:en;country:US;'
};
webappMappings['2001']=webappMappings['2001-location']={
webappId:    '2001',
documentId:  '8501',
internalId:  'location',
customField: 'language:en;country:US;isIncluded:true;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8501',
internalId:  '',
customField: '20090917-004040'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8501',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22601',
internalId:  '',
customField: '20100419-234841'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0INVWCN';
var companyName   = 'Your+favorites.+Our+specialty.';
var htmlTitle	  = 'Hartwood+Beer+Distributor';
var metaKeywords  = 'Hartwood+Beer%2CFox+Chapel+Beer%2CGlenshaw+Beer%2CFox+Chapel+Beer+Distributor%2CGlenshaw+Beer+Distributor%2CHampton+Beer%2CHampton+Beer+Distributor%2CIndiana+Township+Beer%2C15116%2C15238%2C15215%2CCraft+Beer%2CPittsburgh+Beer%2CDorseyville%2COHara+Beer%2CHarts+Run%2CSaxonburg%2CMiller%2CCoors%2CLite%2CYuengling%2CBud%2CSam+Adams%2CDogfish%2CSierra+Nevada%2CVictory%2CBelgian+Beer%2CBlue+Moon%2CLabatt%2CMolson%2CStraub%2CMagic+Hat%2CGreat+Lakes%2CHeineken%2CAmstel%2CBells%2CGuinness%2CCorona%2CStella+Artois%2CIron+City%2CBudweiser%2CHoegaarden%2Cice%2Cimports%2Cdomestic%2Cmicrobrews%2Chartwood+towne+centre%2Chartwood+town+center%2CHart+Wood%2Csnacks%2Ccigars%2Cspecialty+beer+distribitor%2Ckegs';
var metaContents  = 'Hartwood+Beer+Distributor+-+Your+favorites.+Our+specialty.+Hartwood+Beer+Distributor+located+at+Saxonburg+Blvd.++Harts+Run+Rd.+in+Hartwood+Towne+Centre%2C+offers+specialty+beers%2C+ice%2C+soda%2C+and+snacks.+Well+get+your+favorites+for+you%21';
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();
};
