/* [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','8001',jdecode('Home'),jdecode(''), jdecode('%2F8001.html'), 'true',[],'',''],
	['PAGE','8052',jdecode('Trauung'),jdecode(''), jdecode('%2F8052.html'), 'true',[],'',''],
	['PAGE','8073',jdecode('Ueber+mich'),jdecode(''), jdecode('%2F8073.html'), 'true',[],'',''],
	['PAGE','20301',jdecode('Informationsabend%2FMessen'),jdecode(''), jdecode('%2F20301.html'), 'true',[],'',''],
	['PAGE','8094',jdecode('Kosten'),jdecode(''), jdecode('%2F8094.html'), 'true',[],'',''],
	['PAGE','8301',jdecode('Empfehlungen'),jdecode(''), jdecode('%2F8301.html'), 'true',[],'',''],
	['PAGE','38001',jdecode('Dankesschreiben'),jdecode(''), jdecode('%2F38001.html'), 'true',[],'',''],
	['PAGE','27001',jdecode('Taufe'),jdecode(''), jdecode('%2F27001.html'), 'true',[],'',''],
	['PAGE','8136',jdecode('Kontakt'),jdecode(''), jdecode('%2F8136.html'), 'true',[],'',''],
	['PAGE','8157',jdecode('Impressum'),jdecode(''), jdecode('%2F8157.html'), 'true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Sommelier';
theSitetree.paletteFamily='C39987';
theSitetree.keyvisualId='12093';
theSitetree.keyvisualName='kv_12093.jpg';
theSitetree.fontsetId='33296';
theSitetree.graphicsetId='14167';
theSitetree.contentColor='464646';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'de',
  country: 'CH'
};
var prodDef={
  wl_name: 'bluewin',
  product: 'WSCBLUSSSLYTC2MS'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Sommelier',
				paletteFamily: 	'C39987',
				keyvisualId: 	'12093',
				keyvisualName: 	'kv_12093.jpg',
				fontsetId: 		'33296',
				graphicsetId: 	'14167',
				contentColor: 	'464646',
				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:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['7008']=webappMappings['7008-7460']={
webappId:    '7008',
documentId:  '8136',
internalId:  '7460',
customField: 'language:de;country:CH;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8001',
internalId:  '',
customField: '20120127-154403'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8052',
internalId:  '',
customField: '20111215-075717'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8073',
internalId:  '',
customField: '20111216-225111'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8094',
internalId:  '',
customField: '20111214-225151'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8301',
internalId:  '',
customField: '20110916-230204'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '38001',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8136',
internalId:  '',
customField: '20110522-002007'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8157',
internalId:  '',
customField: '20120116-140652'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '8001',
internalId:  '1006',
customField: '1006'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8001',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8052',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8073',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8094',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '38001',
internalId:  '',
customField: '20110926-175956'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8301',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8136',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '8157',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '20301',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20301',
internalId:  '',
customField: '20120116-141521'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '27001',
internalId:  '',
customField: 'language:de;country:CH;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27001',
internalId:  '',
customField: '20111214-014007'
};
var webAppHostname = 'cgi.hpt001.bluewin.ch:80';
var canonHostname = 'hptworkerdb01b.bluewin.ch';
var accountId     = 'ABW330INEYNN';
var companyName   = 'Freie+TRAUUNGSZeremonie';
var htmlTitle	  = 'Freie+TRAUUNGSZeremonie%2CTrauung';
var metaKeywords  = 'Trauungszeremonie%2CTrauung%2Cfreie+Trauung%2CInes+W%C3%A4lti%2Cpers%C3%B6nliche+Trauung%2CTraurituale%2C+Trauzeremonie%2CTrauung%2CHochzeitszeremonie%2CHochzeit%2CZeremonie%2CfreieTrauzeremonie%2CHeiraten%2Cwir+heiraten%2CTraumtag%2CJa-Wort%2C+Ja-ich+will%2Cein+Bekenntnis+der+Liebe%2CInes+W%C3%A4lti%2CWalzenhausen%2C+gleichgeschlechtliche+Paare';
var metaContents  = 'Freie+TRAUUNGSZeremonie-Ein+Bekenntnis+der+Liebe%2C+mit+Ines+W%C3%A4lti.+Gef%C3%BChlvoll%2C+bewegend+mit+einer+Prise+Humor.';
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();
};

