/* XMB20080721 Eliminades refs a .net */ /*IPP20090219 Poso SORT tot en majuscules */

// Definicio de variables per les capes textos urls etc via objectes
// via contructor function Capa(id,left,top,width,zindex,bcolor,lbcolor,esPare,idPare,textes,ids,menus,urls)

// Poblacio
var textes=new Array("Recomptes","Sexe, edat i estat civil","Naturalesa de la poblaci&oacute","Estudis de la poblaci&oacute", "Cens ling&uuml;&iacute;stic","Relaci&oacute; amb l'activitat","Fluxos","Llars i fam&iacute;lies","Mobilitat espacial","Estimacions","Projeccions","Onom&agrave;stica");
var ids=new Array(20,21,22,23,24,25,26,27,28,29,290,291);
var localURL=new Array("cat/poblacio/poblrecomptes.html","cat/poblacio/poblestructura.html","cat/poblacio/poblnaturalesa.html","cat/poblacio/poblestudis.html","cat/poblacio/poblcensling.html","cat/poblacio/poblactivitat.html","cat/poblacio/poblfluxos.html","cat/poblacio/poblllarsfam.html","cat/poblacio/poblmobilitat.html","cat/poblacio/poblestimacions.html","cat/poblacio/poblprojeccions.html","cat/poblacio/poblonomast.html");
ArrayCapas[0]=new Capa(1,152,46,180,3,fons.pob,fons.pob,true,1,textes,ids,ids,localURL);
ArrayCapas[0].esPare=false;
// Economia
var textes=new Array("Macromagnituds","Sector agrari","Ind&uacute;stria","Construcci&oacute","Serveis","Consum i economia de les llars","Inversi&oacute","Treball","Preus i salaris","Turisme","Sector exterior","Sector p&uacute;blic","Sector financer","Empreses","R+D, innovaci&oacute; i TIC");
var ids=new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
var localURL=new Array("cat/economia/ecomacro.html","cat/economia/ecoagrari.html","cat/economia/ecoindust.html","cat/economia/ecoconstr.html","cat/economia/ecoserveis.html","cat/economia/ecoconsum.html","cat/economia/ecoinversio.html","cat/economia/ecotreball.html","cat/economia/ecopreus.html","cat/economia/ecotur.html","cat/economia/ecosectext.html","cat/economia/ecosectpub.html","cat/economia/ecosectfinanc.html","cat/economia/ecoempreses.html","cat/economia/ecormesd.html");
ArrayCapas[1]=new Capa(2,228,46,200,2,fons.eco,fons.eco,false,2,textes,ids,ids,localURL);
// Societat
var textes=new Array("Educaci&oacute;","Treball","Qualitat i condicions de vida","Cultura, lleure, esports","Llengua","Salut i benestar social","Habitatges i edificis","Participaci&oacute; ciutadana","Just&iacute;cia i seguretat ciutadana","Medi ambient","Protecci&oacute social","Societat de la informaci&oacute;");
var ids=new Array(31,32,33,34,35,36,37,38,39,390,391,392);
var localURL=new Array("cat/societat/soceduc.html","cat/societat/soctreball.html","cat/societat/socqualit.html","cat/societat/soccult.html","cat/societat/soclleng.html","cat/societat/socsalut.html","cat/societat/sochabitat.html","cat/societat/socpartic.html","cat/societat/socjustic.html","cat/societat/socmedi.html","cat/societat/socprotec.html","cat/societat/socinfo.html");
ArrayCapas[2]=new Capa(3,301,46,210,4,fons.soc,fons.soc,false,3,textes,ids,ids,localURL);
// Territori
var textes=new Array("Base de dades de municipis","Base de dades inframunicipal","Fitxes municipals","Fitxes comarcals","Atles dels Pirineus","Codis territorials");
var ids=new Array(40,41,42,43,45,46);
var localURL=new Array("bemcat/","territ/BasicTerr?TC=16","territ/BasicTerr?TC=1&V0=1&V1=MUNICIPI","territ/BasicTerr?TC=1&V0=1&V1=COM","http://atlas.ctp.org/site_ct/index_ct.php?lang=ct","cat/territori/codis/");
ArrayCapas[3]=new Capa(4,374,46,190,5,fons.ter,fons.ter,false,4,textes,ids,ids,localURL);
//Idescat
var textes=new Array("L'organisme","Sistema estad&iacute;stic","Publicacions","Biblioteca","Classificacions","Formaci&oacute; i recerca","Perfil del contractant","Webs d'inter&egrave;s","Novetats");
var menus=new Array(51,52,53,54,56,57,59,58,55);
var ids=new Array(51,52,53,54,56,57,59,58,55);
var localURL=new Array("#","#","cat/idescat/publicacions/cataleg/","cat/idescat/biblioteca/","cat/idescat/classif/","#","cat/idescat/organisme/contractacio.html","cat/idescat/altreswebs/","novetats/");
ArrayCapas[4]=new Capa(5,447,46,150,6,fons.ide,fons.ide,true,5,textes,ids,menus,localURL);

// Menus de segon nivell pare idescat
var textes=new Array("Presentaci&oacute;","Organitzaci&oacute;","Mem&ograve;ria","On som");
var ids=new Array(5101,5102,5106,5103);
var localURL=new Array("cat/idescat/organisme/presenta.html","cat/idescat/organisme/organitz.html","cat/idescat/organisme/memoria.html","cat/idescat/organisme/on_som.html");
ArrayCapas[5]=new Capa(51,275,46,172,84,fons.ide,fons.ide,false,5,textes,ids,menus,localURL);

var textes=new Array("Legislaci&oacute;","Pla estad&iacute;stic i programes","Ciutadans");
var ids=new Array(5201,5202,5204);
var localURL=new Array("cat/idescat/sistemaestadistic/legislacio/","cat/idescat/sistemaestadistic/plaestadistic/","cat/idescat/sistemaestadistic/ciutadans/");
ArrayCapas[6]=new Capa(52,273,60,174,71,fons.ide,fons.ide,false,5,textes,ids,menus,localURL);

var textes=new Array("Formaci&oacute; i promoci&oacute;","Projectes de recerca","Revista SORT");
var ids=new Array(5601,5602,5603);
var localURL=new Array("formacio/","cat/idescat/formaciorecerca/recerca/recerca.html","sort/");
ArrayCapas[7]=new Capa(57,262,110,185,59,fons.ide,fons.ide,false,5,textes,ids,menus,localURL);

// Final de dades

var actual = 0;
var cambio = 0;
var actual2 = 0;
var ie = (document.all)? true:false;
var imgActual=0;
var imgActual2=0;
var on = new Array(1);
var off = new Array(1);
off[0] = new Image();
off[0].src=host+"/images/fletxa_02_eco.gif";
on[0] = new Image();
on[0].src=host+"/images/fletxa_02_ecob.gif";
function cambiaImg(cual) {
if(imgActual){
eval("document.images['cat_" + imgActual + "'].src = off[0].src");
}
eval("document.images['cat_" + cual + "'].src = on[0].src");
imgActual = cual;
}
function cambiaImg2(cual) {
if(imgActual2){
eval("document.images['cat_" + imgActual2 + "'].src = off[0].src");
}
eval("document.images['cat_" + cual + "'].src = on[0].src");
imgActual2 = cual;
}
function cambiaMenu(cambio) {
if (cambio) {
if( actual ){
MM_showHideLayers('DIV'+actual,'','hide');
}
if(cambio != 56 && cambio!=520 && cambio!=55  && cambio!=58 && cambio!=54 && cambio!=53)MM_showHideLayers('DIV'+cambio,'','show'); /* Items menu Idescat que no tenen submenu */
actual = cambio;
if(imgActual2){
eval("document.images['cat_" + imgActual2 + "'].src = off[0].src");
}
}
}
function cambiaPrincipal(cambio) {
if (cambio) {
if( actual ){
MM_showHideLayers('DIV'+actual,'','hide');
}
if( actual2 ){
MM_showHideLayers('DIV'+actual2,'','hide');
}
MM_showHideLayers('DIV'+cambio,'','show');
}
actual2 = cambio;
actual=0;
if(imgActual){
eval("document.images['cat_" + imgActual + "'].src = off[0].src");
}
}
function fueraMenus(){
if( actual ){
MM_showHideLayers('DIV'+actual,'','hide');
}
if( actual2 ){
MM_showHideLayers('DIV'+actual2,'','hide');
}
}
function showMenu(cambio, cambio2){
MM_showHideLayers('DIV'+cambio,'','show');
if( cambio2 ){
MM_showHideLayers('DIV'+cambio2,'','show');
}
}
function show2Menu(cambio){
MM_showHideLayers('DIV'+cambio,'','show');
if( actual ){
MM_showHideLayers('DIV'+actual,'','show');}
}
function init() {
	cambio = 1;
}

function creaCapa(capa)
{
	document.write("<div id=\"DIV"+capa.id+"\" style=\"position:absolute; left:"+capa.left+"px; top:"+capa.top+"px; width:"+capa.width+"px;  z-index:"+capa.zindex+"; background-color: "+capa.bcolor+"; layer-background-color: "+capa.lbcolor+"; border: 1px none #000000; visibility: hidden\" onmouseout=\"fueraMenus()\"  onmouseOver=\""+capa.fevento+"\" >"); 
	document.write("<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">"); 
	document.write("&nbsp;<BR>");
	if(! capa.esPare){
		for(var k=0; k < capa.textes.length; k++)
		{
			document.write("&nbsp;<img src=\""+host+"/images/fletxa_02_eco.gif\" width=\"11\" height=\"10\" name=\"cat_"+capa.ids[k]+"\"><a href=\""+capa.urls[k]+"\" onMouseOver=\"cambiaImg2("+capa.ids[k]+");\" class=\"ib\">"+capa.textes[k]+"</a>&nbsp;<br>");
		}
	}else{
		for(var k=0; k < capa.textes.length; k++)
		{	/* Items menu Idescat que no tenen submenu */
		   if(capa.ids[k] != 56 && capa.ids[k]!=520 && capa.ids[k]!=55 && capa.ids[k]!=59 && capa.ids[k]!=58 && capa.ids[k]!=54 && capa.ids[k]!=53)
				document.write("&nbsp;<img src=\""+host+"/images/fletxa_02_eco.gif\" width=\"11\" height=\"10\" name=\"cat_"+capa.ids[k]+"\"><a href=\"javascript:void(null)\" onMouseOver=\"cambiaMenu("+capa.menus[k]+");cambiaImg("+capa.ids[k]+");\" class=\"ib\">"+capa.textes[k]+"</a>&nbsp;<br>");
		   else 
				document.write("&nbsp;<img src=\""+host+"/images/fletxa_02_eco.gif\" width=\"11\" height=\"10\" name=\"cat_"+capa.ids[k]+"\"><a href=\""+capa.urls[k]+"\" onMouseOver=\"cambiaMenu("+capa.menus[k]+");cambiaImg("+capa.ids[k]+");\" class=\"ib\">"+capa.textes[k]+"</a>&nbsp;<br>");
		}
	}
	document.write("&nbsp;<BR>");
	document.write("</font></div>");
}

function Capa(id,left,top,width,zindex,bcolor,lbcolor,esPare,idPare,textes,ids,menus,urls)
{
   this.id=id;
   this.left=left;
   this.top=top;
   this.width=width;
   this.zindex=zindex;
   this.bcolor=bcolor;
   this.lbcolor=lbcolor;
   this.esPare=esPare;
   this.idPare=idPare;
   if(this.esPare == true)this.fevento="show2Menu("+this.id+")";
   else this.fevento="showMenu("+""+this.idPare+","+this.id+")";
   this.textes=textes;
   this.menus=menus;
   this.ids=ids;
   for ( i=0; i < urls.length; i++)
   {
      if( (urls[i].indexOf("http") == -1)&&urls[i].indexOf("abrirVentana")==-1 )urls[i]=host+"/"+urls[i];
   }
      this.urls=urls;
}

function creaMenu(elTitol,trads) {
	//temporalment
	if (typeof trads=="undefined"){ trads=guess(elTitol); }

	var idiomes=Idiomes(trads);
	document.write("<div id=\"NavegacioJS\">"+idiomes+"<form action=\""+host+"/cercador/\"><a id=\"adalt\"></a><img src=\""+host+"/images/pix_transp.gif\" width=\"760\" height=\"20\" alt=\"\">");
	document.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr align=\"left\" valign=\"bottom\">"); 
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"20\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\""+host+"\" ><img src=\""+host+"/images/logo_Idescat_nostre_petit.gif\" width=\"120\" height=\"26\" alt=\"Idescat.cat\" title=\"\"  border=\"0\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"12\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\"javascript:void(null)\" onMouseOver=\"cambiaPrincipal(1)\" onMouseOut=\"fueraMenus()\"><img src=\""+host+"/images/bot_petit_poblacio.png\" width=\"71\" height=\"14\" alt=\"Poblaci&oacute\" title=\"\" border=\"0\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"5\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\"javascript:void(null)\" onMouseOver=\"cambiaPrincipal(2)\" onMouseOut=\"fueraMenus()\"><img src=\""+host+"/images/bot_petit_economia.png\" width=\"68\" height=\"14\" alt=\"Economia\" title=\"\" border=\"0\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"5\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\"javascript:void(null)\" onMouseOver=\"cambiaPrincipal(3)\" onMouseOut=\"fueraMenus()\"><img src=\""+host+"/images/bot_petit_societat.png\" width=\"68\" height=\"14\" alt=\"Societat\" title=\"\" border=\"0\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"5\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\"javascript:void(null)\" onMouseOver=\"cambiaPrincipal(4)\" onMouseOut=\"fueraMenus()\"><img src=\""+host+"/images/bot_petit_territori.png\" width=\"68\" height=\"14\" alt=\"Territori\" title=\"\" border=\"0\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"5\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\"javascript:void(null)\" onMouseOver=\"cambiaPrincipal(5)\" onMouseOut=\"fueraMenus()\"><img src=\""+host+"/images/bot_petit_idescat.png\" width=\"68\" height=\"14\" alt=\"Idescat\" title=\"\" border=\"0\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"5\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\""+host+"/cat/mapa.html\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image31','','"+host+"/images/bot_dalt_mapa_dins_on.gif',1)\"><img name=\"Image31\" border=\"0\" src=\""+host+"/images/bot_dalt_mapa_dins.gif\" width=\"68\" height=\"14\" alt=\"mapa web\" title=\"\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"5\" height=\"26\" alt=\"\"></td>");
	document.write("<td><a href=\""+host+"/cat/idescat/serveis/consultans.html?ref="+encodeURIComponent(url)+"\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image32','','"+host+"/images/bot_dalt_consultans_dins_on.gif',1)\"><img name=\"Image32\" border=\"0\" src=\""+host+"/images/bot_dalt_consultans_dins.gif\" width=\"68\" height=\"14\" alt=\"consulta'ns\" title=\"\"></a></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"4\" height=\"26\" alt=\"\"></td>");
	document.write("<td><input type=\"text\" name=\"q\" size=\"10\" id=\"MotsCerca\"></td>");
	document.write("<td><img src=\""+host+"/images/pix_transp.gif\" width=\"4\" height=\"26\" alt=\"\"></td>");
	document.write("<td><input id=\"Image30\" type=\"image\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image30','','"+host+"/images/lupa_on.gif',1)\" border=\"0\" src=\""+host+"/images/lupa_of.gif\" width=\"18\" height=\"14\" alt=\"cercar\" title=\"cercar\"></td>");
	document.write("</tr></table>");
	document.write("<img src=\""+host+"/images/pix_transp.gif\" width=\"760\" height=\"20\" alt=\"\"></form></div>");
	for(var i=0; i < ArrayCapas.length; i++){creaCapa(ArrayCapas[i]);}
}

function demandes(){
 win=window.open("http://demandes.idescat.cat/serviceweb/consultans_cat.jsp","Demandes","scrollbars=1,resizable=1");
 win.window.focus();
}

function Idiomes(trads){
	if (typeof trads=="undefined" || trads==0){ return ""; }
	var EnllacES, EnllacEN;
	var jo=url.replace(/&/g,"&amp;");
	jo = jo.replace(/#(.*)$/,"");
	var par="lang";

	if(jo.indexOf("/cat/") > -1){
		EnllacES = 	jo.replace("/cat/","/es/");
		EnllacEN = 	jo.replace("/cat/","/en/");
	}else{
		if (jo.indexOf("http://biblio.idescat.cat")>-1){ // biblio
			par="lng";
		}
		if (jo.indexOf(par+"=")==-1){
			if(jo.indexOf("?") > -1){
				jo = jo+"&amp;"+par+"=ca";
			}else{
				jo = jo+"?"+par+"=ca";
			}
		}
		EnllacES = 	jo.replace(par+"=ca",par+"=es");
		EnllacEN = 	jo.replace(par+"=ca",par+"=en");
	}

	if (trads>1){
		return "<div id=\"Idiomes\">Catal&agrave; | <a href=\""+EnllacES+"\" tabindex=\"2\" title=\"Esta p&aacute;gina est&aacute; traducida total o parcialmente al castellano\" hreflang=\"es\">Castellano</a> | <a href=\""+EnllacEN+"\" tabindex=\"3\" title=\"This page is completely or partially translated into English\" hreflang=\"en\">English</a></div>";
	}else{
		return "<div id=\"Idiomes\">Catal&agrave; | <a href=\""+EnllacES+"\" tabindex=\"2\" title=\"Esta p&aacute;gina est&aacute; traducida total o parcialmente al castellano\" hreflang=\"es\">Castellano</a></div>";
	}
}