/* [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','2801',jdecode('Steve+Chapman'),jdecode(''),'/2801.html','true',[],'',''],
	['PAGE','45723',jdecode('Blog'),jdecode(''),'/45723.html','true',[],'',''],
	['PAGE','47323',jdecode('Social+Media'),jdecode(''),'/47323.html','true',[],'',''],
	['PAGE','44323',jdecode('Inner+Voice+Magazine'),jdecode(''),'/44323.html','true',[],'',''],
	['PAGE','44344',jdecode('Safe+Traffic+'),jdecode(''),'/44344/index.html','true',[ 
		['PAGE','8701',jdecode('Traffic+Safety'),jdecode(''),'/44344/8701.html','true',[],'','']
	],'',''],
	['PAGE','2852',jdecode('Bio'),jdecode(''),'/2852.html','true',[],'',''],
	['PAGE','2873',jdecode('Issues'),jdecode(''),'/2873/index.html','true',[ 
		['PAGE','23201',jdecode('Arts'),jdecode(''),'/2873/23201.html','true',[],'',''],
		['PAGE','8743',jdecode('Accountability'),jdecode(''),'/2873/8743.html','true',[],'',''],
		['PAGE','21822',jdecode('Airport+tunnel'),jdecode(''),'/2873/21822.html','true',[],'',''],
		['PAGE','21801',jdecode('Bedford+House'),jdecode(''),'/2873/21801.html','true',[],'',''],
		['PAGE','20601',jdecode('budget'),jdecode(''),'/2873/20601.html','true',[],'',''],
		['PAGE','18501',jdecode('Calgary+first'),jdecode(''),'/2873/18501.html','true',[],'',''],
		['PAGE','23222',jdecode('Crime'),jdecode(''),'/2873/23222.html','true',[],'',''],
		['PAGE','23243',jdecode('Development'),jdecode(''),'/2873/23243.html','true',[],'',''],
		['PAGE','19701',jdecode('Did+you+know%3F'),jdecode(''),'/2873/19701.html','true',[],'',''],
		['PAGE','23264',jdecode('Housing'),jdecode(''),'/2873/23264.html','true',[],'',''],
		['PAGE','22601',jdecode('open+for+business'),jdecode(''),'/2873/22601.html','true',[],'',''],
		['PAGE','21843',jdecode('Plan+It'),jdecode(''),'/2873/21843.html','true',[],'',''],
		['PAGE','34223',jdecode('Poverty+reduction'),jdecode(''),'/2873/34223.html','true',[],'',''],
		['PAGE','20643',jdecode('Recycling+and+Waste'),jdecode(''),'/2873/20643.html','true',[],'',''],
		['PAGE','41423',jdecode('SW+Ring+Road'),jdecode(''),'/2873/41423.html','true',[],'',''],
		['PAGE','31823',jdecode('Taxes'),jdecode(''),'/2873/31823.html','true',[],'',''],
		['PAGE','8722',jdecode('Transparency'),jdecode(''),'/2873/8722.html','true',[],'',''],
		['PAGE','41923',jdecode('Tuxedo+Park'),jdecode(''),'/2873/41923.html','true',[],'',''],
		['PAGE','36223',jdecode('Quarry+Park'),jdecode(''),'/2873/36223.html','true',[],'','']
	],'','']];
var siteelementCount=27;
theSitetree.topTemplateName='Natural';
theSitetree.paletteFamily='A43F21';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='154';
theSitetree.graphicsetId='182';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FCFCF4';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Natural',
				paletteFamily: 	'A43F21',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'154',
				graphicsetId: 	'182',
				contentColor: 	'000000',
				contentBGColor: 'FCFCF4',
				a_color: 		'A43F21',
				b_color: 		'E76E3E',
				c_color: 		'000000',
				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:  '2801',
internalId:  '',
customField: '20110401-154200'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2852',
internalId:  '',
customField: '20110328-193334'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2873',
internalId:  '',
customField: '20110401-170141'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2801',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8701',
internalId:  '',
customField: '20110328-192300'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8722',
internalId:  '',
customField: '20100826-100933'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8743',
internalId:  '',
customField: '20100826-095943'
};
webappMappings['1501']=webappMappings['1501-11815601']={
webappId:    '1501',
documentId:  '2801',
internalId:  '11815601',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '45723',
internalId:  '',
customField: '20110401-164640'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '44344',
internalId:  '',
customField: '20110328-195605'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41423',
internalId:  '',
customField: '20101016-050242'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18501',
internalId:  '',
customField: '20100826-123158'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19701',
internalId:  '',
customField: '20110211-170108'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23201',
internalId:  '',
customField: '20100914-131827'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20643',
internalId:  '',
customField: '20100819-015101'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20601',
internalId:  '',
customField: '20100810-084303'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22601',
internalId:  '',
customField: '20100809-084919'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21801',
internalId:  '',
customField: '20100812-052736'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21822',
internalId:  '',
customField: '20110401-170828'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21843',
internalId:  '',
customField: '20100916-093056'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23222',
internalId:  '',
customField: '20100924-110218'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23243',
internalId:  '',
customField: '20100820-053512'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23264',
internalId:  '',
customField: '20100911-123106'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '47323',
internalId:  '',
customField: '20110407-184526'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '31823',
internalId:  '',
customField: '20100831-130656'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '44323',
internalId:  '',
customField: '20110328-194129'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34223',
internalId:  '',
customField: '20100914-131314'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36223',
internalId:  '',
customField: '20100916-102923'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41923',
internalId:  '',
customField: '20101016-061209'
};
var canonHostname = 'localhost';
var accountId     = 'ANFI20IN2WD0';
var companyName   = 'Making+Calgary+a+Great+City';
var htmlTitle	  = 'Making+Calgary+a+Great+City+';
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();
};

