/* [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','1901',jdecode('Home'),jdecode(''), jdecode('%2F1901.html'), 'true',[],'',''],
	['PAGE','3401',jdecode('Essen+%26+Trinken'),jdecode(''), jdecode('%2F3401%2Findex.html'), 'true',[ 
		['PAGE','1952',jdecode('Tagesmenu'),jdecode(''), jdecode('%2F3401%2F1952.html'), 'true',[],'',''],
		['PAGE','8612',jdecode('Menu-Karte'),jdecode(''), jdecode('%2F3401%2F8612.html'), 'true',[],'',''],
		['PAGE','12912',jdecode('Spezialit%C3%A4ten'),jdecode(''), jdecode('%2F3401%2F12912.html'), 'true',[],'',''],
		['PAGE','8633',jdecode('Dessert-Karte'),jdecode(''), jdecode('%2F3401%2F8633.html'), 'true',[],'',''],
		['PAGE','8654',jdecode('gute+Weine'),jdecode(''), jdecode('%2F3401%2F8654.html'), 'true',[],'',''],
		['PAGE','12512',jdecode('Menuvorschl%C3%A4ge'),jdecode(''), jdecode('%2F3401%2F12512.html'), 'true',[],'','']
	],'',''],
	['PAGE','3422',jdecode('Gastr%C3%A4ume'),jdecode(''), jdecode('%2F3422.html'), 'true',[],'',''],
	['PAGE','3443',jdecode('G%C3%A4stezimmer'),jdecode(''), jdecode('%2F3443.html'), 'true',[],'',''],
	['PAGE','3501',jdecode('Fotos'),jdecode(''), jdecode('%2F3501.html'), 'false',[],'',''],
	['PAGE','8512',jdecode('%C3%9Cber+uns+....'),jdecode(''), jdecode('%2F8512.html'), 'false',[],'',''],
	['PAGE','3622',jdecode('Kontaktformular'),jdecode(''), jdecode('%2F3622.html'), 'true',[],'','']];
var siteelementCount=13;
theSitetree.topTemplateName='Blast';
theSitetree.paletteFamily='FFF476';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='33266';
theSitetree.graphicsetId='14144';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'de',
  country: 'CH'
};
var prodDef={
  wl_name: 'genotec',
  product: 'WSCSYSSSSLY0XYAO'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Blast',
				paletteFamily: 	'FFF476',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'33266',
				graphicsetId: 	'14144',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'D29D0D',
				b_color: 		'F5F36A',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1901',
internalId:  '',
customField: '20100604-111325'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '1952',
internalId:  '',
customField: '20120214-225329'
};
webappMappings['7060']=webappMappings['7060-4859189544528d1fa7e299b66dbaee09']={
webappId:    '7060',
documentId:  '3501',
internalId:  '4859189544528d1fa7e299b66dbaee09',
customField: 'language:de;country:CH;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3401',
internalId:  '',
customField: '20091018-182454'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3422',
internalId:  '',
customField: '20091015-173253'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8512',
internalId:  '',
customField: '20091015-165336'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3501',
internalId:  '',
customField: '20090612-152542'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8612',
internalId:  '',
customField: '20110817-155740'
};
webappMappings['7008']=webappMappings['7008-813']={
webappId:    '7008',
documentId:  '3622',
internalId:  '813',
customField: 'language:de;country:CH;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3443',
internalId:  '',
customField: '20101112-135503'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3622',
internalId:  '',
customField: '20091018-180748'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '1901',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12512',
internalId:  '',
customField: '20110307-164437'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8654',
internalId:  '',
customField: '20110514-103843'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8633',
internalId:  '',
customField: '20110420-172910'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12912',
internalId:  '',
customField: '20120117-210738'
};
var webAppHostname = 'cgi.wsc.genotec.ch:80';
var canonHostname = 'wsc.genotec.ch';
var accountId     = 'AGT010IN2RNU';
var companyName   = 'Hotel+Brunni+in+Alpthal';
var htmlTitle	  = 'Gasthaus+Brunni';
var metaKeywords  = 'Gasthaus+Hotel+Restaurant+Brunni+Alpthal+Gasthaus+Hotel+Restaurant+Brunni';
var metaContents  = 'Das+gepflegte+Hotel+mit+der+feinen+K%C3%BCche';
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();
};

