/* [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','2601',jdecode('Strona+g%C5%82%C3%B3wna'),jdecode(''),'/2601.html','true',[],''],
	['PAGE','2652',jdecode('O+mnie'),jdecode(''),'/2652.html','true',[],''],
	['PAGE','2694',jdecode('Kontakt'),jdecode(''),'/2694.html','true',[],''],
	['PAGE','2801',jdecode('Wersja+Angielska'),jdecode(''),'/2801.html','true',[],''],
	['PAGE','6301',jdecode('Galeria'),jdecode(''),'/6301.html','true',[],'']];
var siteelementCount=5;
theSitetree.topTemplateName='do-it-yourself';
theSitetree.paletteFamily='ED8C23';
theSitetree.keyvisualId='10327';
theSitetree.keyvisualName='kv_10327.jpg';
theSitetree.fontsetId='32277';
theSitetree.graphicsetId='13323';
theSitetree.contentColor='824F17';
theSitetree.contentBGColor='FFF5BB';
var localeDef={
  language: 'pl',
  country: 'PL'
};
var theTemplate={
				name: 			'do-it-yourself',
				paletteFamily: 	'ED8C23',
				keyvisualId: 	'10327',
				keyvisualName: 	'kv_10327.jpg',
				fontsetId: 		'32277',
				graphicsetId: 	'13323',
				contentColor: 	'824F17',
				contentBGColor: 'FFF5BB',
				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',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['7008']=webappMappings['7008-3661']={
webappId:    '7008',
documentId:  '2694',
internalId:  '3661',
customField: 'language:pl;country:PL;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2601',
internalId:  '',
customField: '20090823-132008'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2652',
internalId:  '',
customField: '20090823-143202'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2694',
internalId:  '',
customField: '20090823-141059'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2801',
internalId:  '',
customField: '20090823-131213'
};
webappMappings['1501']=webappMappings['1501-6185185']={
webappId:    '1501',
documentId:  '2601',
internalId:  '6185185',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6301',
internalId:  '',
customField: '20090823-154514'
};
webappMappings['7060']=webappMappings['7060-05d3c48ec949e8701fc14ddf7ab25de7']={
webappId:    '7060',
documentId:  '6301',
internalId:  '05d3c48ec949e8701fc14ddf7ab25de7',
customField: 'language:pl;country:PL;'
};
var canonHostname = 'cm4all.az.pl';
var accountId     = 'AAZ010IN21ED';
var companyName   = 'www.darstol.pl';
var htmlTitle	  = 'www.darstol.pl';
var metaKeywords  = 'darstol%2C+meble+kielce%2C+schody+drewniane+kielce%2C+drzwi+kielce%2C+stolarka+kielce%2C+meble+kuchenne+kielce';
var metaContents  = 'darstol%2C+meble+kielce%2C+schody+drewniane+kielce%2C+drzwi+kielce%2C+stolarka+kielce%2C+meble+kuchenne+kielce';
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();
};





