/* [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 theSitetree=[ 
	['PAGE','2401',jdecode('Strona+g%C5%82%C3%B3wna'),jdecode(''),'/2401/index.html','true',[ 
		['PAGE','4401',jdecode('Lokalizacja%2FRegion'),jdecode(''),'/2401/4401.html','true',[],'']
	],''],
	['PAGE','4422',jdecode('Domki+wczasowe'),jdecode(''),'/4422/index.html','true',[ 
		['PAGE','4443',jdecode('Wyposa%C5%BCenie'),jdecode(''),'/4422/4443.html','true',[],''],
		['PAGE','4464',jdecode('Ceny'),jdecode(''),'/4422/4464.html','true',[],''],
		['PAGE','4485',jdecode('Rezerwacja'),jdecode(''),'/4422/4485.html','true',[],'']
	],''],
	['PAGE','4506',jdecode('Kontakt'),jdecode(''),'/4506.html','true',[],''],
	['PAGE','4527',jdecode('Galeria'),jdecode(''),'/4527.html','true',[],''],
	['PAGE','4548',jdecode('Ciekawe+linki'),jdecode(''),'/4548.html','true',[],'']];
var siteelementCount=9;
theSitetree.topTemplateName='Gaudy';
theSitetree.paletteFamily='207247';
theSitetree.keyvisualId='5931';
theSitetree.keyvisualName='kv_5931.jpg';
theSitetree.fontsetId='27844';
theSitetree.graphicsetId='11906';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='5CB184';
var localeDef={
  language: 'pl',
  country: 'PL'
};
var theTemplate={
				name: 			'Gaudy',
				paletteFamily: 	'207247',
				keyvisualId: 	'5931',
				keyvisualName: 	'kv_5931.jpg',
				fontsetId: 		'27844',
				graphicsetId: 	'11906',
				contentColor: 	'FFFFFF',
				contentBGColor: '5CB184',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2401',
internalId:  '',
customField: '20090205-090349'
};
webappMappings['7060']=webappMappings['7060-baf8838d80641f6e503d0088a9a0386c']={
webappId:    '7060',
documentId:  '4527',
internalId:  'baf8838d80641f6e503d0088a9a0386c',
customField: 'language:pl;country:PL;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4401',
internalId:  '',
customField: '20090126-110200'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4422',
internalId:  '',
customField: '20090127-155031'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4443',
internalId:  '',
customField: '20090126-112759'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4464',
internalId:  '',
customField: '20090127-153534'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4485',
internalId:  '',
customField: '20090205-090514'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4506',
internalId:  '',
customField: '20090205-090609'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4527',
internalId:  '',
customField: '20090126-112537'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4548',
internalId:  '',
customField: '20090128-093424'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2401',
internalId:  '1006',
customField: '1006'
};
var canonHostname = 'wsc2.home.net.pl';
var accountId     = 'AHPL10INZIOZ';
var companyName   = 'ZAPRASZAMY+DO+OW+S%C5%81ONECZNY+STOK+NA+KASZUBACH';
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();
};
