$(document).ready(function() {
    $('#settingsForm').submit(function(event) {
        event.preventDefault();

        $.post("ajax/saveSettings.php", $("#settingsForm").serialize(), function(data) {
            $(".result").html(data);
        }).success(function(e) {
            $.smallBox({
                title: "Änderung erfolgreich",
                content: "Die Einstellungen zur Landingpage wurden &uuml;bernommen und gespeichert.",
                color: "#739E73",
                icon: "fa fa-check",
                timeout: 5000
            });
        });
    });
    $('#logout').click(function(e) {
       $("#ajaxReq").html();
    });
    $('#allDls').click(function(e) {
       var loadData = $.ajax({
           method: "GET",
           url: "ajax/downloadOverview.php",
           beforeSend: function () {
               $('#ajaxReq').html('<h1 class="text-center"><i class="fa fa-refresh fa-spin"></i> Daten werden geladen</h1>')
           }
       });

       loadData.success(function(data) {
           $("#ajaxReq").html(data);
       });

       loadData.fail(function (jqXHR, textStatus) {
           alert("Request failed: " + textStatus);
       });
       e.preventDefault();
    });

    $('#allVisits').click(function(e) {
       var loadData = $.ajax({
           method: "GET",
           url: "ajax/visitorOverview.php",
           beforeSend: function () {
               $('#ajaxReq').html('<h1 class="text-center"><i class="fa fa-refresh fa-spin"></i> Daten werden geladen</h1>')
           }
       });

       loadData.done(function(data) {
          $("#ajaxReq").html(data);
       });

       loadData.fail(function (jqXHR, textStatus) {
           alert("Request failed: " + textStatus);
       });
    });

});