/**
* Funciones de utilería
*/

/*
 * Divide un texto en renglones separados con la cadena <br>, sólo en Internet Explorer.
 * Comprime múltiples espacios en blanco en uno sólo.
 */
/* ATS: Utilizada cuando se mostraba la microayuda y el metadato en el hint */
function wr(txt) {
  txt = txt.replace(/[ ]+/g, " "); // comprime múltiples espacios en blanco en uno sólo

  var max = 50; // longitud máxima de un renglón
  var tt_db = (document.compatMode && document.compatMode != 'BackCompat')? document.documentElement : document.body? document.body : null,
      tt_n = navigator.userAgent.toLowerCase();
  var tt_ie = tt_n.indexOf('msie') != -1 && document.all && tt_db && !tt_op;

  if ( ! tt_ie) {
    return txt; // regresa el texto original si no es Internet Explorer
  }

  var txtwrapped = "";
  for (i = 0; i < txt.length; i += max) {
    var renglon = txt.substring(i,i+max);
    //alert("renglon "+i+"=*"+renglon+"*");

    var last = renglon.lastIndexOf(" ");
    if (last == -1) {
      txtwrapped += renglon;
    } else {
      if (i+max > txt.length) { // ultimo renglon
        txtwrapped += renglon;
      } else {
        txtwrapped += renglon.substring(0,last);
        txtwrapped += "<br>";
        txtwrapped += renglon.substring(last);
      }
    }
  }

  return txtwrapped;
} // wr

