﻿//get the product info
function GetProductDetails_click(CatID) {
    //do callback
    $.ajax({
        type: "POST",
        url: "ProdInfo.aspx/GetProductDetails",
        contentType: "application/json; charset=utf-8",
        data: "{'CatID':'" + CatID + "',IsPopup:true}",
        dataType: "json",
        success: ShowInfo,
        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 ShowInfo(result) {
    var ResultsHtml = "";
    var ItemInfo = result.d; //[0];


    //build the html
    if (ItemInfo !== undefined) {
        //build the HTML
        $("#item-details").html(ItemInfo);

        //show dialog
        $('#item-details').dialog('open');
    }
}

//allows scrolling withing div without scrolling page
function ScrollToAuthBio() {
    var divOffset = $('#item-details').offset().top;
    var pOffset = $('#item-details #authbio').offset().top;
    var pScroll = pOffset - divOffset;
    $('#item-details').animate({ scrollTop: '+=' + pScroll + 'px' }, 500);
}

