var usu = Array('', '', '', '', '', '');

function copiaDatosRmt(va) {
  var XX = document.getElementsByClassName("fld_rmte");
  var YY = document.getElementsByClassName("fld_usuario");

  for (x = 0; x < XX.length; x++)
   if (va.checked) {
     usu[x] = YY[x].value;
     YY[x].value = XX[x].value;
    }
   else
    YY[x].value = usu[x];
 }

function limpia(className) {
  var XX = document.getElementsByClassName(className);

  for (x = 0; x < XX.length; x++)
   XX[x].value = "";
  $("copiarDatos").checked = false;
 }

function limpiaMSG(id) {
  if ($(id).value.length > 1) {
    id = id.replace("mail", "rut");
    $(id + "MSG").innerHTML = "&nbsp;";
   }
 }

function cargaDatos(rutId, capa) {
  var rut = $(rutId);
  if (rut.value != "") {
    var rutX = rut.value;
    if (!Rut(rutX, rutId)) {
      setTimeout("document.getElementById('" + rutId + "').focus();", 1);
      setTimeout("document.getElementById('" + rutId + "').select();", 1);
      new Effect.Highlight($(rutId), {
                                      startcolor:'#FF0000',
                                      endcolor:'#FFDDDD',
                                      duration: 1
                                     }
                          );
      $(rutId + "MSG").innerHTML = "ERROR, RUT incorrecto"
     }
   }
 }

function enter(e) {
  if (e.which == 13 || e.keyCode == 13)
   return true;
  else
   return false;
 }

function validaFrm() {
  var errorMsg = "Faltan campos obligatorios\n\n";
  if ($F("id_rmt_fono") == "")
   errorMsg += "- Fono del remitente\n";
  if ($F("id_rmt_nombre") == "")
   errorMsg += "- Nombre del remitente\n";
  if ($F("id_rmt_mail") == "")
   errorMsg += "- Correo del remintente\n";
/*
  if ($F("factura_proximo") == "")
   errorMsg += "- Fono para la factura\n";
  if ($F("id_fac_giro") == "")
   errorMsg += "- Giro para la factura\n";
  if ($F("id_fac_razonsocial") == "")
   errorMsg += "- Razon Social\n";
  if ($F("id_fac_direccion") == "")
   errorMsg += "- Direccion para la factura\n";
  if ($F("fac_ciudad") == "")
   errorMsg += "- Ciudad para la factura\n";
  if (getCheckedValue(document.forms['frm_equipo'].elements['dispositivo']) == "")
   errorMsg += "- Tipo de dispositivo\n";
  else
   if (getCheckedValue(document.forms['frm_equipo'].elements['dispositivo']) == "otro")
    if ($F("otroInfo") == "")
     errorMsg += "- Tipo de dispositivo [otro]\n";
  if ($F("descripcion") == "")
   errorMsg += "- Descripcion del problema\n";
*/
  if (getCheckedValue(document.forms['frm_equipo'].elements['conocido']) == "")
   errorMsg += "- Como llegó a Kepler\n";
  else
   if (getCheckedValue(document.forms['frm_equipo'].elements['conocido']) == "otro2")
    if ($F("otroInfo2") == "")
     errorMsg += "- Como llegó a Kepler [otro]\n";

  if (errorMsg == "Faltan campos obligatorios\n\n")
   $("id_equipo").submit();
  else {
    errorMsg += "\nDebe llenar estos campos obligatoriamente antes de enviar el formulario.";
    alert(errorMsg);
   }
 }

 function verEsconderDetalles() {
   var hides = document.getElementsByClassName("invisibles");
   for (hh = 0; hh < hides.length; hh++)
    hides[hh].toggle();
   $("botonCambiaVistaM").toggle();
   $("botonCambiaVistaE").toggle();
  }