// Borrar texto defecto input de un form
   function clearText(thefield){
    if (thefield.defaultValue==thefield.value)
    thefield.value = ""
   } 

// Cerrar ventana automaticamente
   function cerrar() {
    window.close();
   }

// Abrir ventana nueva
   function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
   }

// Confirma acción
   function confirmar ( mensaje ) {
   return confirm( mensaje );
   }

// Devuelve texto defecto input de un form
   function myBlur(element) {
     if (element.value == '') {
       element.value = element.defaultValue;
     }
   }
   
// Codifica el texto a UTF8
   function utf8_encode (argString) {   
    var utftext = "";
    var start, end;
    var stringl = 0; 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);    }
 
    return utftext;
   } 
