/* [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','4454',jdecode('Home'),jdecode(''), jdecode('%2F4454.html'), 'true',[],'',''],
	['PAGE','4801',jdecode('Portrait'),jdecode(''), jdecode('%2F4801%2Findex.html'), 'true',[ 
		['PAGE','4855',jdecode('Geschichte'),jdecode(''), jdecode('%2F4801%2F4855.html'), 'true',[],'',''],
		['PAGE','4828',jdecode('Rohstoff+Holz'),jdecode(''), jdecode('%2F4801%2F4828.html'), 'true',[],'','']
	],'',''],
	['PAGE','4909',jdecode('Produkte'),jdecode(''), jdecode('%2F4909%2Findex.html'), 'true',[ 
		['PAGE','10601',jdecode('Pellets'),jdecode(''), jdecode('%2F4909%2F10601.html'), 'true',[],'','']
	],'',''],
	['PAGE','10622',jdecode('Kontakt'),jdecode(''), jdecode('%2F10622%2Findex.html'), 'true',[ 
		['PAGE','12901',jdecode('So+finden+Sie+uns'),jdecode(''), jdecode('%2F10622%2F12901.html'), 'true',[],'','']
	],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='Akropolis';
theSitetree.paletteFamily='5E5E5E';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10344';
theSitetree.graphicsetId='10448';
theSitetree.contentColor='272828';
theSitetree.contentBGColor='5e5e5e';
var localeDef={
  language: 'de',
  country: 'CH'
};
var prodDef={
  wl_name: 'bluewin',
  product: 'WSCBLUSSSLYTC2QE'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Akropolis',
				paletteFamily: 	'5E5E5E',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10344',
				graphicsetId: 	'10448',
				contentColor: 	'272828',
				contentBGColor: '5e5e5e',
				a_color: 		'5E5E5E',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4454',
internalId:  '',
customField: '20110729-190146'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4801',
internalId:  '',
customField: '20100416-210542'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4828',
internalId:  '',
customField: '20100928-174604'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4855',
internalId:  '',
customField: '20100416-211820'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4909',
internalId:  '',
customField: '20110729-181539'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10601',
internalId:  '',
customField: '20110729-173959'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12901',
internalId:  '',
customField: '20100416-211052'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10622',
internalId:  '',
customField: '20100928-174725'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4454',
internalId:  '1006',
customField: '1006'
};
var webAppHostname = 'cgi.hpt001.bluewin.ch:80';
var canonHostname = 'hptworkerdb01a.bluewin.ch';
var accountId     = 'ABW0X0INXEUY';
var companyName   = 'HOLZBAU+ZENGER+HABKERN';
var htmlTitle	  = 'Holzbau+Zenger+Habkern';
var metaKeywords  = 'Blockhaus%2C+Blockbau%2C+Rundholzbau%2C+Chaletbau%2C+Blockhausbau%2C+Riegbau%2C+Schindeln%2C+Schindeldach%2C+Holzbau%2C+Innenausbau%2C+Bedachungen%2C+Umbauten%2C+Renovationen%2C+Heimatschutz%2C+Denkmalpflege%2C+Habkern%2C+Interlaken%2C+Berner+Oberland%2C+Parkett%2C%0D%0A%0D%0AChalet%2C+Sennh%C3%BCtte%2C+Alph%C3%BCtte%2C+Stall%2C+Scheune%2C+Garage%2C+Holztreppe%2C+Zenger%2C+Fichte%2C+Tanne%2C+Rundholz%2C+Haus%2C+Wohnhaus%2C+Holzhaus%2C+Qualit%C3%A4t%2C+Zimmerei%2C+Habkern';
var metaContents  = 'Holzbau+Zenger+Habkern+-+Der+Fachbetrieb+f%C3%BCr+Blockbau%2C+Zimmerei%2C+Holzbau+und+Innenausbau';
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();
};

