if(tipoPalabraClave==""){tipoPalabraClave="Oferta"}function Termino(){this.texto="";this.prefijo="";this.tipo="";this.padre=null;this.hijos=[];this.PCB_SIN_TERMINO=0;this.PCB_TERMINO_PREFIJO=1;this.PCB_TERMINO_COMPUESTO=2;this.PCB_TERMINO_EXACTO=3;this.PCB_TERMINO=4;this.TIPO_LITERAL="LT";this.TIPO_EXACTO="EX";this.TIPO_AND="AND";this.TIPO_OR="OR";if(tipoPalabraClave=="Oferta"){if(getIJMessage("prefijos_validos")=="prefijos_validos_ES"){this.PREFIJOS_VALIDOS=/^\-?(descripci[oóÓ]n|empresa|poblaci[oóÓ]n|puesto|requisitos)$/i}else{if(getIJMessage("prefijos_validos")=="prefijos_validos_IT"){this.PREFIJOS_VALIDOS=/^\-?(descrizione|azienda|citt[aàÀA]|posto|requisiti)$/i}}this.TEXTO_ERROR_PREFIJOS=getIJMessage("los_unicos_prefijos_validos_para_la_palabra_clave_son_1")}else{if(getIJMessage("prefijos_validos")=="prefijos_validos_ES"){this.PREFIJOS_VALIDOS=/^\-?(puesto|empresa|empresa_?actual|descripci[oóÓ]n|futuro_?empleo|poblaci[oóÓ]n|centro|conocimientos|cv_?texto)$/i}else{if(getIJMessage("prefijos_validos")=="prefijos_validos_IT"){this.PREFIJOS_VALIDOS=/^\-?(posto|azienda|azienda_?attuale|descrizione|futuro_?lavoro|citt[aàÀA]|centro|competenze|cv_?dettagliato)$/i}}this.TEXTO_ERROR_PREFIJOS=getIJMessage("los_unicos_prefijos_validos_para_la_palabra_clave_son_2")}Termino.prototype.setTexto=function(a){this.texto=a.replace(/(\*[?*]+|[?*]+\*)/g,"*");this.texto=this.texto.replace(/\*\*+/g,"*");this.texto=this.texto.replace(/(^\s+$|^\s+|\s+$)/g,"");this.texto=this.texto.replace(/\s+/g," ")};Termino.prototype.getTexto=function(){return this.texto};Termino.prototype.setPadre=function(a){this.padre=a};Termino.prototype.getPadre=function(){return this.padre};Termino.prototype.setPrefijo=function(a){this.prefijo=a};Termino.prototype.getPrefijo=function(){return this.prefijo};Termino.prototype.setTipo=function(a){this.tipo=a};Termino.prototype.getTipo=function(){return this.tipo};Termino.prototype.addHijo=function(a){this.hijos[this.hijos.length]=a;a.setPadre(this)}}function leerBusqueda(n,k,j,e,m,h,b){var g=h.PCB_SIN_TERMINO;var d=0;var l=-1;var a=-1;var c="";for(posicion=e;(posicion<=m);posicion++){var f=j.charAt(posicion);if(g==h.PCB_TERMINO_COMPUESTO){if(f==")"){if(d>1){d--}else{if(a==-1){if(b){addErrorMessageWithKey(n,k,getIJMessage("no_puede_haber_terminos_opcionales_vacios"))}return false}else{var i=h.TIPO_OR;if(h.getTipo()==h.TIPO_OR){i=h.TIPO_AND}if((h.getTipo()==h.TIPO_AND)||(c.length==0)||(c.charAt(0)!=" ")){var o=buildTermino(i,a,posicion-1,c,j,h);if(!leerBusqueda(n,k,j,a,posicion-1,o,b)){return false}}c="";g=h.PCB_SIN_TERMINO;l=-1;a=-1;d=0}}}else{if(f!=" "){if(a==-1){a=posicion}if(f=="("){d++}}}}else{if(g==h.PCB_TERMINO_EXACTO){if(f=='"'){if(a==-1){if(b){addErrorMessageWithKey(n,k,getIJMessage("no_puede_haber_terminos_exactos_vacios"))}return false}else{var i=h.TIPO_EXACTO;buildTermino(i,a,posicion-1,c,j,h);c="";g=h.PCB_SIN_TERMINO;l=-1;a=-1}}else{if(f!=" "){if(a==-1){a=posicion}}}}else{if((f=="(")||(f=='"')){if(g==h.PCB_TERMINO){if((l==(posicion-1))&&(j.slice(l,posicion)=="-")){c="-";g=h.PCB_SIN_TERMINO;l=-1}else{if(b){addErrorMessageWithKey(n,k,getIJMessage("sintaxis_erronea_en_la_posicion")+" <"+j.slice(posicion)+">")}return false}}if(g!=h.PCB_TERMINO){if(f=="("){g=h.PCB_TERMINO_COMPUESTO;d++}else{g=h.PCB_TERMINO_EXACTO}l=posicion}}else{if(f==":"){if((g==h.PCB_SIN_TERMINO)||(g==h.PCB_TERMINO_PREFIJO)){if(b){addErrorMessageWithKey(n,k,getIJMessage("separador_de_prefijo_inesperado_en_la_posicion")+" <"+j.slice(posicion)+">")}return false}else{c=j.slice(l,posicion);if(!validar_prefijo(c,h.PREFIJOS_VALIDOS)){if(b){addErrorMessageWithKey(n,k,h.TEXTO_ERROR_PREFIJOS)}return false}g=h.PCB_TERMINO_PREFIJO;l=-1}}else{if(f==" "){if(g==h.PCB_TERMINO){if(j.charAt(l)=="-"){c="-";l=l+1}buildTermino(h.TIPO_LITERAL,l,posicion-1,c,j,h);c="";g=h.PCB_SIN_TERMINO;l=-1}else{if(g==h.PCB_TERMINO_PREFIJO){if(c.charAt(0)=="-"){c=c.slice(1)}h.setPrefijo(c);c="";g=h.PCB_SIN_TERMINO}}}else{if(g!=h.PCB_TERMINO){g=h.PCB_TERMINO;l=posicion}}}}}}}if(g==h.PCB_TERMINO){if(j.charAt(l)=="-"){c="-";l=l+1}buildTermino(h.TIPO_LITERAL,l,m,c,j,h)}else{if(g==h.PCB_TERMINO_COMPUESTO){if(b){addErrorMessageWithKey(n,k,getIJMessage("sintaxis_incorrecta_expresion_opcional_inacabada")+" <"+j.slice(l)+">")}return false}else{if(g==h.PCB_TERMINO_EXACTO){if(b){addErrorMessageWithKey(n,k,getIJMessage("sintaxis_incorrecta_expresion_exacta_inacabada")+" <"+j.slice(l)+">")}return false}}}return true}function buildTermino(b,h,g,e,d,c){if(e==""){e=c.getPrefijo()}var f=new Termino();f.setTipo(b);f.setPrefijo(e);if((b==f.TIPO_EXACTO)||(b==f.TIPO_LITERAL)){var a=d.slice(h,g+1);f.setTexto(a)}c.addHijo(f);return f}function validar_prefijo(c,b){var a=new RegExp(b);return(c.match(a)!=null)}function validar_palabra(a){return validar_palabra_with_key("",a)}function validar_palabra_with_key(b,a){var g=a.value.replace(/(^\s+$|^\s+|\s+$)/g,"");a.value=g;if(g==""){return true}var d=true;if(arguments.length>1){d=arguments[1]}var c=null;if(arguments.length==3){c=arguments[2];c[0]=true}var e=/([^-_a-zA-Z0-9áàâãäåÀÁÂÃÄÅèéêëÈÉÊËìíîïÌÍÎÏòóôõöÒÓÔÕÖùúûüÙÚÛÜñÑçÇ*?.+#:()"/]+|€)/g;g=g.replace(e," ");if(g.replace(" ","")==""){if(d){addErrorMessageWithKey(b,a,getIJMessage("la_expresion_es_incorrecta"));if(c!=null){c[0]=false}}return false}var h=new Termino();h.setTipo(h.TIPO_AND);var f=leerBusqueda(b,a,g,0,g.length-1,h,d);if(f){f=(h.hijos.length>0)}return f};