/* [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','162',jdecode('Home'),jdecode(''),'/162.html','true',[],''],
	['PAGE','183',jdecode('Property+Details+and+Pictures'),jdecode(''),'/183.html','true',[],''],
	['PAGE','535',jdecode('Contact+Us'),jdecode(''),'/535/index.html','true',[ 
		['PAGE','1776',jdecode('Contact+Us+%28follow+up+page%29'),jdecode(''),'/535/1776.html','false',[],'']
	],''],
	['PAGE','544',jdecode('Directions'),jdecode(''),'/544.html','true',[],''],
	['PAGE','553',jdecode('Interesting+Links'),jdecode(''),'/553.html','true',[],'']];
var siteelementCount=6;
theSitetree.topTemplateName='Arena';
theSitetree.paletteFamily='7F98E2';
theSitetree.keyvisualId='1463';
theSitetree.keyvisualName='strasse.jpg';
theSitetree.fontsetId='1';
theSitetree.graphicsetId='2';
theSitetree.contentColor='';
theSitetree.contentBGColor='';
var theTemplate={
				name: 			'Arena',
				paletteFamily: 	'7F98E2',
				keyvisualId: 	'1463',
				keyvisualName: 	'strasse.jpg',
				fontsetId: 		'1',
				graphicsetId: 	'2',
				contentColor: 	'',
				contentBGColor: '',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'7F98E2',
				b_color: 		'4267D6',
				c_color: 		'000000',
				d_color: 		'7792E2',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '162',
internalId:  '1006',
customField: '1006'
};
webappMappings['1001']=webappMappings['1001-ahw050in3nyi75b65d9944fd1d38']={
webappId:    '1001',
documentId:  '535',
internalId:  'ahw050in3nyi75b65d9944fd1d38',
customField: ''
};
webappMappings['1001']=webappMappings['1001-ahw050in3nyi75b65d9944fd1d38']={
webappId:    '1001',
documentId:  '1776',
internalId:  'ahw050in3nyi75b65d9944fd1d38',
customField: 'followUp'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '162',
internalId:  '',
customField: '20081013-122140'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '535',
internalId:  '',
customField: '20070925-152923'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '183',
internalId:  '',
customField: '20081013-122412'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1776',
internalId:  '',
customField: '20070924-050153'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '544',
internalId:  '',
customField: '20081013-122459'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '553',
internalId:  '',
customField: '20070922-202442'
};
var canonHostname = 'wsc-worker04.chi.us.siteprotect.com';
var accountId     = 'AHW050IN3NYI';
var companyName   = 'Town+of+Blue+Chalets';
var htmlTitle	  = 'Your+Blue+Mountain+Chalet+Accommodation';
var metaKeywords  = 'Blue+Mountain.+Chalet.+Cottage.+Collingwood.+Ontario.+Ski.+Golf.+Rental+units.+View+of+Blue+Mountain.+Tyrolean+Village.+Village+at+Blue.+Blue+Mountain+Chalets.+Lodges+at+Blue.';
var metaContents  = 'Blue+Mountain+Ontario+Canada+Chalet+Style+Cottages.+Ski+and+stay+at+Blue+Mountain.+Rent+a+Blue+Mountain+Chalet+from+Town+of+Blue+Mountain+Collingwood+Chalets.+Weekends+available.+Weekdays+available.+Golf+and+stay+at+Blue+Mountain.+Your+weekend+getaway.+Collingwood+Ontario+vacation+lodging.+Tyrolean+Village+Chalet.';
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();
};
