<script type="text/javascript">
    $(document).ready(function () {
        $(".date").datepicker();
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("table").addClass('box-table-a');
        $("table").css('width', '100%');
        $("#bnav").click(function () {
            $("#nav").toggle("slow");
        });

        $('form').keydown(function (e) {
            var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
            if (key == 13) {
                e.preventDefault();
                $(this).next().focus();  //Use whatever selector necessary to focus the 'next' input
                return false;
            }
        });

    });
    function convertDateToString(inputFormat) {
        var d = new Date(inputFormat);
        return ("00" + (d.getDate() + 1)).slice(-2) + "." +
            ("00" + d.getMonth()).slice(-2) + "." +
            d.getFullYear() + " " +
            ("00" + d.getHours()).slice(-2) + ":" +
            ("00" + d.getMinutes()).slice(-2) + ":" +
            ("00" + d.getSeconds()).slice(-2);
    }
    function getData(url, type, dataType, dataString) {
        return getData(url, type, dataType, dataString, true);
    }
    function getData(url, type, dataType, dataString, async) {
        return $.ajax({
            type: type,
            url: url,
            dataType: dataType,
            data: dataString,
            async: async,
            error: function (request, status, error) {
                alert(request.responseText);
            }
        });
    }
    $('.as-form').on('click', function (e) {
        if (!confirm('Silmek istediğinize emin misiniz?')) {
            e.stopPropagation();
            return false;
        }

        var $form = $('<form/>').hide();

        //form options
        $form.attr({
            'action': $(this).attr('href'),
            'method': 'post'
        });

        //adding the _method hidden field
        $form.append($('<input/>', {
            type: 'hidden',
            name: '_method'
        }).val($(this).data('method')));

        //adding a CSRF if needs
        if ($(this).data('csrf')) {
            var csrf = $(this).data('csrf').split(':');
            $form.append($('<input/>', {
                type: 'hidden',
                name: csrf[0]
            }).val(csrf[1]));
        }

        //add form to parent node
        $(this).parent().append($form);

        $form.submit();

        return false;
    });
</script>
{% for flash_message in app.session.flashBag.get('error') %}
    <script src="{{ asset('js/noty/packaged/jquery.noty.packaged.min.js') }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            noty({
                text: "{{ flash_message }}",
                layout: 'top',
                theme: 'defaultTheme', // or 'relax'
                type: 'error',
                template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
                animation: {
                    open: {height: 'toggle'},
                    close: {height: 'toggle'},
                    easing: 'swing',
                    speed: 100 // opening & closing animation speed
                },
                closeWith: ['click'],
                timeout: false, // delay for closing event. Set false for sticky notifications
                force: false // adds notification to the beginning of queue when set to true
            });
        });
    </script>
{% endfor %}
{% for flash_message in app.session.flashBag.get('success') %}
    <script src="{{ asset('js/noty/packaged/jquery.noty.packaged.min.js') }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            noty({
                text: "{{ flash_message }}",
                layout: 'top',
                theme: 'defaultTheme', // or 'relax'
                type: 'success',
                template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
                animation: {
                    open: {height: 'toggle'},
                    close: {height: 'toggle'},
                    easing: 'swing',
                    speed: 100 // opening & closing animation speed
                },
                closeWith: ['click'],
                timeout: false, // delay for closing event. Set false for sticky notifications
                force: false // adds notification to the beginning of queue when set to true
            });
        });
    </script>

{% endfor %}