/* [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','4506',jdecode('EMPRESA'),jdecode(''),'/4506.html','true',[],'',''],
	['PAGE','25021',jdecode('PRODUCTES'),jdecode(''),'/25021.html','true',[],'',''],
	['PAGE','25048',jdecode('CONTACTAR'),jdecode(''),'/25048/index.html','true',[ 
		['PAGE','25538',jdecode('CONTACTAR+%28follow+up+page%29'),jdecode(''),'/25048/25538.html','false',[],'','']
	],'','']];
var siteelementCount=4;
theSitetree.topTemplateName='Cuy';
theSitetree.paletteFamily='F8FCF2';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='385';
theSitetree.graphicsetId='435';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='F8FCF2';
var localeDef={
  language: 'es',
  country: 'ES'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Cuy',
				paletteFamily: 	'F8FCF2',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'385',
				graphicsetId: 	'435',
				contentColor: 	'000000',
				contentBGColor: 'F8FCF2',
				a_color: 		'F8FCF2',
				b_color: 		'BECDA9',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4506',
internalId:  '1006',
customField: '1006'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '25021',
internalId:  '',
customField: 'language:es;country:ES;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4506',
internalId:  '',
customField: 'language:es;country:ES;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4506',
internalId:  '',
customField: '20100708-131436'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25021',
internalId:  '',
customField: '20100330-115251'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25048',
internalId:  '',
customField: '20100531-174815'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25538',
internalId:  '',
customField: '20060222-233215'
};
webappMappings['7008']=webappMappings['7008-7251']={
webappId:    '7008',
documentId:  '25048',
internalId:  '7251',
customField: 'language:es;country:ES;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '25048',
internalId:  '',
customField: 'language:es;country:ES;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '25538',
internalId:  '',
customField: 'language:es;country:ES;'
};
var canonHostname = 'llwc535.servidoresdns.net';
var accountId     = 'Aas010IN2OGJ';
var companyName   = 'MONBOLET+...de+tot+en+bolets%21';
var htmlTitle	  = '';
var metaKeywords  = 'risotto+bolets%2C+fideu%C3%A0+bolets%2C+escudella+bolets%2C+bolet%2C+bolets%2C+setas%2C+trufa%2C+trufas%2C+t%C3%B2fona%2C+t%EF%BF%BDfones%2C+bolets+bergued%EF%BF%BD%2C+parada+bolets%2C+bolets+pirineus%2C+de+tot+en+bolets%2C+especialistes+en+bolets%2C+monbolet%2C+compra-venda+bolets%2C+bolets+i+t%EF%BF%BDfones+de+temporada%2C+rovello%2C+cep%2C+camagroc%2C+centre+bolets%2C+olis+i+vinagres+de+bolets.';
var metaContents  = 'monbolet%2C+especialistes+en+bolets%2C+bolets%2C+risotto%2C+risottos+de+bolets%2Carros+bolets%2C+fideu%C3%A0+de+bolets%2C+escudella+bolets%2C+especialitats+en+t%C3%B2fona%2C+fresc%2C+sec%2C+t%EF%BF%BDfona%2C++bolets+bergued%EF%BF%BD%2C+bolets+pirineus%2C+de+tot+en+bolets%2C+bolets+frescos%2C+t%EF%BF%BDfones%2C+bolets+deshidratats%2C+bolets+secs%2C+pols+de+bolet%2C+bolets+en+pols%2C+bolet+fresc+de+temporada%2C+oli+de+bolets%2C+olis+i+vinagres+de+bolets.';
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();
};
