function validarDatosCliente() //se puede mandar como parametro el modulo
{
        with(document.frmDatosCliente)     
        {
            if(txtUsuario.value == "")
            { 
                alert('¡Ingrese el usuario de acceso');  
                txtUsuario.focus(); 
                txtUsuario.style.background="#FFF0F0"; 
                return; 
            }
            
            if(txtClave.value == "")  
            { 
                alert('¡Ingrese su Contraseña'); 
                txtClave.focus(); 
                txtClave.style.background="#FFF0F0"; 
                return; 
            }
            
            submit();
        }
    
}



function validarInformacionCliente()
{
    with(document.frmInformacion)
    {

        if(txt_usuario.value == ""){ 
            alert('¡Ingrese su Nombre de Usuario '); txt_usuario.focus(); txt_usuario.style.background="#FFF0F0"; return; }                        

        if(txt_clave.value == ""){ 
            alert('¡Ingrese su Clave '); txt_clave.focus(); txt_clave.style.background="#FFF0F0"; return; }

        if(txt_clave.value.length < 6){ 
        alert("Escriba por lo menos 6 caracteres en el campo CLAVE"); txt_clave.focus(); txt_clave.style.background="#FFF0F0"; return; }

                        
        if(txt_clave_rep.value == ""){
            alert('¡Ingrese Nuevamente su Clave'); txt_clave_rep.focus(); txt_clave_rep.style.background="#FFF0F0"; return; }
            
        if(txt_clave_rep.value.length < 6){ 
        alert("Escriba por lo menos 6 caracteres en el campo REESCRIBIR CLAVE"); txt_clave_rep.focus(); txt_clave_rep.style.background="#FFF0F0"; return; }
            
        
        if(txt_clave.value != txt_clave_rep.value){ 
            alert('¡Las Claves NO son iguales');
            txt_clave.value='';
            txt_clave_rep.value='';
            txt_clave.focus();
            return; }            
        
        
        if(txt_correo.value == ""){
            alert('¡Ingrese su Email'); txt_correo.focus(); txt_correo.style.background="#FFF0F0"; return; }
        else 
        {
            if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt_correo.value))
            {} 
            else 
            {    alert ('La dirección de email es incorrecta.');    txt_correo.focus(); txt_correo.style.background="#FFF0F0"; return;
            }
        } 

        
        if(txt_nombre.value == ""){ 
        
            alert('¡Ingrese su Nombre o Razón Social');  txt_nombre.focus(); txt_nombre.style.background="#FFF0F0"; return; }
            
        if(txt_nif.value == ""){ 
            alert('¡Ingrese su NIF/CIF '); txt_nif.focus(); txt_nif.style.background="#FFF0F0"; return; }

        if(txt_direccion.value == ""){ 
            alert('¡Ingrese su Dirección ');  txt_direccion.focus(); txt_direccion.style.background="#FFF0F0"; return; }

        if(txt_telefono.value == "" ){
            alert('¡Ingrese su Teléfono '); txt_telefono.focus(); txt_telefono.style.background="#FFF0F0"; return; }
        else 
        {
          if (txt_telefono.value.length <9 )
            {alert('¡Recuerde el Teléfono consta de 9 números. Gracias '); txt_telefono.focus(); txt_telefono.style.background="#FFF0F0"; return; }
        }


        if(txt_codigo_postal.value == ""){
            alert('¡Ingrese su Código Postal'); txt_codigo_postal.focus(); txt_codigo_postal.style.background="#FFF0F0"; return; }
        else 
        {
          if (txt_codigo_postal.value.length <5 )
            {alert('¡Recuerde el Código Postal deber ser de 5 caracteres. Gracias '); txt_codigo_postal.focus(); txt_codigo_postal.style.background="#FFF0F0"; return; }
        }

        if(txt_poblacion.value == ""){ 
            alert('¡Ingrese su Población'); txt_poblacion.focus(); txt_poblacion.style.background="#FFF0F0"; return; }
            
        if(txt_provincia.value == ""){
            alert('¡Ingrese su Provincia'); txt_provincia.focus(); txt_provincia.style.background="#FFF0F0"; return; }


        if(txt_direccion_entrega.value == ""){
            alert('¡Ingrese su Domicilio de Entrega'); txt_direccion_entrega.focus(); txt_direccion_entrega.style.background="#FFF0F0"; return; }

        if(txt_telefono_entrega.value == ""){
            alert('¡Ingrese su Teléfono de Entrega '); txt_telefono_entrega.focus();  txt_telefono_entrega.style.background="#FFF0F0"; return; }                        
        else 
        {
          if (txt_telefono_entrega.value.length <9 )
            {alert('¡Recuerde el Teléfono consta de 9 números. Gracias '); txt_telefono_entrega.focus(); txt_telefono_entrega.style.background="#FFF0F0"; return; }
        }

        if(txt_codigo_postal_entrega.value == ""){
            alert('¡Ingrese su Código Postal de Entrega'); txt_codigo_postal_entrega.focus(); txt_codigo_postal_entrega.style.background="#FFF0F0"; return; }
        else 
        {
          if (txt_codigo_postal_entrega.value.length <5 )
            {alert('¡Recuerde el Código Postal del Entrega deber ser de 5 caracteres. Gracias '); txt_codigo_postal_entrega.focus(); txt_codigo_postal_entrega.style.background="#FFF0F0"; return; }
        }

        if(txt_poblacion_entrega.value == ""){ 
            alert('¡Ingrese su Población de Entrega'); txt_poblacion_entrega.focus(); txt_poblacion_entrega.style.background="#FFF0F0"; return; }
            
        if(txt_provincia_entrega.value == ""){
            alert('¡Ingrese su Provincia de Entrega'); txt_provincia_entrega.focus(); txt_provincia_entrega.style.background="#FFF0F0"; return; }
    
        if(!chk_acepto.checked){
                        chk_acepto.focus();
                        alert("Para darse de alta como usuario registrado debe marcar la casilla aceptando las Condiciones de uso.");       
                        return;
        }
        /*
        if(txt_pais.value != "ESPAÑA"){
            alert('¡Sólo se ACEPTAN COMPRAS en territorio español !'); txt_pais.focus(); txt_pais.style.background="#FFF0F0"; return; }
        */
 
        submit();
    }
}

function seleccionar_empresa()
{
    if (document.frmInformacion.slt_empresa.value==1)      
    {
         document.frmInformacion.txt_direccion_entrega.value="";
         document.frmInformacion.txt_poblacion_entrega.value="";
         document.frmInformacion.txt_provincia_entrega.value="";
         document.frmInformacion.txt_codigo_postal_entrega.value="";
         document.frmInformacion.txt_telefono_entrega.value="";
         document.frmInformacion.txt_direccion_entrega.focus();
    }
        
    if (document.frmInformacion.slt_empresa.value==2)  
   { 
     document.frmInformacion.txt_direccion_entrega.value       = document.frmInformacion.txt_direccion.value;
     document.frmInformacion.txt_poblacion_entrega.value       = document.frmInformacion.txt_poblacion.value;
     document.frmInformacion.txt_provincia_entrega.value       = document.frmInformacion.txt_provincia.value;
     document.frmInformacion.txt_codigo_postal_entrega.value   = document.frmInformacion.txt_codigo_postal.value;
     document.frmInformacion.txt_telefono_entrega.value        = document.frmInformacion.txt_telefono.value;
   }
}

function validarCampo(evento,patron)
{

    tecla = (document.all) ? evento.keyCode : evento.which;

    //tecla =  8 => retroceso (para borrar) 
    //tecla =  9 y 0 =>  (para tabulador) 
    if (tecla==8 || tecla==9 || tecla==0 || tecla==13 || tecla==27) return true;  

    te = String.fromCharCode(tecla);
    if (patron.test(te))
    {
        return  true;
    }
    else
    {
        alert("\nEl dato introducido [ "+te+" ]  NO es v\u00E1lido.\n\n\tIntente de nuevo");
        return false;
    }
}

//************************************************************************************************************************************
//Funcion añadida el 10/09/2010
// Funcion que es llamada al momento que se presiona sobre el boton "PAGAR CON TARJETA DE CREDITO"
//************************************************************************************************************************************
function pasarela_tarjeta_credito() 
{
   vent = window.open('','tpv','width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no');
   document.frm_compra.submit();   
}

function pasarela_contrareembolso(var_total)
{ 
    if (var_total<100)
    {
        var_gastos_transportista = 5;
        var_total +=var_gastos_transportista; 
    }
    else
    {
        var_gastos_transportista = var_total*0.05
        var_gastos_transportista = redondeo2decimales(var_gastos_transportista); 
        var_total += var_gastos_transportista;
        var_total = redondeo2decimales(var_total);
    }
    
    if (confirm('Para realizar este Tipo de Pago(CONTRA REEMBOLSO), tendr\u00e1 que pagar por Gastos de Gesti\u00f3n de la Agencia de Transporte un importe de '+var_gastos_transportista+' euros \n\n El Total a pagar ser\u00e1 de '+var_total+' euros \n\n\t\t\t ¿ Aceptar el pedido m\u00e1s los Gastos de Gesti\u00f3n del Transportista ?'))
    { 
      document.frm_documento_contra_reembolso.submit()
    } 
}

function redondeo2decimales(numero)
{
    var original=parseFloat(numero);
    var result=Math.round(original*100)/100 ;
    return result;
}

/**
*   function validar_campo(evento,patron)
*   Funcion que permite verificar la pulsacion de la tecla, capturado por el evento onkeypress(evento) y recoge el patron de la 
*   expresion regular que enviamos
*/
function validar_campo(evento,patron)
{

    tecla = (document.all) ? evento.keyCode : evento.which;

    //tecla =  8 => retroceso (para borrar) 
    //tecla =  9 y 0 =>  (para tabulador) 
    if (tecla==8 || tecla==9 || tecla==0 || tecla==13 || tecla==27) return true;  

    te = String.fromCharCode(tecla);
    if (patron.test(te))
    {
        return  true;
    }
    else
    {
        alert("\nEl dato introducido [ "+te+" ]  NO es v\u00E1lido.\n\n\tIntente de nuevo");
        return false;
    }
}

function cuponesVerificar()
{
     valor= document.getElementById("txt_cupon").value;
     if(valor == '')
     {
         alert("Ingrese el codigo del cupon que se le envio a su Email");
         document.getElementById("txt_cupon").focus();
         return false;
     }

    $.post('./index.php?s=cupon&m=verificar&codigoCupon='+valor, function(data)
    {                    
        var aValores    = data.split('|');
        aValores[0]     = core__sanitizeText(aValores[0]);
        
        if( (aValores[0]==='true') || (aValores[0]===true) )
        {                    
            alert(aValores[1]);
        }
        else
        {
            alert(aValores[1]);
        }
    });
    
}

function validarUpdateInformacionCliente()
{
    with(document.frmInformacion)
    {
        if(txt_nombre.value == ""){ 
            alert('¡Ingrese su Nombre o Razón Social');  txt_nombre.focus(); txt_nombre.style.background="#FFF0F0"; return; }
            
        if(txt_nif.value == ""){ 
            alert('¡Ingrese su NIF/CIF '); txt_nif.focus(); txt_nif.style.background="#FFF0F0"; return; }

        if(txt_direccion.value == ""){ 
            alert('¡Ingrese su Dirección ');  txt_direccion.focus(); txt_direccion.style.background="#FFF0F0"; return; }

        if(txt_telefono.value == "" ){
            alert('¡Ingrese su Teléfono '); txt_telefono.focus(); txt_telefono.style.background="#FFF0F0"; return; }
        else 
        {
          if (txt_telefono.value.length <9 )
            {alert('¡Recuerde el Teléfono consta de 9 números. Gracias '); txt_telefono.focus(); txt_telefono.style.background="#FFF0F0"; return; }
        }

        if(txt_codigo_postal.value == ""){
            alert('¡Ingrese su Código Postal'); txt_codigo_postal.focus(); txt_codigo_postal.style.background="#FFF0F0"; return; }
        else 
        {
          if (txt_codigo_postal.value.length <5 )
            {alert('¡Recuerde el Código Postal deber ser de 5 caracteres. Gracias '); txt_codigo_postal.focus(); txt_codigo_postal.style.background="#FFF0F0"; return; }
        }

        if(txt_poblacion.value == ""){ 
            alert('¡Ingrese su Población'); txt_poblacion.focus(); txt_poblacion.style.background="#FFF0F0"; return; }
            
        if(txt_provincia.value == ""){
            alert('¡Ingrese su Provincia'); txt_provincia.focus(); txt_provincia.style.background="#FFF0F0"; return; }


        if(txt_direccion_entrega.value == ""){
            alert('¡Ingrese su Domicilio de Entrega'); txt_direccion_entrega.focus(); txt_direccion_entrega.style.background="#FFF0F0"; return; }

        if(txt_telefono_entrega.value == ""){
            alert('¡Ingrese su Teléfono de Entrega '); txt_telefono_entrega.focus();  txt_telefono_entrega.style.background="#FFF0F0"; return; }                        
        else 
        {
          if (txt_telefono_entrega.value.length <9 )
            {alert('¡Recuerde el Teléfono consta de 9 números. Gracias '); txt_telefono_entrega.focus(); txt_telefono_entrega.style.background="#FFF0F0"; return; }
        }

        if(txt_codigo_postal_entrega.value == ""){
            alert('¡Ingrese su Código Postal de Entrega'); txt_codigo_postal_entrega.focus(); txt_codigo_postal_entrega.style.background="#FFF0F0"; return; }
        else 
        {
          if (txt_codigo_postal_entrega.value.length <5 )
            {alert('¡Recuerde el Código Postal del Entrega deber ser de 5 caracteres. Gracias '); txt_codigo_postal_entrega.focus(); txt_codigo_postal_entrega.style.background="#FFF0F0"; return; }
        }

        if(txt_poblacion_entrega.value == ""){ 
            alert('¡Ingrese su Población de Entrega'); txt_poblacion_entrega.focus(); txt_poblacion_entrega.style.background="#FFF0F0"; return; }
            
        if(txt_provincia_entrega.value == ""){
            alert('¡Ingrese su Provincia de Entrega'); txt_provincia_entrega.focus(); txt_provincia_entrega.style.background="#FFF0F0"; return; }
    
        submit();
    }
}
function validarUpdateUsuarioClaveCliente()
{
    with(document.frmCambiarUsuarioClave)
    {
        if(txt_usuario.value == ""){ 
            alert('¡Ingrese su Nombre de Usuario '); txt_usuario.focus(); txt_usuario.style.background="#FFF0F0"; return; }                        
        if(txt_clave1.value == ""){ 
            alert('¡Ingrese su Clave '); txt_clave1.focus(); txt_clave1.style.background="#FFF0F0"; return; }
        if(txt_clave1.value.length < 6){ 
            alert("Escriba por lo menos 6 caracteres en el campo CLAVE"); txt_clave1.focus(); txt_clave1.style.background="#FFF0F0"; return; }
        if(txt_clave2.value == ""){
            alert('¡Ingrese Nuevamente su Clave'); txt_clave2.focus(); txt_clave2.style.background="#FFF0F0"; return; }
        if(txt_clave2.value.length < 6){ 
            alert("Escriba por lo menos 6 caracteres en el campo REESCRIBIR CLAVE"); txt_clave2.focus(); txt_clave2.style.background="#FFF0F0"; return; }
        if(txt_clave1.value != txt_clave2.value){ 
            alert('¡Las Claves NO son iguales'); txt_clave1.focus(); return; }            
        if(txt_email.value == ""){
            alert('¡Ingrese su Email'); txt_email.focus(); txt_email.style.background="#FFF0F0"; return; }
        else 
        {
            if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt_email.value))
            {} 
            else 
            {    alert ('La dirección de email es incorrecta.');    txt_email.focus(); txt_email.style.background="#FFF0F0"; return;
            }
        } 

        submit();
    }    
}


function popup_cofidis(pagina)
{
    window.open(pagina,"Fisioterapia","width=368, height=550, scrollbars=no, menubar=no, location=no, resizable=no, left=300, top=120");
}
/*********************************************************************************************************************************
*
**********************************************************************************************************************************/
function popup_cofidis_informacion(pagina)
{
    window.open(pagina,"Fisioterapia","width=620, height=550, scrollbars=yes, location=no, resizable=no, left=100, top=120");
}

function mantenerDiv(div)
{
    $.post('./index.php?s=familias&m=mostrarDivFamilia&idFamilia='+div, function(data)
    {
        var aValores = data.split('|');
        aValores[0] = core__sanitizeText(aValores[0]);
        if( (aValores[0]===true) || (aValores[0]==='true') )
        { 
            //alert("Div  : "+aValores[1]);            
        }
    });
}


function pasarela_paypal() 
{
   vent = window.open('','paypal','width=900,height=700,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no');
   document.frm_paypal.submit();   
}
