//********************************************************
//*           DDGRAMATICA.JS: FUNCIONES JAVASCRIPT       * 
//*           DESARROLLADAS POR Jesús Quílez Bielsa      *
//*           jquilez@roble.pntic.mec.es                 *
//*           Y EL GRUPO PALLADIUM                       *
//********************************************************

var oPalabras = new Array()
var nPalTot=0
var nPalAct=0
var nTerTot=0
var nTerAct=0
var nNotAct=0
var nNotTot=0
var aTerminos = new Array()
var lBuscando=false
var lMostrar=true
var cUltUti="dic"
var nUltTip=1
var s_moradj=0
var s_voz=1
var s_tiempo=1 
var s_modo=1
var r_fle=-2
var r_tip=-2
var lImpugna=false
var abralo = new Array( 5)
var nomalo = new Array( 5)
var aOrdLet = new Array("","a)","b)","c)","d)","e)","f)","g")
nomalo[ 0]="No es alomorfo"
abralo[ 0]=""
nomalo[ 1]="Primer alomorfo"
abralo[ 1]="2ª"
nomalo[ 2]="Segundo alomorfo"
abralo[ 2]="3ª"
nomalo[ 3]="Tercer alomorfo"
abralo[ 3]="4ª"
nomalo[ 4]="Cuarto alomorfo"
abralo[ 4]="5ª"
var abrcas = new Array( 8)
var nomcas = new Array( 8)
nomcas[ 0]="Sin caso"
abrcas[ 0]=""
nomcas[ 1]="Nominativo"
abrcas[ 1]="NM"
nomcas[ 2]="Vocativo"
abrcas[ 2]="VC"
nomcas[ 4]="Acusativo"
abrcas[ 4]="AC"
nomcas[ 8]="Genitivo"
abrcas[ 8]="GN"
nomcas[ 16]="Dativo"
abrcas[ 16]="DT"
nomcas[ 32]="Ablativo"
abrcas[ 32]="AB"
nomcas[ 64]="Locativo"
abrcas[ 64]="LC"
var nomgen = new Array( 4)
var abrgen = new Array( 4)
abrgen[ 0]=""
nomgen[ 0]="Sin género"
abrgen[ 1]="m."
nomgen[ 1]="Masculino"
abrgen[ 2]="f."
nomgen[ 2]="Femenino"
abrgen[ 4]="n."
nomgen[ 4]="Neutro"
var abrgra = new Array( 3)
var nomgra = new Array( 3)
nomgra[ 0]="Sin grado"
abrgra[ 0]=""
nomgra[ 1]="Comparativo"
abrgra[ 1]="com."
nomgra[ 2]="Superlativo"
abrgra[ 2]="sup."
var abrmod = new Array( 10)
var nommod = new Array( 10)
nommod[ 0]="Sin modo"
abrmod[ 0]=""
nommod[ 1]="Indicativo"
abrmod[ 1]="ind."
nommod[ 2]="Subjuntivo"
abrmod[ 2]="sub."
nommod[ 4]="Imperativo"
abrmod[ 4]="impr"
nommod[ 8]="Infinitivo"
abrmod[ 8]="inf."
nommod[ 16]="Condicional"
abrmod[ 16]="con."
nommod[ 32]="Participio"
abrmod[ 32]="ppo."
nommod[ 33]="Supino"
abrmod[ 33]="sup."
nommod[ 64]="Gerundio"
abrmod[ 64]="ger."
nommod[ 65]="Gerundivo"
abrmod[ 65]="grv."
var nomnum = new Array( 3)
var abrnum = new Array( 3)
abrnum[ 0]=""
nomnum[ 0]="Sin número"
abrnum[ 1]="Sg."
nomnum[ 1]="Singular"
abrnum[ 4]="Pl."
nomnum[ 4]="Plural"
var abrper = new Array( 4)
var nomper = new Array( 4)
nomper[ 0]="Sin persona"
abrper[ 0]=" "
nomper[ 1]="1ª persona"
abrper[ 1]="1ª"
nomper[ 2]="2ª persona"
abrper[ 2]="2ª"
nomper[ 4]="3ª persona"
abrper[ 4]="3ª"
var abrvoz = new Array( 4)
var nomvoz = new Array( 4)
nomvoz[ 0]="Sin voz"
abrvoz[ 0]=""
nomvoz[ 1]="Activa"
abrvoz[ 1]="act."
nomvoz[ 2]="Pasiva"
abrvoz[ 2]="pas."
nomvoz[ 4]="Media"
abrvoz[ 4]="med."
var nomsub = new Array( 13)
var nomtpl = new Array( 13)
var abrsub = new Array( 13)
var abrtpl = new Array( 13)
abrtpl[ 0]=" "
abrsub[ 0]=" "
nomtpl[ 0]=" "
nomsub[ 0]=" "
abrtpl[ 1]="st."
abrsub[ 1]=" "
nomtpl[ 1]="sustantivo"
nomsub[ 1]=" "
abrtpl[ 2]="vb."
abrsub[ 2]=" "
nomtpl[ 2]="verbo"
nomsub[ 2]=" "
abrtpl[ 3]="ad."
abrsub[ 3]=" "
nomtpl[ 3]="adjetivo"
nomsub[ 3]=" "
abrtpl[ 4]="adv."
abrsub[ 4]=" "
nomtpl[ 4]="adverbio"
nomsub[ 4]=" "
abrtpl[ 5]="pro."
abrsub[ 5]=" "
nomtpl[ 5]="pronombre"
nomsub[ 5]=" "
abrtpl[ 6]="con."
abrsub[ 6]=" "
nomtpl[ 6]="conjunción"
nomsub[ 6]=" "
abrtpl[ 7]="art."
abrsub[ 7]=" "
nomtpl[ 7]="artículo"
nomsub[ 7]=" "
abrtpl[ 8]="ptc."
abrsub[ 8]=" "
nomtpl[ 8]="puntuación"
nomsub[ 8]=" "
abrtpl[ 9]="per."
abrsub[ 9]=" "
nomtpl[ 9]="pronombre personal"
nomsub[ 9]=" "
abrtpl[ 10]="pr."
abrsub[ 10]=" "
nomtpl[ 10]="preposición"
nomsub[ 10]=" "
abrtpl[ 11]="sub."
abrsub[ 11]=" "
nomtpl[ 11]="subordinante"
nomsub[ 11]=" "
var abrtie = new Array( 7)
var nomtie = new Array( 7)
nomtie[ 0]="Sin tiempo"
abrtie[ 0]=""
nomtie[ 1]="Presente"
abrtie[ 1]="pre."
nomtie[ 2]="Imperfecto"
abrtie[ 2]="imp."
nomtie[ 4]="Futuro"
abrtie[ 4]="fut."
nomtie[ 8]="Pretérito perfecto"
abrtie[ 8]="prf."
nomtie[ 16]="Pretérito pluscuamperfecto"
abrtie[ 16]="ppf."
nomtie[ 32]="Futuro perfecto"
abrtie[ 32]="fpf."
var codgen = new Array( 27)
var abrfle = new Array( 27)
var nomfle = new Array( 27)
var codgru = new Array( 27)
codgru[ 1]=0
nomfle[ 1]="Sin flexión"
abrfle[ 1]=""
codgen[ 1]=
codgru[ 1]=0
nomfle[ 1]="1ª Declinación"
abrfle[ 1]="1ª"
codgen[ 1]=2
codgru[ 2]=0
nomfle[ 2]="2ª Declinación"
abrfle[ 2]="2ª"
codgen[ 2]=5
codgru[ 3]=0
nomfle[ 3]="3ª Declinación"
abrfle[ 3]="3ª"
codgen[ 3]=7
codgru[ 4]=0
nomfle[ 4]="4ª Declinación"
abrfle[ 4]="4ª"
codgen[ 4]=3
codgru[ 5]=0
nomfle[ 5]="5ª Declinación"
abrfle[ 5]="5ª"
codgen[ 5]=2
codgru[ 6]=0
nomfle[ 6]="1ª Conjugación"
abrfle[ 6]="1ª"
codgen[ 6]=0
codgru[ 7]=0
nomfle[ 7]="2ª Conjugación"
abrfle[ 7]="2ª"
codgen[ 7]=0
codgru[ 8]=0
nomfle[ 8]="3ª Conjugación"
abrfle[ 8]="3ª"
codgen[ 8]=0
codgru[ 9]=0
nomfle[ 9]="4ª Conjugación"
abrfle[ 9]="4ª"
codgen[ 9]=0
codgru[ 10]=0
nomfle[ 10]="Adverbial"
abrfle[ 10]="Adv."
codgen[ 10]=0
codgru[ 11]=0
nomfle[ 11]="3ª Decl. Temas en -i"
abrfle[ 11]="3ª i"
codgen[ 11]=7
codgru[ 12]=0
nomfle[ 12]="3ª Decl. Adjetivos"
abrfle[ 12]="3ª a"
codgen[ 12]=7
codgru[ 13]=0
nomfle[ 13]="5ª Conjugación"
abrfle[ 13]="5ª"
codgen[ 13]=0
codgru[ 15]=0
nomfle[ 15]="Pronominal"
abrfle[ 15]="pr."
codgen[ 15]=7
codgru[ 18]=0
nomfle[ 18]="Pron. per."
abrfle[ 18]="prp."
codgen[ 18]=3
codgru[ 19]=0
nomfle[ 19]="Sum"
abrfle[ 19]="Sum"
codgen[ 19]=0
codgru[ 20]=0
nomfle[ 20]="Comparativo"
abrfle[ 20]="Cmp."
codgen[ 20]=7
codgru[ 21]=0
nomfle[ 21]="Superlativo"
abrfle[ 21]="Sup."
codgen[ 21]=2
codgru[ 22]=0
nomfle[ 22]="Relativo"
abrfle[ 22]="Rel."
codgen[ 22]=7
codgru[ 16]=0
nomfle[ 16]="Participio presente"
abrfle[ 16]="Ppr."
codgen[ 16]=7
codgru[ 14]=0
nomfle[ 14]="Perfecto"
abrfle[ 14]="Prf."
codgen[ 14]=0
codgru[ 23]=0
nomfle[ 23]="Eo"
abrfle[ 23]="Eo"
codgen[ 23]=0
codgru[ 24]=0
nomfle[ 24]="Fero"
abrfle[ 24]="Fero"
codgen[ 24]=0
codgru[ 25]=0
nomfle[ 25]="Volo"
abrfle[ 25]="Volo"
codgen[ 25]=0
codgru[ 26]=0
nomfle[ 26]="Indeclinable"
abrfle[ 26]="Ind."
codgen[ 26]=7
codgru[ 27]=0
nomfle[ 27]="Numeral ind."
abrfle[ 27]="In."
codgen[ 27]=7
codgru[ 28]=0
nomfle[ 28]="3ª Decl. Adjetivos 1"
abrfle[ 28]="3ªa1"
codgen[ 28]=7
var nomtem = new Array( 14)
nomtem[ 0]="sin tema"
nomtem[ 1]="nominativo"
nomtem[ 2]="comparativo"
nomtem[ 3]="superlativo"
nomtem[ 4]="presente"
nomtem[ 5]="infinitivo"
nomtem[ 6]="perfecto"
nomtem[ 7]="supino"
nomtem[ 8]="presente dep."
nomtem[ 9]="infinitivo dep."
nomtem[ 10]="sin tema dep."
nomtem[ 11]="supino dep."
nomtem[ 20]="alomorfo ante consonante"
nomtem[ 21]="genitivo - dativo"
var t_codtem = new Array( 26)
var t_codsub = new Array( 26)
var t_codtpl = new Array( 26)
t_codtpl[ 1]=0
t_codsub[ 1]=0
t_codtem[ 1]=0
t_codtpl[ 2]=1
t_codsub[ 2]=0
t_codtem[ 2]=0
t_codtpl[ 3]=1
t_codsub[ 3]=0
t_codtem[ 3]=1
t_codtpl[ 4]=2
t_codsub[ 4]=0
t_codtem[ 4]=0
t_codtpl[ 5]=2
t_codsub[ 5]=0
t_codtem[ 5]=4
t_codtpl[ 6]=2
t_codsub[ 6]=0
t_codtem[ 6]=5
t_codtpl[ 7]=2
t_codsub[ 7]=0
t_codtem[ 7]=6
t_codtpl[ 8]=2
t_codsub[ 8]=0
t_codtem[ 8]=7
t_codtpl[ 9]=2
t_codsub[ 9]=1
t_codtem[ 9]=8
t_codtpl[ 10]=2
t_codsub[ 10]=1
t_codtem[ 10]=9
t_codtpl[ 11]=2
t_codsub[ 11]=1
t_codtem[ 11]=10
t_codtpl[ 12]=2
t_codsub[ 12]=1
t_codtem[ 12]=11
t_codtpl[ 13]=3
t_codsub[ 13]=0
t_codtem[ 13]=0
t_codtpl[ 14]=3
t_codsub[ 14]=0
t_codtem[ 14]=1
t_codtpl[ 15]=3
t_codsub[ 15]=0
t_codtem[ 15]=2
t_codtpl[ 16]=3
t_codsub[ 16]=0
t_codtem[ 16]=3
t_codtpl[ 17]=4
t_codsub[ 17]=0
t_codtem[ 17]=0
t_codtpl[ 18]=5
t_codsub[ 18]=0
t_codtem[ 18]=0
t_codtpl[ 19]=5
t_codsub[ 19]=0
t_codtem[ 19]=1
t_codtpl[ 20]=5
t_codsub[ 20]=0
t_codtem[ 20]=21
t_codtpl[ 21]=6
t_codsub[ 21]=0
t_codtem[ 21]=0
t_codtpl[ 22]=9
t_codsub[ 22]=0
t_codtem[ 22]=0
t_codtpl[ 23]=10
t_codsub[ 23]=0
t_codtem[ 23]=0
t_codtpl[ 24]=10
t_codsub[ 24]=0
t_codtem[ 24]=20
t_codtpl[ 25]=11
t_codsub[ 25]=0
t_codtem[ 25]=0
t_codtpl[ 26]=11
t_codsub[ 26]=0
t_codtem[ 26]=20

var r_codfle = new Array( 92)
var r_codtem = new Array( 92)
var r_codsub = new Array( 92)
var r_codtpl = new Array( 92)
r_codtpl[ 1]=0
r_codsub[ 1]=0
r_codtem[ 1]=0
r_codfle[ 1]=0
r_codtpl[ 2]=1
r_codsub[ 2]=0
r_codtem[ 2]=0
r_codfle[ 2]=1
r_codtpl[ 3]=1
r_codsub[ 3]=0
r_codtem[ 3]=0
r_codfle[ 3]=2
r_codtpl[ 4]=1
r_codsub[ 4]=0
r_codtem[ 4]=0
r_codfle[ 4]=3
r_codtpl[ 5]=1
r_codsub[ 5]=0
r_codtem[ 5]=0
r_codfle[ 5]=4
r_codtpl[ 6]=1
r_codsub[ 6]=0
r_codtem[ 6]=0
r_codfle[ 6]=5
r_codtpl[ 7]=1
r_codsub[ 7]=0
r_codtem[ 7]=0
r_codfle[ 7]=11
r_codtpl[ 8]=1
r_codsub[ 8]=0
r_codtem[ 8]=0
r_codfle[ 8]=26
r_codtpl[ 9]=1
r_codsub[ 9]=0
r_codtem[ 9]=1
r_codfle[ 9]=1
r_codtpl[ 10]=1
r_codsub[ 10]=0
r_codtem[ 10]=1
r_codfle[ 10]=2
r_codtpl[ 11]=1
r_codsub[ 11]=0
r_codtem[ 11]=1
r_codfle[ 11]=3
r_codtpl[ 12]=1
r_codsub[ 12]=0
r_codtem[ 12]=1
r_codfle[ 12]=4
r_codtpl[ 13]=1
r_codsub[ 13]=0
r_codtem[ 13]=1
r_codfle[ 13]=5
r_codtpl[ 14]=1
r_codsub[ 14]=0
r_codtem[ 14]=1
r_codfle[ 14]=11
r_codtpl[ 15]=2
r_codsub[ 15]=0
r_codtem[ 15]=0
r_codfle[ 15]=6
r_codtpl[ 16]=2
r_codsub[ 16]=0
r_codtem[ 16]=0
r_codfle[ 16]=7
r_codtpl[ 17]=2
r_codsub[ 17]=0
r_codtem[ 17]=0
r_codfle[ 17]=8
r_codtpl[ 18]=2
r_codsub[ 18]=0
r_codtem[ 18]=0
r_codfle[ 18]=9
r_codtpl[ 19]=2
r_codsub[ 19]=0
r_codtem[ 19]=0
r_codfle[ 19]=13
r_codtpl[ 20]=2
r_codsub[ 20]=0
r_codtem[ 20]=0
r_codfle[ 20]=19
r_codtpl[ 21]=2
r_codsub[ 21]=0
r_codtem[ 21]=0
r_codfle[ 21]=23
r_codtpl[ 22]=2
r_codsub[ 22]=0
r_codtem[ 22]=0
r_codfle[ 22]=24
r_codtpl[ 23]=2
r_codsub[ 23]=0
r_codtem[ 23]=0
r_codfle[ 23]=25
r_codtpl[ 24]=2
r_codsub[ 24]=0
r_codtem[ 24]=4
r_codfle[ 24]=6
r_codtpl[ 25]=2
r_codsub[ 25]=0
r_codtem[ 25]=4
r_codfle[ 25]=7
r_codtpl[ 26]=2
r_codsub[ 26]=0
r_codtem[ 26]=4
r_codfle[ 26]=8
r_codtpl[ 27]=2
r_codsub[ 27]=0
r_codtem[ 27]=4
r_codfle[ 27]=9
r_codtpl[ 28]=2
r_codsub[ 28]=0
r_codtem[ 28]=4
r_codfle[ 28]=13
r_codtpl[ 29]=2
r_codsub[ 29]=0
r_codtem[ 29]=4
r_codfle[ 29]=19
r_codtpl[ 30]=2
r_codsub[ 30]=0
r_codtem[ 30]=4
r_codfle[ 30]=23
r_codtpl[ 31]=2
r_codsub[ 31]=0
r_codtem[ 31]=4
r_codfle[ 31]=24
r_codtpl[ 32]=2
r_codsub[ 32]=0
r_codtem[ 32]=4
r_codfle[ 32]=25
r_codtpl[ 33]=2
r_codsub[ 33]=0
r_codtem[ 33]=5
r_codfle[ 33]=6
r_codtpl[ 34]=2
r_codsub[ 34]=0
r_codtem[ 34]=5
r_codfle[ 34]=7
r_codtpl[ 35]=2
r_codsub[ 35]=0
r_codtem[ 35]=5
r_codfle[ 35]=8
r_codtpl[ 36]=2
r_codsub[ 36]=0
r_codtem[ 36]=5
r_codfle[ 36]=9
r_codtpl[ 37]=2
r_codsub[ 37]=0
r_codtem[ 37]=5
r_codfle[ 37]=13
r_codtpl[ 38]=2
r_codsub[ 38]=0
r_codtem[ 38]=5
r_codfle[ 38]=19
r_codtpl[ 39]=2
r_codsub[ 39]=0
r_codtem[ 39]=5
r_codfle[ 39]=23
r_codtpl[ 40]=2
r_codsub[ 40]=0
r_codtem[ 40]=5
r_codfle[ 40]=24
r_codtpl[ 41]=2
r_codsub[ 41]=0
r_codtem[ 41]=5
r_codfle[ 41]=25
r_codtpl[ 42]=2
r_codsub[ 42]=0
r_codtem[ 42]=6
r_codfle[ 42]=14
r_codtpl[ 43]=2
r_codsub[ 43]=0
r_codtem[ 43]=7
r_codfle[ 43]=1
r_codtpl[ 44]=2
r_codsub[ 44]=0
r_codtem[ 44]=7
r_codfle[ 44]=2
r_codtpl[ 45]=2
r_codsub[ 45]=0
r_codtem[ 45]=7
r_codfle[ 45]=4
r_codtpl[ 46]=2
r_codsub[ 46]=1
r_codtem[ 46]=8
r_codfle[ 46]=6
r_codtpl[ 47]=2
r_codsub[ 47]=1
r_codtem[ 47]=8
r_codfle[ 47]=7
r_codtpl[ 48]=2
r_codsub[ 48]=1
r_codtem[ 48]=8
r_codfle[ 48]=8
r_codtpl[ 49]=2
r_codsub[ 49]=1
r_codtem[ 49]=8
r_codfle[ 49]=9
r_codtpl[ 50]=2
r_codsub[ 50]=1
r_codtem[ 50]=8
r_codfle[ 50]=13
r_codtpl[ 51]=2
r_codsub[ 51]=1
r_codtem[ 51]=8
r_codfle[ 51]=19
r_codtpl[ 52]=2
r_codsub[ 52]=1
r_codtem[ 52]=9
r_codfle[ 52]=6
r_codtpl[ 53]=2
r_codsub[ 53]=1
r_codtem[ 53]=9
r_codfle[ 53]=7
r_codtpl[ 54]=2
r_codsub[ 54]=1
r_codtem[ 54]=9
r_codfle[ 54]=8
r_codtpl[ 55]=2
r_codsub[ 55]=1
r_codtem[ 55]=9
r_codfle[ 55]=9
r_codtpl[ 56]=2
r_codsub[ 56]=1
r_codtem[ 56]=9
r_codfle[ 56]=13
r_codtpl[ 57]=2
r_codsub[ 57]=1
r_codtem[ 57]=9
r_codfle[ 57]=19
r_codtpl[ 58]=2
r_codsub[ 58]=1
r_codtem[ 58]=10
r_codfle[ 58]=6
r_codtpl[ 59]=2
r_codsub[ 59]=1
r_codtem[ 59]=10
r_codfle[ 59]=7
r_codtpl[ 60]=2
r_codsub[ 60]=1
r_codtem[ 60]=10
r_codfle[ 60]=8
r_codtpl[ 61]=2
r_codsub[ 61]=1
r_codtem[ 61]=10
r_codfle[ 61]=9
r_codtpl[ 62]=2
r_codsub[ 62]=1
r_codtem[ 62]=10
r_codfle[ 62]=13
r_codtpl[ 63]=2
r_codsub[ 63]=1
r_codtem[ 63]=10
r_codfle[ 63]=19
r_codtpl[ 64]=2
r_codsub[ 64]=1
r_codtem[ 64]=11
r_codfle[ 64]=1
r_codtpl[ 65]=2
r_codsub[ 65]=1
r_codtem[ 65]=11
r_codfle[ 65]=2
r_codtpl[ 66]=2
r_codsub[ 66]=1
r_codtem[ 66]=11
r_codfle[ 66]=4
r_codtpl[ 67]=3
r_codsub[ 67]=0
r_codtem[ 67]=0
r_codfle[ 67]=1
r_codtpl[ 68]=3
r_codsub[ 68]=0
r_codtem[ 68]=0
r_codfle[ 68]=2
r_codtpl[ 69]=3
r_codsub[ 69]=0
r_codtem[ 69]=0
r_codfle[ 69]=11
r_codtpl[ 70]=3
r_codsub[ 70]=0
r_codtem[ 70]=0
r_codfle[ 70]=12
r_codtpl[ 71]=3
r_codsub[ 71]=0
r_codtem[ 71]=0
r_codfle[ 71]=26
r_codtpl[ 72]=3
r_codsub[ 72]=0
r_codtem[ 72]=1
r_codfle[ 72]=1
r_codtpl[ 73]=3
r_codsub[ 73]=0
r_codtem[ 73]=1
r_codfle[ 73]=2
r_codtpl[ 74]=3
r_codsub[ 74]=0
r_codtem[ 74]=1
r_codfle[ 74]=11
r_codtpl[ 75]=3
r_codsub[ 75]=0
r_codtem[ 75]=1
r_codfle[ 75]=12
r_codtpl[ 76]=3
r_codsub[ 76]=0
r_codtem[ 76]=2
r_codfle[ 76]=20
r_codtpl[ 77]=3
r_codsub[ 77]=0
r_codtem[ 77]=3
r_codfle[ 77]=21
r_codtpl[ 78]=4
r_codsub[ 78]=0
r_codtem[ 78]=0
r_codfle[ 78]=0
r_codtpl[ 79]=4
r_codsub[ 79]=0
r_codtem[ 79]=0
r_codfle[ 79]=10
r_codtpl[ 80]=5
r_codsub[ 80]=0
r_codtem[ 80]=0
r_codfle[ 80]=15
r_codtpl[ 81]=5
r_codsub[ 81]=0
r_codtem[ 81]=0
r_codfle[ 81]=22
r_codtpl[ 82]=5
r_codsub[ 82]=0
r_codtem[ 82]=0
r_codfle[ 82]=26
r_codtpl[ 83]=5
r_codsub[ 83]=0
r_codtem[ 83]=1
r_codfle[ 83]=15
r_codtpl[ 84]=5
r_codsub[ 84]=0
r_codtem[ 84]=1
r_codfle[ 84]=22
r_codtpl[ 85]=5
r_codsub[ 85]=0
r_codtem[ 85]=21
r_codfle[ 85]=22
r_codtpl[ 86]=6
r_codsub[ 86]=0
r_codtem[ 86]=0
r_codfle[ 86]=0
r_codtpl[ 87]=9
r_codsub[ 87]=0
r_codtem[ 87]=0
r_codfle[ 87]=18
r_codtpl[ 88]=10
r_codsub[ 88]=0
r_codtem[ 88]=0
r_codfle[ 88]=0
r_codtpl[ 89]=10
r_codsub[ 89]=0
r_codtem[ 89]=20
r_codfle[ 89]=0
r_codtpl[ 90]=11
r_codsub[ 90]=0
r_codtem[ 90]=0
r_codfle[ 90]=0
r_codtpl[ 91]=11
r_codsub[ 91]=0
r_codtem[ 91]=20
r_codfle[ 91]=0

r_codtpl[ 92]=3
r_codsub[ 92]=0
r_codtem[ 92]=0
r_codfle[ 92]=27

r_codtpl[ 93]=3
r_codsub[ 93]=0
r_codtem[ 93]=0
r_codfle[ 93]=26

var nOk=1

function oPalabra(){
this.forma=""
this.codpal=new Array()
this.forpal=new Array()
this.sigpal=new Array()
this.codtpl=new Array()
this.nomtpl=new Array()
this.codfle=new Array()
this.nomfle=new Array()
this.codgra=new Array()
this.nomgra=new Array()
this.codtie=new Array()
this.nomtie=new Array()
this.codmod=new Array()
this.nommod=new Array()
this.codvoz=new Array()
this.nomvoz=new Array()
this.codcas=new Array()
this.nomcas=new Array()
this.codper=new Array()
this.nomper=new Array()
this.codnum=new Array()
this.nomnum=new Array()
this.codgen=new Array()
this.nomgen=new Array()
}

function cargaGramatica(){
    nNiv=document.getElementById("niv_usu").value
    if (nNiv>4){
       document.getElementById("sigpal").disabled=true
       document.getElementById("tpopal").disabled=true
       document.getElementById("subpal").disabled=true
       document.getElementById("difpal").disabled=true
       //for (nTem=1;nTem<7;nTem++){
       //    document.getElementById("valtem"+nTem).disabled=true
       //}
       for (nTem=1;nTem<7;nTem++){
           document.getElementById("chktem"+nTem).disabled=true
       }
    }
    cargaFlexiones()
    cargaTipos()
}

function cargaFlexiones(){
         nFleTot=nomfle.length
         FLEXION=document.getElementById("selfle")
         COMBO=FLEXION.options
         COMBO.length=null
         for (nFle=1;nFle<=nFleTot;nFle++){
             FLEXION.options[nFle-1]=new Option(nomfle[nFle],nFle)
         }
}

function cargaTipos(){
         nFleTot=nomtpl.length
         FLEXION=document.getElementById("seltip")
         COMBO=FLEXION.options
         COMBO.length=null
         for (nFle=1;nFle<=nFleTot;nFle++){
             FLEXION.options[nFle-1]=new Option(nomtpl[nFle],nFle)
         }
}

function filtraTipo(){
         FLEXION=document.getElementById("selfle")
         nFle=FLEXION.value
         if (nFle != r_fle){
             nEleTot=document.getElementById("seltip").options.length
             for (nEle=0;nEle<nEleTot;nEle++){
                 nTip=document.getElementById("seltip").options[nEle].value 
                 for (n=1;n<130;n++){
                    if (r_codtpl[n]==nTip){
                        if (r_codfle[n]==nFle){
                            if (nomtpl[nTip] > " "){
                              document.getElementById("seltip").selectedIndex=nEle
                              r_fle=nFle
                              return nEle
                            }
                        }
                    }
                 }
             }
             r_fle=nFle
         }
}

function filtraFlexion(){
         TIPO=document.getElementById("seltip")
         nTip=TIPO.value
         if (nTip != r_tip){
             nEleTot=document.getElementById("selfle").options.length
             for (nEle=0;nEle<nEleTot;nEle++){
                 nFle=document.getElementById("selfle").options[nEle].value 
                 for (n=1;n<130;n++){
                    if (r_codtpl[n]==nTip){
                        if (r_codfle[n]==nFle){
                            if (nomtpl[nTip] > " "){
                              document.getElementById("selfle").selectedIndex=nEle
                              r_tip=nTip
                              return nTip
                            }
                        }
                    }
                 }
             }
             r_tip=nTip
         }
}

function filtraFlexion2(){
}
	
function creaPalabra(){
nuevo=new oPalabra
return nuevo;
}

function buscaPalabras(){
        nPalTot=0
        nPalAct=0
        nTerAct=0
        nNotAct=0
        CAJA=document.getElementById("palabra")
        PROG0=document.getElementById("progreso0")
        PROG1=document.getElementById("progreso1")
        PROG2=document.getElementById("progreso2")
        nIzq=daPosX(CAJA)-100
        nArr=daPosY(CAJA)-40
        //nIzq+=CAJA.offsetWidth
        PROG0.style.left=nIzq+"px"
        PROG0.style.top=nArr+"px"
        PROG1.style.left=nIzq+"px"
        PROG1.style.top=nArr+"px"
        PROG2.style.left=nIzq+"px"
        PROG2.style.top=nArr+"px"
        PROG0.style.visibility="visible"
        PROG1.style.visibility="visible"
        PROG2.style.visibility="visible"
        PROG2.innerHTML="Buscado 0% <IMG class=icoacc align=absMiddle src='images/indicator2.gif'>"
        cTexto=CAJA.value
        cTexto2=cTexto
        cTexto2=replaceAll(cTexto2,","," , ")
        cTexto2=replaceAll(cTexto2,"."," . ")
        cTexto2=replaceAll(cTexto2,";"," ; ")
        cTexto2=replaceAll(cTexto2,":"," : ")
        cTexto2=replaceAll(cTexto2,"¿"," ¿ ")
        cTexto2=replaceAll(cTexto2,"?"," ? ")
        cTexto2=replaceAll(cTexto2,"!"," ! ")
        cTexto2=replaceAll(cTexto2,"¡"," ¡ ")
        cTexto2=trim(cTexto2)
        while (cTexto2.indexOf("  ")>-1){
              cTexto2=replaceAll(cTexto2,"  "," ")
        }
        cTerminos=cTexto2
        aTerminos.length=0
        aTerminos=cTerminos.split(" ")
        nTerTot=aTerminos.length
        if (nTerTot>100){
           verMensaje("Búsqueda de palabras",true,true,"No se pueden buscar más de 50 términos a la vez")
        }
        else {
          document.getElementById("texto").innerHTML=""
          document.getElementById("resultados").innerHTML=""
          buscaSiguiente()
        }
}

function buscaSiguiente(){
    if (!lBuscando){
         if (nTerAct<nTerTot){
            lBuscando=true
            nPun=esPuntuacion(aTerminos[nTerAct])
            if (nPun>0){
              leePuntuacion(nPun,aTerminos[nTerAct])
              //document.getElementById("texto").innerHTML+=aTerminos[nTerAct]+"&nbsp;"
              document.getElementById("texto").innerHTML+=aTerminos[nTerAct]+" "
             }
            else {
		if (aTerminos[nTerAct].indexOf("ç")==-1){
			lMostrar=true;
			nNotAct++
			document.getElementById("texto").innerHTML+=aTerminos[nTerAct]+"<sup><b>"+(nNotAct)+"</b></sup> "
		}
		else{
		    lMostrar=false
		    aTerminos[nTerAct]=replaceAll(aTerminos[nTerAct],"ç","")
		    document.getElementById("texto").innerHTML+=aTerminos[nTerAct]+" "
		}
		buscaPalabra(aTerminos[nTerAct])
            }
            nTerAct++
            setTimeout("buscaSiguiente()",500)
         }
         else {
              PROG1.style.width="150px"
              PROG2.innerHTML="Buscado 100 %"
              setTimeout("finBusca()",3000)
         }
    }
    else{
         setTimeout("buscaSiguiente()",1000)
    }
}

function buscaPalabra(ter){
        //verMensaje("progreso",false,true,"Buscando datos...")
	divResultado = document.getElementById("frm_lee");
	divResultado.innerHTML=""
        //divResultado.style.visibility="visible"
        pag="esddbslt.php"
        datos="palabra="+ter
        ajax=objetoAjax();
	ajax.open("GET", pag+"?"+datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			if (divResultado.innerHTML.indexOf("Can't connect")>-1){
                           document.getElementById("resultados").innerHTML="<b>Problemas de conexión con el servidor</b>"
                        }
                        else{
                             leePalabra()
                        }
		}
	}
	ajax.send(null)
}

function leePalabra(){
    if (document.getElementById("totpal")){
        nPalTot++
        nPalAct=nPalTot
        oPalabras[nPalAct]=creaPalabra()
        nForTot=parseInt(document.getElementById("totpal").value)
        oPalabras[nPalAct].forma=aTerminos[nTerAct]
        for (nFor=1;nFor<=nForTot;nFor++){
            //Codigos
            oPalabras[nPalAct].codpal[nFor]=parseInt(document.getElementById("codpal"+nFor).value)
            oPalabras[nPalAct].codtpl[nFor]=parseInt(document.getElementById("codtpl"+nFor).value)
            oPalabras[nPalAct].codfle[nFor]=parseInt(document.getElementById("codfle"+nFor).value)
            oPalabras[nPalAct].codgra[nFor]=parseInt(document.getElementById("codgra"+nFor).value)
            oPalabras[nPalAct].codtie[nFor]=parseInt(document.getElementById("codtie"+nFor).value)
            oPalabras[nPalAct].codmod[nFor]=parseInt(document.getElementById("codmod"+nFor).value)
            oPalabras[nPalAct].codvoz[nFor]=parseInt(document.getElementById("codvoz"+nFor).value)
            oPalabras[nPalAct].codcas[nFor]=parseInt(document.getElementById("codcas"+nFor).value)
            oPalabras[nPalAct].codper[nFor]=parseInt(document.getElementById("codper"+nFor).value)
            oPalabras[nPalAct].codnum[nFor]=parseInt(document.getElementById("codnum"+nFor).value)
            oPalabras[nPalAct].codgen[nFor]=parseInt(document.getElementById("codgen"+nFor).value)
            //Nombres
            oPalabras[nPalAct].forpal[nFor]=document.getElementById("forpal"+nFor).value
            oPalabras[nPalAct].sigpal[nFor]=document.getElementById("sigpal"+nFor).value
            oPalabras[nPalAct].nomtpl[nFor]=nomtpl[oPalabras[nPalAct].codtpl[nFor]]
            oPalabras[nPalAct].nomgra[nFor]=nomgra[oPalabras[nPalAct].codgra[nFor]]
            oPalabras[nPalAct].nommod[nFor]=nommod[oPalabras[nPalAct].codmod[nFor]]
            oPalabras[nPalAct].nomper[nFor]=nomper[oPalabras[nPalAct].codper[nFor]]
            oPalabras[nPalAct].nomnum[nFor]=nomnum[oPalabras[nPalAct].codnum[nFor]]
            oPalabras[nPalAct].nomgen[nFor]=nomgen[oPalabras[nPalAct].codgen[nFor]]
            oPalabras[nPalAct].nomcas[nFor]=nomcas[oPalabras[nPalAct].codcas[nFor]]
            oPalabras[nPalAct].nomvoz[nFor]=nomvoz[oPalabras[nPalAct].codvoz[nFor]]
            oPalabras[nPalAct].nomtie[nFor]=nomtie[oPalabras[nPalAct].codtie[nFor]]
            oPalabras[nPalAct].nomfle[nFor]=nomfle[oPalabras[nPalAct].codfle[nFor]]
            //Códigos
        }
        //document.getElementById("frm_lee").innerHTML=""
        if (nForTot>0){
        	if (lMostrar){muestraPalabra(nPalAct)}
        	lBuscando=false
        }
        else {
		if (lMostrar){document.getElementById("resultados").innerHTML+=nNotAct+".- No se encontró."}
		lBuscando=false
        }
    }
    else {
         document.getElementById("resultados").innerHTML+=nNotAct+".- No hay resultados."
         lBuscando=false
    }

    nPorCie=parseInt((nTerAct/nTerTot)*100)
    nPorTam=parseInt((nTerAct/nTerTot)*150)
    PROG2.innerHTML="Buscado "+nPorCie+"% <IMG class=icoacc align=absMiddle src='images/indicator2.gif'>"
    PROG1.style.width=nPorTam+"px"

}

function leePuntuacion(TIPO,FORMA){
    nPalTot++
    nPalAct=nPalTot
    oPalabras[nPalAct]=creaPalabra()
    oPalabras[nPalAct].forma=aTerminos[nTerAct]
    //Codigos
    oPalabras[nPalAct].codpal[1]=TIPO
    oPalabras[nPalAct].codtpl[1]=8
    oPalabras[nPalAct].codfle[1]=0
    oPalabras[nPalAct].codgra[1]=0
    oPalabras[nPalAct].codtie[1]=0
    oPalabras[nPalAct].codmod[1]=0
    oPalabras[nPalAct].codvoz[1]=0
    oPalabras[nPalAct].codcas[1]=0
    oPalabras[nPalAct].codper[1]=0
    oPalabras[nPalAct].codnum[1]=0
    oPalabras[nPalAct].codgen[1]=0
    //Nombres
    oPalabras[nPalAct].forpal[1]=FORMA
    oPalabras[nPalAct].sigpal[1]=""
    oPalabras[nPalAct].nomtpl[1]=""
    oPalabras[nPalAct].nomgra[1]=""
    oPalabras[nPalAct].nommod[1]=""
    oPalabras[nPalAct].nomper[1]=""
    oPalabras[nPalAct].nomnum[1]=""
    oPalabras[nPalAct].nomgen[1]=""
    oPalabras[nPalAct].nomcas[1]=""
    oPalabras[nPalAct].nomvoz[1]=""
    oPalabras[nPalAct].nomtie[1]=""
    oPalabras[nPalAct].nomfle[1]=""

    nPorCie=parseInt((nTerAct/nTerTot)*100)
    nPorTam=parseInt((nTerAct/nTerTot)*150)
    PROG2.innerHTML="Buscado "+nPorCie+"% <IMG class=icoacc align=absMiddle src='images/indicator2.gif'>"
    PROG1.style.width=nPorTam+"px"
    lBuscando=false

}


function finBusca(){
        PROG0.style.visibility="hidden"
        PROG1.style.visibility="hidden"
        PROG2.style.visibility="hidden"
}

function vermorfo(numero){
     if (document.getElementById("morfo"+numero).style.display=="inline"){
        document.getElementById("morfo"+numero).style.display="none"
     }
     else{
         document.getElementById("morfo"+numero).style.display="inline"
     }
}

function muestraPalabra(numero){
    nForTot=oPalabras[numero].forpal.length
    cPalAnt=""
    cTpoAnt=""
    cFleAnt=""
    cHTM=""
    nNumeros=1
    nCorchetes=0

    if (oPalabras[numero].codtpl[1]==8){
       cHTM=""
    }
    else {
          for (nFor=1;nFor<nForTot;nFor++){
              nIdFor=nFor+(numero*10)
              if (oPalabras[numero].forpal[nFor]==cPalAnt && oPalabras[numero].nomtpl[nFor]==cTpoAnt){
                 if (oPalabras[numero].codfle[nFor] == cFleAnt){
                   cHTM=cHTM+", "
                 }
                 else{
                      cFleAnt = oPalabras[numero].codfle[nFor]
                      if (oPalabras[numero].codfle[nFor]>0){
                         cHTM=cHTM+"]</SPAN> <A href='javascript:vermorfo("+nIdFor+")'>"+oPalabras[numero].nomfle[nFor]+"</A>&nbsp;<SPAN style='display:none;' id=morfo"+nIdFor+">"
                        }
                 }
              }
              else{
                   if (nFor>1){cHTM=cHTM+"]</SPAN>"}
                   if (nNumeros>1){
                       if (nNumeros==2){
                          cHTM="a) "+cHTM
                       }
                       cHTM=cHTM+" "+aOrdLet[nNumeros]+" "
                   }
                   cHTM=cHTM+"'"+oPalabras[numero].forpal[nFor]+"' :"
                   cHTM=cHTM+" \""+oPalabras[numero].sigpal[nFor]+"\". "
                   cHTM=cHTM+"("+oPalabras[numero].nomtpl[nFor]+"). "
                   cPalAnt=oPalabras[numero].forpal[nFor]
                   cTpoAnt=oPalabras[numero].nomtpl[nFor]
                   if (oPalabras[numero].codfle[nFor]>0){
                     cHTM=cHTM+"<A href='javascript:vermorfo("+nIdFor+")'>"+oPalabras[numero].nomfle[nFor]+"</A>&nbsp;<SPAN style='display:none;' id=morfo"+nIdFor+">["
                     nCorchetes=1
                     }
                   cFleAnt = oPalabras[numero].codfle[nFor]
                   nNumeros++
              }
              if (oPalabras[numero].codgra[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nomgra[nFor]+" "}
              if (oPalabras[numero].codcas[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nomcas[nFor]+" "}

              if (oPalabras[numero].codper[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nomper[nFor]+" "}

              if (oPalabras[numero].codnum[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nomnum[nFor]+" "}
              if (oPalabras[numero].codgen[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nomgen[nFor]+" "}

              if (oPalabras[numero].codtie[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nomtie[nFor]+" "}
              if (oPalabras[numero].codmod[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nommod[nFor]+" "}
              if (oPalabras[numero].codvoz[nFor]>0){cHTM=cHTM+""+oPalabras[numero].nomvoz[nFor]+" "}
          }
          //cHTM="&nbsp;"+nPalAct+".- &nbsp;"+cHTM
          cHTM="&nbsp;"+nNotAct+".- &nbsp;"+cHTM
          //cHTM=" "+nNotAct+".- &nbsp;"+cHTM
          if (nCorchetes>0){
             cHTM+="]</SPAN>"
             nCorchetes=0
          }
          document.getElementById("resultados").innerHTML+=cHTM
    }
    lBuscando=false
}


function cambiaUtilidad(util){
  if (util>""){
        cierraLista()
        if (util=="kal"){
          cargafecha()
          }
        document.getElementById(cUltUti).style.display="none"
        document.getElementById(util).style.display="inline"
        cUltIma=document.getElementById(cUltUti+"_ima").src
        cUltIma=cUltIma.replace("1.","0.")
        document.getElementById(cUltUti+"_ima").src=cUltIma
        cNvaIma=document.getElementById(util+"_ima").src
        cNvaIma=cNvaIma.replace("0.","1.")
        document.getElementById(util+"_ima").src=cNvaIma
        cUltUti=util
  }
}

function cierraLista(){
         document.getElementById("lee_cur").style.visibility="hidden"
}

function buscaEnu(CAJA){
        divResultado = document.getElementById("lee_cur");
        divResultado.innerHTML="<table width='100%' height='100%'><tr><td valign=middle><p align=center><IMG class=icoacc src='images/indicator_medium.gif'></p></td></tr></table>"
	divResultado.style.visibility="visible"
        if (CAJA=="flexion"){
          CAJA=document.getElementById("selfle")
          tipo=document.getElementById("seltip").value
          }
        datos=CAJA.value
        nIzq=daPosX(CAJA)-120
        nArr=daPosY(CAJA)-40
        nArr=nArr+CAJA.offsetHeight
        divResultado.style.left=nIzq+"px"
        divResultado.style.top=nArr+"px"
	ajax=objetoAjax();
	if (CAJA.id=="enuesp"){
             ajax.open("GET", "esddlslt.php?texto="+datos+"&modo=dicesp&tipo=0");
        }                                                                               
        else{
             if (CAJA.id=="selfle"){
                  ajax.open("GET", "esddlslt.php?texto="+datos+"&modo=flexion&tipo="+tipo);
             }
             else{
                  ajax.open("GET", "esddlslt.php?texto="+datos+"&modo="+cUltUti+"&tipo=0");
             }
        }
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
                        if (divResultado.innerHTML=="No hay coincidencias"){
			   divResultado.style.visibility="hidden"
                        }
		}
	}
	ajax.send(null)
}


function sele_pal(pal){
        document.getElementById("lee_cur").style.visibility="hidden";
        verMensaje("progreso",false,true,"Buscando datos...")
	divResultado = document.getElementById("frm_lee");
	divResultado.innerHTML=""
        pag="esddlelt.php"
        datos="codigo="+pal
        ajax=objetoAjax();
	ajax.open("GET", pag+"?"+datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			leePal()
		}
	}
	ajax.send(null)
}

function fle_pal(pal,fle){
        document.getElementById("lee_cur").style.visibility="hidden";
        verMensaje("progreso",false,true,"Buscando datos...")
	divResultado = document.getElementById("frm_lee");
	divResultado.innerHTML=""
	//divResultado.style.visibility="visible"
        pag="esddfllt.php"
        datos="codigo="+pal+"&flexion="+fle
        ajax=objetoAjax();
	ajax.open("GET", pag+"?"+datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			leeFle()
		}
	}
	ajax.send(null)
}


function creaFormas(){
        document.getElementById("lee_cur").style.visibility="hidden";
        //verMensaje("progreso",false,true,"Buscando datos...")
	divResultado = document.getElementById("mr_data");
	divResultado.innerHTML="Buscando datos..."
	//divResultado.style.visibility="visible"
        pag="esddmrlt.php"
        //datos="codigo="+pal+"&flexion="+fle
        ajax=objetoAjax();
	ajax.open("GET", pag);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			//leeFle()
		}
	}
	ajax.send(null)
}

function leerFormas(){
        document.getElementById("lee_cur").style.visibility="hidden";
        //verMensaje("progreso",false,true,"Buscando datos...")
	divResultado = document.getElementById("mr_data");
	divResultado.innerHTML="Buscando datos..."
	//divResultado.style.visibility="visible"
        pag="esddlefrlt.php"
        //datos="codigo="+pal+"&flexion="+fle
        ajax=objetoAjax();
	ajax.open("GET", pag+"?coddif="+document.getElementById("coddif").value+"&codgrm="+document.getElementById("codgrm").value);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			//leeFle()
		}
	}
	ajax.send(null)
}


function leePal(){
    limpiaDatos()
    nTot=document.getElementById("totpal").value
    cFle=""
    if (nTot>0){
        document.getElementById("enupal").value=document.getElementById("forpal1").value
        document.getElementById("difpal").value=document.getElementById("coddif1").value
        document.getElementById("sigpal").value=document.getElementById("sigpal1").value
        document.getElementById("tpopal").value=document.getElementById("codtpl1").value
        document.getElementById("subpal").value=document.getElementById("codsub1").value
        document.getElementById("cdoimp").value=document.getElementById("estpal1").value
        cdimp=document.getElementById("cdoimp").value
        document.getElementById("imaimp").src="images/emblem-important"+cdimp+".png"
        lImpugna=false
        document.getElementById("cdopal").innerHTML=document.getElementById("codpal1").value
        document.getElementById("lat_aut").innerHTML=document.getElementById("usuario1").value
        nGen=document.getElementById("codgen1").value
        nSex=document.getElementById("codsex1").value
        nNum=document.getElementById("codnum1").value
        nSem=document.getElementById("codsem1").value
         for (nGenAct=1;nGenAct<5;nGenAct++){
             if (XenY(nGenAct,nGen) && nGen>0){document.getElementById("gen"+nGenAct).checked=true}
             else{
                  if (document.getElementById("gen"+nGenAct)){
                     document.getElementById("gen"+nGenAct).checked=false
                  }
               }
         }
         for (nSexAct=1;nSexAct<5;nSexAct++){
             if (XenY(nSexAct,nSex) && nSex>0){document.getElementById("sex"+nSexAct).checked=true}
             else{
                  if (document.getElementById("sex"+nSexAct)){
                     document.getElementById("sex"+nSexAct).checked=false
                  }
               }
         }
         for (nNumAct=1;nNumAct<7;nNumAct++){
             if (XenY(nNumAct,nNum) && nNum>0){document.getElementById("num"+nNumAct).checked=true}
             else{
                  if (document.getElementById("num"+nNumAct)){
                     document.getElementById("num"+nNumAct).checked=false
                  }
               }
         }
         document.getElementById("semtot").value=nSem
         for (nSemAct=1;nSemAct<264;nSemAct=nSemAct*2){
             if (XenY(nSemAct,nSem) && nSem>0){document.getElementById("sem"+nSemAct).checked=true}
             else{
                  if (document.getElementById("sem"+nSemAct)){
                     document.getElementById("sem"+nSemAct).checked=false
                  }
               }
         }
        for (nAct=1;nAct<=nTot;nAct++){
          if (document.getElementById("valtem"+nAct)){
            document.getElementById("valtem"+nAct).style.visibility="visible"
            document.getElementById("chktem"+nAct).style.visibility="visible"
            document.getElementById("chktem"+nAct).checked=true
            document.getElementById("cdotem"+nAct).style.visibility="visible"
            document.getElementById("nomtem"+nAct).innerHTML=nomtem[document.getElementById("codtem"+nAct).value]
            document.getElementById("valtem"+nAct).value=document.getElementById("fortem"+nAct).value
            document.getElementById("cdotem"+nAct).value=document.getElementById("codtem"+nAct).value
            nFleTot=document.getElementById("totfle"+nAct).value
            for (nFleAct=1;nFleAct<=nFleTot;nFleAct++){
                nFle=document.getElementById("codfle"+nAct+"_"+nFleAct).value
                if (nFle>0){
                   if (cFle.indexOf("value="+nFle+">")==-1){
                      cFle+="<INPUT type=checkbox id='fle"+nFle+"' checked value="+nFle+">"+nomfle[nFle]+"<BR>";
                   }
                }
            }
          }
        }
        if (nNiv<3){
            document.getElementById("valtem"+nAct).style.visibility="visible"
            document.getElementById("chktem"+nAct).style.visibility="visible"
            document.getElementById("chktem"+nAct).checked=false
            document.getElementById("cdotem"+nAct).style.visibility="visible"
            document.getElementById("nomtem"+nAct).innerHTML="Añadir nuevo"           
        }
        document.getElementById("flexion").innerHTML=cFle
    }
    ocultaMensaje()
}

function sele_pla(npla){
    limpiaDatos()
    nTot=document.getElementById("linpla"+npla).value
    cFle=""
    cTem=""
    nTemAct=1
    aTemas=new Array()
    aRaices=new Array()
    aTmaFor=new Array()
    nTmaTot=0
    cTemPri=""
    if (nTot>0){
        for (nAct=1;nAct<=nTot;nAct++){
            if (nAct==1){
                cTemas=document.getElementById("templa"+npla+"_"+nAct).value
                cPlant=document.getElementById("forpla"+npla+"_"+nAct).value
                cRaices=quitaDiacriticos(document.getElementById("enupal").value)
                aTemas=cTemas.split(",")
                aPlant=cPlant.split(",")
                aRaices=cRaices.split(",")
                nLonPla=aPlant.length
                nLonTem=aTemas.length
                if (nLonTem > nLonPla){
                    for (n=nLonPla;n<nLonTem;n++){
                        aPlant[n]=aPlant[0]
                        aRaices[n]=aRaices[0]
                    }
                }
            }
            nFle=document.getElementById("codfle"+npla+"_"+nAct).value
            nGen=document.getElementById("codgen"+npla+"_"+nAct).value
            nTpl=document.getElementById("codtpl"+npla+"_"+nAct).value
            nSub=document.getElementById("codsub"+npla+"_"+nAct).value
            nSex=document.getElementById("codsex"+npla+"_"+nAct).value
            nNum=document.getElementById("codnum"+npla+"_"+nAct).value
            nSem=document.getElementById("codsem"+npla+"_"+nAct).value
            nTem=document.getElementById("codtem"+npla+"_"+nAct).value
            document.getElementById("tpopal").value=nTpl
            if (cTem.indexOf(nTem+";")==-1){
               document.getElementById("nomtem"+nTemAct).innerHTML=nomtem[nTem]
               document.getElementById("cdotem"+nTemAct).value=nTem
               nTemDes=nTem
               if (!aTemas[nTemAct-1]){
                  aTemas[nTemAct-1]=""
                  aPlant[nTemAct-1]=""
                  aRaices[nTemAct-1]=""
               }
               else {
                   cTemNum="01234567890"
                   if (cTemNum.indexOf(aTemas[nTemAct-1].substring(0,1))>-1){
                      nTemDes=aTemas[nTemAct-1].substring(0,1)
                      aTemas[nTemAct-1]=aTemas[nTemAct-1].substring(1)
                   }
               }
               aRaices[nTemAct-1]+=","
               aRaices[nTemAct-1]=aRaices[nTemAct-1].replace(aTemas[nTemAct-1]+",","")
               if (cPlant=="0"){
                  if (nTem==20){
                     aTmaFor[nTemDes]=cRaices.slice(0,cRaices.length - 1)
                  }
                  else{
                       aTmaFor[nTemDes]=cRaices
                  }
               }
               else{
                     if (aRaices[nTemAct-1]+aTemas[nTemAct-1]==aPlant[nTemAct-1]){
                          if (nFle==20 || nFle==21){
                              if (aRaices[1]>""){
                                  aTmaFor[nTemDes]=aRaices[1]+aRaices[nTemAct-1]
                              }
                              else{
                                  aTmaFor[nTemDes]=aRaices[0]+aRaices[nTemAct-1]
                              }
                          }
                          else{
                              aTmaFor[nTemDes]=aRaices[0]+aRaices[nTemAct-1]
                          }
                     }
                     else{
                          if (nFle==13 && nTem==0){
                            aTmaFor[nTemDes]=aRaices[nTemAct-1]+"i"
                          }
                          else {
                               aTmaFor[nTemDes]=aRaices[nTemAct-1].replace(aTemas[nTemAct-1]+"/","/")
                               //aTmaFor[nTemDes]=aRaices[nTemAct-1]
                          }
                     }
               }
               document.getElementById("cdotem"+nTemAct).style.visibility="visible"
               document.getElementById("valtem"+nTemAct).style.visibility="visible"
               document.getElementById("chktem"+nTemAct).style.visibility="visible"
               document.getElementById("chktem"+nTemAct).checked=true
               nTemAct++
               cTem+=nTem+";"
            }
            if (nFle>0){
               if (cFle.indexOf(">"+nomfle[nFle]+"<BR>")==-1){
                  cFle+="<INPUT type=checkbox id='fle"+nFle+"' checked value="+nFle+">"+nomfle[nFle]+"<BR>";
               }
            }
             for (nGenAct=1;nGenAct<5;nGenAct++){
                 if (XenY(nGenAct,nGen) && nGen>0){document.getElementById("gen"+nGenAct).checked=true}
                 else{
                      if (document.getElementById("gen"+nGenAct)){
                         document.getElementById("gen"+nGenAct).checked=false
                      }
                   }
             }
             for (nNumAct=1;nNumAct<7;nNumAct++){
                 if (XenY(nNumAct,nNum) && nNum>0){document.getElementById("num"+nNumAct).checked=true}
                 else{
                      if (document.getElementById("num"+nNumAct)){
                         document.getElementById("num"+nNumAct).checked=false
                      }
                   }
             }
             document.getElementById("semtot").value=nSem
             for (nSemAct=1;nSemAct<264;nSemAct=nSemAct*2){
                 if (XenY(nSemAct,nSem) && nSem>0){document.getElementById("sem"+nSemAct).checked=true}
                 else{
                      if (document.getElementById("sem"+nSemAct)){
                         document.getElementById("sem"+nSemAct).checked=false
                      }
                   }
             }
             for (nSexAct=1;nSexAct<5;nSexAct++){
                 if (XenY(nSexAct,nSex) && nSex>0){document.getElementById("sex"+nSexAct).checked=true}
                 else{
                      if (document.getElementById("sex"+nSexAct)){
                         document.getElementById("sex"+nSexAct).checked=false
                      }
                   }
             }
            document.getElementById("tpopal").value=nTpl
            document.getElementById("subpal").value=nSub
        }
        for (nTma=1;nTma<7;nTma++){
            nCod=document.getElementById("cdotem"+nTma).value
            if (aTmaFor[nCod]){
               document.getElementById("valtem"+nTma).value=quitaDiacriticos(aTmaFor[nCod].replace(",",""))
            }
        }
    }
    document.getElementById("flexion").innerHTML=cFle
    cierraLista()
}

function borraPalabra(){
  cAutor=document.getElementById("lat_aut").innerHTML
  cUsuario=document.getElementById("lat_usu").value
  nNiv=parseInt(document.getElementById("niv_usu").value)
  cCodigo=document.getElementById("cdopal").innerHTML
  if (parseInt(cCodigo)>0){
     if (cAutor==cUsuario || nNiv<2){
        verOpcion("br|cn","borraPalabra2("+cCodigo+")|ocultaOpcion()","¿Borrar la palabra?")
     }
     else {
        verMensaje("No puedes borrar esta palabra. Pertenece a otro usuario",false,true,"Borrar palabra")
     }
  }
}

function borraPalabra2(codigo){
     ocultaOpcion()
     cValores="codpal="+codigo
     cUrl="esddbrlt.php"
     enviaAjax(cUrl,cValores,"fin_borraPAL()")
}

function fin_borraPAL(){

}

function grabaPalabra(){
cAutor=document.getElementById("lat_aut").innerHTML
cUsuario=document.getElementById("lat_usu").value
nNiv=parseInt(document.getElementById("niv_usu").value)
if (document.getElementById("sigpal").value > " "){
    if (parseInt(document.getElementById("cdopal").innerHTML)>0){
       if (cAutor==cUsuario || nNiv<2){
          verOpcion("md|cn", "grabaPalabra2(1)|ocultaOpcion()","¿Modificar la palabra?")
       }
       else{
            verMensaje("Sólo el usuario que ha introducido una palabra ("+cAutor+") puede modificarla. Puedes impugnarla pulsando en el icono (!).",false,true,"Modificar palabras")
       }
     }
     else{
          verOpcion("nv|cn", "grabaPalabra2(0)|ocultaOpcion()","¿Añadir la palabra?")
     }
}
else{
        verMensaje("Es necesario incluir un significado",false,true,"Añadir palabra")
}
}

function grabaPalabra2(modo){
ocultaOpcion()
if (modo==0){
   nCodPal=0
}
else{
     nCodPal=parseInt(document.getElementById("cdopal").innerHTML)
}
cDatos="codpal="+nCodPal
cDatos+="&forpal="+document.getElementById("enupal").value
cDatos+="&coddif="+document.getElementById("difpal").value
cDatos+="&sigpal="+document.getElementById("sigpal").value
cDatos+="&codsub="+document.getElementById("subpal").value
cDatos+="&codtpl="+document.getElementById("tpopal").value
cDatos+="&codimp="+document.getElementById("cdoimp").value
cDatos+="&usuario="+document.getElementById("lat_aut").innerHTML
nGenTot=0
for (nGenAct=1;nGenAct<5;nGenAct++){
   if (document.getElementById("gen"+nGenAct)){
      if (document.getElementById("gen"+nGenAct).checked==true){
         nGenTot+=nGenAct
      }
   }
}
cDatos+="&genpal="+nGenTot
nSexTot=0
for (nSexAct=1;nSexAct<5;nSexAct++){
   if (document.getElementById("sex"+nSexAct)){
      if (document.getElementById("sex"+nSexAct).checked==true){
         nSexTot+=nSexAct
      }
   }
}
cDatos+="&sexpal="+nSexTot
nNumTot=0
for (nNumAct=1;nNumAct<7;nNumAct++){
   if (document.getElementById("num"+nNumAct)){
      if (document.getElementById("num"+nNumAct).checked==true){
         nNumTot+=nNumAct
      }
   }
}
cDatos+="&numpal="+nNumTot
nSemTot=0
for (nSemAct=1;nSemAct<264;nSemAct=nSemAct*2){
   if (document.getElementById("sem"+nSemAct)){
      if (document.getElementById("sem"+nSemAct).checked==true){
         nSemTot+=nSemAct
      }
   }
}
cDatos+="&sempal="+nSemTot
for (nAct=1;nAct<=6;nAct++){
    if (document.getElementById("valtem"+nAct)){
       if (document.getElementById("valtem"+nAct).style.visibility=="visible"){
          cVarTem=document.getElementById("valtem"+nAct).value
          aVarVal=cVarTem.split("/")
          nVarTem=aVarVal.length
          for (n=0;n<nVarTem;n++){
              if (document.getElementById("chktem"+nAct).checked){
                 cDatos+="&codtem[]="+document.getElementById("cdotem"+nAct).value
                 //cDatos+="&fortem[]="+document.getElementById("valtem"+nAct).value
                 cDatos+="&fortem[]="+aVarVal[n]
              }
          }
       }
    }
}
nFleTot=0
for (nAct=1;nAct<30;nAct++){
    if (document.getElementById("fle"+nAct)){
       if (document.getElementById("fle"+nAct).checked){
          cDatos+="&codfle[]="+nAct
          if (nAct==10){
             cDatos+="&codfle[]=0"
          }
          nFleTot+=nAct
       }
    }
}
if (nFleTot==0){
          cDatos+="&codfle[]=0"
}
nAjax=0
enviaAjax("esddgrlt.php",cDatos,"fin_grabaPAL()")
}

function fin_grabaPAL(){
    cCodigo=document.getElementById("codnva").value
    document.getElementById("cdopal").innerHTML=cCodigo
}

function limpiaDatos(){
    document.getElementById("flexion").innerHTML=""
    document.getElementById("cdopal").innerHTML=""
    for (nAct=1;nAct<=6;nAct++){
        document.getElementById("nomtem"+nAct).innerHTML=""
        document.getElementById("valtem"+nAct).value=""
        document.getElementById("valtem"+nAct).style.visibility="hidden"
        document.getElementById("cdotem"+nAct).style.visibility="hidden"
        document.getElementById("chktem"+nAct).style.visibility="hidden"
        document.getElementById("chktem"+nAct).checked=false
    }
    document.getElementById("sigpal").value=""
    document.getElementById("tpopal").value=1
    nUltTip=1
    document.getElementById("subpal").value=0
    document.getElementById("cdopal").innerHTML=""
    document.getElementById("lat_aut").innerHTML=document.getElementById("lat_usu").value
     for (nGenAct=1;nGenAct<5;nGenAct++){
          if (document.getElementById("gen"+nGenAct)){
             document.getElementById("gen"+nGenAct).checked=false
          }
     }
     for (nSexAct=1;nSexAct<5;nSexAct++){
          if (document.getElementById("sex"+nSexAct)){
             document.getElementById("sex"+nSexAct).checked=false
          }
     }
     for (nNumAct=1;nNumAct<7;nNumAct++){
          if (document.getElementById("num"+nNumAct)){
             document.getElementById("num"+nNumAct).checked=false
          }
     }
     for (nSemAct=1;nSemAct<264;nSemAct=nSemAct*2){
          if (document.getElementById("sem"+nSemAct)){
             document.getElementById("sem"+nSemAct).checked=false
          }
     }
    for (nAct=1;nAct<=6;nAct++){
      if (document.getElementById("valtem"+nAct)){
        document.getElementById("valtem"+nAct).style.visibility="hidden"
        document.getElementById("cdotem"+nAct).style.visibility="hidden"
        document.getElementById("nomtem"+nAct).innerHTML=""
        document.getElementById("valtem"+nAct).value=""
        document.getElementById("cdotem"+nAct).value=""
      }
    }
    document.getElementById("flexion").innerHTML=""
}

function daSema(){
  nTot=0
  for (n=1;n<129;n+=n){
       if (document.getElementById("sem"+n).checked){
          nTot+=n
       }
  }
  document.getElementById("semtot").innerHTML=nTot
}

function cambiaTipo(tipo){
     //if (nUltTip != tipo){
     //    limpiaDatos()
     //    nUltTip=tipo
     //    busca_tipo()
     //}
}

function busca_tipo(){
        document.getElementById("lee_cur").style.visibility="hidden";
        verMensaje("progreso",false,true,"Cargando tipo...")
	divResultado = document.getElementById("frm_lee");
	divResultado.innerHTML=""
        pag="esddletp.php"
        datos="codtpl="+document.getElementById("tpopal").value
        datos+="&codsub="+document.getElementById("subpal").value
        ajax=objetoAjax();
	ajax.open("GET", pag+"?"+datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			leeTipo()
		}
	}
	ajax.send(null)
}

function leeTipo(){

}

function impugnaPalabra(){
         nImp=parseInt(document.getElementById("cdoimp").value)+1
         if (!lImpugna){
             if (nImp<9){
                document.getElementById("cdoimp").value=nImp
                document.getElementById("imaimp").src="images/emblem-important"+nImp+".png"
             }
             lImpugna=true
         }
}

function leeFle(){
        nNiv=parseInt(document.getElementById("niv_usu").value)
        nForTot=document.getElementById("totfor").value
        nFleTot=document.getElementById("totfle").value
        if (nFleTot>0){
              cForPal=document.getElementById("forpal0").value
              cSigPal=document.getElementById("sigpal0").value
              document.getElementById("enuesp").value=cSigPal
              document.getElementById("enumor").value=cForPal
              nTip=parseInt(document.getElementById("codtip0").value)
              cTipo=nomtpl[nTip]
              nPla=nTip
              if (nPla==5){nPla=3}
              cPlt=document.getElementById("mor"+nPla).innerHTML;
              for (nFor=1;nFor<=nForTot;nFor++){
                  cCod=document.getElementById("codigo"+nFor).value
                  if (nTip==3){
                     cCod=cCod.replace("r0","")
                  }
                  cFor=document.getElementById("forma"+nFor).value
                  if (document.getElementById("ch_des").checked==false){
                     cFor=replaceAll(cFor,"-","")
                  }
                  if (nNiv<3){
                    cPlt=replaceAll(cPlt,cCod,"<input value='"+cFor+"' size=10 id=valor"+nFor+" title="+cFor+" >")
                  }
                  else{
                    cPlt=replaceAll(cPlt,cCod,cFor)
                  }
              }
              cFlexiones=""
              for (nFle=1;nFle<=nFleTot;nFle++){
                cFlexiones+=nomfle[document.getElementById("flexion"+nFle).value]+", "
              }
              if (nTip==2){cPlt=limpiaVacios(cPlt,"v")}
              if (nTip==1){cPlt=limpiaVacios(cPlt,"n")}
              if (nTip==3 || nTip==5){cPlt=limpiaVacios(cPlt,"g")}
              cPlt="<b>Palabra</b> '"+cForPal+"': "+String.fromCharCode(34)+cSigPal+String.fromCharCode(34)+" <b>Tipo:</b> "+cTipo+" <b>Flexión:</b> "+cFlexiones+"<br>"+cPlt
              document.getElementById("morfo").innerHTML=cPlt
              if (nTip==2){
                 document.getElementById("moradj").style.display="none"
                 document.getElementById("morver").style.display="inline"
                 document.getElementById("voz").value=1
                 document.getElementById("tiempo").value=1
                 document.getElementById("modo").value=1
              }
              else{
                 document.getElementById("morver").style.display="none"
                 if (nTip==3){
                    document.getElementById("grado").value=1
                    document.getElementById("moradj").style.display="inline"
                 }
                 else{
                      document.getElementById("moradj").style.display="none"
                 }
              }
              ocultaMensaje()
        }
        else {
             verMensaje("La palabra no tiene una flexión correcta",false,true,"Error de flexión")
        }
}

function limpiaVacios(plantilla,clave){
   nIni=plantilla.indexOf(">"+clave)
   while (nIni>-1){
        nFin=plantilla.indexOf("<",nIni)
        if (nFin>-1){
           cVacio=plantilla.substring(nIni+1,nFin)
           plantilla=plantilla.replace(cVacio,"-")
           nIni=plantilla.indexOf(">"+clave)
        }
        else {nIni=-1}
   }
   return (plantilla)
}


function leeCon(){
  if (document.getElementById("totfor")){
        nForTot=document.getElementById("totfor").value
        nFleTot=document.getElementById("totfle").value
        cForPal=document.getElementById("forpal0").value
        cSigPal=document.getElementById("sigpal0").value
        nTip=parseInt(document.getElementById("codtip0").value)
        nVoz=parseInt(document.getElementById("voz").value)
        nTie=parseInt(document.getElementById("tiempo").value)
        nMod=parseInt(document.getElementById("modo").value)
        nFll=0
        if (nMod==32){
           if (nTie==1){
              document.getElementById("voz").value=1
              nVoz=1
           }
           if (nTie==8){
             nVoz=2
             document.getElementById("voz").value=2
           }
        }
        if (nMod==32 || nMod==65){
          nTip=3
          if (nMod==65){nTie=0;}
        }
        if (nMod==33 || nMod==64){
          nTip=1
          nTie=0
        }
        if (nMod==8){
          nTip=0
        }
        if (nMod==65){ //Si es gerundivo
           nTie=0
        }
        if (nVoz==2){
           if (nTie>4){
              if (nMod !=32 ){
                nTip=21
                nTie=nTie/8
                nVoz=1
              }
           }
        }
        cTiempo="v"+nVoz+"t"+nTie+"m"+nMod
        cPlt=document.getElementById("mor"+nTip).innerHTML;
        cPlt=replaceAll(cPlt,">v1t1m1",">"+cTiempo)
        cPlt=replaceAll(cPlt," av1t1m1"," a"+cTiempo)
        for (nFor=1;nFor<=nForTot;nFor++){
            cCod=document.getElementById("codigo"+nFor).value
            cFor=document.getElementById("forma"+nFor).value
            if (nTip==21){
                cPlt=replaceAll(cPlt,">"+cCod,">"+cFor)
            }
            if (cCod.indexOf("m"+nMod)>0){
                if (nMod==32 || nMod==65){ //Si es participio o gerundivo
                   cCod=cCod.replace(cTiempo+"p0","")
                }
                if (nMod==33 || nMod==64){ //Si es supino o gerundio
                   cCod=cCod.replace(cTiempo+"p0g4","")
                }
                if (nMod==8){
                   if (cCod.indexOf(cTiempo)>-1){
                      cCod="*"
                   }
                }
                if (nTip==21){
                   cPlt=replaceAll(cPlt," "+cCod," "+cFor)
                }
                else{
                     cPlt=replaceAll(cPlt,">"+cCod,">"+cFor)
                }
            }
        }
        cFlexiones=""
        for (nFle=1;nFle<=nFleTot;nFle++){
          cFlexiones+=nomfle[document.getElementById("flexion"+nFle).value]+", "
        }
        if (nMod>8){
             cPlt=limpiaVacios(cPlt,"v")
        }
        else{
             cPlt=limpiaVacios(cPlt,"v")
        }
        if (!document.getElementById("ch_des").checked){
            cPlt=replaceAll(cPlt,"-","")   
        }
        for (n=0;n<8;n++){
            if (cPlt.indexOf("g"+n)>0){
               cPlt="<br><b>No existen formas de esas características</b>"
            }
        }
        cPlt="<b>Palabra</b> '"+cForPal+"': "+cSigPal+" <b>Tipo:</b> "+cTipo+" <b>Flexión:</b> "+cFlexiones+"<br>"+cPlt
        document.getElementById("morfo").innerHTML=cPlt
        ocultaMensaje()
  }
}

function leeGra(){
        nForTot=document.getElementById("totfor").value
        nFleTot=document.getElementById("totfle").value
        cForPal=document.getElementById("forpal0").value
        cSigPal=document.getElementById("sigpal0").value
        nGra=parseInt(document.getElementById("grado").value)
        cPlt=document.getElementById("mor3").innerHTML;
        for (nFor=1;nFor<=nForTot;nFor++){
            cCod=document.getElementById("codigo"+nFor).value
            if (cCod.indexOf("r"+nGra)>-1){
                cCod=cCod.replace("r"+nGra,"")
                cFor=document.getElementById("forma"+nFor).value
                cPlt=replaceAll(cPlt,cCod,cFor)
            }
        }
        cFlexiones=""
        for (nFle=1;nFle<=nFleTot;nFle++){
          cFlexiones+=nomfle[document.getElementById("flexion"+nFle).value]+", "
        }
        cPlt=limpiaVacios(cPlt,"g")
        cPlt="<b>Palabra</b> '"+cForPal+"': "+cSigPal+" <b>Tipo:</b> "+cTipo+" <b>Flexión:</b> "+cFlexiones+"<br>"+cPlt
        document.getElementById("morfo").innerHTML=cPlt
        document.getElementById("morver").style.display="none"
        document.getElementById("moradj").style.display="inline"
}

function esPuntuacion(CADENA){
   cSuave=","
   cFuerte=".;:¿?¡!"
   nPun=0
   if (cSuave.indexOf(CADENA)>-1){nPun=1}
   else {
        if (cFuerte.indexOf(CADENA)>-1){nPun=2}
   }
   return (nPun)
}

function arreglaPalabras(){
enviaAjax("esddardclt.php","","fin_arreglaPAL()")
}

function fin_arreglaPAL(){

}

function addPalabras(){
enviaAjax("esddadlt2.php","","fin_addPAL()")
}

function fin_addPAL(){

}

function hazClave(cadena){
   var cDia="vtmpgncx"
   var nLon=cadena.length
   var cNva=""
   for (nD=0;nD<nLon;nD++){
       cCar=cadena.substring(nD,nD+1)
       nPos=cDia.indexOf(cCar)
       if (nPos>-1){
          cNva=cNva+"_"
       }
       else {
          cNva=cNva+cCar
       }
   }
   return (cNva)
}

function grabaFormas(MODO){
    nTip=parseInt(document.getElementById("codtip0").value)
    nCam=0
    cDatos=""
    aFor=Array()
    aCod=Array()
    nForTot=document.getElementById("totfor").value
    if (nTip==1 || nTip==3 || nTip==5){
      for (nFor=1;nFor<nForTot;nFor++) {
      	      if (MODO==2){
		      if (nCam==0){
			cDatos+="nPal="+document.getElementById("codpal0").value  
			cDatos+="&nFle="+document.getElementById("selfle").value
		      }
		      if (document.getElementById("valor"+nFor)){
		      	      nCam++
			      cFor=document.getElementById("valor"+nFor).value
			      cCod=document.getElementById("clave"+nFor).value             
			      cDatos+="&aFor[]="+cFor
			      cDatos+="&aCod[]="+cCod
		      }
      	      }
      	      else {
		if (document.getElementById("valor"+nFor)){
		  if (document.getElementById("valor"+nFor).value != document.getElementById("valor"+nFor).title){
		      if (nCam==0){
			cDatos+="nPal="+document.getElementById("codpal0").value  
		      }
		      if (document.getElementById("valor"+nFor)){
			      nCam++
			      cFor=document.getElementById("valor"+nFor).value
			      cCod=document.getElementById("clave"+nFor).value             
			      cDatos+="&aFor[]="+cFor
			      cDatos+="&aCod[]="+cCod
		      }
		   }
		}
	      }
      }    
    }
    if (MODO==2){
	    enviaAjax("esddgrltfl.php",cDatos,"fin_grabaFormas()")
    }
    if (nCam>0){
    	    if (MODO==0){
    	    	    enviaAjax("esddgrltds.php",cDatos,"fin_grabaFormas()")
      	    }
      	    if (MODO==1){
    	    	    enviaAjax("esddgrltfr.php",cDatos,"fin_grabaFormas()")
      	    }
    }
}

function fin_grabaFormas(){

}

function analizaTexto(){
    for (nPal=1;nPal<=nPalTot;nPal++){
      if (oPalabras[nPal].codtpl[1]==2){
        alert(oPalabras[nPal].forpal+oPalabras[nPal].codpal)
      }            
    }

}

function addMarca(){
	myArea=document.getElementById("palabra")
	if (typeof(myArea.selectionStart) != "undefined") { 
		 var begin = myArea.value.substr(0, myArea.selectionStart); 
		 var selection = myArea.value.substr(myArea.selectionStart, myArea.selectionEnd - myArea.selectionStart); 
		 var end = myArea.value.substr(myArea.selectionEnd); 
		 if (selection.indexOf("ç")>-1){selection=replaceAll(selection,"ç","")}
		 else {selection="ç"+selection}
		 myArea.value = begin + selection + end; 
	}	
	else {
		if (document.selection){
			myArea.focus();
			var selection = document.selection.createRange();
			if (selection.text.indexOf("ç")>-1){selection.text=replaceAll(selection.text,"ç","")}
			else {selection.text="ç"+selection.text}
			
		}
	}
}

function marcaTodo(){
        nPalTot=0
        nPalAct=0
        nTerAct=0
        nNotAct=0
        CAJA=document.getElementById("palabra")
        cTexto=CAJA.value
        if (cTexto.indexOf("ç")>-1){
        	cTexto=replaceAll(cTexto,"ç","")
        }
        else {
        	cTexto=replaceAll(cTexto,"ç","")
		cTexto2=cTexto
		cTerminos=cTexto2
		aTerminos.length=0
		aTerminos=cTerminos.split(" ")
		nTerTot=aTerminos.length
		cTexto=""
		for (nTer=0;nTer<nTerTot;nTer++){
			cTexto+="ç"+aTerminos[nTer]+" "
		}
	}
        CAJA.value=cTexto
}

