/* [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','66922',jdecode('Gawra'),jdecode(''),'/66922.html','true',[],'',''],
	['PAGE','83001',jdecode('Price-list'),jdecode(''),'/83001.html','true',[],'',''],
	['PAGE','78501',jdecode('Special+offers'),jdecode(''),'/78501.html','true',[],'',''],
	['PAGE','78201',jdecode('Gallery'),jdecode(''),'/78201/index.html','true',[ 
		['PAGE','83601',jdecode('GAWRA+Manor'),jdecode(''),'/78201/83601.html','true',[],'',''],
		['PAGE','78222',jdecode('Gawra+%E2%80%93+new+part'),jdecode(''),'/78201/78222.html','true',[],'',''],
		['PAGE','86901',jdecode('Gawra+%E2%80%93+old+part'),jdecode(''),'/78201/86901.html','true',[],'',''],
		['PAGE','78301',jdecode('Conference+rooms'),jdecode(''),'/78201/78301.html','true',[],'',''],
		['PAGE','78322',jdecode('Surroundings'),jdecode(''),'/78201/78322.html','true',[],'','']
	],'',''],
	['PAGE','66943',jdecode('About+us%2C+localization'),jdecode(''),'/66943.html','true',[],'','']];
var siteelementCount=10;
theSitetree.topTemplateName='Trade';
theSitetree.paletteFamily='68856A';
theSitetree.keyvisualId='12108';
theSitetree.keyvisualName='kv_12108.jpg';
theSitetree.fontsetId='36731';
theSitetree.graphicsetId='14173';
theSitetree.contentColor='666666';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'pl',
  country: 'PL'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Trade',
				paletteFamily: 	'68856A',
				keyvisualId: 	'12108',
				keyvisualName: 	'kv_12108.jpg',
				fontsetId: 		'36731',
				graphicsetId: 	'14173',
				contentColor: 	'666666',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '78501',
internalId:  '',
customField: '20091122-123507'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '83601',
internalId:  '',
customField: '20091209-040649'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '78222',
internalId:  '',
customField: '20091209-043940'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '78301',
internalId:  '',
customField: '20091115-133348'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '78322',
internalId:  '',
customField: '20091115-135733'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '83001',
internalId:  '',
customField: '20091122-123449'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '86901',
internalId:  '',
customField: '20091209-044322'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '66922',
internalId:  '',
customField: '20091122-123623'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '66943',
internalId:  '',
customField: '20091209-023454'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '78201',
internalId:  '',
customField: '20091209-044624'
};
var canonHostname = 'wsc0.home.net.pl';
var accountId     = 'AHPL10INX2YF';
var companyName   = 'Bia%C5%82owieski+O%C5%9Brodek+Noclegowo-Gastronomiczny+GAWRA';
var htmlTitle	  = 'Bia%C5%82owieski+O%C5%9Brodek+Noclegowo-Gastronomiczny+GAWRA+-+Hotelowy+komfort+++z+kameraln%C4%85+atmosfer%C4%85+za+rozs%C4%85dn%C4%85+cen%C4%99';
var metaKeywords  = 'Bia%C5%82owie%C5%BCa+Bialowieza+agroturystyka+Bia%C5%82owie%C5%BCa+Puszcz+Bia%C5%82owieska+noclegi+relax+agrotouristic+Bia%C5%82owiska+Primeval+Forest+accommodation';
var metaContents  = 'Bia%C5%82owie%C5%BCa+-+GAWRA+Bia%C5%82owieski+O%C5%9Brodek+Noclegowo-Gastronomiczny';
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();
};

