/* [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','501',jdecode('Strona+g%C5%82%C3%B3wna'),jdecode(''),'/501.html','true',[],'',''],
	['PAGE','552',jdecode('Kontakt'),jdecode(''),'/552.html','true',[],'','']];
var siteelementCount=2;
theSitetree.topTemplateName='Business';
theSitetree.paletteFamily='003366';
theSitetree.keyvisualId='2485';
theSitetree.keyvisualName='schwimmen.jpg';
theSitetree.fontsetId='27032';
theSitetree.graphicsetId='463';
theSitetree.contentColor='020E66';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'pl',
  country: 'PL'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Business',
				paletteFamily: 	'003366',
				keyvisualId: 	'2485',
				keyvisualName: 	'schwimmen.jpg',
				fontsetId: 		'27032',
				graphicsetId: 	'463',
				contentColor: 	'020E66',
				contentBGColor: 'FFFFFF',
				a_color: 		'003366',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20100305-005748'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '552',
internalId:  '',
customField: '20100303-210643'
};
webappMappings['7008']=webappMappings['7008-289']={
webappId:    '7008',
documentId:  '552',
internalId:  '289',
customField: 'language:pl;country:PL;'
};
var canonHostname = 'wsc0.home.net.pl';
var accountId     = 'AHPL10IN3LIR';
var companyName   = 'BIMO+Technologie+i+materia%C5%82y';
var htmlTitle	  = 'BIMOTECH%3A+blachy+tytanowe%2C+pr%C4%99ty%2C+rury+tytanowe%2C+wolfram%2C+elektrody+molibdenowe%2C+druty+wolframowe';
var metaKeywords  = 'tytan%2C+drut+tytanowy%2C+blacha+tytanowa%2C+stopy+tytanu%2C+rury+tytanowe%2C+wolfram%2C+drut+wolframowy%2C+elektroda+wolframowa%2C+wolframu%2C+druty%2C+elektrody+wolframowe%2C+molibden%2C+molibdenowy%2C+molibdenowa%2C+molibdenu%2C+molibdenowe%2C+niob%2C+niobowy%2C+niobowa%2C+niobu%2C+niobowe%2C+tantal%2C+tantalowy%2C+tantalowa%2C+tantalu%2C+elektrody+molibdenowe%2C+tantalowe%2C+pr%C4%99ty+tytanowe%2C+cyrkon%2C+cyrkonowy%2C+cyrkonowa%2C+cyrkonu%2C+cyrkonowe%2C+metale%2C+gie%C5%82da+z%C5%82omu%2C+z%C5%82om+metali%2C+sprzeda%C5%BC+metali%2C+przemys%C5%82u+metalowego%2C+metalurgicznego%2C+metalurgiczne%2C+metalurgia%2C+blachy%2C+pr%C4%99ty%2C+rury%2C+folie++';
var metaContents  = 'Oferujemy+tytan%2C+wolfram%2C+molibden%2C+niob%2C+tantal%2C+cyrkon%2C+metale+ziem+rzadkich.+Elektrody+wolframowe%2C+tytanowe+i+elektrody+molibdenowe%2C+proszki%2C+stop+TZM+i+inne+rzadkie+metale+i+surowce.+Bimo+to+producent+i+dostawca%3A+blacha+tytanowa%2C+drut+tytanowy%2C+pr%C4%99ty+tytanowe%2C+p%C5%82askowniki%2C+rury+tytanowe%2C+dyski%2C+druty+wolframowe%2C+elektroda+wolframowa+folie+i+inne+wyroby.';
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();
};

