$(document).ready(function () {

    $(window).keydown(function (event) {
        if (event.keyCode == 13) {
            event.preventDefault();
            return false;
        }
    });
    var allw = '';
    var addflag = $('.addflg').val();
//    if (addflag != 1) {
        $("#edit").click(function () {
            addflag = 0;
        });
//    }
//    var addflag = $('.addflg').val();


    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (allw == '') {
            if (!(String.fromCharCode(event.which).toLowerCase() == 'q' && event.altKey) && !(event.which == 19))
                return true;
            //alert("Ctrl-s pressed");
            $(".roundoff").focus();
            event.preventDefault();
            return false;
        }
    });

    $(document).keydown(function (event) {
//for save
        if (addflag != 2 ) {

            if (!(String.fromCharCode(event.which).toLowerCase() == 'r' && event.altKey) && !(event.which == 19))
                return true;
            $("#addnew").click();
            event.preventDefault();
            return false;
        }
    });
    $(document).keydown(function (event) {
//for save
        if (addflag != 2 ) {

            if (!(String.fromCharCode(event.which).toLowerCase() == 's' && event.altKey) && !(event.which == 19))
                return true;
            $("#submit").click();
            event.preventDefault();
            return false;
        }
    });

    $(document).keydown(function (event) {
        //for add
        if (addflag != 1) {
            if (!(String.fromCharCode(event.which).toLowerCase() == 'a' && event.altKey) && !(event.which == 19))
                return true;
            $("#add").click();
            event.preventDefault();
            return false;
        }
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'c' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#cancel").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'd' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#delete").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'x' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#exit").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'b' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#previous").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'n' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#next").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'f' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#search").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'e' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#edit").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'p' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#print").click();
        event.preventDefault();
        return false;
    });


});