<!--
var img_on = new Image();
img_on.src="/imgs/fletxa_avall.jpg"
var img_off = new Image();
img_off.src="/imgs/fletxa_t.jpg"
var facetes=new Array();
if (!window.mapa)
	var mapa=false;
var sufixTipus="";
function posiciona(vpos)
{

	if (top.fmenu.location.href.indexOf("#")<0)
	{
	top.fmenu.location.href=top.fmenu.location.href+"#"+vpos;
	}
	else
	{
	top.fmenu.location.href=top.fmenu.location.href.substring(0,top.fmenu.location.href.indexOf("#"))+"#"+vpos;
	}
}

function trimr(vstr)
{	
	if (vstr.substring(vstr.length-1,1)==' ' || vstr.charCodeAt(vstr.length-1)<33)
		vstr=trimr(vstr.substring(0,vstr.length-1));
	return vstr;
}
function trobats(vtrob)
{
	top.fcap.location.replace("/home/hec/sf/cap.html?menu="+escape(vtrob));
}

function menu_pos(vpos)
{
	top.fcap.location.replace("/home/hec/sf/cap_ll.html?menu="+vpos);

}

// seccions trobades (cos article, suplement, estructura, actualitat, arbre, vegeu, GGCC, Internet)

function troba(ind)
{
     indi=""+ind;

}

//capçaleres de secció
function separa(num)    
{
    if (ant==1) {document.write("</p></td></tr>");};
    if (indi.substring(num, num+1)=="1") 
    {
   txt="<tr><td valign=\"top\" width=\"100%\" bgcolor=\"#ffffff\"><p align=\"justify\">";
        if (ancores[num]!="")
        {
		txt=txt+ "<a name=\""+ ancores[num]+"\"></a>";
        }
        if (titols[num]!="")
        {
txt=txt+"<table width=\"100%\" border=0 cellpadding=0 cellspacing=0     ";
txt=txt+ "height=16><tr>";
txt=txt+ "<td valign=\"top\" class=\"titular"+ num +"\">" + titols[num]+"<br></td></tr></table>";
        }

     document.write(txt);
     ant=1;
    }
}


function escriu_iqua()
{
	////////////////////////////////////////////////////
	// segell de qualitat
	var lang1 = new Array(3);
	var lang2 = new Array(3);
	lang1[1] = "segell";
	lang2[1] = "L'Agència de la Qualitat d'Internet";
	lang1[2] = "sello";
	lang2[2] = "La Agencia de Calidad de Internet";
	lang1[3] = "seal";
	lang2[3] = "The Internet Quality Agency";
	var iqua_id=53;
	var iqua_lang=1;
	var dir_remoto="/home/jsp/imatges/";
	var striqua="<center><small><font color=\"#FFFFFF\" face=\"Verdana\"><strong>Segell de Qualitat:&nbsp;&nbsp;&nbsp;</strong></font></small><a href=\"http://www.iqua.net/segell/?id="+ iqua_id + "&lang=" + iqua_lang + "&url=" + escape(document.location.href) + "\" onclick=\"iqua_open(this.href,'iqua','600','450','no');return false;\"><img src=\""+dir_remoto+"segelliquafb.gif\" width=\"63\" height=\"49\" border=\"0\" alt=\"" + lang2[iqua_lang] + "\"></a></center>";


	
	
	document.write(striqua);
}

function iqua_open(mypage, myname, w, h, scroll) {
winl = (screen.width - w) / 2;
wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function parseqs(vqs, vkey)
{
	var vpos=0;
	var vfi=0;
	vkey=vkey+"=";
	if ((vpos=vqs.indexOf(vkey))>-1 && (vpos==0 || vqs.substring(vpos-1,vpos)=="&"))
	{
		vpos=vpos+vkey.length;
		vfi=vqs.indexOf("&",vpos);
		if (vfi<0)
			vfi=vqs.length;
		return vqs.substring(vpos,vfi);
	}
	return "";		
}

function traduc(vstr,vsbstr,vnsbstr)
{
	var vpos=0;
	
	while ((vpos=vstr.indexOf(vsbstr))>-1)
{
vstr=vstr.substring(0,vpos)+vnsbstr+vstr.substring(vpos+vsbstr.length);
}
return vstr;
}

strtop_t=top.location.href;
frase_cerca="";
if (strtop_t.indexOf("?")>-1)
{
qs_t=strtop_t.substring(strtop_t.indexOf("?")+1);
//qs_t=traduc(qs_t,"%26","&");
qs_t=traduc(qs_t,"+"," ");
qs_t=unescape(qs_t);

frase_cerca=parseqs(qs_t,"FRASE");
}

function recupera_cerca()
{
	document.write(frase_cerca);
}
function escr_patroc()
{

	if (usu=="XTC" || usu=="EDU" || usu.substring(0,4)=="xtec" || usu.substring(0,3)=="edu")
		document.write("<center><IMG SRC=\"/HOME/IMG2/LACAIXA.GIF\" BORDER=0></center>"); 

}
function escr_patroc2()
{

	if (usu.substring(0,2)=="b." || usu.substring(0,2)=="B." || usu.substring(0,6)=="gencat")
		document.write("<a href=\"http://www10.gencat.net/dursi/AppJava/home.jsp?area=0&idioma=\"><img src=\"/home/imgs/dursi_vert.jpg\" align=\"center\" border=\"1\" STYLE=\"border-color:#aaaaaa\"></a>");                                  
}
function obrefin(vfin)
{
window.open(vfin,"altres","width=600,height=400,location=no,toolbar=no,directories=no,menubar=no,resizable=YES,Scrollbars=YES,status=yes") 
}

function fquadre(vstr)
{
	window.open("http://www.enciclopedia.cat/MonXifres/estaduni9.jsp?NDCHEC="+vstr,"estaduni","width=600,height=400,menubar=no,location=no,scrollbars=yes,resizable=yes");
}
function fquadre_HTM(vstr)
{
	window.open("http://www.grec.com/hiperenc/gran/"+vstr,"estaduni","width=600,height=400,menubar=no,location=no,scrollbars=yes,resizable=yes");
}

function mostra_img(vurl) 
{
img_g = new Image(); 
img_g.src=vurl;

ample=img_g.width;
alt=img_g.height;



var propietats="location=no,toolbars=no,width=" + ample + ",height=" +alt +",left=100,top=100,resizable=yes";
win=window.open("", "", propietats);
win.document.open();
win.document.write("<html><head><script>function resize(){if (document.images[0].width!=" + ample +" || document.images[0].height!="+ alt + ") window.resizeTo(document.images[0].width+10,document.images[0].height+10); }</script><title>foto gran</title><body  marginwidth=0 marginheight=0 topmargin=0 leftmargin=0><img src=\""+img_g.src+"\" onload=\"resize()\"></body></html>");
win.document.close();
}
function items(id)
{	if (document.getElementById('f'+id))
		if (document.getElementById('f'+id).src==img_off.src) {
			desplegaItems(id);
		}
		else {
			document.getElementById("t"+id).style.display = 'none'; 
			document.getElementById('f'+id).src=img_off.src;
		}
}
function desplegaItems(id) {
	list = document.getElementById('sumari');
	if (window.list)
	{
		contenidors    = list.getElementsByTagName('div');
		numContenidors = contenidors.length;
	
		for (var m=0; m < numContenidors; m++)
		{
			if (contenidors[m].id.indexOf('t') == 0 && document.getElementById('f'+contenidors[m].id.substring(1))) 
				if (contenidors[m].id!=('t'+id)) {	contenidors[m].style.display = 'none'; document.getElementById('f'+contenidors[m].id.substring(1)).src=img_off.src }
		}
		if (document.getElementById('f'+id)) {
			document.getElementById("t"+id).style.display = 'block'; 
			document.getElementById('f'+id).src=img_on.src;
		}
	}
}
function items_s(id) {
	desplegaItems(id);
	return "#s"+id;
}

 function hideItems()
 {
	var titolVisible=0;
	if (window.titol)
		titolVisible=window.titol;
    list           = document.getElementById('sumari');
	if (window.list)
	{
		contenidors    = list.getElementsByTagName('div');
		numContenidors = contenidors.length;
    
		for (m=0; m < numContenidors; m++)
		{
			if (contenidors[m].id.indexOf('t') == 0 && contenidors[m].id!=('t'+titolVisible)) contenidors[m].style.display = 'none';
		}
	}

 }
 
  function activaFacetes()
 {
	var obj;
	for (var fac in facetes)
	{
		obj=document.getElementById(fac);
		if (obj.addEventListener)
			obj.addEventListener('click',function (e) { eClick=e; posicioFaceta();},true);
		else
			obj.attachEvent('onclick',	function () {eClick= new emula_event();posicioFaceta();});
	}
}
 
function posicioFaceta()
{
	var obj = top.document.getElementById('faceta');
	
	if (obj)
	{
		obj.style.display='none';
		mouObjA(eClick.pageX,eClick.pageY,obj);
	}
	
	var vndc=eClick.target.id;
	obj.style.display='block';
	faceta(vndc);

}
function faceta(vndc)
{
	var req = new XMLHttpRequest(); 
	if (req) { 
	req.onreadystatechange = function() {
			 if (req.readyState == 4 && (req.status == 200 || req.status == 304)) { var demo = document.getElementById('faceta'); demo.innerHTML=req.responseText; } };
		 req.open('GET', 'faceta_nova.jsp?NDCHEC='+vndc);
		 req.send(null); 
	
	}

}


function emula_event()
{	
	this.which=window.event.button;
	this.pageX=window.event.clientX+document.body.scrollLeft;
	this.pageY=window.event.clientY+document.body.scrollTop;
	this.target=window.event.srcElement;
	this.target.id=window.event.srcElement.id;
}

function mouObjA(x,y,objecte)
{
	if (x < 0) x = 0;
	if (y < 0) y = 0;
	
	if (document.all || document.getElementById)
	{
		objecte.style.left = x + "px";
		objecte.style.top  = y + "px";
	}
	else
	{
		objecte.left = x;
		objecte.top = y;
	}
}
function amaga()
{
	var obj = top.document.getElementById('faceta');
	obj.style.display='none';
	obj.innerHTML="";
}
function novaFaceta(vfac)
{
	facetes[vfac]=true;
}
function iniFac()
{
	document.write("<table width=\"100%\"><tr><td class=\"SumariTitol\">");

}
function fiFac()
{
	document.write("<td align=\"right\"><a href=\"javascript:amaga()\"><img src=\"imgs/x.jpg\" border=\"0\"></a></td></tr></table>");
}

var arrossec=false;
function capa()
{
document.write("<SPAN ID=\"l1\"></SPAN>");
}
	
function mostraAltdef(vtxt)
{
	if (document.all)
	{
		document.all.l1.innerHTML="<table width=240 cellpadding=8 cellspacing=0 class=\"t_l1\"><tr><td><font face=\"Verdana\" size=-2>"+vtxt+"&nbsp;</font></td></tr></table>";
	}	
	else
	{
		if (document.getElementById)
			document.getElementById("l1").innerHTML="<table width=240 cellpadding=8 cellspacing=0 class=\"t_l1\"><tr><td><font face=\"Verdana\" size=-2>"+vtxt+"&nbsp;</font></td></tr></table>";
		else
		{
		document.layers["l1"].document.open();
		document.layers["l1"].document.write("<table width=240 cellpadding=8 cellspacing=0 class=\"t_l1\"><tr><td><font face=\"Verdana\" size=-2>"+vtxt+"&nbsp;</font></td></tr></table>");
		document.layers["l1"].document.close();
		}

	}
	// inicia moviment 
	activa_drag();
	
}

//Joan
function mostraAltdef2(vtxt,mida)
{
	if (document.all)
	{
		document.all.l1.innerHTML="<table width=" + mida + " cellpadding=8 cellspacing=0 class=\"t_l1\"><tr><td><font face=\"Verdana\" size=-2>"+vtxt+"&nbsp;</font></td></tr></table>";
	}	
	else
	{
		if (document.getElementById)
			document.getElementById("l1").innerHTML="<table width=" + mida + " cellpadding=8 cellspacing=0 class=\"t_l1\"><tr><td><font face=\"Verdana\" size=-2>"+vtxt+"&nbsp;</font></td></tr></table>";
		else
		{
		document.layers["l1"].document.open();
		document.layers["l1"].document.write("<table width=240 cellpadding=8 cellspacing=0 class=\"t_l1\"><tr><td><font face=\"Verdana\" size=-2>"+vtxt+"&nbsp;</font></td></tr></table>");
		document.layers["l1"].document.close();
		}

	}
	// inicia moviment 
	activa_drag();
	
}

function amagaAltdef()
{
	if (document.all)
		document.all.l1.style.display="none";
	else
		if (document.getElementById)
			document.getElementById("l1").style.display="none";
		else
			document.layers["l1"].visibility="hide";
	desactiva_drag();
}


function activa_drag()
{
	if (arrossec==false)
	{
	if (!document.all)
		document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove=arrossega;


	arrossec=true;
	return true;
	}
	else return false;
}

function desactiva_drag()
{

	
	arrossec=false;
	if (!document.all)
		document.releaseEvents(Event.MOUSEMOVE);
	document.onmousemove=null;	
		
	return true;	
}


//------------------------------------------------------------------------------------------------------------------------
//  Moviment del layer
//
//------------------------------------------------------------------------------------------------------------------------



function arrossega(e)
{
	if (!e)
	{var e= new emula_event();
	}
		if (arrossec)
		{
			if (document.all)
				obj=document.all["l1"];
			else
				if (document.getElementById)
					obj=document.getElementById("l1");
				else
					obj=document.layers["l1"];
		var pos=new Array();
		pos=posicionaObj(obj,e.pageX,e.pageY);
		mouObjA(pos[0],pos[1],obj);
		if (document.all || document.getElementById)
		{
			if (obj.style.display!="block")
				obj.style.display="block";
		}
		else
		{
			if (obj.visibility!="show")
				obj.visibility="show";
		}
		return true;
		}
		else return false;
	
}


function posicionaObj(obj,x,y)
{
	var wh_body = new Array();
	wh_body     = mySize();
	var xy_scr = new Array();
	xy_scr     = getScrollXY();

	obj.style.display = 'block';
				
	var	w_div = obj.clientWidth+30;
	var	h_div = obj.clientHeight+30;

	if (x+w_div > wh_body[0]+xy_scr[0]) 	x = wh_body[0]+xy_scr[0] - w_div;
	else									x += xy_scr[0];
	
	if (y+h_div > wh_body[1]+xy_scr[1])		y = wh_body[1]+xy_scr[1] - h_div;
	else									y += xy_scr[1];
	
	return [x+5,y+12];
}



function mySize() 
{
  var myWidth = 0, myHeight = 0;
  
  if (typeof (window.innerWidth) == 'number') 
  {
    //Non-IE
    myWidth  = window.innerWidth;
    myHeight = window.innerHeight;
  } 
  else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth  = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) 
		{
			//IE 4 compatible
			myWidth  = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
  
    return [myWidth, myHeight];
}

function getScrollXY() 
{
  var scrOfX = 0, scrOfY = 0;

  if (typeof( window.pageYOffset ) == 'number') 
  {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } 
  else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) 
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} 
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) 
		{
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
  
  return [scrOfX, scrOfY];
}


// funcions per la part superior de la fitxa


function ampliaMapa(pNDC, pFOTOG)
{
	document.write("<a href=\"javascript:ffoto('"+pFOTOG+"')\">");
}

// funcions per mapes


function mostraGrafic(fitxer) {
	var str = '<td width="45" valign="top" class="Banderes"><table width="100%" border="0" cellpadding="0" cellspacing="0" valign="middle"><tr>'
	str += '<td width="48" height="28" align="center" valign="bottom">';
	str += '<a href="javascript:ffoto(\'GRAFIC/' + fitxer + '\')"><img src="http://www.enciclopedia.cat/imgs/grafic.jpg" border="0"></a>'; 
	str += '</td></tr><tr><td height="24" valign="middle" class="txtbanderas">Gr\u00e0fics</td></tr></table></td>';
	document.write(str);
}
function MAPAICC(UTMX, UTMY, zoom) {
	if (!mapa) {
		UTMX=UTMX+"00";
		UTMY=UTMY+"00";

		if (isNaN(parseInt(zoom,10)) || parseInt(zoom,10)==0 )
			zoom = 6;
		document.write("<td valign=\"top\" class=\"mapa imgmapa\"><iframe frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://www.icc.cat/vissir2/?lang=ca_ES&zoom="+zoom+"&lat="+UTMY+"&lon="+UTMX+"&layers=B00FFFFFTF&embedded=true\" class=\"imgmapa\"></iframe></td>");
		mapa=true;
	}
}
function MonXifres(ndc) {
	var str = '<td width="91" valign="middle" class="Banderes">';
	str += '<table width="100%" border="0" cellpadding="0" cellspacing="0" valign="middle"><tr>';
	str += '<td width="93" height="28" align="center" valing="bottom">';
	str += '<a href="javascript:fquadre(\''+ndc+'\')">';
	str += '<img src="http://www.enciclopedia.cat/imgs/xifres.jpg" border="0" align="center"></a>';
	//str += '</td></tr><tr><td valign="top" class="txtbanderas">'+ bateigjs +'</td></tr></table></td>';
	str += '</td></tr><tr><td valign="top" class="txtbanderas">xifres </td></tr></table></td>';
	document.write(str);
}
function MAPAGL(longitud,latitud,zoom) {
	if (!mapa) {
		if (isNaN(parseInt(zoom,10)) || parseInt(zoom,10)==0)
			zoom = 10;
		document.write('<td valign="top" class="mapa imgmapa"><iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.es/?ie=UTF8&amp;hl=ca&amp;source=embed&amp;ll='+latitud+','+longitud+'&amp;spn=0.588048,0.88028&amp;z='+zoom+'&amp;output=embed" class="imgmapa"></iframe></td>');
		mapa=true;
	}
}
function MAPAGIF(fitxer) {
	if (!mapa) {
		var str = "<td valign=\"top\" class=\"mapa imgmapa\"><img src=\"http://editor.enciclopedia.cat/medies/mapa/"+fitxer+"\" class=\"imgmapa\"></td>";
		document.write(str);
		mapa=true;
	}
}
function IniciRem(vndc) {
	tancarEnllac = false;
	if (vndc != "") {
		document.write('<a class="gec3lnk" href="http://www.enciclopedia.cat/fitxa_v2.jsp?NDCHEC='+norm(vndc,7)+'">');
		tancarEnllac = true;
	}

}

function pref(tipus) {
// afegim això perquè els tipus 1 a la defin surtin amb parèntesis
	if (tipus=="1") {
		sufixTipus = ")";
		document.write("(");
	}
}
function FinalRem() {
	document.write(sufixTipus);
	sufixTipus = "";
	if (tancarEnllac) 
		document.write('</a>');
		
}
function mostrarColaboradors() {
	var element = document.getElementById("colaboradors");
	element.innerHTML = stringColaboradors(json, json.length);
}

function stringColaboradors(json,numeroResultats) {
	var str="";
	if (json.length>0) {
		str += '<table class="SumariTaula"  width="190" border="0" cellpadding="0" cellspacing="0">'; 
        str += '<tr><td height="28" colspan="2"  valign="top" class="SumariTitol">COL&middot;LABORADORS</td></tr>';
    }
	for (var i=0; i<json.length && i<numeroResultats; i++) {
		str += '<tr><td width="186" height="14" valign="top" >';
		if (json[i].BAIXA!=1)
			str += '<A  HREF="http://editor.enciclopedia.cat/fitxaUsuari/fusuari.php?USR='+escape(json[i].USUARI)+'" border="0" class="colabora">';
		else 
			str += '<span class="colabora">';
		str += json[i].NOM.toLowerCase()+' '+ json[i].COGNOMS.toLowerCase();
		if (json[i].BAIXA!=1)
			str += '</A>';
		else
			str += '</span>';
		str += '</td></tr>';
	}	
	if (json.length>numeroResultats) 
		str +='<tr><td height="14" valign="top" ><a href="#" onclick="mostrarColaboradors()" class="veuremes">Vegeu-ne m&eacute;s</a></td></tr>';
	if (json.length>0) 
		str += '<tr><td height="19"></td></tr></table>';

	return str;
}

function cercaG(tipuscerca)
{
	var que = trim(document.forms["form1"].q.value); 
	var que2;

	if (que.length == 0)
	{
		// no fer res
		return false;
	}
	else
	{
		if (tipuscerca == '1')   // cerca per titol
		{
			que2 = "allintitle:" + encodeURIComponent(que);
		}
		else
		{
			que2 = escape(que);
		}
		
		location.href = "http://www.enciclopedia.cat/totcerca.jsp?q=" +   que2 +"&client=enci_cat_interfaz&filter=0&ie=utf8&oe=utf8&site=enciclopedia_cat&output=xml_no_dtd&proxystylesheet=enci_cat_interfaz&ud=1&start=0&entqr=0";

		return false;
	}	
}

function fotoGran(vthis, pFOTOG){
	var divPare=vthis;
	var strStyle = ' style="text-align:left;"';
	for (var i=0; i<divPare.childNodes.length;i++)
		if (divPare.childNodes[i].nodeName=="IMG") {
			var amplada = divPare.childNodes[i].width;
			divPare.childNodes[i].removeAttribute("width");
			if (!isNaN(parseInt(divPare.childNodes[i].width)) && parseInt(divPare.childNodes[i].width)>0) 
				strStyle = ' style="text-align:left;margin-left:auto;margin-right:auto;width:'+parseInt(divPare.childNodes[i].width)+'px;"';
			divPare.childNodes[i].setAttribute("width",amplada);
		}
	
	if (divPare.parentNode)
	while ((divPare=divPare.parentNode) && (divPare.className!='foto')){}
	if (divPare) {
		var textFoto = divPare.childNodes[0].innerHTML;
		var copyright = "";
		if (textFoto.toLowerCase().indexOf("<br><br>")>-1)
				textFoto = textFoto.substring(textFoto.toLowerCase().indexOf("<br><br>")+8);
		if (textFoto.indexOf("- ")>-1) {
			copyright = textFoto.substring(textFoto.indexOf("- ")+2).replace(/<i>/gi,"").replace(/<\/i>/gi,"");
			textFoto = textFoto.substring(0,textFoto.indexOf("- "));
		}

		strFoto = '<div ';
		strFoto += strStyle;
		strFoto += '><img src="http://editor.enciclopedia.cat/medies/'+pFOTOG+'" border="0"><br><br>'+textFoto+'</div></div><div class="peuFoto">'+ copyright +'</div>';

		document.domain="enciclopedia.cat";
		finestraFoto = window.open('http://enciclopedia.cat/fotoGran.htm','foto',"width=790,height=600,toolbar=0,location=0,scrollbars=1,statusbar=0,menubar=0,resizable=1");
	}
	return false;
}

//*--------------------------------------------------------
// funcions que escriuen contingut mentre es carrega
//*--------------------------------------------------------

function ampliaFoto(pFOTOG)
{
	document.write("<a href=\"#\" onclick=\"return fotoGran(this,'"+pFOTOG+"')\">");
}
function finalFoto() {
	document.write("</a>");
}

function item_titol (nivell, text,lnk)
{
	this.nivell=nivell;
	this.text=text; 
	this.lnk=lnk;
}

function altaTitol(nivell,text,lnk) {
	Titols[Titols.length] = new item_titol(nivell,text,lnk);
}

function escriuSumari() {
	var str = "";	
	var comptadorTitols1 = 0;
	var prefixTitols = new Array();
		prefixTitols["2"] = '<table cellpadding="0" cellspacing="0"><tr><td class="STit2"><img src="/imgs/1x1.gif" width="10" border="0" height="3"><br><img src="/imgs/quadrat.gif"></td><td align="left">';
		prefixTitols["3"] = '<table cellpadding="0" cellspacing="0"><tr><td class="STit3"><img src="/imgs/1x1.gif" width="30" border="0" height="1"><br><img src="/imgs/quadratbuit.gif"></td><td align="left">';

	if (Titols.length>0)
			str = '<table class="SumariTaula" id="sumari" width="170" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2" class="SumariTitol" valign="top" align="left"><strong>SUMARI</strong></td><td width="3"><img src="fitxa_v2.jsp_files/1x1_003.gif" width="3" height="1"></td></tr><tr><td colspan="3"><img src="/imgs/1x1.gif" width="1" height="9"></td></tr>';


	for ( var i=0;i<Titols.length;i++) {
		// muntem els títols 1 a banda perquè tenen la part desplegable que és diferent
		if (parseInt(Titols[i].nivell)==1)
			str += muntarTitol1(Titols[i],comptadorTitols1++,((i+1)<Titols.length && parseInt(Titols[i+1].nivell)!=1));
		else
				str += prefixTitols[Titols[i].nivell] + lnkTitols(Titols[i]) + '</td></tr></table>';
	}
	if (Titols.length>0) {
		str += '</table><img src="/imgs/1x1.gif" width=1" height="15">';
		document.write(str);
	}
}
function muntarTitol1(obj,comptador,si_no) {
	var str="";
	if (comptador>0)
		str += '<br></div></td><td width="3"><img src="/imgs/1x1.gif" width="3" height="1"></td></tr>';
		str += '<tr><td class="SumariFletxa" width="11">';
		if (si_no) 
			str += '<a class="LnkTitol1" href="javascript:void(items(\''+comptador+'\'))"><img src="/imgs/fletxa_t.jpg" vspace="2" id="f'+comptador+'" border="0"></a>';
		else
			str += '<img align="left" src="/imgs/quadrat_f.gif" vspace="5" hspace="1" border="0">';

		str += '</td><td class="SumariPunts">';
	str += '<a class="LnkTitol1" href="#' + obj.lnk + '" onclick="items_s(\''+comptador+'\')">';
	str += '<div class="Titol1">' + obj.text + '</div></a>';
		str += '</td><td width="3"><img src="/imgs/1x1.gif" width="3" height="1"></td></tr><tr><td colspan="2" class="SumariCos" valign="top"><div style="display: none;" id="t'+comptador+'">';
	return str;
}
function lnkTitols(obj) {
	var str='<a href="#' + obj.lnk +'" class="LnkCos">' + obj.text + '</a>';
	return str;
}
function espais(numero) {
	var longitud=parseInt(numero,10);
	var str="";
	for (var i=0; i<longitud;i++)
		str+="&nbsp;&nbsp;&nbsp;";
	return str;
}

function posEndCursor(nameCtrl){  
	var ctrl = document.getElementsByName(nameCtrl);

	if (ctrl.length == 1) {
		var pos  = ctrl[0].value.length;

	    if (typeof document.selection != 'undefined' && document.selection) { //IE 
			var str = document.selection.createRange();  
	        str.move("character", pos);  
	        str.moveEnd("character", 0);  
	        str.select(); 
	    } 
	    else if (typeof laCaja.selectionStart != 'undefined') { //standard
			ctrl[0].setSelectionRange(pos,pos);  
		} 
	}
}

function hihaCookies(capa){
	var browser = navigator.appName
	var element = document.getElementById(capa);
	
	if (element.style.display == 'block'){
		if (getcookie('UsuariGEC') && getcookie('ClauGEC')){
			document.acces.usuari.value = getcookie('UsuariGEC');
			document.acces.password.value = getcookie('ClauGEC');
			document.acces.dades.checked = true;
		}

		document.acces.usuari.focus();
		if (browser == "Microsoft Internet Explorer")	posEndCursor('usuari');
	}
} 
function esborrarCamp(obj){
	obj.value = "";
}

function focusEmail(){
	var element = document.getElementById('registre2');
	if (element.style.display == 'block'){
		document.recordar.email.focus(); 
		document.recordar.email.value = "";
	}
}

function validar(principal) {
	document.domain="enciclopedia.cat";
	var nouFrame = document.getElementById("validarUsuari");
	if (nouFrame.document) {
		if (principal) {
			nouFrame.contentWindow.document.acces.usuari.value = document.acces.usuari.value;
			nouFrame.contentWindow.document.acces.password.value = document.acces.password.value;
			nouFrame.contentWindow.document.acces.dades.checked = document.acces.dades.checked;
		}
		else {
			nouFrame.contentWindow.document.recordar.email.value = document.recordar.email.value;
		}
		
	}
	else {
		if (principal) {	
			nouFrame.contentDocument.acces.usuari.value = document.acces.usuari.value;
			nouFrame.contentDocument.acces.password.value = document.acces.password.value;
			nouFrame.contentDocument.acces.dades.checked = document.acces.dades.checked;
		}
		else {
			nouFrame.contentDocument.recordar.email.value = document.recordar.email.value;
		}
		
	}
	
	nouFrame.contentWindow.validar(principal);
}


function reloadIdentificacio(){
	document.domain="enciclopedia.cat";
	var nouFrame = document.getElementById("validarUsuari");
	var text = "";
	
	if (nouFrame.document) 	text = nouFrame.contentWindow.document.getElementById("identificacio").innerHTML;
	else			text = nouFrame.contentDocument.getElementById("identificacio").innerHTML;
	
	top.document.getElementById("identificacio").innerHTML = text; 

	if (window.ndchec && window.ndchec!=null)
		actualitzarAEditor();
}



function ltrim(str) 
{ 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}

function rtrim(str) 
{
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}

function trim(str) 
{
	return ltrim(rtrim(str));
}

function isWhitespace(charToCheck) 
{
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
function cercaBuida(par)
{
	document.forms["form"+par].q.value = trim(TradUnicode(document.forms["form"+par].q.value));
	if (trim(document.forms["form"+par].q.value).length==0)
	{
		location.href = "http://www.enciclopedia.cat/fitxa_v2.jsp?NDCHEC=0";
		return false;
	}
	else return true;
}

function cercaEnciclopedia(vCerca)
{
	if (cercaBuida(vCerca)) document.forms["form"+vCerca].submit();
	else 	location.href = "http://www.enciclopedia.cat/fitxa_v2.jsp?NDCHEC=0";
}
function cercaDiccionari(vCerca)
{
	var que = trim(document.forms["form"+vCerca].q.value); // la part de dalt (capçalera)

	if (que.length == 0)
		location.href = "http://ec.grec.net/lexicx.jsp?GECART=0"; 
	else
		location.href = "http://ec.grec.net/cgi-bin/AppDLC3.exe?APP=CERCADLC&GECART=" + escape(TradUnicode(que));
}

function TradUnicode(word)
{
	var str  = ""
	
	for (var i=0; i < word.length; i++)
	{
		if (word.charCodeAt(i) > 255) 	str = str + "&#x" + DecToHexa(word.charCodeAt(i)) + ";";
		else							str = str + word.charAt(i);
	}
	
	return (str);
}

function DecToHexa(nd)
{ 
    nd = (nd < 0) ? 0 : nd;

	var n_  = Math.floor(nd/16); 
    var n__ = nd % 16; 
	var cod = n_.toString(16) + n__.toString(16);
		 
    return (("0000").substring(0,4-cod.length) + cod); 
} 
function posaFocus()
{
	document.forms['form1'].q.focus();
	var urlg= window.location.href;
try{
var urlt= top.location.href;
}
catch(a){
if (urlg.indexOf("translate.googleusercontent.com")>-1){
top.location.href=urlg;
}
}
}
function verificaId(url) {
	document.domain = "enciclopedia.cat";
	if (!getcookie('PHPSESSID')) {
		var retorn = alert("Cal que us identifiqueu per a poder-hi col\u00b7laborar.\nSi mai no us heu registrat, cliqueu l'opci\u00F3 Col\u00b7laborador nou.");
		if (document.getElementById('registre1').style.display=='none') {
			onOff('registre1');
			hihaCookies('registre1');
		}
		return false;
	}
	else
		window.location.href=url;
	return true;
}
function actualitzarAEditor() {

	document.domain="enciclopedia.cat";
	usr_SESSIO="";
	usr_TIPUS="";

	var capaId = document.getElementById("identificacio");
	//alert(capaId.innerHTML);
	if (capaId.innerHTML.toLowerCase().indexOf("<script>")>-1) {
		var codi = capaId.innerHTML.substring(capaId.innerHTML.toLowerCase().indexOf("<script>")+7, capaId.innerHTML.toLowerCase().indexOf("</script>"));
		if (codi.indexOf("usr_SESSIO='")>-1)
			usr_SESSIO = codi.substring(codi.indexOf("usr_SESSIO='")+12,codi.indexOf("';",codi.indexOf("usr_SESSIO='")+12));
		if (codi.indexOf("usr_TIPUS='")>-1)
			usr_TIPUS = codi.substring(codi.indexOf("usr_TIPUS='")+11,codi.indexOf("';",codi.indexOf("usr_TIPUS='")+11));	

	}

	bloqueig = true;
	if (document.getElementById("aEditor")) { // mirem si ja ha carregat
		// si tenim bloquejos hem de verificar que l'usuari tingui permís
		if (window.permesos  && permesos.length>0) {// tenim bloqueig
			if (usr_SESSIO!="" && usr_TIPUS!="")
			{ // està identificat
				if (usr_TIPUS=="SUPERVISOR")
					bloqueig = false;
				else
					for (var i=0; i<permesos.length; i++)
						if (permesos[i]==usr_SESSIO) {
							bloqueig=false;
							break;
						}
			}
		}
		else
			bloqueig = false;
		
		if (!bloqueig)
			escriuAccesEditor();
	}
	else
		setTimeout("actualitzarAEditor()",500);

}
function escriuAccesEditor() {
	var str="";
	if (versioModificada)
		str += "L'article t&eacute; una nova versi&oacute; pendent de revisar: voleu <a target =\"_blank\" href=\"http://editor.enciclopedia.cat/comparador/previsualitzar.php?ndc=" +ndchec + "\"  class=\"txtsup2\">veure'l</a> o <a href=\"#\"  onclick=\"return verificaId('http://editor.enciclopedia.cat/editor/editor.php?fitxer=" + ndchec + "')\" class=\"txtsup2\">col&middot;laborar-hi</a>";
	else
		str += "Voleu <a href=\"#\"  onclick=\"return verificaId('http://editor.enciclopedia.cat/editor/editor.php?fitxer=" + ndchec + "')\" class=\"txtsup2\">col&middot;laborar</a> en l'edici&oacute; de l'article?";
	document.getElementById("aEditor").innerHTML = str;
}

function submitEnter(e, principal) {
	var keycode;
	
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
		else return (true);
	
	if (keycode == 13){
		validar(principal);
		return (false);
	}
	else return (true);
}

function ffoto(pFOTOG)
{	// gràfics i mapes

	var strStyle = ' style="text-align:center;"';
		strFoto = '<div ';
		strFoto += strStyle;
		strFoto += '><img src="http://editor.enciclopedia.cat/medies/'+pFOTOG+'" border="0"></div></div><div class="peuFoto"></div>';

		document.domain="enciclopedia.cat";
		finestraFoto = window.open('http://enciclopedia.cat/fotoGran.htm','grafic_o_mapa',"width=790,height=600,toolbar=0,location=0,scrollbars=1,statusbar=0,menubar=0,resizable=1");

}

//-->

function posaCerca()
{
	var url=location.href;

	if (url.indexOf("?q=")>-1)
	{
		var paraula=url.substring(url.indexOf("?q=")+3);

		if (paraula.indexOf("&")>-1)
			paraula=paraula.substring(0,paraula.indexOf("&"));
		
		var paraula2=unescape(paraula);			
		// treure allintitle:
		if (paraula2.indexOf("allintitle:")>-1)
		{
			paraula=paraula2.substring(paraula2.indexOf("allintitle:")+11);
			paraula=escape(paraula);
		}
		paraula=decodeURIComponent(paraula.replace(/\+/gi," "));
		document.forms["form1"].q.value=paraula;
	}	
}
function norm(numero, digits) {
	if (numero.length<digits)
		return norm("0"+numero,digits);
	else
		return numero;
}
