/* [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','5001',jdecode('Home'),jdecode(''), jdecode('%2F5001.html'), 'true',[],'',''],
	['PAGE','5301',jdecode('Monthly+Specials'),jdecode(''), jdecode('%2F5301.html'), 'true',[],'',''],
	['PAGE','5073',jdecode('Wine'),jdecode(''), jdecode('%2F5073.html'), 'true',[],'',''],
	['PAGE','5094',jdecode('Beer'),jdecode(''), jdecode('%2F5094.html'), 'true',[],'',''],
	['PAGE','5115',jdecode('Coolers+%26+Ciders'),jdecode(''), jdecode('%2F5115.html'), 'true',[],'',''],
	['PAGE','5157',jdecode('Home+Brew+Supplies'),jdecode(''), jdecode('%2F5157.html'), 'true',[],'',''],
	['PAGE','5136',jdecode('Labels'),jdecode(''), jdecode('%2F5136.html'), 'true',[],'',''],
	['PAGE','10001',jdecode('Store+Hours'),jdecode(''), jdecode('%2F10001.html'), 'true',[],'',''],
	['PAGE','5178',jdecode('Contact'),jdecode(''), jdecode('%2F5178.html'), 'true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Card';
theSitetree.paletteFamily='990000';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='430';
theSitetree.graphicsetId='479';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'endurance',
  product: 'WSCSYSSSSLY0XRNC'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Card',
				paletteFamily: 	'990000',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'430',
				graphicsetId: 	'479',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'FFFFFF',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5001',
internalId:  '',
customField: '20111102-182959'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5178',
internalId:  '',
customField: '20111102-182602'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5301',
internalId:  '',
customField: '20111102-182421'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5094',
internalId:  '',
customField: '20101102-170934'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5157',
internalId:  '',
customField: '20101102-172608'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5115',
internalId:  '',
customField: '20110302-123515'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '5001',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5073',
internalId:  '',
customField: '20110721-201618'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10001',
internalId:  '',
customField: '20110302-123234'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5136',
internalId:  '',
customField: '20101102-171819'
};
var webAppHostname = 'cgiwsc.enhancedsitebuilder.com:80';
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0INVAZS';
var companyName   = '';
var htmlTitle	  = '';
var metaKeywords  = 'wine%2C+beer%2C+wine+equipment%2C+wine+making%2C+cider%2C+coolers%2C+Chilliwack%2C+beer+making%2C+vineco%2C+divine+wines%2C+christies+ubrew%2C+christies+custom+brewing%2C+u-vin%2C+uu-brew%2C+hobby+brew%2C+wine+kits%2C+beer++wine+store%2C+beer+kits%2C+sardis%2C+brewery%2C+micro+brewery%2C+wine+making+supplies%2C+beer+making+supplies%2C+vinoka%2C+wine+craft%2C+spagnolds%2C+spagnols%2C+cellarcraft%2C+home+wine+making%2C+draught+beer%2C+kegs%2C+carboys%2C+kegerator%2C+cold+beer%2C+stout%2C+ale%2C+lager%2C+grapes%2C+advintage%2C+limited+edition+kits%2C+water%2C+chilliwack+water%2C+port%2C+ice%2C+party+supplies%2C+beverages%2C+custom+brewing%2C+wine+making+need+of+chilliwack%2C+wine+making+needs+of+sardis%2C+beer+making+in+chilliwack%2C+vinters%2C+micro+breweries+in+chilliwack%2C+hops%2C+yeast%2C+barley%2C+wine+makers+supplies+and+equipment%2C+beer+makers+equipment+and+supplies%2C+quality+wine+and+beer%2C+wine+and+beer+specials%2C+liquor+stores%2C+liquers%2C+wines+in+chilliwack%2C+beer+in+chilliwack%2C+pinot+gris%2C+piont+noir%2C+valpolicella%2C+chardonnay%2C+sauvignon+blanc%2C+cheeky+monkey%2C+vinterra%2C+the+brew+house%2C+kenridge%2C+vineco%2C+labels%2C+custom%2C+personalized%2C+bottles%2C+wine+bottles%2C+beer+bottles%2C+beer+cans%2C+corks%2C+corkscrews%2C+corkers%2C+wine+kitz%2C+connors+wine+cella%2C+vine+o+wine%2C+carbonated+wines+and+beer%2C+carbonated+wine%2C+carbonated+beer%2C+canned+beer%2C+collectors%2C+founders%2C+series%2C+showcase';
var metaContents  = 'La+Brewhouse+is+the+only+u-brew+in+Chilliwack+that+offers+Micro-Brewed+beer+and+award+wining+Vneco+wine+kits.+Located+on+Young+Rd.';
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();
};

