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"){this.PREFIJOS_VALIDOS=/^\-?(descripci[oóÓ]n|empresa|poblaci[oóÓ]n|puesto|requisitos)$/i;this.TEXTO_ERROR_PREFIJOS='Los únicos prefijos válidos para la palabra clave son "puesto:", "descripcion:", "poblacion:", "requisitos:" y "empresa:".'}else{this.PREFIJOS_VALIDOS=/^\-?(puesto|empresa|empresa_?actual|descripci[oóÓ]n|futuro_?empleo|poblaci[oóÓ]n|centro|conocimientos|cv_?texto)$/i;this.TEXTO_ERROR_PREFIJOS='Los únicos prefijos válidos para la palabra clave son "puesto:", "empresa:", "empresa_actual:", "descripcion:", "futuro_empleo:", "poblacion:", "centro:", "conocimientos:", y "cv_texto:".'}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(k,j,d,m,h,b){var g=h.PCB_SIN_TERMINO;var e=0;var l=-1;var a=-1;var c="";for(posicion=d;(posicion<=m);posicion++){var f=j.charAt(posicion);if(g==h.PCB_TERMINO_COMPUESTO){if(f==")"){if(e>1){e--}else{if(a==-1){if(b){addErrorMessage(k,'No puede haber términos 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 n=buildTermino(i,a,posicion-1,c,j,h);if(!leerBusqueda(k,j,a,posicion-1,n,b)){return false}}c="";g=h.PCB_SIN_TERMINO;l=-1;a=-1;e=0}}}else{if(f!=" "){if(a==-1){a=posicion}if(f=="("){e++}}}}else{if(g==h.PCB_TERMINO_EXACTO){if(f=='"'){if(a==-1){if(b){addErrorMessage(k,'No puede haber términos 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){addErrorMessage(k,"Sintaxis erronea en la posición <"+j.slice(posicion)+">")}return false}}if(g!=h.PCB_TERMINO){if(f=="("){g=h.PCB_TERMINO_COMPUESTO;e++}else{g=h.PCB_TERMINO_EXACTO}l=posicion}}else{if(f==":"){if((g==h.PCB_SIN_TERMINO)||(g==h.PCB_TERMINO_PREFIJO)){if(b){addErrorMessage(k,"Separador de prefijo inesperado en la posición <"+j.slice(posicion)+">")}return false}else{c=j.slice(l,posicion);if(!validar_prefijo(c,h.PREFIJOS_VALIDOS)){if(b){addErrorMessage(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){addErrorMessage(k,"Sintaxis incorrecta, expresión opcional inacabada <"+j.slice(l)+">")}return false}else{if(g==h.PCB_TERMINO_EXACTO){if(b){addErrorMessage(k,"Sintaxis incorrecta, expresión 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){var f=a.value.replace(/(^\s+$|^\s+|\s+$)/g,"");a.value=f;if(f==""){return true}var c=true;if(arguments.length>1){c=arguments[1]}var b=null;if(arguments.length==3){b=arguments[2];b[0]=true}var d=/([^-_a-zA-Z0-9áàâãäåÀÁÂÃÄÅèéêëÈÉÊËìíîïÌÍÎÏòóôõöÒÓÔÕÖùúûüÙÚÛÜñÑçÇ*?.+#:()"/]+|€)/g;f=f.replace(d," ");if(f.replace(" ","")==""){if(c){addErrorMessage(a,"La expresión es incorrecta.");if(b!=null){b[0]=false}}return false}var g=new Termino();g.setTipo(g.TIPO_AND);var e=leerBusqueda(a,f,0,f.length-1,g,c);if(e){e=(g.hijos.length>0)}return e};