/* [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','3701',jdecode('Strona+g%C5%82%C3%B3wna'),jdecode(''), jdecode('%2F3701.html'), 'true',[],'',''],
	['PAGE','11701',jdecode('O+nas'),jdecode(''), jdecode('%2F11701.html'), 'true',[],'',''],
	['PAGE','3752',jdecode('Pomoce+naukowe'),jdecode(''), jdecode('%2F3752.html'), 'true',[],'',''],
	['PAGE','3815',jdecode('Kontakt+i+zapisy'),jdecode(''), jdecode('%2F3815.html'), 'true',[],'',''],
	['PAGE','27001',jdecode('W%C5%82oc%C5%82awek'),jdecode(''), jdecode('%2F27001.html'), 'true',[],'',''],
	['PAGE','27022',jdecode('Ksi%C4%99ga+go%C5%9Bci'),jdecode(''), jdecode('%2F27022.html'), 'true',[],'','']];
var siteelementCount=6;
theSitetree.topTemplateName='Unity';
theSitetree.paletteFamily='922C36';
theSitetree.keyvisualId='11820';
theSitetree.keyvisualName='kv_11820.jpg';
theSitetree.fontsetId='35819';
theSitetree.graphicsetId='14075';
theSitetree.contentColor='363636';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'pl',
  country: 'PL'
};
var prodDef={
  wl_name: 'azpl',
  product: 'WSCSYSSSSLY0XKDP'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Unity',
				paletteFamily: 	'922C36',
				keyvisualId: 	'11820',
				keyvisualName: 	'kv_11820.jpg',
				fontsetId: 		'35819',
				graphicsetId: 	'14075',
				contentColor: 	'363636',
				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:  '3701',
internalId:  '',
customField: '20111230-212816'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3752',
internalId:  '',
customField: '20100910-175654'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3815',
internalId:  '',
customField: '20111116-123310'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11701',
internalId:  '',
customField: '20111005-123551'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '3701',
internalId:  '1006',
customField: '1006'
};
webappMappings['1002']=webappMappings['1002-27022aaz010in32qe']={
webappId:    '1002',
documentId:  '27022',
internalId:  '27022aaz010in32qe',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27001',
internalId:  '',
customField: '20111116-123137'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27022',
internalId:  '',
customField: '20110909-122454'
};
var webAppHostname = 'cgi-kreatorstron.az.pl:80';
var canonHostname = 'cm4all.az.pl';
var accountId     = 'AAZ010IN32QE';
var companyName   = 'Academia+Espa%C3%B1ola+wita%21';
var htmlTitle	  = 'HISZPA%C5%83SKI+TORU%C5%83+SZKO%C5%81A+HISZPA%C5%83SKIEGO+KURS+HISZPANSKI+ACADEMIA+ESPANOLA+KURSY+NAUKA';
var metaKeywords  = 'HISZPA%C5%83SKI%2C+KURS%2C+HISZPANSKIEGO%2C+TORUN%2C+WLOCLAWEK%2C+HISZPANSKI%2C+SZKO%C5%81A%2C+J%C4%98ZYKOWA%2C+W%C5%81OC%C5%81AWEK%2C+T%C5%81UMACZ%2C+T%C5%81UMACZENIA+HISZPA%C5%83SKIEGO%2C+KURSY%2C+TORU%C5%83%2C+NAUKA%2C+HISZPANSKI';
var metaContents  = 'SZKO%C5%81A+J%C4%98ZYKOWA+HISZPA%C5%83SKI++TORU%C5%83++WLOCLAWEK+KURSY+HISZPA%C5%83SKIEGO+TORUN+W%C5%81OC%C5%81AWEK+T%C5%81UMACZ++HISZPA%C5%83SKI+T%C5%81UMACZENIA+ACADEMIA+ESPANOLA';
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();
};

