










/// 
/// @param obj referencia al objeto SELECT
/// 
/// @return valor seleccionado
function getValorSelect(obj) {
    if (!obj) {
        alert('No existe el objeto SELECT');
    } else if (obj.selectedIndex == -1) {
        //alert('No hay ninguna opción seleccionada');
    } else {
        return obj.options[obj.selectedIndex].value;
    }
    return false;
}




function getValorRadio(nombre) {
    var radios = YAHOO.util.Selector.query('input', 'subcontenedor_'+nombre);

    if (!radios || !radios.length) {
        return false;
    }

    var i;
    for (i in radios) {
        if (radios[i].checked) {
            return radios[i].value;
        }
    }

    return false;
}








// Abre la ventana del calendario
function calendario(dia,mes,ano) {
   valmes = eval(mes).value;
   valano = eval(ano).value;

	winVar = window.open('/calendario/calendarioNormal.php?oD='+dia+'&oM='+mes+'&oA='+ano+'&mes='+valmes+'&ano='+valano, 'Calendario', 'width=290,height=200,toolbar=0,menubar=0,scrollbars=0,resizable=0,status=0,location=0');
   if (winVar) { winVar.focus(); }
}






















// ***************************************************************
//                                VALIDACIONES
// ***************************************************************




// Valida que se ingrese un valor
// Para <select> no funciona
function validaRequerido(obj, nombre) {
    // trim
    var txt = obj.value.replace(/^\s+|\s+$/g,"");

    //-- Valido que se ingrese algo ---------------

    if (txt.length == 0) {
        if (obj && obj.style.display != 'none') {
            obj.focus();
        }
        alert("Debe ingresar '" + nombre + "'");
        return false;
    } else {
        return true;
    }
}








// Valida algunos aspectos del código HTML
function validaHTML(obj, nombre) {
    if (obj.value.indexOf('file://') != -1) {
        return confirm("'" + nombre + "' posee referencias (file://) a archivos locales de su computador que no se verán en internet\n¿Desea ignorar este error?");
    }

    return true;

}






// Valida el ingreso de un string
function validaLargo(obj, nombre, requerido, min, max) {
    //-- Valido que se ingrese algo ---------------

    if (!obj || obj.disabled) {
      return true;
    }


    if (obj.value == undefined) {
      return true;
    }


    // trim
    var txt = obj.value.replace(/^\s+|\s+$/g,"");
    // Reemplazos fin de linea \n por \r\n con el fin de maximizar
    // el conteo de caracteres utilizados
    txt = txt.replace(/\n/g, '\r\n');
    txt = txt.replace(/\r\r\n/g, '\r\n');



    if (txt.length == 0 && requerido) {
        if (!obj.style || obj.style.display != 'none') {
            obj.focus();
        }
        alert("Debe ingresar '" + nombre + "'");
        return false;
    }
    //-- Valido el largo minimo ---------------
    if (txt.length != 0 && txt.length < min) {
        if (!obj.style || obj.style.display != 'none') {
            obj.focus();
        }
        alert("'" + nombre + "' debe tener al menos " + min + " caracteres.\nActualmente posee " + txt.length);
        return false;
    }
    //-- Valido el largo maximo ---------------
    if (max && txt.length > max) {
        if (!obj.style.display != 'none') {
            obj.focus();
        }
        alert("'" + nombre + "' debe tener como máximo " + max + " caracteres.\nActualmente posee " + txt.length);
        return false;
    }
    return true;
}





// Valida el ingreso de un email
function validaEmail(obj, nombre) {
    // Valida la sintaxis correcta del email
    // si el largo es 0 se considera que la sintaxis es correcta
    if (obj.value.length > 0 && (obj.value.indexOf('@') == -1 || obj.value.indexOf('.') == -1)) {
        obj.focus();
        alert("'" + nombre + "' debe ser de la forma usuario@servidor.dominio");
        return false;
    } else {
        return true;
    }
}






 
// Valida el ingreso de un valor en el select
function validaSelect(obj, nombre) {
    if (!obj) {
        //alert("No existe el Objeto '" + nombre + "'");
        return true;
    }
    if (obj.disabled) {
        return true;
    }

    if (obj.selectedIndex == -1 || getValorSelect(obj) == '\tNULL') {
        obj.focus();
        alert("Debe seleccionar al menos una opcion de '" + nombre + "'");
        return false;
    }
    return true;
}




/*
 * Verifica que el archivo especificado (formulario: obj),
 * tenga alguna de las extensiones espeficicadas
 * Es case insensitive
 */
function validaExtensiones(obj, nombre, extensiones) {
    // Si no hay archivo especificado, retorno true
    if (obj.value.length == 0)
        return true;

    // Flag que especifica si la extension es aceptada
    correcto = false;

    // Obtengo la extension del archivo
    ultimoPunto = obj.value.lastIndexOf('.');
    extension = obj.value.substr(ultimoPunto).toUpperCase();

    // Itero por todas las extensiones validas
    // verificando si la extensión del arrchivo corresponde
    for (i = 0; i < extensiones.length; i++)
        {
        if (extension == extensiones[i].toUpperCase())
            correcto = true;
        }

    if (!correcto)
        {
        obj.focus();
        if (extensiones.length == 1)
            alert("'" + nombre + "' debe tener la extensión " + extensiones[0]);
        else
            alert("'" + nombre + "' debe tener alguna de las extensiones: " + extensiones);

        return false;
        }
    else
        return true;
    }








// Busca si el valor de obj está en el select objSelect.
// Si se encuentra, se selecciona el select y se borra el campo
// de texto. Para la búsqueda del valor en el select, se ignoran
// los espacios iniciales y finales de ambos strings a comparar (trim)
function validaNoEnSelect(obj, nombre, objSelect) {
    if (obj.value == '') {
        return true;
    }
    pos = buscaTextoEnSelect(objSelect, obj.value);
    if (pos != -1) {
        alert("Ya existe '" + obj.value + "' en '" + nombre + "'.\nSe seleccionará dicha opción.");
        obj.value = '';
        objSelect.selectedIndex = pos;
        objSelect.focus();
        return false;
    } else {
        return true;
    }
}












/**
 * Realiza la comparación de 2 password, si no son iguales, borra
 * su valor y muestra un alert
 *
 * @param p1 Referencia al objeto 1
 * @param p2 Referencia al objeto 2
 * @param nombre String con el nombre del campo
 * @return true o false de acuerdo a si son iguales o distintos
 */
function comparaPassword(p1, p2, nombre) {
    if (p1.value != p2.value) {
        p1.value = "";
        p2.value = "";
        p1.focus();
        alert("'" + nombre + "' no coincide, ingreselo nuevamente");
        return false;
    } else {
        return true;
    }
}





/**
 * valida que el valor del objeto sea un número entero
 *
 * @param obj Referencia al objeto
 * @param nombre String con el nombre del campo
 * @return true/false
 */
function validaInt(obj, nombre) {
    if (obj.value == '') {
        return true;
    }
    var numero = parseInt(obj.value, 10);
    if (isNaN(numero) || ' ' + numero != ' ' + obj.value) { // Comparación de strings
        obj.focus();
        alert("'" + nombre + "' debe ser un número entero");
        return false;
    } else {
        return true;
    }
}






/**
 * valida que el valor del objeto sea un número real
 *
 * @param obj Referencia al objeto
 * @param nombre String con el nombre del campo
 * @return true/false
 */
function validaFloat(obj, nombre) {
    if (obj.value == '') {
        return true;
    }
    var numero = parseFloat(obj.value, 10);
    if (isNaN(numero) || ' ' + numero != ' ' + obj.value) { // Comparación de strings
        obj.focus();
        alert("'" + nombre + "' debe ser un número");
        return false;
    } else {
        return true;
    }
}





// Valida que el objeto posea un numero máximo de enteros y decimales
function validaDecimales(obj, nombre, maxEnteros, maxDecimales) {
    if (obj.value == '') {
        return true;
    }


   pos = obj.value.indexOf('.');
   
   if (pos == -1) {
      nDecimales = 0;
      nEnteros   = obj.value.length;
   } else {
      decimales = obj.value.substr(pos);
      nDecimales = decimales.length-1;
      nEnteros   = obj.value.length - nDecimales - 1;
   }



   if (nEnteros > maxEnteros) {
      if (!obj.style || obj.style.display != 'none') {
         obj.focus();
      }
      alert("'" + nombre + "' no puede poseer mas de " + maxEnteros + " dígitos enteros");
      return false;
   }




   if (nDecimales > maxDecimales) {
      if (!obj.style || obj.style.display != 'none') {
         obj.focus();
      }
      alert("'" + nombre + "' no puede poseer mas de " + maxDecimales + " decimales");
      return false;
   }



}










/**
 * valida que el valor del objeto no sea mayor que 'max'
 *
 * @param obj Referencia al objeto
 *
 * @param nombre String con el nombre del campo
 *
 * @param max valor máximo que puede tener el objeto
 *
 * @return true/false
 */
function validaValorMax(obj, nombre, max) {
    if (obj.value == '') {
        return true;
    }
    
    // Compatibilidad con autonumero
    if (obj.getAttribute && obj.getAttribute('autonumerotipo')) {
      var numero = form_autonumero_getvalor(obj);
    } else {
      var numero = parseFloat(obj.value, 10);
      if (isNaN(numero)) {
        obj.focus();
        alert("'" + nombre + "' debe ser numérico");
        return false;
      }
    }
    
    
    if (numero > max) {
        if (!obj.style || obj.style.display != 'none') {
           obj.focus();
        }
        alert("'" + nombre + "' debe ser menor o igual a " + max);
        return false;
    } else {
        return true;
    }
}














/**
 * valida que el valor del objeto no sea menor que 'min'
 *
 * @param obj Referencia al objeto
 * @param nombre String con el nombre del campo
 * @param min valor mínimo que puede tener el objeto
 *
 * @return true/false
 */
function validaValorMin(obj, nombre, min) {
    if (obj.value == '') {
        return true;
    }
    
    
    // Compatibilidad con autonumero
    if (obj.getAttribute && obj.getAttribute('autonumerotipo')) {
      var numero = form_autonumero_getvalor(obj);
    } else {
      var numero = parseFloat(obj.value, 10);
      if (isNaN(numero)) {
        obj.focus();
        alert("'" + nombre + "' debe ser numérico ");
        return false;
      }
    }

    
    
    if (numero < min) {
        if (!obj.style || obj.style.display != 'none') {
            obj.focus();
        }
        alert("'" + nombre + "' debe ser mayor o igual a " + min);
        return false;
    } else {
        return true;
    }
}










 
// MES entre 1 y 12
// Valida una fecha
/**
 * Valida que una fecha sea válida
 * Si esUNIX es true, se validará que el año pertenezca a [1902 - 2037]
 * 
 * @bugs
 * Tiene problemas para browsers antiguos (3.x) o alternativos
 * 
 * FALTA:
 * Si esUNIX=false, acepta un rango mayor de fechas, debe definirse correctamente
 * el rango de años válidos a aceptar
 */
function validaFecha(nombre, objDia, objMes, objAno, esUNIX) {
    ano = objAno.value;
    mes = getValorSelect(objMes);
    dia = objDia.value;

    // Si es fecha UNIX valido que sea entre 1902-2037
    if (esUNIX)
        esUNIX = true;
    else
        esUNIX = false;

    var mesModifi=parseInt(mes,10)- 1;

    if(ano.length+mes.length+dia.length>0) {
        var newDateObj = new Date(parseInt(ano,10), parseInt(mesModifi,10),parseInt(dia,10));
        if (ano.length == 0 && dia.length == 0 && parseInt(mes, 10) == 1) {
            objDia.focus();
            alert("Debe ingresar '" + nombre + "'");
            return false;
        }
        if(esUNIX && parseInt(ano,10) < 1902) {
            objAno.focus();
            alert("'" + nombre + "' debe ser igual o superior al año 1902");
            return false;
        }
        if(esUNIX && parseInt(ano,10) > 2037) {
            objAno.focus();
            alert("'" + nombre + "' no debe ser superior al año 2037");
            return false;
        }
        if(isNaN(newDateObj) || parseInt(ano,10) < 1902 || parseInt(newDateObj.getFullYear(),10)!=parseInt(ano,10) || (parseInt(newDateObj.getMonth(),10))!=parseInt(mesModifi,10) || parseInt(newDateObj.getDate(),10)!=parseInt(dia,10)) {
            objDia.focus();
            alert("La fecha: " + dia + "/" + mes + "/" + ano + " (" + nombre + ") es inválida\nVerifique que el año tenga 4 digitos y que\nel día y mes pertenezcan a un rango válido");
            return false;
        }
    }
    return true;
}



function validaIP (IP, Nombre) { 
errorString = ""; 
theName = "Error en "+Nombre; 

IPvalue= myTrim(IP.value);

var ipArray=IPvalue.split(".");

if (IPvalue == "0.0.0.0") {
  errorString = errorString + theName + ': '+IPvalue+' es una dirección ip especial y no puede ser usada acá'; 
}
else if (IPvalue == "255.255.255.255") {
  errorString = errorString + theName + ': '+IPvalue+' es una dirección ip especial y no puede ser usada acá'; 
}

if (!ipArray||!ipArray[0]||!ipArray[1]||!ipArray[2]||!ipArray[3]||ipArray.length>4) {
  errorString = errorString + theName + ': '+IPvalue+' no es una dirección IP valida'; 
}
else { 
  for (i = 0; i < 4; i++) { 
    thisSegment = ipArray[i]; 
    if (thisSegment > 255 || thisSegment < 0) { 
      errorString = errorString + theName + ': '+IPvalue+' no es una dirección IP valida'; 
      i = 4; 
    } 
  } 
} 

extensionLength = 3; 
if (errorString == "") {
  return true
}

alert (errorString); 
return false;
} 






// ***************************************************************
//                        MANEJO DE STRINGS
// ***************************************************************


 

// Transforma el valor del objeto a un número entero
function soloNumeros(obj) {
    numero = parseInt(obj.value, 10);
    if (! numero > 0)
        numero = 0;
    obj.value = numero;
}





// Transforma el valor del objeto a un número con decimales
function soloFloat(obj) {

    // Reemplazo las comas por puntos
    numero = '';
    tope = obj.value.length;
    for (i = 0; i < tope; i++) {
        c = obj.value.charAt(i);
        if (c == ',')
            numero = numero + '.';
        else
            numero = numero + c;
    }

    numero = parseFloat(numero, 10);
    if (! numero > 0)
       numero = 0;
    obj.value = numero;
}



function charValidos(obj, nombre) {

   var cValidos = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";  // ñÑáéíóúüÁÉÍÓÚ";
   var s = obj.value;

   for (i = 0; i < s.length; i++)  {   
      // Revisa si cada caracter es válido
      var c = s.charAt(i);

      if (cValidos.indexOf(c) == -1) {
         alert (nombre+' posee caracteres no válidos');
         if (!obj.style || obj.style.display != 'none') {
             obj.focus();
         }
         return false;
      }
    }
    return true;
}




function charValidosPwd(obj, nombre) {

   var cValidos = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ* ";  // ñÑáéíóúüÁÉÍÓÚ";
   var s = obj.value;

   for (i = 0; i < s.length; i++)  {   
      // Revisa si cada caracter es válido
      var c = s.charAt(i);

      if (cValidos.indexOf(c) == -1) {
        if (!obj.style || obj.style.display != 'none') {
            obj.focus();
        }
        alert (nombre+' posee caracteres no válidos');
        return false;
      }
    }
    return true;
}


function charValidosNom(obj, nombre) {

   var cValidos = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ñÑáéíóúüÁÉÍÓÚ'.";
   var s = obj.value;

   for (i = 0; i < s.length; i++)  {   
      // Revisa si cada caracter es válido
      var c = s.charAt(i);

      if (cValidos.indexOf(c) == -1) {
         if (!obj.style || obj.style.display != 'none') {
            obj.focus();
         }
         alert (nombre+' posee caracteres no válidos');
         return false;
      }
    }
    return true;
}







// Le quita los puntos a un string
function quitaPuntos(obj) {
    tope = obj.value.length;
    numero = '';

    for (i = 0; i < tope; i++) {
        c = obj.value.charAt(i);
        if (c != '.')
            numero = numero + c;
    }
    obj.value = numero;
}




 
// Quita los espacios anteriores y finales
function myTrim(string) {
    var i;
    var str;
    var tope;
    var c;

    str = '';
    tope = string.length;
    saca = true;
    for (i = 0; i < tope; i++) {
        c = string.charAt(i);
        if (!(c == ' ' && saca)) {
            str = str + c;
            saca = false;
        }
    }
    string = str;
    str = '';

    tope = string.length;
    saca = true;
    for (i = tope-1; i >= 0; i--) {
        c = string.charAt(i);
        if (!(c == ' ' && saca)) {
            str = c + str;
            saca = false;
        }
    }

    return str;
}



// ***************************************************************
//                     ACTIVACION DE CAMPOS
// ***************************************************************


// Define una variable que indica si el browser soporta
// las características javascript avanzadas del mantenedor
app = navigator.appName;
ver = parseInt(navigator.appVersion, 10);

//alert(app + ", " + ver + "\n" + navigator.appVersion);


if (
    (app.indexOf('MSIE') != -1 || (app.indexOf('Microsoft Internet Explorer') != -1) && ver > 3) ||
    (app.indexOf('Konqueror') != -1 && ver > 4) ||
    (app.indexOf('Netscape') != -1 && ver > 4)
   ) {
    isOld = false;
} else {
    isOld = true;
}













// Activa y desctiva un objeto de formulario

function inactiva(obj) {
    if (!obj) { return; }

    if (isOld) {
        obj.value = '---';
    } else {
        obj.disabled=true;
        YAHOO.util.Dom.removeClass(obj, "campo-mantenedor-activo");
        YAHOO.util.Dom.addClass(obj,    "campo-mantenedor-inactivo");
        /*
        if (obj.style)
            obj.style.backgroundColor="#dddddd";
            */
    }
}


function activa(obj) {
    if (!obj) { return; }

    if (isOld) {
        if (obj.value == '---')
            obj.value = '';
    } else {
        obj.disabled=false;
        YAHOO.util.Dom.addClass(obj,    "campo-mantenedor-activo");
        YAHOO.util.Dom.removeClass(obj, "campo-mantenedor-inactivo");
        /*
        if (obj.style)
            obj.style.backgroundColor="#ffffff";
            */
    }
}




function activaM(el, name) {
   eval("activa("+el+".campo_"+name+"_text)");
   eval("activa("+el+".campo_"+name+")");
   eval("activa("+el+".campo2_"+name+")");
   eval("activa("+el+".aux_campo_"+name+")");
   eval("activa("+el+".campo_VISIBLE_"+name+")");
   eval("activa("+el+".campo_AGREGAR_"+name+")");
   eval("activa("+el+".campo_"+name+"_DIA)");
   eval("activa("+el+".campo_"+name+"_MES)");
   eval("activa("+el+".campo_"+name+"_ANO)");
   eval("activa("+el+".campo_"+name+"_HOR)");
   eval("activa("+el+".campo_"+name+"_MIN)");
   eval("activa("+el+".campo_"+name+"_SEG)");
   eval("activa("+el+".campo_DV_"+name+")");
}

function inactivaM(el, name) {
   eval("inactiva("+el+".campo_"+name+"_text)");
   eval("inactiva("+el+".campo_"+name+")");
   eval("inactiva("+el+".campo2_"+name+")");
   eval("inactiva("+el+".aux_campo_"+name+")");
   eval("inactiva("+el+".campo_VISIBLE_"+name+")");
   eval("inactiva("+el+".campo_AGREGAR_"+name+")");
   eval("inactiva("+el+".campo_"+name+"_DIA)");
   eval("inactiva("+el+".campo_"+name+"_MES)");
   eval("inactiva("+el+".campo_"+name+"_ANO)");
   eval("inactiva("+el+".campo_"+name+"_HOR)");
   eval("inactiva("+el+".campo_"+name+"_MIN)");
   eval("inactiva("+el+".campo_"+name+"_SEG)");
   eval("inactiva("+el+".campo_DV_"+name+")");
}










// Indica si el browser soporta <IFRAME>
function soportaiframe() {
   app = navigator.appName;
   ver = parseInt(navigator.appVersion, 10);

   if (
       (app.indexOf('MSIE') != -1 || (app.indexOf('Microsoft Internet Explorer') != -1) && ver > 3) ||
       (app.indexOf('Netscape') != -1 && ver > 4)
      ) {
       return true;
   } else {
       return false;
   }
}




















// ***************************************************************
//                                NAVEGACION
// ***************************************************************

 
/// 
/// Carga la URL especificada en el documento actual.
/// A la URL se le agrega una porció aleatoria para no tener
/// problemas con caches
/// 
function cargaPagina(url) {
    urlExtra = "basura_" + Math.random() + "=1";

    if (url.indexOf("?") != -1)
        url = url + "&" + urlExtra;
    else
        url = url + "?" + urlExtra;

    document.location = url;
}





/// 
/// Carga la URL especificada en el documento actual.
/// A la URL se le agrega una porció aleatoria para no tener
/// problemas con caches. Recibe un segundo parámetro
/// en el que se especifica el frame o ventana en que se cargará
/// 
function cargaPaginaEn(url, target) {
    urlExtra = "basura_" + Math.random() + "=1";

    if (url.indexOf("?") != -1)
        url = url + "&" + urlExtra;
    else
        url = url + "?" + urlExtra;

    target.location = url;
}





// ***************************************************************
//                           OTROS
// ***************************************************************

 
/**
 * 
 * Busca si el valor 'valor' está en el select
 * 
 * 
 */
function buscaTextoEnSelect(obj, valor) {
    var tope;
    var txt;
    var i;

    tope = obj.options.length;
    valor = myTrim(valor);
    for (i = 0; i < tope; i++) {
        txt = myTrim(obj.options[i].text);
        if (valor.toUpperCase() == txt.toUpperCase()) {
            return i;
        }
    }
    return -1;
}









/**
 *
 * Deja en blanco el campo
 * Hay que validar los tipos de datos aquí procesados
 *
 * Hasta ahora han sido validados: text, int, relacion, lista, password, memo, fecha
 *                                  
 * jos: 2004-8-3
 * 
 */
function mantenedor_limpia(form, nombre, tipo, subtipo) {
   obj = eval("document."+form+"."+nombre);


   // Valido que exista el objeto
   // En algunos tipos de campo no existe este objeto
   if (!obj && tipo != 'fecha') {
      //alert('No existe el objeto ' + nombre);
      return;
   }



   switch (tipo) {
      case 'funcion':
      case 'htmlarea':
      case 'fckeditor':
      case 'multirelacion':
      case 'file':
      case 'checkbox':
      case 'nub':
         alert('No se pueden borrar los datos del campo ' + nombre);
      break;

      case 'lista':
      case 'relacion':
         if (subtipo == 'select') {
            obj.selectedIndex = 0;
         }
         if (subtipo == 'radio') {
            // Dejo marcado siempre el primero
            obj[0].checked = true;
            /*
            for (i = 0; i < obj.length; i++) {
               obj[i].checked = false;
            }
            */
         }
         if (subtipo == 'popup') {
            obj2 = eval("document."+form+".campo_VISIBLE_"+nombre.substr(6));
            obj2.value = '';
         }
         if (subtipo == 'checkbox') {
            alert('No se pueden borrar los datos del campo ' + nombre);
         }

      break;

      case 'password':
         obj.value = '';
         // El campo de validación del password comienza con 'campo2_' en vez de 'campo_'
         obj2 = eval("document."+form+".campo2_"+nombre.substr(6));
         obj2.value = '';
      break;

      case 'fecha':
         obj2 = eval("document."+form+".campo_DIA_"+nombre.substr(6)); if (obj2) { obj2.value = ''        };
         obj2 = eval("document."+form+".campo_MES_"+nombre.substr(6)); if (obj2) { obj2.selectedIndex = 0 };
         obj2 = eval("document."+form+".campo_ANO_"+nombre.substr(6)); if (obj2) { obj2.value = ''        };
         obj2 = eval("document."+form+".campo_HOR_"+nombre.substr(6)); if (obj2) { obj2.value = ''        };
         obj2 = eval("document."+form+".campo_MIN_"+nombre.substr(6)); if (obj2) { obj2.value = ''        };
         obj2 = eval("document."+form+".campo_SEG_"+nombre.substr(6)); if (obj2) { obj2.value = ''        };
      break;

      case 'rut':
         obj.value = '';
         // El campo del digito verificador comienza con 'campo_DV_' en vez de 'campo_'
         obj2 = eval("document."+form+".campo_DV_"+nombre.substr(6));
         obj2.value = '';
      break;

      default:
         obj.value = '';
   }
}









/**
 * Recibe un elemento HTML (ejemplo: "SELECT") y al atributo
 * especificado le aplica el valor
 * 
 */
function recorreObjetos(tag, atributo, valor) {
   if (!document.all) { return; }

   objArray = document.all.tags(tag);
   for (i=0; i<objArray.length; i++) {
      tCommand = "objArray[i]." + atributo + " = '" + valor + "'";
      eval(tCommand);
   }
}



/**
 * Recibe un elemento HTML (ejemplo: "SELECT") y al atributo
 * especificado le aplica el valor
 * 
 */
function recorreObjetosDocumento(tag, atributo, valor, doc) {
   if (!doc.all) { return; }

   objArray = doc.all.tags(tag);
   for (i=0; i<objArray.length; i++) {
      tCommand = "objArray[i]." + atributo + " = '" + valor + "'";
      eval(tCommand);
   }

}























/**
 * 
 * Recibe la URL a cargar y la función que se llamará
 * durante el proceso de carga
 * 
 * La función se llamará 4 veces. Cuando se cumpla (xmlhttp.readyState == 4)
 * significa que la página ha sido cargada satisfactoriamente.
 * 
 */
function mantenedor_get(url, funcion) {
   if (document.all)  {
     var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } else {
     var xmlhttp = new XMLHttpRequest();
   }

   if (xmlhttp) {
      xmlhttp.open("GET", url);
      xmlhttp.onreadystatechange = funcion;
      xmlhttp.send("");
   }
   
}





