﻿$(document).ready(function() {

    $("#bottomAddRemove").click(function() {

        var pdfId = $("input#thePdf").val();
        var action = $("input#action").val();
        var pageType = $("input#pageType").val();
        var handler = $("input#handler").val();

        $.ajax({
            type: "GET",
            url: handler,
            dataType: "xml",
            data: "pdf=" + pdfId + "&act=" + action,
            cache: false,
            success: function(xml) {
                var pdfResponse = $(xml).find('echo').text();
                //var pdfAction = $(xml).find('pdfAction').text();

                var addClass = "addPage";
                var removeClass = "removePage";

                if (pageType == "section") {
                    addClass = "addSection";
                    removeClass = "removeSection";
                }

                if (action == 'add' && pdfResponse == 'ok') {
                    $("#content_feet").removeClass(addClass);
                    $("#content_feet").addClass(removeClass);
                    $("input#action").val("remove");
                }
                else if (action == 'remove' && pdfResponse == 'ok') {
                    $("#content_feet").removeClass(removeClass);
                    $("#content_feet").addClass(addClass);
                    $("input#action").val("add");
                }
            }
        });

        return false;

    });

});
