<script type="text/javascript">
	
var getBrowserInfo = function() {
    var ua= navigator.userAgent, tem, 
    M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
    if(/trident/i.test(M[1])){
        tem=  /\brv[ :]+(\d+)/g.exec(ua) || [];
        return 'IE '+(tem[1] || '');
    }
    if(M[1]=== 'Chrome'){
        tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
        if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
    }
    M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
    if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
    return M.join(' ');
};

if (getBrowserInfo().substr(0,5)==="Firef")
{
   
}else{
    $('#fecha1').datepicker({
        language: "es",
        calendarWeeks: true,
        autoclose: true,
        todayHighlight: true,
        format: "yyyy-mm-dd"
    });
    $('#fecha2').datepicker({
        language: "es",
        calendarWeeks: true,
        autoclose: true,
        todayHighlight: true,
        format: "yyyy-mm-dd"
    });
}

$("#juris").on("change", evalua);
$("#tipo_sucursal").on("change", evalua);
$("#nivel_atencion").on("change", evalua);

function evalua()
{
	var $juris = $("#juris").val();
	var $tipo_sucursal = $("#tipo_sucursal").val();
	var $nivel_atencion = $("#nivel_atencion").val();
	sucusales($juris, $tipo_sucursal, $nivel_atencion);
}

function sucusales($juris, $tipo_sucursal, $nivel_atencion)
{
    var $url = '<?php echo site_url('cliente/getSucursales'); ?>';
    var $variables = { juris: $juris, tipo_sucursal: $tipo_sucursal, nivel_atencion: $nivel_atencion };
    var posting = $.post( $url, $variables );
            
             posting.done(function( data ) {
                
                $('#sucursal').html(data);
                
             });
}

$( "#cveArticulo" ).autocomplete({
source: function (request, response) {
            $.ajax({
                url: '<?php echo site_url('reportes/busca_cveArticulo'); ?>',
                dataType: "json",
                data: {
                    term : request.term
                },
                success: function(data) {
                    response(data);
                }
            });
        },
minLength: 2,
select: function ( event, ui ) {
    
    
    $("#cveArticulo").val(ui.item.cveArticulo);
    return false;
    
    }
});

$( "#expedienteAll" ).autocomplete({
source: function (request, response) {
            $.ajax({
                url: '<?php echo site_url('reportes/busca_expediente'); ?>',
                dataType: "json",
                data: {
                    term : request.term,
                    juris: $("#juris").val(),
                    sucursal: $("#sucursal").val()
                },
                success: function(data) {
                    response(data);
                }
            });
        },
minLength: 2,
select: function ( event, ui ) {
    
    
    $("#expedienteAll").val(ui.item.cvepaciente);
    return false;
    
    }
});

$( "#cveMedicoAll" ).autocomplete({
source: function (request, response) {
            $.ajax({
                url: '<?php echo site_url('reportes/busca_cveMedicoAll'); ?>',
                dataType: "json",
                data: {
                    term : request.term,
                    sucursal: $("#sucursal").val()
                },
                success: function(data) {
                    response(data);
                }
            });
        },
minLength: 2,
select: function ( event, ui ) {
    
    
    $("#cveMedicoAll").val(ui.item.cvemedico);
    return false;
    
    }
});

</script>