

function Texts() { 

    vxTTS.value = '';

    if (vxSemanticInt.value == 'menu') {
        //Obtenemos el nombre de la seccion de nivel 1 elegida
        vxColumnaIzquierda = document.getElementById('colIzqsecc');
        vxSeccionNivel1 = vxColumnaIzquierda.getElementsByTagName('IMG')(0).alt;
        vxTTS.value += vxSeccionNivel1 + '. ';

        //Obtenemos los nombres de las secciones nivel 2 si hay mas de una
        vxSeccionesNivel2 = vxColumnaIzquierda.getElementsByTagName('A');
        vxTTS.value += 'Elija la información que desee consultar. ';
        for(i=1;i<vxSeccionesNivel2.length-1;i++) {
            vxSeccionNivel2 = vxSeccionesNivel2(i).innerText;
            vxTTS.value += vxSeccionNivel2 + '. ';
        }
        vxTTS.value += ' Para oir de nuevo estas opciones, diga: menú. ';
        vxTTS.value += ' Para oir las noticias de esta sección, diga: noticias. ';
        vxTTS.value += ' Para volver a la pagina principal, diga: volver, o, atrás. ';

    } else if (vxSemanticInt.value == 'noticias') {
        //LEEMOS LOS TITULARES DE LAS NOTICIAS
        vxVarContenido = document.getElementById('contenido');
        vxNoticias = vxVarContenido.getElementsByTagName('A');
        vxTextoNoticias = '';
        for(i=0;i<vxNoticias.length;i++) {
            if (i == -1)
              i = vxNoticias.length;
            else {
              vxNoticia = vxNoticias(i).innerText;
              vxNum = i+1;
              vxTextoNoticias += 'Noticia ' + vxNum + ': ' + vxNoticia + '. ';
            }
        }
        vxTTS.value = 'A continuación podrá escuchar las noticias de esta sección. Para escuchar la noticia completa diga el número de la noticia. ';
        vxTTS.value += vxTextoNoticias + '. ';
        vxMasNot = document.getElementById('seccionmasnoticias');
        if (vxMasNot != null) vxTTS.value += ' Para oir el resto de noticias, diga, más noticias. ';
        vxTTS.value += ' Para oir de nuevo las opciones de esta sección, diga: menú. ';
        vxTTS.value += ' Para volver a la página principal, diga: volver, o, atrás. ';

    } else {
        //TEXTO QUE SE LEERA LA PRIMERA VEZ QUE SE EJECUTE EL CODIGO DE ESTA SECCION TTS

        //NORMALMENTE LEEMOS LAS OPCIONES DE LA COLUMNA IZQUIERDA. SIN EMBARGO PARA EL CASO
        //PARTICULAR EN QUE EL USUARIO DIGA MAS NOTICIAS HABRA QUE
        //LEER DIRECTAMENTE LA PARTE CENTRAL DE LA SECCION

        if (document.location.href.indexOf('not=t') != -1) {
            //ESTAMOS EN MAS NOTICIAS Y HAY QUE LEER DIRECTAMENTE LAS NOTICIAS
            vxVarContenido = document.getElementById('contenido');
            vxNoticias = vxVarContenido.getElementsByTagName('A');
            vxFechas = vxVarContenido.getElementsByTagName('EM');
            vxTextoNoticias = '';
            for(i=0;i<vxNoticias.length;i++) {
                if (i == -1) {
                  i = vxNoticias.length;
                } else {
                  vxFecha = vxFechas(i).innerText;
                  vxNoticia = vxNoticias(i).innerText;
                  vxNum = i+1;
                  vxTextoNoticias += 'Noticia ' + vxNum + ': ' + vxFecha + '. ' + vxNoticia + '. ';
                }
            }
            vxTTS.value = 'A continuación podrá escuchar TODAS las noticias de esta sección. Para escuchar la noticia completa diga el número de la noticia. ';
            vxTTS.value += vxTextoNoticias + '. ';
            vxTTS.value += ' Fin de la lectura de las noticias. ';
            vxTTS.value += ' Para oir de nuevo las opciones de esta sección, diga: menú. ';
            vxTTS.value += ' Para volver a la página principal, diga: volver, o, atrás. ';

        } else {
            //CASO NORMAL, LEEMOS LAS OPCIONES DE LA IZQUIERDA
            //Obtenemos el nombre de la seccion de nivel 1 elegida
            vxColumnaIzquierda = document.getElementById('colIzqsecc');
            vxSeccionNivel1 = vxColumnaIzquierda.getElementsByTagName('IMG')(0).alt;
            vxTTS.value += vxSeccionNivel1 + '. ';

            //Obtenemos los nombres de las secciones nivel 2 si hay mas de una
            vxSeccionesNivel2 = vxColumnaIzquierda.getElementsByTagName('A');
            vxTTS.value += 'Elija la información que desee consultar. ';
            for(i=1;i<vxSeccionesNivel2.length-1;i++) {
              vxSeccionNivel2 = vxSeccionesNivel2(i).innerText;
              vxTTS.value += vxSeccionNivel2 + '. ';
            }
            vxTTS.value += ' Para oir de nuevo estas opciones, diga: menú. ';
            vxTTS.value += ' Para oir las noticias de esta sección, diga: noticias. ';
            vxTTS.value += ' Para volver a la pagina principal, diga: volver, o, atrás. ';
        }
    }
    return vxTTS.value;


  }


function VoiceCommands() { 

    vxASR.value = '';

    //METEMOS EN LA GRAMATICA LOS NOMBRES DE LAS SECCIONES DE LA IZQUIERDA
    vxColumnaIzquierda = document.getElementById('colIzqsecc');
    vxSeccionesNivel2 = vxColumnaIzquierda.getElementsByTagName('A');
    for(i=1;i<vxSeccionesNivel2.length-1;i++) {
        vxSeccionNivel2 = vxSeccionesNivel2(i).innerText;
        var er = /\"/g;
        vxSeccionNivel2 = vxSeccionNivel2.replace(er,' ');
        vxASR.value += vxSeccionNivel2 + '==' + i + '#####';
    }

    //METEMOS EN LA GRAMATICA LOS NUMEROS DE LAS NOTICIAS
    vxVarContenido = document.getElementById('contenido');
    vxNoticias = vxVarContenido.getElementsByTagName('A');
    for(i=0;i<vxNoticias.length;i++) {
        vxNumNoticia = i + 1;
        vxIdNoticia = i + 1 + 1000;
        vxASR.value += vxNumNoticia + '==' + vxIdNoticia + '#####';
        vxASR.value += 'Noticia ' + vxNumNoticia + '==' + vxIdNoticia + '#####';
    }

    vxMasNot = document.getElementById('seccionmasnoticias');
    if (vxMasNot != null) vxASR.value += 'mas noticias==mas noticias#####';

    vxASR.value += 'noticias==noticias#####';
    vxASR.value += 'volver==volver#####';
    vxASR.value += 'atrás==volver#####';
    vxASR.value += 'inicio==volver#####';
    vxASR.value += 'menu==menu#####';

    return vxASR.value;

  }


function Management() { 

	vxVoiceCommand.value = vxRC.value;
      	vxSemanticInt.value = vxRSI.value;
      
      return 'vxSemanticInt==' + vxSemanticInt.value + '#####';
    }


function Navigation() { 


      if (vxSemanticInt.value == 'volver') {
          /* Pulsamos en volver */
          vxEnlaceVolver = document.getElementsByName('volverseccion')(0);
          vxEnlaceVolver.click();

      } else if (vxSemanticInt.value == 'mas noticias') {
          /* PULSAMOS EN EL ENLACE DE MAS NOTICIAS */
          vxMasNot = document.getElementById('seccionmasnoticias');
          vxMasNot.getElementsByTagName('A')(0).click();

      } else if (vxSemanticInt.value == 'noticias') {
        return '0';

      } else if (vxSemanticInt.value == 'menu') {
        return '0';

      } else {
          /* Pulsamos en la seccion de nivel 2 elegida o pulsamos en el enlace de la noticia */
          if (vxSemanticInt.value > 1000) {
              //El usuario ha dicho un numero para entrar en una noticia
              vxIdNoticia = parseInt(vxSemanticInt.value) - 1 - 1000;
              vxVarContenido = document.getElementById('contenido');
              vxListaNoticias = vxVarContenido.getElementsByTagName('A');
              vxListaNoticias(vxIdNoticia).click();
          } else {
              //El usuario ha dicho el nombre de una seccion de nivel 2
              vxColumnaIzquierda = document.getElementById('colIzqsecc');
              vxSeccionesNivel2 = vxColumnaIzquierda.getElementsByTagName('A');
              vxIdSeccion = parseInt(vxSemanticInt.value);
              vxSeccionesNivel2(vxIdSeccion).click();
          }
      }
      return '1';

    }



function visualTexts() { 

    vxTTS.value = '';

    //Obtenemos el nombre de la seccion de nivel 1 elegida
    vxColumnaIzquierda = document.getElementById('colIzqsecc');
    vxSeccionNivel1 = vxColumnaIzquierda.getElementsByTagName('IMG')(0).alt;
    //Obtenemos los nombres de las secciones nivel 2 si hay mas de una
    vxSeccionesNivel2 = vxColumnaIzquierda.getElementsByTagName('A');
    vxSeccionesNivel2txt = '';
    for(i=1;i<vxSeccionesNivel2.length-1;i++) {
        vxSeccionNivel2 = vxSeccionesNivel2(i).innerText;
        vxSeccionesNivel2txt += vxSeccionNivel2 + '. ';
    }
    //Obtenemos los titulares de las noticias
    vxVarContenido = document.getElementById('contenido');
    vxNoticias = vxVarContenido.getElementsByTagName('A');
    vxTextoNoticias = '';
    for(i=0;i<vxNoticias.length;i++) {
        if (i == -1)
            i = vxNoticias.length;
        else {
              vxNoticia = vxNoticias(i).innerText;
              vxNum = i+1;
              vxTextoNoticias += 'Noticia ' + vxNum + ': ' + vxNoticia + '. ';
        }
     }
     
     vxTTS.value += vxSeccionNivel1 + '. Las secciones disponibles son: ';
     vxTTS.value += vxSeccionesNivel2txt + '. Las noticias de esta sección son: ';
     vxTTS.value += vxTextoNoticias;
     vxTTS.value += ' Recuerde que puede volver a activar el reconocimiento de voz diciendo, inicio. ';

    return vxTTS.value;

}



