function botoB2(a,b){if(a==1){$(b).style.border="3px solid";$(b).style.borderColor="#9f0000"}else{$(b).style.border="1px solid";$(b).style.borderColor="#C1A53A"}}function capturaOnSubmit(b){document.cercaOculta.topo.value="";document.cercaOculta.kw.value="";document.cercaOculta.filtre.value="";if(locs){if(locs.length>0){if(b==1&&heFet==false){escriuBBOX((parseInt(locs[0].idTipus)),locs[0].x,locs[0].y,tractaAP(locs[0].nom),0)}}else{if($("q_d").value=""){}else{alert(al1)}}}botoB2(b,"btCerca");document.cercaOculta.topo.value=$("q_d").value;document.cercaOculta.kw.value=treuAccent($("q_k").value);document.cercaOculta.filtre.value="";peticioNova=true;jQuery("div.jsonSuggestResults").hide();$("divQ").style.display="none";creaTaula("","","","",0,"","");var a="/c_idec/cerca/"+document.cercaOculta.topo.value+"/"+document.cercaOculta.kw.value+"/"+document.cercaOculta.filtre.value;pageTracker._trackPageview(a);botoB2(b,"btCerca")}function cercaSerie(a){$("q_k").value=a;capturaOnSubmit(0)}function emergencia(a){bboxLatLon=ObteLloc(a);if(!bboxLatLon){alert("Problemes de connectivitat amb el servei de topònims")}else{$("q_d").value=a;$("divQ").style.display="none";enviaPeticio(bboxLatLon,a,"",0,-1,-1)}}var heFet=false;function escriuBBOX(d,b,a,e,f){var h;var l;var c;heFet=true;if(d==1||d==17){c=ObteLloc(e);if(!c){h=creaRectangle(a,b,300);c=TransformaCoord(h);l=creaRectangleBounds(a,b,300)}else{l=trans4326To23031(c.left,c.bottom,c.right,c.top)}}else{h=creaRectangle(a,b,300);c=TransformaCoord(h);l=creaRectangleBounds(a,b,300)}$("q_d").value=e;$("q_d").focus();$("divQ").style.display="none";document.cercaOculta.bbox.value=rondo(c.left,4)+","+rondo(c.bottom,4)+","+rondo(c.right,4)+","+rondo(c.top,4);map.zoomToExtent(l)}var JSONPOST;var POSTproductes;var POSTvalor;function PostEnviaPeticio(b,a){if(b==1){esborraFiltres()}if(b==2){netejaFiltreDates();filtreProducte(a)}if(b==3){insertaFiltreDates(a)}}var peticioNova=true;var inici="";function enviaPeticio(f,d,a,e,c,b){inici=new Date().getTime();netejaFF();espeDiv();peticioNova=true;creaTaula(null,a,d,f,e,c,b);return true}function ObteLloc(c){var b=c;var a=null;var d=null;c=treuAccent(c);for(i=0;i<lcs.length;i++){if(lcs[i][5].substring(0,c.length)==c){a=new Object();a.y0=lcs[i][1];a.x0=lcs[i][0];a.y1=lcs[i][3];a.x1=lcs[i][2];d=new OpenLayers.Bounds(a.x0,a.y0,a.x1,a.y1)}}return d}function TransformaCoord(a){var b=trans23031To4326(a.x0,a.y0,a.x1,a.y1);return b}function intelVissir(a){var d=7;var b="B00FFFFFTF";var c=true;var e=new Array();if(a.indexOf("Orto")!=-1){c=false}if(a.indexOf("-1M")!=-1){d=6;b="B00FFFFFTFT"}if(a.indexOf("-5M")!=-1&&c){d=6;b="B00FTFFFTFF"}if(a.indexOf("-25M")!=-1&&c){d=4;b="B00FFFTFTF"}if(a.indexOf("-50M")!=-1&&c){d=5;b="B00FFFFTTFF"}if(a.indexOf("-5M")!=-1&&!c){d=6;b="0B0FTFFFTF"}if(a.indexOf("-25M")!=-1&&!c){d=4;b="0B0FFFTFTF"}if(a.indexOf("-50M")!=-1&&!c){d=5;b="0B0FFFFTTFF"}e.push(d);e.push(b);return e}var matriuJSON=new Array();function creaMatriuTaula(c,b){var a=new Array();a=c.aaData;return a}var Table1;var oTable;var matriuTaula;function determinaPeticio(a){var b="";if(document.cercaOculta.bbox.value!=""){b+="bbox="+document.cercaOculta.bbox.value+"&"}if($F("q_k")!=""){b+="kw="+document.cercaOculta.kw.value+"&"}if(document.cercaOculta.filtre.value!=""){b="filtre="+encodeURIComponent(document.cercaOculta.filtre.value)+"&"}return b}function creaTaula(n,q,e,p,c,f,d){var l=1;espeDiv();$("lResultats").innerHTML='<div align="center">'+m18+"</div>";var o=0;var a="bbox="+document.cercaOculta.bbox.value+"&";var b=document.cercaOculta.kw.value;var m="";var h=determinaPeticio(c);h=h+"metode=GetFeature&clau="+clau+"&tName="+document.cercaOculta.tName.value+"&idioma="+idioma+"&lang="+lang+"&";jQuery("#dynamic").html('<table cellpadding="0" cellspacing="0" border="0" class="display" name="example" id="example"></table>');oTable=jQuery("#example").dataTable({bFilter:true,bAutoWidth:false,bProcessing:true,bServerSide:true,sAjaxSource:"catalegJSONO.jsp?"+h,sDom:'<"top"ir><"fixed_height"t><"bottom"lp><"clear">',sPaginationType:"full_numbers",bSortClasses:true,iDisplayLength:25,fnDrawCallback:function(){o=0;heFet=false;fetDiv();var r=boxes.features;r.reverse();netejaCapa("boxes");boxes.addFeatures(r);revisaFF();if(boxes.getDataExtent()!=null){var s=parseInt(boxes.getDataExtent().right-boxes.getDataExtent().left);if(s<=50000){map.zoomToExtent(boxes.getDataExtent())}}},fnRowCallback:function(u,s,r){o++;if(o==1){netejaCapa("boxes")}if(boxes){box=xurroToBounds(s[2],"NO");var t=new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(box.right,box.bottom),new OpenLayers.Geometry.Point(box.left,box.bottom),new OpenLayers.Geometry.Point(box.left,box.top),new OpenLayers.Geometry.Point(box.right,box.top),new OpenLayers.Geometry.Point(box.right,box.bottom)]);t.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:23031"));var w=new OpenLayers.Feature.Vector(t);var v=s[5].split("#");w.attributes.ia=v[0];w.attributes.nik=v[1];boxes.addFeatures([w])}return u},oLanguage:{oPaginate:{sFirst:"<<",sLast:">>",sNext:">",sPrevious:"<"},sInfo:m19+" <b> _TOTAL_ </b> (_START_ a _END_) <div id='infoFiltre'></div></div>",sInfoEmpty:"0 registres trobats",sInfoFiltered:" - filtrant _MAX_ registres",sLengthMenu:m22+" _MENU_ "+m23,sProcessing:"Cercant...",sSearch:"Filtrar registres:",sZeroRecords:m20},aoColumns:[{sTitle:"",sWidth:"85%",bSortable:false},{sTitle:"",bSortable:false,sClass:"center",fnRender:function(r){var w="";var v=r.aData[5].split("#");if(v[2].indexOf("WMS")!=-1){var t=xurroToBounds(r.aData[2],"NO");if(clauPrimaria=="prg"){var s=r.aData[3].split("</b>");w='<a href="http://doctorzamenhof:8181/PRG/eines/editorWMS.action?urlInput='+s[2]+'" target="_top"><div title="'+m16+'" class="divService"></div></a>'}else{w='<div title="'+m16+'" onclick="addServei(\''+v[0]+"',"+rondo(t.left,4)+","+rondo(t.bottom,4)+","+rondo(t.right,4)+","+rondo(t.top,4)+')" class="divService"></div>'}}if(v[3]!="NO"){var u=v[3];if(u.indexOf("http://")==-1){u="http://"+u}w='<a target="_blank"  href="'+u+'"><div title="'+m17+'" class="divDownload"></div></a>'}return w}},{sTitle:"bbox",bSortable:false,bVisible:false},{sTitle:"",bSortable:false,bVisible:false},{sTitle:"",bSortable:false,bVisible:false},{sTitle:"",bSortable:false,bVisible:false}],fnServerData:fnDataTablesPipeline});addClick();initCerques(e,p,c,q);fnOpenClose()}function ordenaDataVol(b,a){if(b=="center sorting"){oTable.fnSort([[1,"desc"]]);jQuery("#tV th:last").removeClass("sorting");jQuery("#tV th:last").addClass("sorting_desc")}else{if(b=="center sorting_desc"){oTable.fnSort([[1,"asc"]]);jQuery("#tV th:last").removeClass("sorting_desc");jQuery("#tV th:last").removeClass("sorting");jQuery("#tV th:last").addClass("sorting_asc")}else{if(b=="center sorting_asc"){oTable.fnSort([[0,"asc"]]);jQuery("#tV th:last").removeClass("sorting_asc");jQuery("#tV th:last").addClass("sorting")}}}}function fixaH(a){var c=0;if(a<5){for(i=0;i<a;i++){c+=50}}else{c=300}var b=document.getElementById("vvv");b.style.height=c+"px"}function splitX(a,b){var c=a.split(b);return c}function revisaFF(){if(oTable){var a=oTable.fnSettings();if(a.aiDisplay.length==0){netejaCapa("boxes")}}}function addClick(){jQuery("#example tbody").click(function(f){if(jQuery(f.target.parentNode).hasClass("odd")||jQuery(f.target.parentNode).hasClass("even")){jQuery(oTable.fnSettings().aoData).each(function(){jQuery(this.nTr).removeClass("row_selected")});jQuery(f.target.parentNode).addClass("row_selected");var c=fnGetSelected(oTable);var l=oTable.fnGetPosition(c[0]);var b=oTable.fnGetData(l);box=xurroToBounds(b[2],"23031");for(k=0;k<boxes.features.length;k++){var a=boxes.features[k].attributes.ia;var d=boxes.features[k].attributes.nik;var e=boxes.features[k];var h=b[5].split("#");e.attributes.nik=h[1];if(d=="Selected"){e.attributes.nik=h[1];boxes.removeFeatures([e]);boxes.addFeatures([e])}if(a.indexOf(h[0])!=-1){e.attributes.nik="Selected";boxes.removeFeatures([e]);boxes.addFeatures([e]);map.zoomToExtent(box)}}}})}function fnGetSelected(a){var c=new Array();var b=a.fnGetNodes();for(var d=0;d<b.length;d++){if(jQuery(b[d]).hasClass("row_selected")){c.push(b[d])}}return c}function fnFormatDetails(d){var b=oTable.fnGetPosition(d);var a=oTable.fnSettings().aoData[b]._aData;var c='<table class="N_labelMin" height="40" cellpadding="2" cellspacing="2" border="0" style="padding-left:10px;">';c+="<tr>"+a[3]+"</tr>";c+="<tr>"+a[4]+"</tr>";c+="</table>";return c}function fnOpenClose(){if(oTable){jQuery("td img",oTable.fnGetNodes()).each(function(){jQuery(this).click(function(){var b=this.parentNode.parentNode;if(this.src.match("dc")){this.src="images/misc/do.png";var a=jQuery(b).next()[0];a.parentNode.removeChild(a)}else{this.src="images/misc/dc.png";oTable.fnOpen(b,fnFormatDetails(b),"details")}})})}}function flowCerca(a){var b=$("flow_div").innerHTML}var recD=false;function enviaPrePeticio(a,b){espeDiv();recD=b;netejaFiltreDates();$("divQ").style.display="none";document.cercaOculta.bbox.value=rondo(a.left,4)+","+rondo(a.bottom,4)+","+rondo(a.right,4)+","+rondo(a.top,4);peticioNova=true;creaTaula(null,"","","",0,"","")}function enviaHistoPeticio(b,p,o,l,d,e){cercaActiva=e;var m=$(p).value;dd2=m.split("#");var n=new Array();var h=dd2[1];if(h.indexOf(",")==-1){n.push(dd2[1])}else{var f=h.split(",");for(j=0;j<f.length;j++){n.push(f[j])}}var a=xurroToBounds(dd2[0],"N0");try{rr=enviaPeticio(a,"hist",n,b,o,l)}catch(c){}netejaCapa("marca");cercaAcEstil()}function peticioInfo(a,b){if(!catalegLocal){document.cercaOculta.topo.value="";document.cercaOculta.kw.value="";document.cercaOculta.filtre.value="";document.cercaOculta.reset();if(recD){netejaCapa("vector")}peticioNova=true;lonlat=a;bbox=creaRectangle(lonlat.lat,lonlat.lon,100);bboxLatLon=TransformaCoord(bbox);windowClickInfo("");document.cercaOculta.bbox.value=rondo(bboxLatLon.left,4)+","+rondo(bboxLatLon.bottom,4)+","+rondo(bboxLatLon.right,4)+","+rondo(bboxLatLon.top,4);$("lResultats").style.display="block";creaTaula(null,"","","",0,"","")}}var winMD=null;function windowClickInfo(h){var b=map.getPixelFromLonLat(lonlat);var l=map.getSize();var n=((l.h-305)/2);var a=((l.w-600)/2)+260;var c=(l.w-600)/2;var d=(l.h-305)/2;if(b.x<(l.w/2)){a=b.x+275}else{a=b.x-30}if(b.y<(l.h/2)){n=b.y+85}else{n=b.y-100}var o=map.getLayersByName("marca")[0];if(o!=null){o.destroy()}var f=new OpenLayers.Layer.Markers("marca",{displayInLayerSwitcher:false});map.addLayer(f);var p=new OpenLayers.Size(30,24);var e=new OpenLayers.Pixel(-10,-p.h);var m=new OpenLayers.Icon("/SDIExplorer/images/misc/marker.png",p,e);f.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(lonlat.lon,lonlat.lat),m))}function showRCCMD(b,f,d,a,c){winMD=dhtmlwindow.open("WBBOX","iframe",b,f,"width="+a+"px,height="+c+"px,left=200px,top=130px,resize=1,scrolling=0")}function sMD(b){var c="/wefex/client?";var a="/c_idec/consulta/md/"+b;pageTracker._trackPageview(a);var d=b.split("#");c=c+"idioma="+d[5]+"&do="+d[0]+"&id="+d[1]+"&fontText=tahoma,arial,helvetica,sans-serif&tamanyText=8&";winMD=dhtmlwindow.open("WBBOX","iframe",c,d[2],"width=550px,height=400px,left=150px,top=130px,resize=1,scrolling=0")}function sSD(b){var c="/wefex/client?";var a="/c_idec/consulta/disponibilitat/"+b;pageTracker._trackPageview(a);var d=b.split("#");c=c+"idioma="+d[1]+"&do=mostraSSC&url="+encodeURIComponent(d[0])+"&fontText=tahoma,arial,helvetica,sans-serif&tamanyText=8&";winMD=dhtmlwindow.open("WBBX","ajax",c,"Monitoring","width=500px,height=400px,left=150px,top=130px,resize=1,scrolling=0")}function showKML(a,b){var c='<table width="99%" border="0" cellspacing="3" cellpadding="3"><tr><td><div align="center"><img align="center" src="/SDIExplorer/images/misc/espe.gif"></div></td></tr></table>';winMD=dhtmlwindow.open("KML","inline",c,"KML","width="+a+"px,height="+b+"px,left=400px,top=400px,resize=1,scrolling=0")}function exportaKML(b){var c=new Array();if(b==-1){c=matriuJSON}else{c.push(matriuJSON[b])}var a="UTF-8";if(document.all){a="UTF-8"}new Ajax.Request("catalogKML.jsp",{method:"post",parameters:{mdJSON:Object.toJSON(c)},encoding:a,onCreate:function(){showKML(200,100)},onSuccess:function(f){var e=f.responseText.evalJSON()||"no response text";var d='<table width="99%" border="0" cellspacing="3" cellpadding="3"><tr><td><div align="center"><a class="mdtextlink" href="'+e.ruta+'" target="_blank">'+e.idarxiu+"</a></div></td></tr></table>";winMD.load("inline",d,"KML")},onFailure:function(){alert("Error en la petició...")}})}function espeDiv(){$("lResultats").innerHTML='<div align="center"><h2>Cercant...</h2><br>La cerca amb navegadors com Internet Explorer 6.x o 7.x pot esdevenir molt més lenta que amb altres navegadors com FireFox 3.x o Google Chrome 2.x</div>';$("lEstadistica").style.display="none";$("pr_div").style.display="none";$("cc_div").style.display="none";$("lResultats").style.display="block";$("lResultats").style.backgroundImage="url(/SDIExplorer/images/misc/espe.gif)";$("dynamic").style.display="none"}function fetDiv(){$("lResultats").style.display="none";$("divQ").style.display="none";$("vL").style.display="block";$("pr_div").style.display="block";$("dynamic").style.display="block"}function tornarInici(){document.cercaOculta.topo.value="";document.cercaOculta.kw.value="";document.cercaOculta.filtre.value="";document.cercaOculta.reset();$("q_d").value="";$("q_k").value="";escriuEstadistiques();netejaMapa()}var newwindow;function addServei(a,d,f,c,e){var b="/idecwebservices/mapawms/index.jsp?clau="+clauPrimaria+"&metode=GetServeiId&desc=&orga="+a+"&lang="+lang+"&language="+idioma+"&bbll="+d+","+f+","+c+","+e+"&";newwindow=window.open(b,"gestor","menubar=no,status=no,toolbar=no,width="+screen.width+",height="+screen.height+",scrollbars=yes,top=10,left=10,resizable=yes");if(window.focus){newwindow.focus()}}function addServeiPRG(b){var a="http://doctorzamenhof:8181/PRG/eines/editorWMS.action?urlInput="+b;document.location.href=a}function addDescarrega(a){}function cercaExterna(a){a=unescape(a);var b=miraToponim(a);if(b.bounds!=null){document.cercaOculta.bbox.value=b.bounds.left+","+b.bounds.bottom+","+b.bounds.right+","+b.bounds.top;bbox=trans4326To23031(b.bounds.left,b.bounds.bottom,b.bounds.right,b.bounds.top);map.zoomToExtent(bbox)}document.cercaOculta.kw.value=b.value;$("q_k").value=b.value;peticioNova=true;creaTaula(null,"","","",0,"","")}function miraToponim(c){var a=new Object();a.bounds=null;a.value=c;var l=null;c=trim(c);c=replaceAll(c," ","%20");l=recorreLlistaTopo(c);if(l==null){if(c.indexOf("%20")!=-1){var b=c.split("%20");var h=b.length;for(j=0;j<h;j++){if(j==0){var f=recorreLlistaTopo(b[0]);var e=c.substring(b[0].length+3,c.length);if(f==null){var d=recorreLlistaTopo(e);if(d==null){}else{a.bounds=d;a.value=b[0];return a}}else{a.bounds=f;a.value=e;return a}}if(j==2){var f=recorreLlistaTopo(b[0]+" "+b[1]);var e=c.substring(b[0].length+3+b[1].length+3,c.length);if(f==null){var d=recorreLlistaTopo(e);if(d==null){}else{a.bounds=d;a.value=b[0]+" "+b[1];return a}}else{a.bounds=f;a.value=e;return a}}}}else{a.bounds=l;a.value=c;return a}}else{a.bounds=l;a.value=null;return a}return a}function recorreLlistaTopo(c){var a=null;c=c.toUpperCase();accent=new Array("À","È","É","Í","Ì","Ò","Ó","Ú","Ù","Ï","Ü","%20","EL ","L'","D'","%E7");noaccent=new Array("A","E","E","I","I","O","O","U","U","I","U"," ","","","","");for(b=0;b<accent.length;b++){if(c.indexOf(0,accent[b])){c=replaceAll(c,accent[b],noaccent[b])}}var d=null;for(var b=0;b<lcs.length;b++){if(lcs[b][5].substring(0,c.length)==c&&(excepcions(c))){a=new Object();a.y0=lcs[b][1];a.x0=lcs[b][0];a.y1=lcs[b][3];a.x1=lcs[b][2];d=new OpenLayers.Bounds(a.x0,a.y0,a.x1,a.y1);return d}}return d}function excepcions(a){excep=new Array("MEDI ","ESCA","PLA ");for(i=0;i<excep.length;i++){if(a==excep[i]){return false}}return true}function initCerques(b,d,c,a){$("pres_div").style.display="none";$("lEstadistica").style.display="none";escriuProductes();if(document.all){}}function obteNomProducte(a){var c=null;for(i=0;i<productes.pr.length;i++){var b=productes.pr[i].Nom;if(b.indexOf(a)!=-1){c=b}}return c}function escriuEstadistiques(){$("pres_div").style.display="block";$("lEstadistica").style.display="block";$("pr_div").style.display="none";$("lResultats").style.display="none";$("dynamic").style.display="none";$("cc_div").style.display="none";document.cercaOculta.kw.value="";var n=new Array();var d=new Array();var f=new Array();var o=0;var h=0;n.push('<table width="99%" cellpadding="3" cellspacing="3"  border="0" class="N_label">');n.push('<tr><td  align="left" width="65%"><b>'+m3+"</b>");n.push('&nbsp;&nbsp;<input style=" font-size:9px;" class="N_text"  id="txtSearch" name="txtSearch"  title="Filtrar" type="text">&nbsp;');n.push("</td>");n.push('<td  align="center" ><b>'+_serie+'  <img class="img" src="/SDIExplorer/images/misc/help.png" onMouseover="ddrivetip(avis5, 200)" onMouseout="hideddrivetip()"></b></td>');n.push('<td  align="center" ><b>'+_dad+'  <img class="img" src="/SDIExplorer/images/misc/help.png" onMouseover="ddrivetip(avis3, 200)" onMouseout="hideddrivetip()"></b></td>');n.push('<td  align="center" ><b>'+_serv+'   <img class="img" src="/SDIExplorer/images/misc/help.png" onMouseover="ddrivetip(avis4, 200)" onMouseout="hideddrivetip()"></b></td></tr></table>');n.push('<div class="intern">');n.push('<table id="tblSearch"  width="100%" cellpadding="2" cellspacing="3"  border="0" class="N_labelPro">');d.push("<div>");d.push('<table width="100%" cellpadding="2" cellspacing="0"  border="0" class="N_label">');for(i=0;i<productes.organitzacions.length;i++){var l=productes.organitzacions[i].org.nom;l=l.replace("''","'");var c=l.replace("'","%27");var b="#F2F2F2";h++;if(i%2!=0){b="#FFFFFF"}n.push("<tr>");n.push("<td bgcolor="+b+' class="cr" width="65%">');var e=l;if(e.length>80){e=e.replace(".",".<br>");e=e.replace("(","<br>(")}n.push('<a href="#" class="mdtextlink" onclick="filtreOrg(\''+(c)+"')\">"+e+"</a>");n.push("</td>");n.push('<td align="center"  bgcolor='+b+">");var p=productes.organitzacions[i].org.seriesOrg;if(p.length>0){var m=p.length+"_"+i;n.push('<a href="#"  class="mdtextlinkDown" onclick="obreTanca(\'lstSerie_'+m+"')\">"+productes.organitzacions[i].org.seriesOrg.length+"</a><br>");kkIE="";if(document.all){kkIE="left:300px"}n.push('<div style="'+kkIE+";text-align:left;background-color:"+b+';z-index:2000;width:auto;height:auto;" class="N_Div_q2" id="lstSerie_'+m+'">');for(g=0;g<p.length;g++){serieNom=p[g].replace("''","´");var a=serieNom.replace("'","%27");n.push('<a href="#" class="mdtextlink" onclick=" filtreOrg(\''+(c)+"#SERIE#"+(a)+"')\">"+p[g]+"</a><br>")}n.push("</div>")}else{n.push("&nbsp;")}n.push("</td>");n.push('<td align="center"  bgcolor='+b+">");if(productes.organitzacions[i].org.totalDatasetsOrg!="0"){n.push('<a href="#" class="mdtextlink" onclick="filtreOrg(\''+(c)+"#SUBCLASSIF#Dataset')\">"+productes.organitzacions[i].org.totalDatasetsOrg+"</a>")}else{n.push("&nbsp;")}n.push("</td>");n.push('<td align="center"  bgcolor='+b+">");if(productes.organitzacions[i].org.totalServeisOrg!="0"){n.push('<a href="#" class="mdtextlink" onclick="filtreOrg(\''+(c)+"#SUBCLASSIF#Servei')\">"+productes.organitzacions[i].org.totalServeisOrg+"</a>")}else{n.push("&nbsp;")}n.push("</td>");n.push("</tr>")}d.push("<tr>");d.push('<td  width="90%"><b>'+m4+_tit+" </b>("+new Date().toLocaleDateString()+")<br>");d.push("<ul><li>"+m5+" <b>"+productes.pr.total+"</b></li>");d.push("<li>"+m6+" <b>"+productes.pr.totalDatasets+"</b></li>");d.push("<li>"+m7+" <b>"+productes.pr.totalServeis+"</b></li>");d.push("<li>"+m27+" <b>"+productes.pr.totalNumOrgS+"</b></li>");d.push("<li>"+m26+" <b>"+productes.pr.totalNumOrgD+"</b></li>");d.push("<li>"+m8+" <b>"+productes.pr.totalOrg+"</b></li></ul>");d.push("</td>");d.push("</tr>");d.push("</table>");d.push("</div>");n.push("</table>");n.push("</div>");$("pres_div").innerHTML=d.join(" ");$("lEstadistica").innerHTML=n.join(" ");inicialitzaFiltreOrg()}function esZ(b){var a=false;if(b=="0"||b==0){a=true}return a}function es1(b){var a=false;if(b=="1"||b==1){a=true}return a}var llista=new Array("lstOrg","lstFod","lstFos","lstEsc");function escriuProductes(c){if(c){var f=new Array();f.push('<h3 class="_h3"><b>'+m9+"</b></h3>");f.push('<div style="z-index:100"  class="olLayerGroup" >');if(c.Organitzacions){f.push('<table border="0" width="100%" cellpadding="2" class="N_labelPro">');f.push("<tr>");f.push('<td><a href="#" class="tots" onclick="filtreProducte(\'\')">'+m10+"</a></td>");f.push("<td>");if(esZ(c.Datasets)){f.push('<a href="#" class="filtreGris" >'+_dad+" ("+c.Datasets+")</a>")}else{f.push('<a href="#" class="filtre" onclick="filtreProducte(\'SUBCLASSIF#Dataset\')">'+_dad+" ("+c.Datasets+")</a>")}f.push("</td>");f.push("<td>");if(esZ(c.Serveis)){f.push('<a href="#" class="filtreGris" >'+_serv+" ("+c.Serveis+")</a>")}else{f.push('<a href="#" class="filtre" onclick="filtreProducte(\'SUBCLASSIF#Servei\')" >'+_serv+" ("+c.Serveis+")</a>")}f.push("</td>");f.push("</tr>");f.push("<tr>");f.push("<td>");if(es1(c.Organitzacions.length)){f.push('<a href="#" class="filtreGris" >&nbsp;</a>')}else{f.push('<a href="#" class="filtreDown" onclick="obreTancaLLista(\'lstOrg\',llista)">'+_orga+" ("+c.NOrganitzacions+')</a><br><div style="z-index:1000;width:340px;height:200px;" class="N_Div_q2" id="lstOrg">');for(i=0;i<c.Organitzacions.length;i++){var a=c.Organitzacions[i].org;var h=a.nom;h=replaceAll(h,"'","%27");f.push('<p><a href="#" onclick="filtreProducte(\'ORGANITZAC#'+h+"')\" >"+a.nom+"</a> (<b>"+a.total+"</b>)</p>")}f.push("</div>")}f.push("</td>");f.push("<td>");if(esZ(c.FormatsDades.length)){f.push('<a href="#" class="filtreGris" >'+m111+"</a>")}else{f.push('<a href="#"  class="filtreDown" onclick="obreTancaLLista(\'lstFod\',llista)">'+m111+'</a><br><div style="z-index:1000;width:100px;height:auto;" class="N_Div_q2" id="lstFod">');for(i=0;i<c.FormatsDades.length;i++){var d=c.FormatsDades[i].fod;f.push('<p><a href="#" onclick="filtreProducte(\'FORMAT#'+d.nom+"');\"  >"+d.nom+"</a> (<b>"+d.total+"</b>)</p>")}f.push("</div>")}f.push("</td>");f.push("<td>");if(esZ(c.TipusServeis.length)){f.push('<a href="#" class="filtreGris" >'+m12+"</a>")}else{f.push('<a href="#" class="filtreDown" onclick="obreTancaLLista(\'lstFos\',llista)">'+m12+'</a><br><div style="z-index:1000;width:100px;height:auto;" class="N_Div_q2" id="lstFos">');for(i=0;i<c.TipusServeis.length;i++){var d=c.TipusServeis[i].fos;f.push('<p><a href="#" onclick="filtreProducte(\'FORMAT#'+d.nom+"');\"  >"+d.nom+"</a> (<b>"+d.total+"</b>)</p>")}f.push("</div>")}f.push("</td>");f.push("</tr>");f.push("<tr>");f.push('<td><input class="N_text_C" id="cLL"  onKeyUp="javascript:getFiltreLLiure(event);" title="'+m13+'" type="text"></td>');f.push("<td>");if(esZ(c.Escala.length)){f.push('<a href="#" class="filtreGris" >'+m14+"</a>")}else{f.push('<a href="#" class="filtreDown" onclick="obreTancaLLista(\'lstEsc\',llista)">'+m14+'</a><br><div style="z-index:1000;width:100px;height:200px;" class="N_Div_q2" id="lstEsc">');for(i=0;i<c.Escala.length;i++){var d=c.Escala[i].esc;f.push('<p><a href="#" onclick="filtreProducte(\'ESCALA#'+d.nom+"');\" >"+d.nom+"</a> (<b>"+d.total+"</b>)</p>")}f.push("</div>")}f.push("</td>");f.push("<td>&nbsp;</td>");f.push("</tr>");f.push("</table>");if(!catalegLocal){f.push('<table width="99%" cellpadding="2" cellspacing="2"  border="0" class="N_labelPro"><tr><td align="right"><a class="mdR"  href=#" onClick="tornarInici();"> << '+jsinici+"</a></td></tr></table>")}}else{if(!catalegLocal){f.push('<table width="99%" cellpadding="2" cellspacing="2"  border="0" class="N_labelPro"><tr><td align="right"><a class="mdR"  href=#" onClick="tornarInici();"> << '+jsinici+"</a></td></tr></table>")}}var b="none";if(document.all){b="none"}var e=f.join("");$("pr_div").update(e);$("pr_div").style.display="block";fetSubmit=true;veureTextbox()}}function getFiltreLLiure(b){var a=$("cLL").value;if(a.length>=2){var c=(document.all)?b.keyCode:b.which;if(c==13){filtreProducte("MULTI#"+a)}}}function veureTextbox(){jQuery('input[id="cLL"]').each(function(){this.value=jQuery(this).attr("title");jQuery(this).focus(function(){if(this.value==jQuery(this).attr("title")){this.value=""}});jQuery(this).blur(function(){if(this.value==""){this.value=jQuery(this).attr("title")}})})}function inicialitzaFiltreOrg(){jQuery('input[id="txtSearch"]').each(function(){this.value=jQuery(this).attr("title");jQuery(this).focus(function(){if(this.value==jQuery(this).attr("title")){this.value=""}});jQuery(this).blur(function(){if(this.value==""){this.value=jQuery(this).attr("title")}})});jQuery.expr[":"].containsNoCase=function(el,i,m){var search=m[3];if(!search){returnfalse}return eval("/"+search+"/i").test(jQuery(el).text())};jQuery("#txtSearch").keyup(function(event){if(event.keyCode==27){resetSearch()}});jQuery("#txtSearch").keyup(function(){if(jQuery("#txtSearch").val().length>=2){jQuery("#tblSearch tr").hide();jQuery("#tblSearch tr td:containsNoCase('"+jQuery("#txtSearch").val()+"')").parent().show()}else{if(jQuery("#txtSearch").val().length==0){resetSearch()}}if(jQuery("#tblSearch tr:visible").length==1){jQuery(".norecords").remove();jQuery("#tblSearch").append('<tr class="norecords"><td colspan="5" class="Normal">'+m15+"</td></tr>")}})}function resetSearch(){jQuery("#txtSearch").val("");jQuery("#tblSearch tr").show();jQuery(".norecords").remove();jQuery("#txtSearch").focus()}function vis(a){if(a==0){document.getElementById("eD12").style.display="none"}else{document.getElementById("eD12").style.display="block"}}var CAL1;var CAL2;function activaCalendaris(){CAL1=new Calendar.setup({inputField:"dt1",ifFormat:"%Y-%m-%d",daFormat:"%A, %B %d, %Y",button:"f_trigger_e",align:"Tl",singleClick:true});CAL2=new Calendar.setup({inputField:"dt3",ifFormat:"%Y-%m-%d",daFormat:"%A, %B %d, %Y",button:"f_trigger_d",align:"Tl",singleClick:true})}function filtreXData(a,c){var b="";jQuery.fn.dataTableExt.afnFiltering.push(function(n,l,h,o){var e=$("dt3").value;e=e.replace(/-/g,"");e=trim(e);var m=$("dt1").value;m=m.replace(/-/g,"");m=trim(m);var d=l[1];d=d.replace('<span class="mdsubtitol1">',"");d=d.replace("</span>","");d=trim(d);d=d.replace(/-/g,"");var f=d;if(m==""&&e==""){return true}else{if(m==""&&f<e){return true}else{if(m<f&&""==e){return true}else{if(m<f&&f<e){return true}}}}return false});if(c!=-1){if($("dt1").value!=""){escriuHistorial($("dt1").value+" >> "+$("dt3").value,3,"","")}}oTable.fnDraw()}function escriuFlow(b,e,c,a){var d=new Array();if(histo.length==0){d.push("<h3>Historial cerca de la sessió:</h3>");d.push('<div class="olLayerGroup" style="height:45px;overflow:auto" id="flow_div" ></div>');$("cc_div").innerHTML=d.join(" ")}$("cc_div").style.display="block";if(c==0){escriuHistorial(b,1,e,a)}}function cercaAcEstil(){var c=$$("li");var b="";var d="li_"+cercaActiva;for(var a=0;a<c.length;a++){if(c[a].id==d){c[a].addClassName("liac");c[a].removeClassName("lide")}else{c[a].addClassName("lide");c[a].removeClassName("liac")}}}var histo=new Array();var cercaActiva=1;function escriuHistorial(a,l,p,r){var m=new Array();if(histo.length==0){m.push('<a class="mdtextlink"  href="javascript:void(0);" onClick="escriuEstadistiques();netejaMapa();">Tornar Inici</a>')}var b=parseInt(histo.length);if(l==1){histo.push("cerca");var b=parseInt(histo.length);cercaActiva=b;if(a=="bbox"){a="Selecció mapa"}m.push('<li id="li_'+b+'" class="liac"><span id="hs1'+b+'"></span><span id="hs2'+b+'"></span><span id="hs3'+b+'"></span></li>');if(histo.length==1){$("flow_div").innerHTML=m.join(" ")}if(histo.length>1){var q=$("flow_div").innerHTML;$("flow_div").innerHTML=q+m.join(" ")}var c=p.left+","+p.bottom+","+p.right+","+p.top+"#"+r;var o='<span><input type="hidden" id="hs1bbox'+b+'" value="'+c+'"><a class="mdtextlink"  href="javascript:void(0);" onClick="enviaHistoPeticio(1,\'hs1bbox'+b+"',-1,-1,-1,"+b+')">Lloc:'+a+"</a></span>";var f="hs1"+b;$(f).innerHTML=o;if(document.all){setTimeout("cercaAcEstil()",500)}else{cercaAcEstil()}}else{if(l==2){var b=parseInt(histo.length);if(cercaActiva!=b){b=cercaActiva}var n='+ <span><input type="hidden" id="hs2filtre'+b+'" value="'+a+'"><a class="mdtextlink" href="javascript:void(0);" onClick="enviaHistoPeticio(1,\'hs1bbox'+b+"','hs2filtre"+b+"',-1,-1,"+b+');">Producte:'+a+"</a></span>";var e="hs2"+b;$(e).innerHTML=n}else{if(l==3){var b=parseInt(histo.length);if(cercaActiva!=b){b=cercaActiva}var h='+ <span><input type="hidden" id="hs3dates'+b+'" value="'+a+'"><a class="mdtextlink" href="javascript:void(0);" onClick="enviaHistoPeticio(1,\'hs1bbox'+b+"','hs2filtre"+b+"','hs3dates"+b+"',-1,"+b+');">Data:'+a+"</a></span>";var d="hs3"+b;$(d).innerHTML=h}}}}function filtreProducteHis(a){oTable.fnFilter(a)}function filtreOrg(a){peticioNova=true;a=a.replace("%27","''");document.cercaOculta.filtre.value=a;creaTaula(null,"","","",0,"","")}function filtreProducte(a){jQuery(oTable.fnSettings().aoData).each(function(){jQuery(this.nTr).removeClass("row_selected")});obreTancaLLista(null,llista);a=replaceAll(a,"%27","''");oTable.fnFilter(a)}function escriuFiltre(){if(filtreActiu.indexOf("#")){var a=filtreActiu.split("#");filtreActiu=a[1]}$("infoFiltre").innerHTML=filtreActiu}function esborraFiltres(a){oTable.fnFilter("");netejaFiltreDates();histo.length=0;oTable.fnDraw()}function netejaFF(){if(oTable){oTable.fnFilter("");netejaFiltreDates()}}function netejaFiltreDates(){if($("dt1")){$("dt1").value=""}if($("dt3")){$("dt3").value=""}}function retornaValorsFiltresDates(){var a=$("dt1").value;if($("dt3")){a+="#"+$("dt3").value}return a}function insertaFiltreDates(b){if(b.indexOf(">>")!=-1){var a=b.split(">>");$("dt1").value=a[0];if(a[1].length>2){$("eD12").style.display="block";$("dt3").value=a[1];$("opD").checked=true;$("opP").checked=false}else{$("opP").checked=true;$("opD").checked=false;$("eD12").style.display="none"}}else{$("dt1").value=b}}function proColor(b){for(i=0;i<productes.pr.length;i++){var a=productes.pr[i].Nom;if(b.indexOf(a)!=-1){clase=productes.pr[i].Nick;return clase}}};