/* [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','552',jdecode('Strona+g%C5%82%C3%B3wna'),jdecode(''),'/552.html','true',[],''],
	['PAGE','573',jdecode('Kombajn+po%C5%82%C3%B3wkowy'),jdecode(''),'/573.html','true',[],''],
	['PAGE','594',jdecode('Otrz%C4%85sarka+do+wi%C5%9Bni'),jdecode(''),'/594.html','true',[],''],
	['PAGE','615',jdecode('Kosiarko-rozdrabniacz'),jdecode(''),'/615.html','true',[],''],
	['PAGE','636',jdecode('Sadzarka+krzew%C3%B3w'),jdecode(''),'/636.html','true',[],''],
	['PAGE','657',jdecode('Elementy+stalowe'),jdecode(''),'/657/index.html','true',[ 
		['PAGE','13001',jdecode('Konstrukcje+stalowe'),jdecode(''),'/657/13001.html','true',[],''],
		['PAGE','13022',jdecode('Os%C5%82ony+i+Zapory'),jdecode(''),'/657/13022.html','true',[],'']
	],''],
	['PAGE','678',jdecode('Kontakt'),jdecode(''),'/678.html','true',[],''],
	['PAGE','23712',jdecode('english+version'),jdecode(''),'/23712.html','true',[],'']];
var siteelementCount=10;
theSitetree.topTemplateName='Hands';
theSitetree.paletteFamily='999999';
theSitetree.keyvisualId='7394';
theSitetree.keyvisualName='kv_7394.jpg';
theSitetree.fontsetId='28023';
theSitetree.graphicsetId='12167';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'pl',
  country: 'PL'
};
var theTemplate={
				name: 			'Hands',
				paletteFamily: 	'999999',
				keyvisualId: 	'7394',
				keyvisualName: 	'kv_7394.jpg',
				fontsetId: 		'28023',
				graphicsetId: 	'12167',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				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:  '552',
internalId:  '',
customField: '20100225-231000'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '573',
internalId:  '',
customField: '20091201-225807'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '594',
internalId:  '',
customField: '20090309-232014'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '615',
internalId:  '',
customField: '20081208-205700'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '636',
internalId:  '',
customField: '20091202-234346'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '657',
internalId:  '',
customField: '20081212-190049'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '678',
internalId:  '',
customField: '20100225-224141'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '552',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13001',
internalId:  '',
customField: '20081211-234240'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '13022',
internalId:  '',
customField: '20081210-235719'
};
webappMappings['7008']=webappMappings['7008-4489']={
webappId:    '7008',
documentId:  '678',
internalId:  '4489',
customField: 'language:pl;country:PL;'
};
webappMappings['7008']=webappMappings['7008-5876']={
webappId:    '7008',
documentId:  '23712',
internalId:  '5876',
customField: 'language:pl;country:PL;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23712',
internalId:  '',
customField: '20100411-105914'
};
var canonHostname = 'cm4all.az.pl';
var accountId     = 'AAZ010IN23FL';
var companyName   = 'Maszyny+Sadownicze';
var htmlTitle	  = 'Karmasz+kombajn+do+porzeczek%2C+kosiarko+rozdrabniacz%2C+otrz%C4%85sarka+do+wi%C5%9Bni%2C+sadzarka+do+krzew%C3%B3w';
var metaKeywords  = 'kombajn+do+porzeczek%2C+kombajn+do+zbioru+porzeczek%2C+aronii%2C+agrestu%2C+kosiarko+rozdrabniacz%2C+kosiarka+sadownicza%2C+otrz%C4%85sarka+do+wi%C5%9Bni%2C+otrz%C4%85sarka+do+owoc%C3%B3w+pestkowych%2C+sadzarka+do+krzew%C3%B3w%2C+sadzarka+do+topoli+energetycznej%2C+wierzby+energetycznej%2C+konstrukcje+stalowe%2C+podesty%2C+zapory+no%C5%BCycowe%2C+rozdrabniacz+ga%C5%82%C4%99zi%2C+Harvester+currant%2C+gooseberry+chokeberry%2C+cherry+harvester%2C+rotary+mower%2C+bush+planter';
var metaContents  = 'kombajn+do+porzeczek%2C+kosiarko+rozdrabniacz%2C+kosiarki+sadownicze%2C+otrz%C4%85sarki+do+wi%C5%9Bni%2C+otrz%C4%85sarki+do+owoc%C3%B3w+pestkowych%2C+sadzarka+do+krzew%C3%B3w+';
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();
};
