/* [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','4521',jdecode('Home'),jdecode(''),'/4521.html','true',[],'',''],
	['PAGE','4578',jdecode('News'),jdecode(''),'/4578.html','true',[],'',''],
	['PAGE','32781',jdecode('Jubil%C3%A4um+%26+Geschichtliches'),jdecode(''),'/32781.html','true',[],'',''],
	['PAGE','4713',jdecode('Im+Bau'),jdecode(''),'/4713.html','true',[],'',''],
	['PAGE','41767',jdecode('Zahnradnorm+'),jdecode(''),'/41767.html','true',[],'',''],
	['PAGE','8338',jdecode('Aktuell+-+Verkauf'),jdecode(''),'/8338.html','true',[],'',''],
	['PAGE','4605',jdecode('Lokomotiven'),jdecode(''),'/4605.html','true',[],'',''],
	['PAGE','4632',jdecode('Dampfmaschine'),jdecode(''),'/4632.html','true',[],'',''],
	['PAGE','4659',jdecode('Gleismaterial'),jdecode(''),'/4659.html','true',[],'',''],
	['PAGE','4686',jdecode('Zubeh%C3%B6r'),jdecode(''),'/4686.html','true',[],'',''],
	['PAGE','30264',jdecode('Gebrauchte-Lok%26%23x27%3Bs'),jdecode(''),'/30264.html','true',[],'',''],
	['PAGE','4740',jdecode('Restposten'),jdecode(''),'/4740.html','true',[],'',''],
	['PAGE','4767',jdecode('SLB+-+Liliputbahn+'),jdecode(''),'/4767.html','true',[],'',''],
	['PAGE','9344',jdecode('Fotogalerie'),jdecode(''),'/9344.html','true',[],'',''],
	['PAGE','5133',jdecode('Kontakt'),jdecode(''),'/5133.html','true',[],'','']];
var siteelementCount=15;
theSitetree.topTemplateName='Seifenblase';
theSitetree.paletteFamily='C8E2FF';
theSitetree.keyvisualId='2353';
theSitetree.keyvisualName='blanko.jpg';
theSitetree.fontsetId='379';
theSitetree.graphicsetId='427';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'de',
  country: 'CH'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Seifenblase',
				paletteFamily: 	'C8E2FF',
				keyvisualId: 	'2353',
				keyvisualName: 	'blanko.jpg',
				fontsetId: 		'379',
				graphicsetId: 	'427',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'FFFFFF',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'6666CC',
				e_color: 		'3333CC',
				f_color: 		'9999CC',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4521',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4521',
internalId:  '',
customField: '20100216-090851'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '30264',
internalId:  '',
customField: '20091020-085922'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4578',
internalId:  '',
customField: '20100706-082114'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '32781',
internalId:  '',
customField: '20090611-083720'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4713',
internalId:  '',
customField: '20100503-074552'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '41767',
internalId:  '',
customField: '20071008-082526'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8338',
internalId:  '',
customField: '20100503-104651'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4605',
internalId:  '',
customField: '20100202-091346'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4632',
internalId:  '',
customField: '20081107-091948'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4659',
internalId:  '',
customField: '20081117-074022'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4686',
internalId:  '',
customField: '20070514-082114'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4740',
internalId:  '',
customField: '20100224-084240'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4767',
internalId:  '',
customField: '20100706-081827'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '9344',
internalId:  '',
customField: '20100111-102857'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5133',
internalId:  '',
customField: '20090609-103004'
};
var canonHostname = 'hptworkerdb01a.bluewin.ch';
var accountId     = 'ABW0X0INXEI1';
var companyName   = 'Dampfmodellbau%2FGartenbahn%2FGleisbau';
var htmlTitle	  = '';
var metaKeywords  = '';
var metaContents  = '';
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();
};
