﻿//build query string for add-to-cart request
function AddToCart_click(CatID, ISBN) {
    //show mouse busy
    //$('body').css('cursor', 'wait');

    //do callback
    $.ajax({
        type: "POST",
        url: "ProdInfo.aspx/AddItemToDLCart",
        contentType: "application/json; charset=utf-8",
        data: "{'CatID':'" + CatID + "'}",
        dataType: "json",
        success: ProcessCartCallback,
        error: function(xhr, err, e) {
            alert("An Error occurred during your request\r\nError:\r\n\tStatus: " + xhr.statusText + '\r\n\tText: ' + err);
            //$("#ProcessingImg").attr("style", "visibility:hidden;");
        }
    });

    //show product info
    function ProcessCartCallback(result) {
        var Result = result.d; //[0];

        //reset mouse
        //$('body').css('cursor', 'auto');

        //build the html
        if (Result) {
            alert(ISBN + " has been added to your cart.")
        }
        else {
            alert("There was an error while trying to add your product to the cart!!  If this continues please contact technical support." )
        }
    }
}
