/* [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','3512',jdecode('O+NAS'),jdecode(''),'/3512.html','true',[],''],
	['PAGE','3563',jdecode('Kontakt'),jdecode(''),'/3563.html','true',[],''],
	['PAGE','12712',jdecode('Galeria'),jdecode(''),'/12712.html','true',[],'']];
var siteelementCount=3;
theSitetree.topTemplateName='Sportfan1';
theSitetree.paletteFamily='CBCBC4';
theSitetree.keyvisualId='10069';
theSitetree.keyvisualName='kv_10069.jpg';
theSitetree.fontsetId='28244';
theSitetree.graphicsetId='13172';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'pl',
  country: 'PL'
};
var theTemplate={
				name: 			'Sportfan1',
				paletteFamily: 	'CBCBC4',
				keyvisualId: 	'10069',
				keyvisualName: 	'kv_10069.jpg',
				fontsetId: 		'28244',
				graphicsetId: 	'13172',
				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: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['7008']=webappMappings['7008-5278']={
webappId:    '7008',
documentId:  '3563',
internalId:  '5278',
customField: 'language:pl;country:PL;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3512',
internalId:  '',
customField: '20100222-184124'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3563',
internalId:  '',
customField: '20100223-143623'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '3512',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-10183862']={
webappId:    '1501',
documentId:  '3512',
internalId:  '10183862',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12712',
internalId:  '',
customField: '20100226-180114'
};
var canonHostname = 'cm4all.az.pl';
var accountId     = 'AAZ010IN3OTF';
var companyName   = 'OPA%C5%81+%3E%3E+EKOGROSZEK';
var htmlTitle	  = 'Opa%C5%82%2C+ekogroszek%2C+drewno+opa%C5%82owe%2C+transport';
var metaKeywords  = 'w%C4%99giel%2C+opa%C5%82%2C+sprzeda%C5%BC+w%C4%99gla%2C+sk%C5%82ad+opa%C5%82owy%2C+dealer+w%C4%99glowy%2C+paliwa+ekologiczne%2C+eko+groszek%2C+materia%C5%82+opa%C5%82owy%2C+koks%2C+brykiet%2C+opa%C5%82+w%C4%99glowy%2C+ogrzewanie%2C+kujawsko-pomorskie%2C+mazowieckie%2C+ekogroszek%2C+transport%2C+us%C5%82ugi+transporowe%2C+sprzedaz+opa%C5%82u%2C+';
var metaContents  = 'Serwis+firmy+zajmuje+si%C4%99+g%C5%82%C3%B3wnie+sprzeda%C5%BC%C4%85+ekogroszku%2C+drewna+opa%C5%82owego+i+kominkowego.Sprzeda%C5%BC+ze+sk%C5%82ad%C3%B3w+i+dow%C3%B3z+w%C5%82asnym+transporterem+do+zamawiaj%C4%85cego.%C5%9Awiadczymy+us%C5%82ugi+transportu+specjalistycznego.';
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();
};
