
//Menu
$(document).ready(function(){
//    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
    $('.subnav').width($('.subnav').width());
    //$('ul.topnav li').click(
    $('ul.topnav li').hover(
        function () {
            $('.menu-first', this).addClass('slide-down');
            $('.subnav', this).slideDown(0);
        }
    ).hover(
        function () {
            $('.menu-first', this).addClass('slide-down');
        },
        function () {
            obj = this;
            $('.subnav', this).slideUp(0, function(){ $('.menu-first', obj).removeClass('slide-down'); });
        }
    );
});

//Esconder div
function o(whichLayer){
    var elem, vis;
    if( document.getElementById ) // this is the way the standards work
      elem = document.getElementById( whichLayer );
    else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
    else if( document.layers ) // this is the way nn4 works
      elem = document.layers[whichLayer];
      vis = elem.style;
    // if the style.display value is blank we try to figure it out here
    if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
      vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
        vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

//Funciones para enviar estado al seleccionar del combo
//$(function estado() {
//    // navigate to page on click event
//    $('#id_filtroEstado').bind('change', function() { goToPage1(); } );
//});
//function goToPage1() {
//    var baseUrl = '/sipe/funcionarios/estado/';
//    window.location.href = baseUrl + $('#id_filtroEstado').val()
//}

//Funciones para enviar cargo al seleccionar del combo
$(function cargo() {
    // navigate to page on click event
    $('#id_filtroCargo').bind('change', function() { goToPage(); } );
});
function goToPage() {
    var baseUrl = '/sipe/funcionarios/cargo/';
    window.location.href = baseUrl + $('#id_filtroCargo').val()
}

$(function cargo2() {
    // navigate to page on click event
    $('#id_filtroCargo2').bind('change', function() { goToPage2(); } );
});
function goToPage2() {
    var baseUrl = '/sipe/funcionarios/cargos/cargo/';
    window.location.href = baseUrl + $('#id_filtroCargo2').val()
}

//Funciones para enviar depto/unidad al seleccionar del combo
$(function depto() {
    // navigate to page on click event
    $('#id_filtroDepto').bind('change', function() { goToPage3(); } );
});
function goToPage3() {
    var baseUrl = '/sipe/funcionarios/cargos/depto/';
    window.location.href = baseUrl + $('#id_filtroDepto').val()
}

$(function depto2() {
    // navigate to page on click event
    $('#id_filtroDepto2').bind('change', function() { goToPage4(); } );
});
function goToPage4() {
    var baseUrl = '/sipe/funcionarios/consulta/cantidad/depto/';
    window.location.href = baseUrl + $('#id_filtroDepto2').val()
}

//Ordenar tablas
$(document).ready(function() {      
    $("#venc_cedulas").tablesorter(); 
    $("#venc_licencias").tablesorter();
    $("#venc_carnesalud").tablesorter();
    $("#venc_uniformes").tablesorter();
    $("#funcionarios").tablesorter();
    $("#funcionarios_cargos").tablesorter();
    $("#sorter_hijos").tablesorter();
    $("#sorter_primaria").tablesorter();
    $("#sorter_secundaria").tablesorter();
    $("#sorter_bachillerato").tablesorter();
    $("#sorter_terciarios").tablesorter();
    $("#sorter_postgrados").tablesorter();
    $("#sorter_tecnicos").tablesorter();
    $("#sorter_seminarios").tablesorter();
    $("#sorter_publicados").tablesorter();
    $("#sorter_idiomasCursos").tablesorter();
    $("#sorter_informatica").tablesorter();
    $("#sorter_experiencias").tablesorter();
    $("#sorter_licencias").tablesorter();
    $("#sorter_faltas").tablesorter();
    $("#sorter_seguros").tablesorter();
    $("#sorter_sanciones").tablesorter();
    $("#sorter_capacitaciones").tablesorter();
    $("#sorter_cursosDictados").tablesorter();
    $("#sorter_evaluaciones").tablesorter();
    $("#sorter_obras").tablesorter();
    $("#sorter_funcionarioObras").tablesorter();
    $("#sorter_artUniformes").tablesorter();
    $("#sorter_uniformes").tablesorter();
    $("#sorter_historialUniformes").tablesorter();
    $("#sorter_liquidaciones").tablesorter();
    $("#sorter_reingresos").tablesorter();
    $("#sorter_prestamos").tablesorter();
    $("#sorter_cargos").tablesorter();
    $("#uniformes_trimestral").tablesorter();
    $("#uniformes_semestral").tablesorter();
    $("#uniformes_anual").tablesorter();
    $("#consulta_funcionarios").tablesorter();
    $("#cargos").tablesorter();
    $("#categorias").tablesorter();
    $("#sorter_deptos").tablesorter();
    $("#sorter_socMedica").tablesorter();
    $("#sorter_emergenciaMedica").tablesorter();
    $("#sorter_sector").tablesorter();
    $("#sorter_tipoContrato").tablesorter();
    $("#sorter_idioma").tablesorter();
    $("#sorter_curso").tablesorter();
    $("#sorter_organismo").tablesorter();
    $("#sorter_estado").tablesorter();
    $("#sorter-cargos").tablesorter();
}); 

//Calendario
$(function() {
    Date.firstDayOfWeek = 7;
    Date.format = 'yyyy-mm-dd';
    $('.date-pick').datePicker({startDate:'2000-01-01'});
});

//Facebox
jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox()
})

