var i=0;
var j=0;
var checked_val="";
var isNN,isIE;
if (parseInt(navigator.appVersion.charAt(0))>=4){
    isNN=(navigator.appName=="Netscape")?1:0;
    isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}
function postform(theForm) {
    theForm.method = "post";
    theForm.submit();
}
function SelRow(Fila,tipo) {
    /*if (tipo==1) Fila.height="100";
    else Fila.height="50";
    Fila.bgcolor="#FFFFFF";
    MousePointer = 4;*/

}
// funcion que verificia el PIN enviado para el minipago
function verificaPIN(ini,fin) {
    if (document.formulario.pin.value == '') {
        alert("Debe colocar el PIN recibido..");
        return;
    } else {
        if (document.formulario.pin.value != '897563') {
            alert("Su PIN es Invalido favor enviar su minimensaje al 3832 con la palabra LP, gracias..");
            return;
        }
    }
    alert("Su PIN es correcto, gracias por utilizar la Pulga Virtual!");
    return;
    var jspin=document.formulario.pin.value;
    var inidate=ini;
    var findate=fin;
    abreWindow('validaminimensaje.php?pin=' + jspin + '&inidate=' + inidate + '&findate=' + findate ,'','left=50,top=100,scrollbars=no,width=160,height=160');
    //alert('validaminimensaje.php?mobile=' + jsmobile + '&pin=' + jspin + '&inidate=' + inidate + '&findate=' + findate ,'','left=50,top=100,scrollbars=no,width=160,height=160');
}

// funcion que envia mensaje de duplicado al usuario
function msgduplicado(articulo) {
    if (confirm("Esta seguro de enviar este mensaje??")) {
        abreWindow('msgduplicado.php?op=le&id=$id&uid=$loged_uid&asunto=$articulomsg&estatus=$estatus','','left=50,top=100,scrollbars=yes,width=410,height=400');
        location.href="msgduplicado.php";
    }
}
// funcion que activas los campos opcionales para mobil y PIN
function activaopcionales(valor) {
    if (valor == 'N') {
      // document.formulario.mobil.disabled = true;
       document.formulario.pin.disabled = true;

    } else {
      // document.formulario.mobil.disabled = false;
       document.formulario.pin.disabled = false;
    }
  //  document.formulario.mobil.value = '';
    document.formulario.pin.value = '';
}
/*

controla el enter en el formulario
<script type="text/javascript">
function noenter() {
  return !(window.event && window.event.keyCode == 13); }
</script>
*/
// funcion que muestra y oculta lista en mi pulga
function muestraoculta(lista,label) {
var ocultar="Ocultar este listado";
var mostrar ="Mostrar este listado";
    if (document.getElementById(lista).style.display == 'none') {
        document.getElementById(label).innerHTML = ocultar;
        document.getElementById(lista).style.display='';
    } else {
        document.getElementById(label).innerHTML = mostrar;
        document.getElementById(lista).style.display='none';
    }
}
// funcion no blanco formulario olvida clave
function noblancoolvido(theForm) {
    if (theForm.tipo[0].checked) {
        if (theForm.usuario.value == "") {
            alert("Debe colocar su usuario para continuar ... ");
            return false;
        }
    } else {
        if (theForm.email.value != "") {
          if (!chequeaEmail(theForm.email.value)) return false;
        } else {
          alert("El email debe ser llenado!!");
          return false;
        }
    }
    if (confirm("Esta correcto?") == true) return true;
    else return false;
}
// funcion que cambia recueperar por
function recuperarpor(campo) {
    document.getElementById('filaemail').style.display='';
    document.getElementById('filausuario').style.display='';
    if (campo.value == 'u') document.getElementById('filaemail').style.display='none';
    else document.getElementById('filausuario').style.display='none';
}
//function que enciende el pais
function cambiaprovincia(campo) {
    if (campo.value != 40) {
        document.getElementById('pais').style.display='none';
        document.getElementById('sector').style.display='';
    } else {
        document.getElementById('pais').style.display='';
        document.getElementById('sector').style.display='none';
    }
}
function cambiatipoanuncio(campo) {
    if (document.formulario.tipotemp.value == 'S') {
        if (campo.value != 'S') {
            alert("Usted no puede cambiar de tipo de articulo esta subasta, gracias");
            document.formulario.tipo="S";
            return false;
        }
    }
    if(campo.value != 'S') {
        document.getElementById('preciominimo').style.display='none';
        document.getElementById('precioinicial').style.display='none';
        document.getElementById('duracionsubasta').style.display='none';
        document.getElementById('masinf').style.display='none';
        document.getElementById('lblprecio').innerHTML = 'Precio.:';
    } else {
        document.getElementById('masinf').style.display='';
        document.getElementById('preciominimo').style.display='';
        document.getElementById('precioinicial').style.display='';
        document.getElementById('duracionsubasta').style.display='';
        document.getElementById('lblprecio').innerHTML = 'Precio "Cómprelo Ahora".:';
        alert("Para las Subastas se debe tener en cuenta lo siguiente: \n\n" +
              "1- Los articulos que se coloquen deben ser individuales o lotes. \n" +
              "2- Si coloca un anuncio en subasta, al mismo tiempo no puede estar en Venta normal. \n" +
              "3- Si vende su articulo antes que acabe la subasta notifique a los que hayan pujado. \n" +
              "4- El encabezado del anuncio no puede ser algo como esto (ME VOY Y LO VENDO, ETC), o sera ELIMINADO. \n" +
              "5- Coloque precio de venta, minimo y valor inicial que sean justos. \n\n" +
              "Si deseas click en mas informacion \n" +
              "Ayudenos a servirles mejor, \nEquipo de La Pulga Virtual");
        //document.formulario.preciomini.value = 0;
        //document.formulario.precioinic.value = 0;
    }
    document.getElementById('lblnegociable').style.display = 'none';
    switch(campo.value) {
        case 'A':
          document.getElementById('lblprecio').innerHTML = 'Precio de Alquiler.:';
        break;
        case 'T':
          document.getElementById('lblprecio').innerHTML = 'Valor del Traspaso.:';
        break;
        case 'B':
          document.getElementById('lblprecio').innerHTML = 'Valor aproximado del cambio.:';
        break;
        case 'C':
          document.getElementById('lblprecio').innerHTML = 'Precio de Compra.:';
        break;
        case 'V':
          document.getElementById('lblprecio').innerHTML = 'Precio de Venta.:';
          document.getElementById('lblnegociable').style.display = '';
        break;
        case 'S':
    //    document.getElementById('lblnegociable').innerHTML = 'Muestra en detalle "Comprelo Ahora" hasta la primera puja <br>' +
          "<a href='#' onClick=abreWindow('subastaayuda.html','','left=50,top=100,scrollbars=yes,width=310,height=320');>¿Más información?</a>";
        break;
    }
}
// function que cambia los campos para el tipo de usuario
function cambiatipousuario(campo,nivel) {
    //document.getElementById('tipousuario').style.display='none';
    document.getElementById('nivel').style.display='none';
    document.getElementById('cedula').style.display='none';
    document.getElementById('rnc').style.display='none';
    document.getElementById('pais').style.display='none';
    document.getElementById('logo').style.display='none';
    document.getElementById('encabezado').style.display='none';
    document.getElementById('mapa').style.display='none';
    document.getElementById('tipotienda').style.display='none';
    if (parseInt(nivel) < 3) {
        // si es operador o administrador
       document.getElementById('tipousuario').style.display='';
       document.getElementById('nivel').style.display='';
    }
    switch(campo.value) {
        case '1':
           //document.getElementById('cedula').style.display='';
           break;
        case '2':
           document.getElementById('rnc').style.display='';
           break;
        case '3':
           document.getElementById('rnc').style.display='';
           document.getElementById('logo').style.display='';
           document.getElementById('encabezado').style.display='';
           document.getElementById('mapa').style.display='';
           document.getElementById('tipotienda').style.display='';
           break;
    }
}
// funcion llamada desde boton eliminar
function verificaEliminar(campo) {
//  validachequeados(mipulga);
//  if (j==0) {
//     alert("No hay seleccion a eliminar, trate de nuevo!!");
//     return false;
  //  } else if (confirm("Desea eliminar esta seleccion?") == true) return true;
//  else return false;
}
function nacionalidad(theForm) {
    if (theForm.nac.value != 1) {
        theForm.ced_serie.disabled = true;
        theForm.ced_numero.disabled = true;
        theForm.ced_digito.disabled = true;
    }
}
function validachequeados(theForm) {
    j=0;
    for(i=0;i < theForm.elements.length;i++) {
     if (theForm.elements[i].type == "checkbox"){
         if(theForm.elements[i].checked == true){
           j++;
           if (checked_val == "")
               checked_val=theForm.elements[i].value;
           else
               checked_val=theForm.elements[i].value + ", " + checked_val;
         }
     }
    } /* for */
    if (j==0) {
       alert("No hay selección a procesar, trate de nuevo!!");
       return false;
    } else if (confirm("Desea procesar esta seleccion?") == true) {
        theForm.chequeados.value = checked_val;
        return true;
    }   else return false;
}
function validaganados(theForm) {
    if (confirm("Desea procesar esta seleccion?") == true) return true;
    else return false;
}
function selsubcat(forma,campo) {
    if (campo.value == 0) alert("Debe seleccionar una Categoria!!");
    else forma.submit();
}
function ajustaImagen(){
    if (isIE) {
        alert("entra aqui");
        window.resizeTo(100,100);
        width=100-(document.body.clientWidth-document.images[0].width);
        height=100-(document.body.clientHeight-document.images[0].height);
        window.resizeTo(width,height);
    }
    if (isNN){
        window.innerWidth=document.images["George"].width;
        window.innerHeight=document.images["George"].height;
    }
}
// funcion que relista articulo del anunmanager
function relista(theForm,id,duracion) {
    if (confirm("Desea relistar este articulo tal como esta?") == true) {
        theForm.oprelista.value="Rel";
        theForm.relistar_id.value = id;
        theForm.duracion.value = duracion;
        theForm.submit();
    }
}
// funcion que retira articulo del anunmanager
function retira(url) {
    if (confirm("Desea procesar esta seleccion?") == true) {
        self.location.href=url;
    }
}
function abreImagen(theURL,titulo) {
  handle = window.open('about:blank','','scrollbars=no,left=50,top=10');
  with (handle.document) {
    writeln('<html><head><title>' + titulo + '</title><style>body{margin:0px;}</style>');
    writeln('<script>');
    writeln('var isNN,isIE;');
    writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0;');
    writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
    writeln('function ajustaImagen(){');
    writeln('if (isIE){');
    writeln('window.resizeTo(100,100);');
    writeln('width=100-(document.body.clientWidth-document.images[0].width);');
    writeln('height=100-(document.body.clientHeight-document.images[0].height);');
    writeln('window.resizeTo(width,height);}');
    writeln('if (isNN){');
    writeln('window.innerWidth=document.images["George"].width;');
    writeln('window.innerHeight=document.images["George"].height;}}');
    writeln('</script>');
    writeln('</head><body bgcolor=FFFFFF scroll="no" onload="ajustaImagen();" onblur="window.close();">');
    writeln('<img src="../guestbook/%27+theURL+%27" style="display:block"></body></html>');
    close();
  }
} // function abre imagen
function abreWindow(theURL,winName,features) {
    window.open(theURL,winName,features);
}
function noblancologin(theForm) {
   if (theForm.login.value == "") {
       alert("El login no puede estar en blanco, trata de nuevo!!");
       return false;
   }
}
function focus() {
//  alert(formlogin.login.value);
//  formlogin.login.SetFocus();
}
// funcion que valida pujas no en blanco
function validapuja(theForm,maximo,uid,logedid) {
    if (uid == logedid) {
        alert("Usted mismo no puede colocar puja para este articulo, gracias");
        return false;
    }
    if (theForm.uid.value == "0") {
        if (confirm("Usted no esta logeado para colocar una puja, presione Ok para logearse, Cancel para cancelar") == true) {
            location.href='login.php?id=detalles.php?id=' + theForm.id.value;
            return false;
        } else  return false;
    }
    if ((theForm.valorpuja.value == "") || (eval(theForm.valorpuja.value) <= eval(maximo))) {
        alert("Debe colocar un valor mayor de " + maximo + " para procesar esta puja..");
        return false;
    } else {
        if (confirm("Esta seguro de enviar este (" + theForm.valorpuja.value + ") valor como su puja?, pujadores irresponsables recibiran feedbacks negativos del ADMINISTRADOR, Gracias.") == true) return true;
        else return false;
    }

}
// fin -valida puja
function checkBusqueda(theForm) {
  if ((theForm.qrybuscar.value == "Empieza a buscar aqui") || (theForm.qrybuscar.value == "") ||
      (theForm.qrybuscar.value == "Sigue buscando aqui")) {
     alert("Debes de escribir lo que andas buscando en tu Pulga Virtual!!");
     return false;
  }
}
// valida formulario registar
function noblancoregistro(theForm) {
var user="";
var pos=0;
var msn="Estan todos los datos correctos?, Click Ok para enviar!!";
var clave = theForm.password.value;
var tipotienda = theForm.tipotienda.value;
  if (theForm.tipo.value == 3) {
        if (theForm.tipotienda.value == 0) {
           alert("Debe seleccionar la categora de la tienda");
           return false;
        }
  }
  if (theForm.usuario.value == "") {
     alert("El Usuario o Nick debe ser llenado sin espacios !!");
     return false;
  } else {
      user = theForm.usuario.value;
      pos = user.indexOf(" ");
      if (pos>0) {
          alert("El Usuario o Nick no puede contener espacios, Favor verifique y trate de nuevo!!");
          return false;
      }
      pos = user.indexOf("'");
      if (pos>0) {
          alert("El Usuario o Nick no puede contener comillas simples, Favor verifique y trate de nuevo!!");
          return false;
      }
      pos = user.indexOf("&");
      if (pos>0) {
          alert("El Usuario o Nick no puede contener este caracter (&), cambielo por otro y trate de nuevo!!");
          return false;
      }
      valor  = user.substring(0,1);
      if ((valor >= "0") && (valor <= "9")) {
          alert("El Usuario o Nick no puede empezar con numeros, verifique y trate de nuevo!!");
          return false;
      }
  }
  if (theForm.nombres.value == "") {
     alert("El Nombre debe ser llenado!!");
     return false;
  }
  if (theForm.apellidos.value == "") {
     alert("El Apellido debe ser llenado!!");
     return false;
  }
  if (theForm.password.value == "") {
     alert("La contrasena debe ser llenada!!");
     return false;
  }
  if (theForm.password2.value == "") {
     alert("La contrasena debe ser llenada!!");
     return false;
  }
  if (theForm.password.value != theForm.password2.value) {
     alert("Las contrasenas no coinciden, favor trate de nuevo!!");
     return false;
  }
  if (clave.length < 4) {
      alert("La clave debe contener por lo menos 4 caracteres de largo, trate de nuevo!!");
      return false;
  }
/*  if (theForm.rncclave.length < 4) {
      alert("La clave debe contener por lo menos 4 caracteres de largo, trate de nuevo!!");
      return false;
  }  */
  if (theForm.direccion1.value == "") {
     alert("La dirección debe ser llenada!!");
     return false;
  }

  if (theForm.provincia.value == 'none') {
     alert("Debe seleccionar una  Provincia!!");
     return false;
  }
  if (theForm.sector.value == 'none') {
     alert("Debe seleccionar un  Sector para esta provincia!!");
     return false;
  }
  if ((theForm.provincia.value == 40) && (theForm.pais.value == 0)) {
     alert("Debe seleccionar una Pais!!");
     return false;
  }
  if (theForm.email.value != "") {
      if (!chequeaEmail(theForm.email.value)) return false;
  } else {
      alert("El email debe ser llenado!!");
      return false;
  }
  if (theForm.email2.value != "") {
      if (!chequeaEmail(theForm.email2.value)) return false;
  } else {
      alert("El email debe ser llenado!!");
      return false;
  }
  if (theForm.email.value != theForm.email2.value) {
     alert("Los emails deben coincidir, favor trate de nuevo!!");
     return false;
  }
  if ((theForm.telefono1.value == "(999) 999-9999") || (theForm.telefono1.value == "(000) 000-0000") || (theForm.telefono1.value == "(111) 111-1111")) {
      theForm.telefono1.value = "";
  }
  if ((theForm.telefono2.value == "(999) 999-9999") || (theForm.telefono2.value == "(000) 000-0000") || (theForm.telefono2.value == "(111) 111-1111")) {
      theForm.telefono2.value = "";
  }
  if ((theForm.telefono3.value == "(999) 999-9999") || (theForm.telefono3.value == "(000) 000-0000") || (theForm.telefono3.value == "(111) 111-1111")) {
      theForm.telefono3.value = "";
  }
  /*if (theForm.telefono1.value == "") {
      alert("Debe poner por lo menos un telefono, si es celular coloquelo en ambos campos, gracias) !!");
      return false;
  }*/
  if (!theForm.terminos[0].checked) {
      alert("Debe leer los terminos y contestar correctamente!!");
      return false;
  }

  if (confirm(msn) == true) return true;
  else return false;
} /* checks */
// valida formulario de colocar anuncio
function noblanco(theForm) {
var msn="Estan todos los datos correctos?, Click Ok para enviar!!";
var precio = parseFloat(theForm.precio.value);
var preciomini = parseFloat(theForm.preciomini.value);
var precioinic = parseFloat(theForm.precioinic.value);

  if (theForm.tipo.value == '0') {
     alert("Debe seleccionar el tipo de anuncio (Venta, compra, subasta, alquiler, traspaso, etc.) !!");
     return false;
  }
  if ((theForm.tipo.value == 'S') && (theForm.duracion.value == '0')) {
     alert("Debe seleccionar duracion de esta subasta !!");
     return false;
  }
  if (theForm.categoria.value == 'none') {
     alert("Debe seleccionar una categoria!!");
     return false;
  }
  if (theForm.subcategoria.value == 'none') {
     alert("Debe seleccionar una Subcategoria!!");
     return false;
  }
  if (theForm.precio.value == "0" && theForm.negociable.checked == true) {
      alert("Debe poner precio de compra o venta para poder marcar como negociable!!");
      return false;
  }
  if (theForm.tipo.value == 'S') {
      if (!goodFloat(theForm.preciomini, "El precio minimo debe ser un numero en formato (XXX.XX) \n (no letras, comas, signos)!!")) return false;
      if (!goodFloat(theForm.precioinic, "El precio de la puja inicial debe ser un numero (XXX.XX) \n (no letras, comas, signos)!!")) return false;
      if (preciomini > precio) {
          alert("El precio de minimo debe ser menor que el precio de venta, favor verifique!!");
          return false;
      }
      if (precioinic > precio) {
          alert("El precio inicial debe ser menor que el precio de venta, por lo menos un 10%, favor verifique!!");
          return false;
      }
  }
  if (theForm.precio.value == 0) {
      alert("Debe poner precio para este artículo!!");
      return false;
  } else if (!goodFloat(theForm.precio, "El precio debe ser un numero en formato (XXX.XX) \n (no letras, comas, signos)!!")) return false;

  if (theForm.cantidad.value != "") {
      if (!goodInt(theForm.cantidad, "La cantidad debe ser numerica")) return false;
  }
  if (theForm.condicion.value == "0") {
      alert("Debe seleccionar alguna condicion del articulo!!");
      return false;
  }
  if (theForm.articulo.value == "") {
      alert("Debe llenar el encabezado del articulo!!");
      return false;
  }
  if (theForm.descripcion.value == "") {
      alert("Debe llenar la descripcion del articulo!!");
      return false;
  }
  if (theForm.cantfotos.value > 0) {
    // if (nonBlank(theForm.foto, "Please specify a file to upload")) return false;
  }
  if (!theForm.opcionales[0].checked) {
      if (theForm.pin.value == '') {
          alert("Usted ha seleccionado una opcion adicional, favor colocar el PIN recibido en su movil. \n" +
                "Luego de click en verifica PIN para confirmar y luego inserte el anuncio. \n" +
                "Si no envia el minimensaje su anuncio sera colocado normalmente, Gracias");
          return false;
      }
  }
/*  if (theForm.url.value != "") {
       if (goodURL(theForm.url, "Favor especificar una direccion URL valida")) {
           return false;
       }
  } */

  /*if (theForm.foto[0].value != "") {
      msn = "Si la foto es mayor de (100k=102400 bytes) será rechazada, favor verifica antes de enviar, sino Click Ok para enviar!!";
  } */
  return confirm(msn);
} /* checks */

function chequeaEmail(valor)
{
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(valor)) return true;
    else  {
        alert("Este no parece se una dirección de email válida, favor verifique!!");
        return false;
        }
}

// funcion que valida foto al entrar
function validafoto(foto) {
    alert(foto.value);
}
// fucnion para cantidad de fotos
function cantidadfotos(cantidad) {
var i = 1;
var hasta=parseInt(cantidad.value);
    for (i = 1;i<=6; i++) {
        document.getElementById('foto' + i).style.display='none';
    }
    for (i = 1;i<=hasta; i++) {
        document.getElementById('foto' + i).style.display='';
    }
}


// format phone numbers
function FormatNumber(num, format, shortformat)
{
    if(format==null)
    {
            // Choose the default format you prefer for the number.
        //format = "#-(###) ###-#### ";     // Telephone w/ LD Prefix and Area Code
        format = "(###) ###-#### ";         // Telephone w/ Area Code
        //format = "###-###-####";          // Telephone w/ Area Code (dash seperated)
        //format = "###-##-####";           //Social Security Number
    }
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
    if(shortformat==null)
    {
        // Choose the short format (without area code) you prefer.
        //If you do not want multiple formats, leave it as "".

        //var shortformat = "###-#### ";
        var shortformat = "";
    }

//---------------------------------------------------------------------------------------------------------------------
//----------------------------------------This code can be used to format any number. ---------------------------------
//----------------------------------------Simply change the format to a number format ---------------------------------
//---------------------------------------- you prefer. It will ignore all characters  ---------------------------------
//----------------------------------------  except the #, where it will replace with  ---------------------------------
//----------------------------------------               user input.                  ---------------------------------
//---------------------------------------------------------------------------------------------------------------------

    var validchars = "0123456789";
    var tempstring = "";
    var returnstring = "";
    var extension = "";
    var tempstringpointer = 0;
    var returnstringpointer = 0;
    count = 0;

    // Get the length so we can go through and remove all non-numeric characters
    var length = num.value.length;


    // We are only concerned with the format of the phone number - extensions can be left alone.
    if (length > format.length)
    {
        length = format.length;
    };

    // scroll through what the user has typed
    for (var x=0; x<length; x++)
    {
        if (validchars.indexOf(num.value.charAt(x))!=-1)
        {
        tempstring = tempstring + num.value.charAt(x);
        };
    };
    // We should now have just the #'s - extract the extension if needed
    if (num.value.length > format.length)
    {
        length = format.length;
        extension = num.value.substr(format.length, (num.value.length-format.length));
    };

    // if we have fewer characters than our short format, we'll default to the short version.
    for (x=0; x<shortformat.length;x++)
    {
        if (shortformat.substr(x, 1)=="#")
        {
            count++;
        };
    }
    if (tempstring.length <= count)
    {
        format = shortformat;
    };


    //Loop through the format string and insert the numbers where we find a # sign
    for (x=0; x<format.length;x++)
    {
        if (tempstringpointer <= tempstring.length)
        {
            if (format.substr(x, 1)=="#")
            {
                returnstring = returnstring + tempstring.substr(tempstringpointer, 1);
                tempstringpointer++;
            }else{
                returnstring = returnstring + format.substr(x, 1);
            }
        }

    }

    // We have gone through the entire format, let's add the extension back on.
        returnstring = returnstring + extension;

    //we're done - let's return our value to the field.
    num.value = returnstring;
}
// fin

//Format Phone Number 9999999999 = (999)999-9999
//Call the function like so onKeyPress="javascript:formatPhone(this);
function formatPhone(key, objFormField){
   intFieldLength = objFormField.value.length;
/*   if(intFieldLength == 3){
        objFormField.value = "(" + objFormField.value + ") ";
        return false;
        }*/
  if (key < 48 && key > 57) return true;
  if (key == 45) return true;
  if(intFieldLength >= 3 && intFieldLength <= 3){
      objFormField.value = objFormField.value + "-";
      return false;
  }
}
// format la cedula
function formatCedula(key, objFormField){
   intFieldLength = objFormField.value.length;
/*   if(intFieldLength == 3){
        objFormField.value = "(" + objFormField.value + ") ";
        return false;
        }*/
  if (key < 48 && key > 57) return true;
  if (key == 45) return true;
  if(intFieldLength >= 3 && intFieldLength <= 3){
      objFormField.value = objFormField.value + "-";
      return false;
  }
}
/* funcion que blanquea valores de un campo */
function blanquea(campo) {
   campo.value = "";
}
/* submit la forma para modificar items en el pago */

// funcion para el scroll principal de articulos
/*
* The arguments for this object are as follows:
*  a. - The variable name you are giving this scrollObject
*  b. - ID of the target tag (from step 1)
*  c. - Width (in pixels) of your scroller
*  d. - Height (in pixels) of your scroller
*  e. - Default background colour of the outer tag, can also be hexcode in the form: #rrggbb
*  f. - Scroll direction: one of "up", "down", "left" or "right"
*  g. - Decceleration index as block is moved (nominal range: 1 => 2)
*  h. - Initial speed of a block at beginning of slide:
*         Maximum speed as this value approaches one
*         Minimum speed as this value approaches scroller height
*  i. - Delay between each incremental movement upwards (milliseconds)
*  j. - Amount of time to pause before next scroll begins (milliseconds)
*  k. - CSS class name for blocks (from step 2)
*/
//var scrolltips = new scrollObject("scrolltips", "divtips", 464, 18, "#FFFFFF", "left", 1.37, 2.7, 30, 5000, "scrollClass");



function scrollObject(objName, main, width, height, bkgcol, direct, deccel, begin, speed, pause, classname) {
  this.objName = objName;
  this.main = main;
  this.one = main + "Block1";
  this.two = main + "Block2";
  this.block = new Array();
  this.blockup = 1;
  this.divup = 1;
  this.height = height;
  this.width = width;
  this.bkgcol = bkgcol;
  this.direct = direct;
  this.deccel = Math.max(deccel, 1);
  this.begin = Math.max(Math.min(begin, (direct == "up" || direct == "down") ? height : width), 1);
  this.speed = speed;
  this.pause = pause;
  this.slide = ((direct == "up" || direct == "down") ? height : width) / this.begin;
  this.table = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td class=\"" + classname + "\" style=\"width:" + width + "px;height:" + height + "px;\">";
  this.scroll = scroll;
  this.scrollLoop = scrollLoop;
}

function scroll() {
  if (!document.getElementById) return false;
  document.getElementById(this.main).innerHTML = "<div id=\"" + this.one + "\"></div><div id=\"" + this.two + "\"></div>";
  var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
  for (var i = 0; i <= 2; i++) {
    if (i > 0) {
      divList[i].style.position = "absolute";
      if (this.direct == "up" || this.direct == "down") {
        divList[i].style.left = "0px";
        divList[i].style.top = (i == 1) ? "0px" : ((this.direct == "up") ? "" : "-") + this.height + "px";
      } else {
        divList[i].style.left = (i == 1) ? "0px" : ((this.direct == "left") ? "" : "-") + this.width + "px";
        divList[i].style.top = "0px";
      } divList[i].innerHTML = this.table + this.block[i - 1] + "</td></tr></table>";
    } else {
      divList[i].style.position = "relative";
      divList[i].style.background = this.bkgcol;
    }
    divList[i].style.width = this.width + "px";
    divList[i].style.height = this.height + "px";
    divList[i].style.overflow = "hidden";
  } setTimeout(this.objName + ".scrollLoop();", this.pause);
}

function scrollLoop() {
  var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
  this.slide = Math.max(this.slide / this.deccel, 1);
  var slideInc = (this.direct == "up" || this.direct == "left") ? -parseInt(this.slide) : parseInt(this.slide);
  if ((this.direct == "up" && Math.max(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) <= 0) ||
      (this.direct == "down" && Math.min(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) >= 0) ||
      (this.direct == "left" && Math.max(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) <= 0) ||
      (this.direct == "right" && Math.min(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) >= 0)) {
    this.slide = ((this.direct == "up" || this.direct == "down") ? this.height : this.width) / this.begin;
    if (++this.blockup >= this.block.length) this.blockup = 0;
    this.divup = (this.divup == 1) ? 2 : 1;
    if (this.direct == "up" || this.direct == "down") {
      divList[3 - this.divup].style.top = ((this.direct == "down") ? "-" : "") + this.height + "px";
      divList[this.divup].style.top = "0px";
    } else {
      divList[3 - this.divup].style.left = ((this.direct == "right") ? "-" : "") + this.width + "px";
      divList[this.divup].style.left = "0px";
    } divList[3 - this.divup].innerHTML = this.table + this.block[this.blockup] + "</td></tr></table>";
    setTimeout(this.objName + ".scrollLoop();", this.pause);
  } else {
    for (var j = 1; j <= 2; j++) {
      if (this.direct == "up" || this.direct == "down") {
        divList[j].style.top = (parseInt(divList[j].style.top) + slideInc) + "px";
      } else divList[j].style.left = (parseInt(divList[j].style.left) + slideInc) + "px";
    } setTimeout(this.objName + ".scrollLoop();", this.speed);
  }
}
// fin scroll principal





/*
// funcion al salir

<script language=javascript>
<!--
var nohp = 0;

function hpe() {
  if (nohp == 1) {return;}
  if (document.cookie.indexOf("h=") == -1) {
    var exp = new Date();
    exp.setTime(exp.getTime()+(600));
    document.cookie = "h=1; expires=" + exp.toGMTString() + "; path=/;";
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage('http://www.searchguide.com');
    return 0;
    }
    var popurl="http://www.webbrowser.com/quotes.html"

    winpops=window.open(popurl,"","width=650,height=275,")

    if (!popurl.opener)
        popurl.opener = self;

}
//-->
</script>
*/


/*************** funcion que valida campos de entrada */
// Form Guard

// Copyright Xin Yang 2003, 2004
// Web Site: www.yxScripts.com
// EMail: m_yangxin@hotmail.com
// Last Updated: Sep-06-2005

// This script is free as long as the copyright notice remains intact.

// to consolidate all error messages
var totalAlert="";

// form submit counter
var submitCounter=0;

// regular expressions used by checking functions
var reNonBlank=/[\S]/;
var reHexColor=/^#[0-9a-fA-F]{6}$/;
var reInt=/^\d+$/;
var reSignedInt=/^(\+|-)?\d+$/;
var reFloat=/^\d+(\.\d+)?$/;
var reSignedFloat=/^(\+|-)?\d+(\.\d+)?$/;
var reChar=/^[\w\-]+$/;
var reEMail=/^\w[\w\-\.]+\@\w[\w\-]+(\.\w[\w\-]+)+$/;
var reIP=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
var rePostalCA=/^(\w\d){3}$/;
var reURL=/^http(s)?\:\/\/\w[\w\-]+(\.\w[\w\-]+)+([\/\%\?\&\+\#\.\w\-\=]+)*$/;

function rpChar(f) {
  var df=f;

  df=df.replace(/\\/g, '\\\\');
  df=df.replace(/\//g, '\\\/');
  df=df.replace(/\[/g, '\\\[');
  df=df.replace(/\]/g, '\\\]');
  df=df.replace(/\(/g, '\\\(');
  df=df.replace(/\)/g, '\\\)');
  df=df.replace(/\{/g, '\\\{');
  df=df.replace(/\}/g, '\\\}');
  df=df.replace(/\</g, '\\\<');
  df=df.replace(/\>/g, '\\\>');
  df=df.replace(/\|/g, '\\\|');
  df=df.replace(/\*/g, '\\\*');
  df=df.replace(/\?/g, '\\\?');
  df=df.replace(/\+/g, '\\\+');
  df=df.replace(/\^/g, '\\\^');
  df=df.replace(/\$/g, '\\\$');

  return df;
}

function rePhone(f) {
  var df=rpChar(f);

  df=df.replace(/d/gi, '\\d');
  df=df.replace(/w/gi, '(\\w|\\d)');

  return new RegExp('^'+df+'$');
}

function reDate(f) {
  var df=rpChar(f);

  df=df.replace(/dd/gi, '\\d\\d');
  df=df.replace(/mm/gi, '\\d\\d');
  df=df.replace(/yyyy/gi, '\\d\\d\\d\\d');

  return new RegExp('^'+df+'$');
}

function reCharNM(n,m) {
  return new RegExp("\^[\\w\\-]{"+n+","+m+"}\$");
}

function reNumberN(n,mode) {
  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{1,"+n+"}\$");
}

function reNumberN2(n,mode) {
  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{"+n+"}\$");
}

function reNumberNM(n,m,mode) {
  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{1,"+n+"}(\\.\\d{1,"+m+"})?\$");
}

function reNumberNM2(n,m,mode) {
  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{"+n+"}\\.\\d{"+m+"}\$");
}

// wrapper functions
function _checkValue(re, value, msg, mode) {
  if (!re.test(value)) {
    _alertIt(msg, mode);

    return (mode && mode==1)?true:false;
  }

  return true;
}

function _alertIt(msg, mode) {
  if (mode) {
    totalAlert+=msg+"\n";
  }
  else {
    totalAlert="";
    alert(msg);
  }
}

function _checkIt(re, field, msg, mode) {
  if (!re.test(field.value)) {
    _alertIt(msg, mode);

    if (field.select) {
      field.select();
    }
    if (field.focus) {
      field.focus();
    }

    return (mode && mode==1)?true:false;
  }

  return true;
}

function noErrors() {
  if (totalAlert=="") {
    return true;
  }
  else {
    alert(totalAlert);
    totalAlert="";
    return false;
  }
}

// the checking functions
function goodPasswords(field1, field2, msg1, msg2, mode) {
  if (nonBlank(field1, msg1, mode?2:0) && nonBlank(field2, msg1, mode?2:0)) {
    if (field1.value == field2.value) {
      return true;
    }
    else {
      _alertIt(msg2, mode);
    }
  }

  return (mode && mode==1)?true:false;
}

function goodPasswordsLen(field1, field2, n, m, msg1, msg2, msg3, mode) {
  if (nonBlank(field1, msg1, mode?2:0) && nonBlank(field2, msg1, mode?2:0)) {
    if (field1.value == field2.value) {
      if (goodCharLen(n, m, field1, msg3, mode?2:0)) {
        return true;
      }
    }
    else {
      _alertIt(msg2, mode);
    }
  }

  return (mode && mode==1)?true:false;
}

function goodEMails(field1, field2, msg1, msg2, mode) {
  if (goodEMail(field1, msg1, mode?2:0) && goodEMail(field2, msg1, mode?2:0)) {
    if (field1.value == field2.value) {
      return true;
    }
    else {
      _alertIt(msg2, mode);
    }
  }

  return (mode && mode==1)?true:false;
}

function goodEMail2(value, msg, mode) {
  return _checkValue(reEMail, value, msg, mode);
}

function goodMultiEMails(field, msg, mode) {
  var values = field.value.split(/\s*[,;]\s*/), allGood = reNonBlank.test(field.value);

  if (!allGood) {
    _alertIt(msg, mode);
  }

  for (var i = 0; i < values.length && allGood; i++) {
    if (reNonBlank.test(values[i])) {
      allGood = goodEMail2(values[i], msg, mode?2:0);
    }
  }

  return allGood?true:(mode && mode==1)?true:false;
}

function goodPhone(pf, field, msg, mode) {
  return _checkIt(rePhone(pf), field, msg, mode);
}

function goodPostalCA(field, msg, mode) {
  return _checkIt(rePostalCA, field, msg, mode);
}

function goodDate(df, field, msg, mode) {
  if (_checkIt(reDate(df), field, msg, mode?2:0)) {
    var di=field.value;
    var y4=df.search(/yyyy/i), y=di.substring(y4, y4+4)-0;
    var m2=df.search(/mm/i), m=di.substring(m2, m2+2)-1;
    var d2=df.search(/dd/i), d=di.substring(d2, d2+2)-0;

    var dd=new Date(y, m, d);
    if (y==dd.getFullYear() && m==dd.getMonth() && d==dd.getDate()) {
      return true;
    }
    else {
      _alertIt(msg, mode);

      field.select();
      field.focus();
    }
  }

  return (mode && mode==1)?true:false;
}

function goodIP(field, msg, mode) {
  return _checkIt(reIP, field, msg, mode);
}

function goodChar(field, msg, mode) {
  return _checkIt(reChar, field, msg, mode);
}

function goodEMail(field, msg, mode) {
  return _checkIt(reEMail, field, msg, mode);
}

function goodInt(field, msg, mode) {
  return _checkIt(reInt, field, msg, mode);
}

function goodSignedInt(field, msg, mode) {
  return _checkIt(reSignedInt, field, msg, mode);
}

function goodFloat(field, msg, mode) {
  return _checkIt(reFloat, field, msg, mode);
}

function goodSignedFloat(field, msg, mode) {
  return _checkIt(reSignedFloat, field, msg, mode);
}

function goodIntLen(n, field, msg, mode) {
  return _checkIt(reNumberN(n,0), field, msg, mode);
}

function goodSignedIntLen(n, field, msg, mode) {
  return _checkIt(reNumberN(n,1), field, msg, mode);
}

function goodIntLen2(n, field, msg, mode) {
  return _checkIt(reNumberN2(n,0), field, msg, mode);
}

function goodSignedIntLen2(n, field, msg, mode) {
  return _checkIt(reNumberN2(n,1), field, msg, mode);
}

function goodCharLen(n, m, field, msg, mode) {
  return _checkIt(reCharNM(n,m), field, msg, mode);
}

function goodFloatLen(n, m, field, msg, mode) {
  return _checkIt(reNumberNM(n,m,0), field, msg, mode);
}

function goodSignedFloatLen(n, m, field, msg, mode) {
  return _checkIt(reNumberNM(n,m,1), field, msg, mode);
}

function goodFloatLen2(n, m, field, msg, mode) {
  return _checkIt(reNumberNM2(n,m,0), field, msg, mode);
}

function goodSignedFloatLen2(n, m, field, msg, mode) {
  return _checkIt(reNumberNM2(n,m,1), field, msg, mode);
}

function _rangeIt(field, r1, r2, msg, mode) {
  if (field.value>=r1 && field.value<=r2) {
    return true;
  }
  else {
    _alertIt(msg, mode);

    field.select();
    field.focus();

    return (mode && mode==1)?true:false;
  }
}

function rangeInt(field, r1, r2, msg, mode) {
  if (goodInt(field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeSignedInt(field, r1, r2, msg, mode) {
  if (goodSignedInt(field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeFloat(field, r1, r2, msg, mode) {
  if (goodFloat(field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeSignedFloat(field, r1, r2, msg, mode) {
  if (goodSignedFloat(field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeIntLen(n, field, r1, r2, msg, mode) {
  if (goodIntLen(n, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeSignedIntLen(n, field, r1, r2, msg, mode) {
  if (goodSignedIntLen(n, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeIntLen2(n, field, r1, r2, msg, mode) {
  if (goodIntLen2(n, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeSignedIntLen2(n, field, r1, r2, msg, mode) {
  if (goodSignedIntLen2(n, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeFloatLen(n, m, field, r1, r2, msg, mode) {
  if (goodFloatLen(n, m, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeSignedFloatLen(n, m, field, r1, r2, msg, mode) {
  if (goodSignedFloatLen(n, m, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeFloatLen2(n, m, field, r1, r2, msg, mode) {
  if (goodFloatLen2(n, m, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function rangeSignedFloatLen2(n, m, field, r1, r2, msg, mode) {
  if (goodSignedFloatLen2(n, m, field, msg, mode?2:0)) {
    return _rangeIt(field, r1, r2, msg, mode);
  }

  return (mode && mode==1)?true:false;
}

function _dd(n) {
  return (n<10)?"0"+n:""+n;
}

function _getOffset(n) {
  var d=new Date();
  if (n!=0) {
    d.setTime(d.getTime()+n*86400000);
  }
  return d.getFullYear()+""+_dd(d.getMonth()+1)+""+_dd(d.getDate())+"";
}

function _stringIt(df, d) {
  var y4=df.search(/yyyy/i), m2=df.search(/mm/i), d2=df.search(/dd/i);
  return d.substring(y4, y4+4)+d.substring(m2, m2+2)+d.substring(d2, d2+2);
}

function rangeDate(df, field, r1, r2, msg, mode) {
  if (goodDate(df, field, msg, mode?2:0)) {
    var d=_stringIt(df, field.value);

    var r1x="", r2x="";
    if (r1.search(/^\d+$/)!=-1) {
      r1x=_getOffset(r1-0);
    }
    else {
      r1x=_stringIt(df, r1);
    }
    if (r2.search(/^\d+$/)!=-1) {
      r2x=_getOffset(r2-0);
    }
    else {
      r2x=_stringIt(df, r2);
    }

    if (d<r1x || d>r2x) {
      _alertIt(msg, mode);

      field.select();
      field.focus();
    }
    else {
      return true;
    }
  }

  return (mode && mode==1)?true:false;
}

function goodDateRange(df, field1, field2, msg, mode) {
  if (goodDate(df, field1, msg, mode?2:0) && goodDate(df, field2, msg, mode?2:0)) {
    if (_stringIt(df, field1.value)>_stringIt(df, field2.value)) {
      _alertIt(msg, mode);
      field1.focus();
    }
    else {
      return true;
    }
  }

  return (mode && mode==1)?true:false;
}

function goodDateRange2(df, field1, field2, msg, mode) {
  if (goodDate(df, field1, msg, mode?2:0) && goodDate(df, field2, msg, mode?2:0)) {
    if (_stringIt(df, field1.value)>=_stringIt(df, field2.value)) {
      _alertIt(msg, mode);
      field1.focus();
    }
    else {
      return true;
    }
  }

  return (mode && mode==1)?true:false;
}

function goodHexColor(field, msg, mode) {
  return _checkIt(reHexColor, field, msg, mode);
}

function nonBlank(field, msg, mode) {
  if (field.type) {
    if (/file|select|text|password/.test(field.type)) {
      return _checkIt(reNonBlank, field, msg, mode);
    }
    else if (/radio|checkbox/.test(field.type)) {
      if (field.checked) {
        return true;
      }
      else {
        _alertIt(msg, mode);
        field.focus();
        return (mode && mode==1)?true:false;
      }
    }
    else {
      _alertIt("Invalid field for nonBlank() checking", mode);
      return (mode && mode==1)?true:false;
    }
  }
  else if (field.length && field[0].type && /radio|checkbox/.test(field[0].type)) {
    for (var i=0; i<field.length; i++) {
      if (field[i].checked) { return true; }
    }

    _alertIt(msg, mode);
    field[0].focus();
    return (mode && mode==1)?true:false;
  }
  else {
    _alertIt("Invalid field for nonBlank() checking", mode);
    return (mode && mode==1)?true:false;
  }
}

function goodRadioedFields(form, fn, re, msgs, msg, mode) {
  for (var i=0; i<form[fn].length; i++) {
    if (form[fn][i].checked) {
      return _checkIt(re, form[form[fn][i].value], msgs[i], mode);
    }
  }

  _alertIt(msg, mode);
  return (mode && mode==1)?true:false;
}

function goodRadioedFields2(form, fn, re, msgs, msg, mode) {
  for (var i=0; i<form[fn].length; i++) {
    if (form[fn][i].checked) {
      return _checkIt(re[i], form[form[fn][i].value], msgs[i], mode);
    }
  }

  _alertIt(msg, mode);
  return (mode && mode==1)?true:false;
}

function noBadWords(field, strict, words, msg, mode) {
  var lw=[], nwb=strict?'':'\\b';
  for (var i=0; i<words.length; i++) {
    lw[i]=nwb+words[i].toLowerCase()+nwb;
  }

  var re=new RegExp(lw.join("|"), "i");
  if (re.test(field.value)) {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;
  }
  else {
    return true;
  }
}

// credit card checking codes taken from Netscape LivePayment samples codes and modified to fit Form Guard
function goodCreditCard(field, msg, mode) {
  var sum=0, mul=1, l=field.value.length;
  var digit, tproduct;

  if (_checkIt(reInt, field, msg, mode?2:0)) {
    for (var i=0; i<l; i++) {
      digit=field.value.substring(l-i-1,l-i);
      tproduct=parseInt(digit ,10)*mul;
      if (tproduct>=10) {
        sum+=(tproduct%10)+1;
      }
      else {
        sum+=tproduct;
      }

      if (mul==1) {
        mul++;
      }
      else {
        mul--;
      }
    }

    if ((sum%10)==0) {
      return true;
    }
    else {
      _alertIt(msg, mode);
      return (mode && mode==1)?true:false;
    }
  }
}

function goodVisa(field, msg, mode) {
  if ((field.value.length==16 || field.value.length==13) && field.value.substring(0,1)==4) {
    return goodCreditCard(field, msg, mode);
  }
  else {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;
  }
}

function goodMasterCard(field, msg, mode) {
  var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2);
  if (field.value.length==16 && firstdig==5 && (seconddig>=1 && seconddig<=5)) {
    return goodCreditCard(field, msg, mode);
  }
  else {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;;
  }
}

function goodAmericanExpress(field, msg, mode) {
  var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2);
  if (field.value.length==15 && firstdig==3 && (seconddig==4 || seconddig==7)) {
    return goodCreditCard(field, msg, mode);
  }
  else {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;;
  }
}

function goodDinersClub(field, msg, mode) {
  var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2);
  if (field.value.length==14 && firstdig==3 && (seconddig==0 || seconddig==6 || seconddig==8)) {
    return goodCreditCard(field, msg, mode);
  }
  else {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;;
  }
}

function goodCarteBlanche(field, msg, mode) {
  return goodDinersClub(field, msg, mode);
}

function goodDiscover(field, msg, mode) {
  var first4digs=field.value.substring(0,4);
  if (field.value.length==16 && first4digs=="6011") {
    return goodCreditCard(field, msg, mode);
  }
  else {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;;
  }
}

function goodEnRoute(field, msg, mode) {
  var first4digs=field.value.substring(0,4);
  if (field.value.length==15 && (first4digs=="2014" || first4digs=="2149")) {
    return goodCreditCard(field, msg, mode);
  }
  else {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;;
  }
}

function goodJCB(field, msg, mode) {
  var first4digs=field.value.substring(0,4);
  if (field.value.length==16 && (first4digs=="3088" || first4digs=="3096" || first4digs=="3112" || first4digs=="3158" || first4digs=="3337" || first4digs=="3528")) {
    return goodCreditCard(field, msg, mode);
  }
  else {
    _alertIt(msg, mode);
    return (mode && mode==1)?true:false;;
  }
}

function notSubmitted(msg) {
  if (submitCounter==0) {
    submitCounter=1;
    return true;
  }
  else {
    alert(msg);
    return false;
  }
}

function goodURL(field, msg, mode) {
  return _checkIt(reURL, field, msg, mode);
}
