/* [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','2001',jdecode('Home'),jdecode(''),'/2001.html','true',[],''],
	['PAGE','36357',jdecode('Blue+Skys+Skatewear'),jdecode(''),'/36357/index.html','true',[ 
		['PAGE','36378',jdecode('Catalogue+List'),jdecode(''),'/36357/36378.html','true',[],'']
	],''],
	['PAGE','3201',jdecode('Blue+Skys+Bldg'),jdecode(''),'/3201/index.html','true',[ 
		['PAGE','35357',jdecode('Edmonton+New+Technology+Society'),jdecode(''),'/3201/35357.html','true',[],''],
		['PAGE','39057',jdecode('Azimuth+Theatre'),jdecode(''),'/3201/39057.html','true',[],''],
		['PAGE','39078',jdecode('6+Artists'),jdecode(''),'/3201/39078.html','true',[],'']
	],''],
	['PAGE','7615',jdecode('Equipment+for+Sale'),jdecode(''),'/7615/index.html','true',[ 
		['PAGE','7657',jdecode('Gerber+Pattern+Design+Machine'),jdecode(''),'/7615/7657.html','true',[],''],
		['PAGE','7699',jdecode('High+Pressure+Steam+Dobbiboiler'),jdecode(''),'/7615/7699.html','true',[],''],
		['PAGE','7720',jdecode('Devilbiss+15+HP+300+gallon+150psi+250cfm+compressor'),jdecode(''),'/7615/7720.html','true',[],'']
	],'']];
var siteelementCount=11;
theSitetree.topTemplateName='Avocation';
theSitetree.paletteFamily='999997';
theSitetree.keyvisualId='4583';
theSitetree.keyvisualName='kv_4583.jpg';
theSitetree.fontsetId='10825';
theSitetree.graphicsetId='11281';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='999997';
var theTemplate={
				name: 			'Avocation',
				paletteFamily: 	'999997',
				keyvisualId: 	'4583',
				keyvisualName: 	'kv_4583.jpg',
				fontsetId: 		'10825',
				graphicsetId: 	'11281',
				contentColor: 	'FFFFFF',
				contentBGColor: '999997',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'999997',
				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:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2001',
internalId:  '',
customField: '20100210-200115'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3201',
internalId:  '',
customField: '20090916-061944'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7615',
internalId:  '',
customField: '20090521-234057'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36378',
internalId:  '',
customField: '20090818-123256'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7657',
internalId:  '',
customField: '20090304-213441'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7699',
internalId:  '',
customField: '20090227-114911'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7720',
internalId:  '',
customField: '20090227-115156'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2001',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35357',
internalId:  '',
customField: '20090803-230318'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39057',
internalId:  '',
customField: '20090819-002104'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39078',
internalId:  '',
customField: '20090819-002425'
};
webappMappings['1501']=webappMappings['1501-5041424']={
webappId:    '1501',
documentId:  '2001',
internalId:  '5041424',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36357',
internalId:  '',
customField: '20090820-013507'
};
var canonHostname = 'wsc-worker01.chi.us.siteprotect.com';
var accountId     = 'AHW050INLKCR';
var companyName   = 'Blue+Skys+Arts+Lofts+-+The+Affordable+Creative+Workplace%21+In+Oliver+';
var htmlTitle	  = 'Downtown+Artists+Lofts+-+Legendary+Blue+Skys+Skating+Pants';
var metaKeywords  = 'Arts+Edmonton';
var metaContents  = 'Arts+Lofts+Edmonton+Community+';
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();
};
