$(document).ready(function() {
    // Hiding the category panel by default
    $('.categoryPanel').hide();

    // Add Button Clicked
    $('#add').click(function(e) {
            e.preventDefault();
            hideShow();
        })
        // Edit Button Clicked
    $('#edit').click(function(e) {
            e.preventDefault();
            hideShow();
        })
        // Cancel Button clicked
    $('#cancel').click(function(e) {
        e.preventDefault();
        Swal.fire({
            title: 'Cancel Form Submition?',
            text: "Are you sure, you want to cancel the form submission?",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: "Yes",
            cancelButtonText: "No"
        }).then((result) => {
            if (result.value) {
                location.reload();
            }
        })
    })

    // Delete button clicked
    $('#delete').click(function(e) {
        e.preventDefault();
        Swal.fire({
            title: 'Cancel Form Submition?',
            text: "Are you sure, you want to cancel the form submission?",
            type: 'error',
            showCancelButton: true,
            confirmButtonColor: '#d33',
            cancelButtonColor: '#3085d6',
            confirmButtonText: "Yes",
            cancelButtonText: "No"
        }).then((result) => {
            if (result.value) {
                // YOur real code goes here about deleting the record
                location.reload();
            }
        })
    })

    function hideShow() {
        $('input, select, .saveCancel').removeAttr('disabled');
        $('.categoryPanel').show();
        $('.addEditButton').hide();
    }
});

function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    	try {
    		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try {
    			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    		} catch (E) {
    			xmlhttp = false;
    		}
    	}
    @else
    	xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}