/* [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','4755',jdecode('Autorin%2C+Kunsthandwerk%2C+Susi+Hahn'),jdecode(''), jdecode('%2F4755.html'), 'true',[],'',''],
	['PAGE','5901',jdecode('Produkte%2C+B%C3%BCcher+und+Handarbeiten+'),jdecode(''), jdecode('%2F5901.html'), 'true',[],'',''],
	['PAGE','4893',jdecode('Kontakt+%2F+Bestellung'),jdecode(''), jdecode('%2F4893.html'), 'false',[],'',''],
	['PAGE','4920',jdecode('Interessante+Links'),jdecode(''), jdecode('%2F4920.html'), 'true',[],'',''],
	['PAGE','34020',jdecode('Produkte%2C+Kunsthandwerk'),jdecode(''), jdecode('%2F34020.html'), 'true',[],'',''],
	['PAGE','6502',jdecode('G%C3%A4stebuch'),jdecode(''), jdecode('%2F6502%2Findex.html'), 'true',[ 
		['PAGE','6503',jdecode('Eintr%C3%A4ge'),jdecode(''), jdecode('%2F6502%2F6503.html'), 'false',[],'','']
	],'',''],
	['PAGE','8265',jdecode('Tagebuch'),jdecode(''), jdecode('%2F8265.html'), 'true',[],'','']];
var siteelementCount=8;
theSitetree.topTemplateName='Pencil';
theSitetree.paletteFamily='2D3DA5';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10361';
theSitetree.graphicsetId='10514';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
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: 			'Pencil',
				paletteFamily: 	'2D3DA5',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10361',
				graphicsetId: 	'10514',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana,Arial, Helvetica, sans-serif',
				contentFontSize:'10',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4755',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5901',
internalId:  '',
customField: '20111125-205328'
};
webappMappings['1002']=webappMappings['1002-6502ABW0X0INXSG8']={
webappId:    '1002',
documentId:  '6502',
internalId:  '6502ABW0X0INXSG8',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4755',
internalId:  '',
customField: '20120118-070013'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4893',
internalId:  '',
customField: '20091227-223525'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4920',
internalId:  '',
customField: '20100525-224413'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34020',
internalId:  '',
customField: '20111213-151651'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6502',
internalId:  '',
customField: '20100723-134054'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6503',
internalId:  '',
customField: '20081220-150658'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8265',
internalId:  '',
customField: '20120118-071109'
};
var webAppHostname = 'cgi.hpt001.bluewin.ch:80';
var canonHostname = 'hptworkerdb01a.bluewin.ch';
var accountId     = 'ABW0X0INXSG8';
var companyName   = 'SusiHahn+Autorin%2FKunsthandwerk';
var htmlTitle	  = 'Autorin%2FHandarbeiten%3A+Susi+Hahn+und+Partner';
var metaKeywords  = 'Autorin+%2F+Handarbeiten';
var metaContents  = 'Autorin+%2F+Handarbeiten';
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();
};

