


function keyEvent(event) {
    if (event.keyCode == 13) {
        if (document.getElementById("action")) {
            document.getElementById("action").value = "";
        }
        $("#HM-Form-Report").submit();
    }
}

function switchPage(page) {
    document.getElementById('pos').value = page;
    if (document.getElementById("action")) {
        document.getElementById("action").value = "";
    }
    $("#HM-Form-Report").submit();
}


function sortList(sortExpression) {
    var elem = document.getElementById("sorting");
    elem.value = sortExpression;
    if (document.getElementById("action")) {
        document.getElementById("action").value = "";
    }
    $("#HM-Form-Report").submit();
}

function toggleSortOrder() {
    var elem = document.getElementById("sortOrder");
    elem.value = (elem.value == "DESC") ? "ASC" : "DESC";

    if (document.getElementById("action")) {
        document.getElementById("action").value = "";
    }

    $("#HM-Form-Report").submit();
}


function ShowHideColumn(colIndex) {
    var table = document.getElementById('reportTable');
    for (var r = 0; r < table.rows.length; r++) {
        if (table.rows[r].cells[colIndex].style.display == 'none') {
            table.rows[r].cells[colIndex].style.display = '';
        } else {
            table.rows[r].cells[colIndex].style.display = 'none';
        }
    }
}

function setAction(action) {
    document.getElementById("action").value = action;
}



function printList() {
    var MeinFenster = window.open("", "Druckansicht", "width=800,height=300,left=100,top=200,scrollbars=yes");
    MeinFenster.focus();
}

$(document).ready(function () {

    $(".dialog").fancybox({
        maxWidth: 900,
        maxHeight: 600,
        autoCenter: true,
        closeClick: false,
        beforeShow: function () {
            //this.width = $('.fancybox-inner').width($(this).contents().find('body').width()+30);
            //this.height = $('.fancybox-inner').height($(this).contents().find('body').height()+30);
        }
    });

    $("#miniStatusID, #miniCategoryID").multiselect({
        noneSelectedText: 'Kategorie wählen',
        height: 'auto',
        checkAllText: 'Alle',
        uncheckAllText: 'Keine',
        selectedList: 1,
        selectedText: '# Kategorien gewählt',
        header: true
    });

    $("#miniStatusID").multiselect({
        noneSelectedText: 'Status wählen',
        selectedText: '# Status gewählt'
    });

    $(".datepicker").datepicker();


    $(".multiple").multiselect({
        checkAllText: 'Alle',
        uncheckAllText: 'Keine',
        noneSelectedText: 'Wählen Sie',
        selectedText: '# gewählt',
        selectedList: 1,
        selectedText: false,
        header: false,
        multiple: false
    });



    var MultiSelectStatusID = $("#ShowHideColumns").multiselect({
        checkAllText: 'Alle',
        uncheckAllText: 'Keine',
        noneSelectedText: 'Wählen Sie',
        selectedText: '# gewählt',
        selectedList: 1,
        header: true,
        multiple: true,
        click: function (event, ui) {
            if (ui.checked) {
                MultiSelectStatusID.multiselect("widget").find(":checked").each(function () {
                    //                        $('td:nth-child('+$(this).val()+')').show();
                });
            }
        }
    });

});


$(".dialog").fancybox({
    maxWidth: 850,
    maxHeight: 600,
    closeClick: false
});

function keyEvent(event) {
    if (event.keyCode == 13) {
        switchPage(0);
    }
}


