/* [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','4478',jdecode('Home'),jdecode(''),'/4478.html','true',[],'',''],
	['PAGE','5411',jdecode('facilities'),jdecode(''),'/5411/index.html','true',[ 
		['PAGE','28791',jdecode('Bedrooms+'),jdecode(''),'/5411/28791.html','true',[],'','']
	],'',''],
	['PAGE','39538',jdecode('Photo+Gallery'),jdecode(''),'/39538.html','true',[],'',''],
	['PAGE','4589',jdecode('reservations+%2F+rates'),jdecode(''),'/4589/index.html','true',[ 
		['PAGE','25943',jdecode('map'),jdecode(''),'/4589/25943.html','true',[],'','']
	],'',''],
	['PAGE','25970',jdecode('about+us'),jdecode(''),'/25970/index.html','true',[ 
		['PAGE','25997',jdecode('the+team'),jdecode(''),'/25970/25997.html','true',[],'','']
	],'',''],
	['PAGE','27917',jdecode('creation+pictures'),jdecode(''),'/27917.html','true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Squares';
theSitetree.paletteFamily='003700';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='229';
theSitetree.graphicsetId='266';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Squares',
				paletteFamily: 	'003700',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'229',
				graphicsetId: 	'266',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'003700',
				b_color: 		'FF9900',
				c_color: 		'000000',
				d_color: 		'FFFFBB',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1501']=webappMappings['1501-836230']={
webappId:    '1501',
documentId:  '4478',
internalId:  '836230',
customField: '1501'
};
webappMappings['7060']=webappMappings['7060-361d926aef6c350c60f97f7ea80fbb66']={
webappId:    '7060',
documentId:  '27917',
internalId:  '361d926aef6c350c60f97f7ea80fbb66',
customField: 'language:en;country:US;'
};
webappMappings['7060']=webappMappings['7060-645bd21d6513bc5a9e2ad710835de90f']={
webappId:    '7060',
documentId:  '28791',
internalId:  '645bd21d6513bc5a9e2ad710835de90f',
customField: 'language:en;country:US;'
};
webappMappings['7060']=webappMappings['7060-53511c288b53f244e03c419eaa170ff6']={
webappId:    '7060',
documentId:  '39538',
internalId:  '53511c288b53f244e03c419eaa170ff6',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4478',
internalId:  '',
customField: '20081017-211847'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5411',
internalId:  '',
customField: '20081021-143531'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '28791',
internalId:  '',
customField: '20081016-221213'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '39538',
internalId:  '',
customField: '20081017-212253'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4589',
internalId:  '',
customField: '20091122-192345'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25943',
internalId:  '',
customField: '20081016-235523'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25970',
internalId:  '',
customField: '20081016-223348'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25997',
internalId:  '',
customField: '20081016-223659'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27917',
internalId:  '',
customField: '20081016-223954'
};
var canonHostname = 'diywk01.verio.stngva01.us.diy-servers.net';
var accountId     = 'AVEC10IN2GXW';
var companyName   = 'Backpackers+Nelson+NZ';
var htmlTitle	  = '';
var metaKeywords  = 'the+bug+backpackers+nelson+new+zealand';
var metaContents  = 'Backpackers%0AHostel%0ABudget+Accommodation';
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();
};
