/* [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','601',jdecode('Qui+som'),jdecode(''), jdecode('%2F601.html'), 'true',[],'',''],
	['PAGE','16401',jdecode('Trapelles+2010+-+2011'),jdecode(''), jdecode('%2F16401.html'), 'true',[],'',''],
	['PAGE','14643',jdecode('Agenda+del+mes'),jdecode(''), jdecode('%2F14643.html'), 'true',[],'',''],
	['PAGE','14664',jdecode('Not%C3%ADcies'),jdecode(''), jdecode('%2F14664.html'), 'true',[],'',''],
	['PAGE','71112',jdecode('Festes+AMIPA'),jdecode(''), jdecode('%2F71112.html'), 'true',[],'',''],
	['PAGE','14685',jdecode('Articles+d%26%23x27%3Binter%C3%A9s'),jdecode(''), jdecode('%2F14685.html'), 'true',[],'',''],
	['PAGE','14601',jdecode('Enlla%C3%A7os+d%26%23x27%3Binter%C3%A9s'),jdecode(''), jdecode('%2F14601.html'), 'true',[],'',''],
	['PAGE','15301',jdecode('Galeria+d%26%23x27%3Bimatges'),jdecode(''), jdecode('%2F15301.html'), 'false',[],'',''],
	['PAGE','16337',jdecode('Llibre+de+visites'),jdecode(''), jdecode('%2F16337.html'), 'true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Bubbles';
theSitetree.paletteFamily='FF7C00';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='13';
theSitetree.graphicsetId='10';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'es',
  country: 'ES'
};
var prodDef={
  wl_name: 'arsys',
  product: 'WSCSYSSSSLYTC2IK'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Bubbles',
				paletteFamily: 	'FF7C00',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'13',
				graphicsetId: 	'10',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'FF7C00',
				b_color: 		'FF8900',
				c_color: 		'000000',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '601',
internalId:  '',
customField: '20110321-151033'
};
webappMappings['7060']=webappMappings['7060-27a6b0301729433bed0993d7224d4dc6']={
webappId:    '7060',
documentId:  '15301',
internalId:  '27a6b0301729433bed0993d7224d4dc6',
customField: 'language:es;country:ES;'
};
webappMappings['1002']=webappMappings['1002-16337aars20invmou']={
webappId:    '1002',
documentId:  '16337',
internalId:  '16337aars20invmou',
customField: 'icq=false'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16401',
internalId:  '',
customField: '20101123-114759'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14643',
internalId:  '',
customField: '20110410-123608'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14664',
internalId:  '',
customField: '20110410-123929'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14685',
internalId:  '',
customField: '20110330-202734'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16337',
internalId:  '',
customField: '20100214-225407'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14601',
internalId:  '',
customField: '20101123-121117'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '15301',
internalId:  '',
customField: '20081028-125852'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '71112',
internalId:  '',
customField: '20110321-155221'
};
var webAppHostname = 'wsc.webaporter.com:80';
var canonHostname = 'llwc535.servidoresdns.net';
var accountId     = 'AARS20INVMOU';
var companyName   = 'AMIPA+TRAPELLES+CELR%C3%80';
var htmlTitle	  = 'AMIPA+E.B.M.+TRAPELLES';
var metaKeywords  = 'AMIPA%2C+ASSOCIACI%C3%93+DE+MARES+I+PARES%2C+EB+TRAPELLES%2C+E.B.+TRAPELLES%2C+A.M.I.P.A.%2C+A.M.I.P.A.+E.B.+TRAPELLES%2C+ESCOLA+BRESSOL%2C+ESCOLA+BRESSOL+TRAPELLES%2C+CELRA%2C+CELR%C3%80';
var metaContents  = 'AMIPA+EB+TRAPELLES';
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();
};

