var dma = {};

(function($){

    var disabled_delete_request = function() {
        alert('Something is trying to click on buttons automatically');
    };

    dma.delete_request = disabled_delete_request;

    var delete_request = function(){
        var data = {};
        data[window.dmaToken] = 1;
        $.ajax({
            url: f90_dma_base+"index.php?option=com_f90dma&task=sendDeleteRequest",
            data:data,
            method: 'POST'
        }).done(function(data) {
            data = $.parseJSON(data);

            $('body').append(data.html);

            if(data.error == false){
                alert(Joomla.JText._('PLG_SYSTEM_F90DELETEMYACCOUNT_SUCCESS'));
                location.reload();
            }
            else{
                alert(data.html);
            }
        }).fail(function() {
            alert('There is some error in sending request to admin. Please contact them by using any other means.');
        });
    };

	$(document).ready(function(){
			$('.f90-delete-my-account').click(function(){
					if(confirm(Joomla.JText._('PLG_SYSTEM_F90DELETEMYACCOUNT_ARE_YOU_SURE_MSG'))){
                        dma.delete_request = delete_request;
						dma.delete_request();
					}
					return false;
			});
	});
	
})(jQuery);
