/* [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','401',jdecode('%C2%BFInstitut+Psiquia%3F'),jdecode(''),'/401.html','true',[],'',''],
	['PAGE','452',jdecode('%C2%BFQui%C3%A9nes+somos%3F'),jdecode(''),'/452.html','true',[],'',''],
	['PAGE','473',jdecode('Informaci%C3%B3n+General'),jdecode(''),'/473.html','true',[],'',''],
	['PAGE','494',jdecode('L%C3%ADneas+de+Intervenci%C3%B3n'),jdecode(''),'/494/index.html','true',[ 
		['PAGE','18001',jdecode('Programas+Especiales'),jdecode(''),'/494/18001.html','true',[],'',''],
		['PAGE','21401',jdecode('Programa+Infantil'),jdecode(''),'/494/21401.html','true',[],'',''],
		['PAGE','17401',jdecode('Servicios+a+Empresas'),jdecode(''),'/494/17401.html','true',[],'','']
	],'',''],
	['PAGE','515',jdecode('Ubicaci%C3%B3n+y+Contacto'),jdecode(''),'/515.html','true',[],'',''],
	['PAGE','16501',jdecode('Aviso+legal'),jdecode(''),'/16501.html','true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Konzept';
theSitetree.paletteFamily='6C05A7';
theSitetree.keyvisualId='568';
theSitetree.keyvisualName='handel.jpg';
theSitetree.fontsetId='121';
theSitetree.graphicsetId='139';
theSitetree.contentColor='000066';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'es',
  country: 'ES'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Konzept',
				paletteFamily: 	'6C05A7',
				keyvisualId: 	'568',
				keyvisualName: 	'handel.jpg',
				fontsetId: 		'121',
				graphicsetId: 	'139',
				contentColor: 	'000066',
				contentBGColor: 'FFFFFF',
				a_color: 		'6C05A7',
				b_color: 		'C8D0ED',
				c_color: 		'000000',
				d_color: 		'15094B',
				e_color: 		'C5B39F',
				f_color: 		'900B4D',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '401',
internalId:  '',
customField: '20100314-220652'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '452',
internalId:  '',
customField: '20100314-202517'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '473',
internalId:  '',
customField: '20100306-214831'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '494',
internalId:  '',
customField: '20100308-190144'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '515',
internalId:  '',
customField: '20100306-002254'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '401',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16501',
internalId:  '',
customField: '20100317-234030'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '17401',
internalId:  '',
customField: '20100308-192605'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18001',
internalId:  '',
customField: '20100317-235103'
};
webappMappings['7008']=webappMappings['7008-7930']={
webappId:    '7008',
documentId:  '515',
internalId:  '7930',
customField: 'language:es;country:ES;'
};
webappMappings['1501']=webappMappings['1501-10969880']={
webappId:    '1501',
documentId:  '401',
internalId:  '10969880',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '21401',
internalId:  '',
customField: '20100314-222058'
};
var canonHostname = 'llwc535.servidoresdns.net';
var accountId     = 'AARS20INLVE0';
var companyName   = 'INSTITUT+PSIQUIA';
var htmlTitle	  = '';
var metaKeywords  = 'Psicologia%2C+Psicoterapia%2C+Salud+Mental%2C+Psiquiatria%2C+Consultas%2C+ansiedad%2C+depresion%2C+terapia+familiar%2C+terapia+de+pareja%2C+salut+barcelona%2C+psicoterapiabarcelona';
var metaContents  = 'Psicologia%2C+Psicoterapia%2C+Salud+Mental%2C+Psiquiatria%2C+Consultas%2C+Depresi%C3%B3n%2C+Ansiedad%2C+Terapia+familiar%2C+Terapia+de+pareja%2C+Salut+barcelona%2Cpsicoterapiabarcelona';
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();
};
