﻿function fn_toggle_contents_v2(contents) {
    var shortCnt = $("#" + contents + "_short");
    var allCnt = $("#" + contents + "_all");
    
    if (allCnt.css("display") == "none") {
        shortCnt.hide();
        allCnt.show();
    }
    else {
        shortCnt.show();
        allCnt.hide();        var root = $("#" + contents);        var scrollTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;        var divGroupTop = root.offset().top + 75;                if (scrollTop > divGroupTop) {
            $('html, body').animate({
                scrollTop: root.offset().top
                }, '100', 'swing'
            );
        }    }
}

function fn_toggle_contents(contents) {
    var btn = $(".btn_"+contents);
    var menu = btn.find("div:eq(0)");
    var container = $("#ctl_"+contents);
    if (btn.hasClass("on")) {
        btn.removeClass("on");
        container.hide();
        menu.removeClass().addClass("book_cb10");
    } else {
        btn.addClass("on");
        container.show();
        menu.removeClass().addClass("book_cb11");
    }
}

function fn_toggle_community(communityType, itemId, pageCount) {
    var btn = $(".cl_"+communityType);
    var container = $("#container_"+communityType);
    var cont = $("#"+communityType+"Updates");
    if (btn.hasClass("on")) {
        btn.removeClass("on");
        container.hide();
        btn.find("div:eq(0)").removeClass().addClass("book_cb10");
    } else {
        if(cont.text().length < 1) {
            getMoreUCCList(communityType, itemId, pageCount);
        }
        btn.addClass("on");
        container.show();
        btn.find("div:eq(0)").removeClass().addClass("book_cb11");
    }
}

function fn_toggle_spoiler(communityType, paperId) {
    var obj = "#div_" + communityType + "Paper" + paperId;
    if ($(obj).hasClass("spoiler_box")) {
        $(obj).removeClass("spoiler_box");
        $(obj + " div[id=paperSpoiler_" + paperId + "]").toggle();
        $(obj + " div[id=paper_" + paperId + "]").toggle();
    }
}

function fn_toggle_ugcmenu(communityType, paperId) {
    if (communityType == "MyVideo") {
        var obj = "#div_MyVideo" + paperId;
        $(obj).find(".ugc_menu_layer").toggle();
    } else {
        var obj = "#ul_" + communityType + "Paper" + paperId;
        $(obj).find("li").find(".ugc_menu_layer").toggle();
    }
    
}

function fn_toggle_report(communityType, paperId) {
    if (communityType == "MyVideo") {
        var obj = "#div_MyVideo" + paperId;
        $(obj + " div[id=paper_block_" + paperId + "]").toggle();
        //$(obj + " div[id=paper_content_" + paperId + "]").toggle();
        //$(obj + " div[id=paper_action_" + paperId + "]").toggle();
    } else {
        var obj = "#ul_" + communityType + "Paper" + paperId;
        $(obj + " div[id=paper_block_" + paperId + "]").toggle();
        $(obj + " div[id=paper_content_" + paperId + "]").toggle();
        $(obj + " li[id=paper_action_" + paperId + "]").toggle();
    }
}

function fn_paper_toast_on(msg) {
    $("#paperComment").html(msg);
    $("#paperLayer").slideDown();
}

function fn_paper_toast_off() {
    if ($("#paperLayer").css("display") != "none") {
        setTimeout('$("#paperLayer").slideUp();', 2000);
    }
}

function fn_paper_login() {
    var result = false;

    $.ajax({
        url: "/ucl/m/product/ajax/m_ajax_paper_util.aspx",
        data: "type=auth",
        type: 'post',
        dataType: 'html',
        async: false,
        error: function (xhr, textStatus, errorThrown) {
            console.log(errorThrown);
        },
        success: function (data) {
            var d = JSON.parse(data);
            console.log(d);
            if (d.Result == 1) {
                result = true;
            } else {
                result = false;
            }
        }
    });

    return result;
}

function fn_ugc_requestReport(communityType, paperId) {

    fn_toggle_ugcmenu(communityType, paperId);

    if (fn_paper_login()) {

        if (communityType == "MyVideo") {
            var obj = "#div_MyVideo" + paperId;
            var objUgcReport = $(obj).find(".ugc_menu_layer").find(".ugc_report");
        } else {
            var obj = "#ul_" + communityType + "Paper" + paperId;
            var objUgcReport = $(obj).find("li").find(".ugc_menu_layer").find(".ugc_report");
        }

        var report = $(objUgcReport).attr("data-report");

        if (report == 0) {
            alert('이미 신고한 글입니다.');
            return false;
        }

        var htm = '<div class="alert_out ugc_report_layer">'
                + '    <div class="alert_box">'
                + '        <button type="button" class="close_btn">닫기</button>'
                + '        <div class="alert_text">'
                + '            <h3>신고하기</h3>'
                + '            <p>사유를 선택해주세요. <span class="small">(중복 선택 가능)</span></p>'
                + '            <div class="report_check">'
                + '                <label><input type="checkbox" name="chkReportReason" id="chkReportReason1" class="input_check_square"><span>욕설, 혐오, 차별, 비하, 모욕적인 표현</span></label>'
                + '                <label><input type="checkbox" name="chkReportReason" id="chkReportReason2" class="input_check_square"><span>인신공격, 명예훼손</span></label>'
                + '                <label><input type="checkbox" name="chkReportReason" id="chkReportReason3" class="input_check_square"><span>표절, 저작권 분쟁의 소지가 있는 글</span></label>'
                + '                <label><input type="checkbox" name="chkReportReason" id="chkReportReason4" class="input_check_square"><span>상품과 무관한 글</span></label>'
                + '                <label><input type="checkbox" name="chkReportReason" id="chkReportReason5" class="input_check_square"><span>결말을 암시하는 내용</span></label>'
                + '            </div>'
                + '        <div class="block_check">'
                + '        <label>'
                + '        <input type="checkbox" name="chkBlock" id="chkBlock" class="input_check_square">'
                + '            <span>이 글을 작성한 사용자를 차단할까요?<br><span class="small">차단한 사용자가 작성한 모든 글은 숨김 처리 됩니다.</span></span>'
                + '        </label>'
                + '        </div>'
                + '    </div>'
                + '    <div class="alert_btn">'
                + '        <button type="button" class="pink_btn off ok">신고하기</button>'
                + '    </div>'
                + '    </div>'
                + '    <div class="dim"></div>'
                + '</div>';

        var $ucf = $(htm).appendTo('body');

        $ucf.find('button.close_btn').unbind("click").bind("click", function () {
            $ucf.remove();
        });

        $ucf.find('.report_check input:checkbox').click(function (e) {
            if ($(this).is(':checked')) {
                $ucf.find('button.ok').removeClass('off');
            } else {
                $ucf.find('button.ok').addClass('off');
            }
        });

        $ucf.find('button.ok').unbind("click").bind("click", function () {
            var $btn = $ucf.find('button.ok');
            var reason = '';
            $ucf.find('.report_check input:checkbox').each(function (index, item) {
                if ($(item).is(':checked')) {
                    reason += (reason.length > 0 ? '|' : '') + $(item).next("span").html().trim();
                }
            });

            var block = $ucf.find('input[name="chkBlock"]').is(':checked') ? 1 : 0;

            if (reason == '') {
                alert('사유를 선택해주세요');
                return false;
            }

            $.ajax({
                url: "/ucl/m/product/ajax/m_ajax_paper_util.aspx",
                data: "type=report&paperid=" + paperId + "&reason=" + reason + "&block=" + block,
                type: 'post',
                dataType: 'html',
                async: false,
                error: function (xhr, textStatus, errorThrown) {
                    alert(' 실패되었습니다. 다시 시도해주세요.' + errorThrown);
                },
                success: function (data) {
                    var d = JSON.parse(data);
                    //console.log(d);
                    if (d.Result == 1) {
                        fn_paper_toast_on("신고되었습니다.");
                        getUCCPaper(communityType, paperId);
                    } else {
                        if (d.Result == 2) {
                            location.href = Common.format("/m/mlogin.aspx?returnUrl={0}", escape(location.href));
                        } else {
                            if (d.ErrMsg !== '') {
                                alert(d.ErrMsg);
                            }
                        }
                    }
                },
                complete: function () {
                    $ucf.remove();
                    fn_paper_toast_off();
                }
            });
        });

    } else {
        location.href = Common.format("/m/mlogin.aspx?returnUrl={0}", escape(location.href));
    }

}

var posY = 0;
function fn_ugc_requestBlock(communityType, paperId) {

    fn_toggle_ugcmenu(communityType, paperId);

    if (fn_paper_login()) {
        if (communityType == "MyVideo") {
            var obj = "#div_MyVideo" + paperId;
            var objUgcBlock = $(obj).find(".ugc_menu_layer").find(".ugc_block");
        } else {
            var obj = "#ul_" + communityType + "Paper" + paperId;
            var objUgcBlock = $(obj).find("li").find(".ugc_menu_layer").find(".ugc_block");
        }

        var nickname = $(objUgcBlock).attr("data-nick");
        var block = $(objUgcBlock).attr("data-block");

        var htm = "<div class='alert_out ugc_block_layer user_block_confirm'>"
                + " <div class='alert_box'>"
                + "     <button type='button' class='close_btn'>닫기</button>"
                + "     <div class='alert_text'>"
                + "         <h3>" + nickname + "님을<br>" + ((block == 1) ? "차단하시겠습니까?" : "차단 해제하시겠습니까?") + "</h3>"
                + "         <p>" + ((block == 1) ? "차단하면 사용자의 모든 글을<br>볼 수 없습니다." : "해제하면 사용자의 모든 글을 볼 수 있습니다.") + "</p>"
                + "     </div>"
                + "      <div class='alert_btn'>"
                + "          <button type='button' class='cancel'>취소</button>"
                + "          <button type='button' class='ok'>" + ((block == 1) ? "차단" : "해제") + "</button>"
                + "      </div>"
                + "  </div>"
                + "  <div class='dim'></div>"
                + "</div>";

        var $ucf = $(htm).appendTo('body');

        $ucf.find('button.close_btn').unbind("click").bind("click", function () {
            $ucf.remove();
        });

        $ucf.find('button.cancel').unbind("click").bind("click", function () {
            $ucf.remove();
        });

        $ucf.find('button.ok').unbind("click").bind("click", function () {
            $ucf.remove();

            $.ajax({
                url: "/ucl/m/product/ajax/m_ajax_paper_util.aspx",
                data: "type=block&paperid=" + paperId + "&block=" + block,
                type: 'post',
                dataType: 'html',
                async: false,
                error: function (xhr, textStatus, errorThrown) {
                    alert(' 실패되었습니다. 다시 시도해주세요.' + errorThrown);
                },
                success: function (data) {
                    console.log(data);
                    var d = JSON.parse(data);
                    if (d.Result == 1) {
                        var msg = (block == 1 ? "차단되었습니다." : "차단 해제되었습니다.");
                        fn_paper_toast_on(msg);
                        if (communityType == 'MyPaper') {

                            setTimeout(function () {
                                window.location.reload();
                            }, 2500);

                            //const params = new Proxy(new URLSearchParams(window.location.search.toLowerCase()), {
                            //    get: (searchParams, prop) => searchParams.get(prop),
                            //});
                            //var page = $('input[name="MyPaper_page"]').val();
                            //fn_toggle_community(communityType, params.itemid, 10);

                            //posY = document.querySelector("#cl_MyPaper").offsetTop;

                            //window.scrollTop({ top: posY, behavior: 'smooth' });
                        } else {
                            getUCCPaper(communityType, paperId);
                        }
                    } else {
                        if (d.Result == 2) {
                            location.href = Common.format("/m/mlogin.aspx?returnUrl={0}", escape(location.href));
                        } else {
                            if (d.ErrMsg !== '') {
                                alert(d.ErrMsg);
                            }
                        }
                    }
                },
                complete: function () {
                    fn_paper_toast_off();
                }
            });

        });
    } else {
        location.href = Common.format("/m/mlogin.aspx?returnUrl={0}", escape(location.href));
    }
}

function getUCCPaper(communityType, paperId) {
    $.ajax({
        url: "/ucl/m/product/ajax/m_ajax_paper_util.aspx",
        data: "type=paper&paperid=" + paperId,
        type: 'post',
        dataType: 'html',
        async: false,
        error: function (xhr, textStatus, errorThrown) {
            alert(' 실패되었습니다. 다시 시도해주세요.' + errorThrown);
        },
        success: function (data) {
            var d = JSON.parse(data);
            if (d.Result == 1) {
                var obj = "#ul_" + communityType + "Paper" + paperId;
                
                var objUgcBlock = $(obj).find("li").find(".ugc_menu_layer").find(".ugc_block");
                var objUgcReport = $(obj).find("li").find(".ugc_menu_layer").find(".ugc_report");

                if (communityType == "MyVideo") {
                    obj = "#div_MyVideo" + paperId;
                    objUgcBlock = $(obj).find(".ugc_menu_layer").find(".ugc_block");
                    objUgcReport = $(obj).find(".ugc_menu_layer").find(".ugc_report");
                }

                $(objUgcBlock).text((d.IsBlock ? "차단 해제" : "차단"));
                $(objUgcBlock).attr("data-block", (d.IsBlock ? 0 : 1));
                $(objUgcReport).attr("data-report", (d.IsReport ? 0 : 1));

                if (d.IsBlock || d.IsReport) {

                    //if (communityType == "MyVideo") {
                    //    if (d.IsBlock) {
                    //        $(obj + " div[id=paper_content_" + paperId + "]").hide();
                    //    } else {
                    //        $(obj + " div[id=paper_content_" + paperId + "]").show();
                    //    }
                    //} else {
                    //    $(obj + " div[id=paper_content_" + paperId + "]").hide();
                    //}

                    $(obj + " div[id=paper_content_" + paperId + "]").hide();

                    $(obj + " " + (communityType == "MyVideo" ? "div" : "li")+ "[id=paper_action_" + paperId + "]").hide();

                    var htm = '';
                        if (communityType == "MyVideo") {
                            htm = '<div class="clear"></div><div class=\"report_box\">';
                        }
                        htm += '<span>' + (d.IsBlock ? "차단한 사용자의 글입니다." : (d.IsReport ? "신고한 글입니다." : "")) + '</span>';
                        
                        if (communityType == "MyVideo") {
                            htm += '</div>';
                        } 

                    $(obj + " div[id=paper_block_" + paperId + "]").html(htm);
                    $(obj + " div[id=paper_block_" + paperId + "]").show();
                } else {
                    $(obj + " div[id=paper_block_" + paperId + "]").hide();
                    $(obj + " div[id=paper_content_" + paperId + "]").show();
                    $(obj + " " + (communityType == "MyVideo" ? "div" : "li") + "[id=paper_action_" + paperId + "]").show();

                }
            } 
        }
    });
}

function getUCCList(communityType, itemId, pageCount, isOrderer) {

    var pageObj = $("input[name='" + communityType + "_page'][type='hidden']");
    var updatesObj = $("div#" + communityType + "Updates");
    var sortOrder = $("#" + communityType + "_SortOrder").val();
    $("#" + communityType + "_IsOrderer").val(isOrderer);
    var pagerDiv = $("div#" + communityType + "_more");
    //var tmpPageHtml = pagerDiv.html();
    var tmpPageHtml = '<a href="javascript:getMoreUCCList(\'' + communityType + '\',' + itemId + ',' + pageCount + ');">{0}' +
        '<img src="//image.aladin.co.kr/img/account/m/2015/arrow_down.png" alt="" width="30" /></a>';
    var paperLength = 0;
    var isIPad = 0;
    var page = 1;
    updatesObj.html('');

    if (communityType.indexOf('Underline') != -1) {
        communityType = "Underline";
    }

    $.ajax({
        type: "POST",
        url: "/ucl/m/product/ajax/m_ajax_moreList.aspx",
        data: Common.format("ItemId={0}&CommunityType={1}&page={2}&pageCount={3}&paperLength={4}&isIPad={5}&isOrderer={6}&sortOrder={7}"
            , itemId, communityType, page, pageCount, paperLength, isIPad, isOrderer, sortOrder),
        cache: false,
        success: function (data) {
            var result, list, listData;
            eval("result = " + data);
            list = result.List;

            $.each(list, function (index, paper) {
                if (communityType == "CommentReview")
                    updatesObj.append(Common.format(htm_commentReview
                        , paper.Rank, paper.Paper, paper.NickName, paper.RecommendCount, paper.PaperId, paper.PaperInDate, paper.CommentCount
                        , paper.IsOrderer == "True" ? "<img src=\"//image.aladin.co.kr/img/shop/m/icon_buy.gif\" width=\"40px\" />" : ""
                        , paper.BlogUrl, paper.FaceImage, paper.MyBlogUrl
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ? "cancelthanksto" : "thanksto")
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ?
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks_c_m.gif\" width=\"98px\" />" :
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks.gif\" width=\"70px\" />")
                        , paper.IsSpoiler == "True" ? "spoiler_box" : ""
                        , paper.IsSpoiler == "True" ? "" : "display:none"
                        , paper.IsSpoiler == "True" ? "display:none" : ""
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "cancelrecommend" : "recommend")
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "re_like_c_m.gif" : "re_like.gif")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "" : "display:none")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "display:none" : "")
                        , paper.IsBlock == "True" ? "0" : "1"                                                                                        //20
                        , paper.IsBlock == "True" ? "차단해제" : "차단"                                                                              //21
                        , paper.IsBlock == "True" ? "차단한 사용자의 글입니다." : (paper.IsReport == "True" ? "신고한 글입니다." : "")               //22
                        , paper.IsReport == "True" ? "0" : "1"
                        ));
                else if (communityType == "MyReview")
                    updatesObj.append(Common.format(htm_myReview
                        , paper.Rank
                        , paper.Title
                        , paper.NickName
                        , paper.RecommendCount
                        , paper.PaperInDate
                        , paper.Paper
                        , paper.PaperId
                        , paper.CommentCount
                        , paper.IsOrderer == "True" ? "<img src=\"//image.aladin.co.kr/img/shop/m/icon_buy.gif\" width=\"40px\" />" : ""
                        , paper.BlogUrl
                        , paper.FaceImage
                        , paper.MyBlogUrl
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ? "cancelthanksto" : "thanksto")
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ?
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks_c_m.gif\" width=\"98px\" />" :
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks.gif\" width=\"70px\" />")
                        , paper.IsSpoiler == "True" ? "spoiler_box" : ""
                        , paper.IsSpoiler == "True" ? "" : "display:none"
                        , paper.IsSpoiler == "True" ? "display:none" : ""
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "cancelrecommend" : "recommend")
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "re_like_c_m.gif" : "re_like.gif")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "" : "display:none")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "display:none" : "")
                        , paper.IsBlock == "True" ? "0" : "1"                                                                                        
                        , paper.IsBlock == "True" ? "차단해제" : "차단"                                                                              
                        , paper.IsBlock == "True" ? "차단한 사용자의 글입니다." : (paper.IsReport == "True" ? "신고한 글입니다." : "")               
                        , paper.IsReport == "True" ? "0" : "1"
                        ));
                else if (communityType == "MyPaper")
                    updatesObj.append(Common.format(htm_myPaper
                        , paper.Rank, paper.Title, paper.NickName, paper.RecommendCount, paper.PaperInDate, paper.Paper, paper.PaperId, paper.CommentCount
                        , paper.IsOrderer == "True" ? "<img src=\"//image.aladin.co.kr/img/shop/m/icon_buy.gif\" width=\"40px\" />" : ""
                        , paper.BlogUrl, paper.FaceImage, paper.MyBlogUrl
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ? "cancelthanksto" : "thanksto")
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ?
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks_c_m.gif\" width=\"98px\" />" :
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks.gif\" width=\"70px\" />")
                        , paper.IsSpoiler == "True" ? "spoiler_box" : ""
                        , paper.IsSpoiler == "True" ? "" : "display:none"
                        , paper.IsSpoiler == "True" ? "display:none" : ""
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "cancelrecommend" : "recommend")
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "re_like_c_m.gif" : "re_like.gif")

                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "" : "display:none")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "display:none" : "")
                        , paper.IsBlock == "True" ? "0" : "1"
                        , paper.IsBlock == "True" ? "차단해제" : "차단"
                        , paper.IsBlock == "True" ? "차단한 사용자의 글입니다." : (paper.IsReport == "True" ? "신고한 글입니다." : "")
                        , paper.IsReport == "True" ? "0" : "1"
                        ));
                else if (communityType == "PhotoReview")
                    updatesObj.append(Common.format(htm_photoReview, paper.Title, paper.NickName, paper.RecommendCount, paper.PaperInDate, paper.PaperId, paper.BlogUrl, paper.htmPhoto));
                else if (communityType == "BlogThis")
                    updatesObj.append(Common.format(htm_BlogThis, paper.Title, paper.NickName, paper.LabelImg, paper.PaperInDate, paper.PaperId, paper.PostUrl));
            });

            if (list.length == 0) {
                updatesObj.append("<div style='text-align:center;'>등록된 " + (isOrderer == 1 ? "구매자" : "") + "평이 없습니다.</div>");
            }

            if (parseInt(result.Remainder) > 0) {
                //pagerDiv.html(tmpPageHtml).show().find(".btn_more_gray_o").html("+ " + result.Remainder + "개 더보기");
                tmpPageHtml = Common.format(tmpPageHtml, result.Remainder + "편 더보기");
                pagerDiv.html(tmpPageHtml).show();
            }
            else {
                pagerDiv.hide();
            }
        }
    });
}

function getMoreUCCList(communityType, itemId, pageCount, paperLength, isIPad) {
    var pageObj = $("input[name='" + communityType + "_page'][type='hidden']");
    var updatesObj = $("div#" + communityType + "Updates");
    var isOrderer = $("#" + communityType + "_IsOrderer").val();
    var sortOrder = $("#" + communityType + "_SortOrder").val();
    var pagerDiv = $("div#" + communityType + "_more");
    var contentType = $("#" + communityType + "_ContentType").val();
    var tmpPageHtml = pagerDiv.html();
    pagerDiv.html("<div style=\"text-align:center;padding:5px 0\"><img src=\"//image.aladin.co.kr/img/tablet/indicator.gif\" width=\"25\" height=\"25\"/></div>");

    if (typeof paperLength != "undefined") {
        paperLength = parseInt(paperLength);
    } else {
        paperLength = 0;
    }

    if (typeof isIPad != "undefined") {
        isIPad = parseInt(isIPad);
    } else {
        isIPad = 0;
    }

    if (communityType.indexOf('Underline') != -1) {
        communityType = "Underline";
    }

    var page = parseInt(pageObj.val());

    var cont = $("#" + communityType + "Updates");
    if (page == 1 && cont.text().length > 0) {
        page = page + 1;
    }
    
    $.ajax({
        type: "POST",
        url: "/ucl/m/product/ajax/m_ajax_moreList.aspx",
        data: Common.format("ItemId={0}&CommunityType={1}&page={2}&pageCount={3}&paperLength={4}&isIPad={5}&isOrderer={6}&sortOrder={7}&contentType={8}"
            , itemId, communityType, page, pageCount, paperLength, isIPad, isOrderer, sortOrder, contentType),
        cache: false,
        success: function (data) {
            var result, list, listData;
            eval("result = " + data);
            list = result.List;

            $.each(list, function (index, paper) {
                if (communityType == "CommentReview")
                    updatesObj.append(Common.format(htm_commentReview
                        , paper.Rank, paper.Paper, paper.NickName, paper.RecommendCount, paper.PaperId, paper.PaperInDate, paper.CommentCount
                        , paper.IsOrderer == "True" ? "<img src=\"//image.aladin.co.kr/img/shop/m/icon_buy.gif\" width=\"40px\" />" : ""
                        , paper.BlogUrl, paper.FaceImage, paper.MyBlogUrl
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ? "cancelthanksto" : "thanksto")
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ?
                            "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks_c_m.gif\" width=\"98px\" />" :
                            "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks.gif\" width=\"70px\" />")
                        , paper.IsSpoiler == "True" ? "spoiler_box" : ""
                        , paper.IsSpoiler == "True" ? "" : "display:none"
                        , paper.IsSpoiler == "True" ? "display:none" : ""
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "cancelrecommend" : "recommend")
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "re_like_c_m.gif" : "re_like.gif")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "" : "display:none")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "display:none" : "")
                        , paper.IsBlock == "True" ? "0" : "1"                                                                                        //20
                        , paper.IsBlock == "True" ? "차단해제" : "차단"                                                                              //21
                        , paper.IsBlock == "True" ? "차단한 사용자의 글입니다." : (paper.IsReport == "True" ? "신고한 글입니다." : "")               //22
                        , paper.IsReport == "True" ? "0" : "1"
                        ));
                else if (communityType == "MyReview")
                    updatesObj.append(Common.format(htm_myReview
                        , paper.Rank, paper.Title, paper.NickName, paper.RecommendCount, paper.PaperInDate, paper.Paper, paper.PaperId, paper.CommentCount
                        , paper.IsOrderer == "True" ? "<img src=\"//image.aladin.co.kr/img/shop/m/icon_buy.gif\" width=\"40px\" />" : ""
                        , paper.BlogUrl, paper.FaceImage, paper.MyBlogUrl
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ? "cancelthanksto" : "thanksto")
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ?
                            "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks_c_m.gif\" width=\"98px\" />" :
                            "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks.gif\" width=\"70px\" />")
                        , paper.IsSpoiler == "True" ? "spoiler_box" : ""
                        , paper.IsSpoiler == "True" ? "" : "display:none"
                        , paper.IsSpoiler == "True" ? "display:none" : ""
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "cancelrecommend" : "recommend")
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "re_like_c_m.gif" : "re_like.gif")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "" : "display:none")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "display:none" : "")
                        , paper.IsBlock == "True" ? "0" : "1"                                                                                        //20
                        , paper.IsBlock == "True" ? "차단해제" : "차단"                                                                              //21
                        , paper.IsBlock == "True" ? "차단한 사용자의 글입니다." : (paper.IsReport == "True" ? "신고한 글입니다." : "")               //22
                        , paper.IsReport == "True" ? "0" : "1"
                        ));
                else if (communityType == "MyPaper")
                    updatesObj.append(Common.format(htm_myPaper
                        , paper.Rank, decodeURIComponent(paper.Title), paper.NickName, paper.RecommendCount, paper.PaperInDate
                        , decodeURIComponent(paper.Paper), paper.PaperId, paper.CommentCount
                        , paper.IsOrderer == "True" ? "<img src=\"//image.aladin.co.kr/img/shop/m/icon_buy.gif\" width=\"40px\" />" : ""
                        , paper.BlogUrl, paper.FaceImage, paper.MyBlogUrl
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ? "cancelthanksto" : "thanksto")
                        , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ?
                            "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks_c_m.gif\" width=\"98px\" />" :
                            "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks.gif\" width=\"70px\" />")
                        , paper.IsSpoiler == "True" ? "spoiler_box" : ""
                        , paper.IsSpoiler == "True" ? "" : "display:none"
                        , paper.IsSpoiler == "True" ? "display:none" : ""
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "cancelrecommend" : "recommend")
                        , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "re_like_c_m.gif" : "re_like.gif")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "" : "display:none")
                        , (typeof paper.IsReport === "undefined") ? "" : (paper.IsReport == "True" || paper.IsBlock == "True" ? "display:none" : "")
                        , paper.IsBlock == "True" ? "0" : "1"                                                                                        //20
                        , paper.IsBlock == "True" ? "차단해제" : "차단"                                                                              //21
                        , paper.IsBlock == "True" ? "차단한 사용자의 글입니다." : (paper.IsReport == "True" ? "신고한 글입니다." : "")               //22
                        , paper.IsReport == "True" ? "0" : "1"
                        ));
                else if (communityType == "PhotoReview")
                    updatesObj.append(Common.format(htm_photoReview, paper.Title, paper.NickName, paper.RecommendCount, paper.PaperInDate, paper.PaperId, paper.BlogUrl, paper.htmPhoto));
                else if (communityType == "BlogThis")
                    updatesObj.append(Common.format(htm_BlogThis, paper.Title, paper.NickName, paper.LabelImg, paper.PaperInDate, paper.PaperId, paper.PostUrl));
                else if (communityType == "Underline") {

                    if (contentType > 0) {
                        if (paper.PhotoImage == "") {
                            paper.Phrase = decodeURIComponent(paper.Phrase);
                        }
                        updatesObj.append(Common.format(htm_bookUnderline, paper.RowNum, paper.PageNo, paper.Phrase, paper.btnClose, contentType));
                    } else {
                        // P Page Review
                        updatesObj.append(Common.format(htm_underline
                            , paper.Rank, decodeURIComponent(paper.Title), paper.NickName, paper.RecommendCount, paper.PaperInDate
                            , decodeURIComponent(paper.Paper), paper.PaperId, paper.CommentCount
                            , paper.IsOrderer == "True" ? "<img src=\"//image.aladin.co.kr/img/shop/m/icon_buy.gif\" width=\"40px\" /> " : ""
                            , paper.BlogUrl, paper.FaceImage, paper.MyBlogUrl
                            , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ? "cancelthanksto" : "thanksto")
                            , (typeof paper.ThanksTo === "undefined") ? "" : (paper.ThanksTo == "True" ?
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks_c_m.gif\" width=\"98px\" />" :
                                "<img src=\"//image.aladin.co.kr/img/shop/m/re_thanks.gif\" width=\"70px\" />")
                            , paper.IsSpoiler == "True" ? "spoiler_box" : ""
                            , paper.IsSpoiler == "True" ? "" : "display:none"
                            , paper.IsSpoiler == "True" ? "display:none" : ""
                            , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "cancelrecommend" : "recommend")
                            , (typeof paper.IsRecom === "undefined") ? "" : (paper.IsRecom == "True" ? "re_like_c_m.gif" : "re_like.gif")
                            , paper.UnderlineCount > 1 ? "" : "display:none"
                            , paper.UnderlineCount > 1 ? (paper.UnderlineCount - 1) : 0
                        ));
                    }

                }

            });

            if (parseInt(result.Remainder) > 0) {
                pageObj.val(page + 1);
                //pagerDiv.html(tmpPageHtml).show().find(".btn_more_gray_o").html("+ " + result.Remainder + "개 더보기");
                pagerDiv.html(tmpPageHtml).show();
            }
            else {
                pagerDiv.hide();
            }
        }
    });
}

function fn_IsOrderer(communityType, isOrderer, itemId, pageCount) {
    getUCCList(communityType, itemId, pageCount, isOrderer);
    if (isOrderer == 1) {
        $("#" + communityType + "_All").hide();
        $("#" + communityType + "_Buy").show();
    }
    else {
        $("#" + communityType + "_All").show();
        $("#" + communityType + "_Buy").hide();
    }
}

function fn_IsOrdererTab(communityType, isOrderer, itemId, pageCount, sender) {

    $("#" + communityType + "Tab .pdp_review_tab_l li").removeClass("on");
    $(sender).closest("li").addClass("on");

    getUCCList(communityType, itemId, pageCount, isOrderer);
}


function fn_show_mypaper(paperId, communityType)
{
    var paperDiv = $("#paper_" + paperId);
    $.get("/m/ajax/m_ajax_paper.aspx?paperid=" + paperId + "&CommunityType=" + communityType, function(data) { 
        paperDiv.html(data);
    });
}

function fn_show_authorInfo(authorId) {
    var authorDiv = $("#author_" + authorId + "_short");
    var authorDivAll = $("#author_"+ authorId + "_all");
    if(authorDivAll.length < 1) {
        $.get("/m/ajax/m_ajax_authorInfo.aspx?authorId=" + authorId, function(data) { 
            authorDiv.hide().parent().append(data);
        });
    } else {
        authorDiv.hide();
        authorDivAll.show();
    }
}

function fn_hide_authorInfo(authorId) {
    var authorDivAll = $("#author_"+authorId+"_all");
    authorDivAll.hide().prev().show();
    var root = $("#author_" + authorId);    var scrollTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;    var divGroupTop = root.offset().top + 75;    if (scrollTop > divGroupTop) {
        $('html, body').animate({
            scrollTop: root.offset().top
        }, '100', 'swing'
        );
    }
}

function getMoreContents(cType, bookId, branchType)
{
    var parent = $("div#"+cType);
    var shortCnt = $("div#"+cType+"_short");
    var allCnt = $("div#"+cType+"_all");
    var tag = $("#a_"+cType);
    
    if(parent.hasClass("book_cont_all"))
    {
        allCnt.hide();
        shortCnt.show();
        parent.removeClass().addClass("book_cont_short");
        location.href = "#a_"+cType;
    }
    else
    {
        if(allCnt.length < 1) {
            if(branchType == 4 || branchType == 5)
            {
                if(!confirm("데이터 용량이 커서 wifi로 보시기를 권장합니다. 3G로 보실 경우 데이터 이용요금이 과금됩니다."))
                    return;
            }
        
            $.get(Common.format("/ucl/m/product/ajax/m_ajax_moreContents.aspx?cType={0}&bookId={1}&branchType={2}", cType, bookId, branchType), function(data) {  
                shortCnt.hide().parent().append(data);
                allCnt.show();
                parent.removeClass().addClass("book_cont_all");
            }); 
        }
        else
        {
            shortCnt.hide();
            allCnt.show();
            parent.removeClass().addClass("book_cont_all");
        }
    }
}

function getSummaryContents(cType, bookId, branchType) {
    $("div#"+cType+"_all").hide().prev().show();
}


function toggle_paperMore(cType, paperId) {
    var paperShort = $("div#paperShort_"+paperId);
    var paperAll = $("div#paperAll_"+paperId);
    
    if(paperAll.is(':visible') && paperAll.html().length > 0) {
        paperAll.hide();
        paperShort.show();
    } else {
        if(paperAll.html().length < 1) {
            getMorePaper(cType, paperId);
        }
        paperAll.show();
        paperShort.hide();
    }
}

function basket_change_isbn()
{
    var isbn = $("#basket_select > option:selected").val();
    $("input[id='hd_ISBN'][type='hidden']").val(isbn);
}

function fn_coupon_get(nType) {
    $.ajax({
        type: "GET",
        url: "/ucl/coupon/wcoupondown_result_ajax.aspx?nType=" + nType,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function (json) {
            console.log(json.IsLogin);
            if (json.IsLogin == "False") {
                location.href = "/m/mlogin.aspx?returnurl=" + encodeURIComponent(location.href);
                return;
            }
            alert(json.Message);
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
        }
    });

}

function fn_checkTabletTelecom() {
    var $TabletTelecom = $( "#TabletTelecom" );
    if ( typeof $TabletTelecom !== 'undefined' && $TabletTelecom !== null ) {
        if ( $TabletTelecom.val() === "0" ) {
            alert( "이용 가능한 이통사를 선택해주세요" );
            return false;
        }
    }

    return true;
}

function fn_addbasket_v1(isbn) {
    GetStandbyRequire(isbn, function cb(StandbyEnabled, title) {
        if (StandbyEnabled == 1) {
            NetfunnelSkinUtil.SetOption({ showlogo: true, title: title });
            NetFunnel_Action({ action_id: "product" }, function (ev, ret) {
                fn_addbasket_origin(isbn, true);
            });
        } else {
            fn_addbasket_origin(isbn, false);
        }
    });
}

function fn_addbasket_origin(isbn, isStandby) {
    closePopBox();
    var qty = $("#qty").val();
    if (typeof (isStandby) == 'undefined') isStandby = false;

    if ( typeof ( qty ) == 'undefined' ) qty = 1;
    // if (typeof (isYp1HourBasket) == 'undefined') isYp1HourBasket = false;
    
    if ( !fn_checkTabletTelecom() ) return false;

    var htmResult = $("div#addBasketResult");
    htmResult.empty();
    
    var divAddBasket = $("div#addBasket")

    // 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
    // 리스트에서 사용된다. by radioni
    var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');
    
    if (footerTool.length > 0)
        divAddBasket.prependTo(footerTool);
    
    divAddBasket.show();
    
    htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
    var query = 'method=basketaddwithexistcheck&isbn=' + isbn + '&qty=' + qty;

    //var rebindingPrice = $("#rebinding_select").val();
    var rebindingPrice = $(".hd_Rebinding_Price").val();
    if (rebindingPrice > 0) query = query + "&rebinding=1";

    var isGiftVoucher = $("#hd_GiftVoucher");
    var isCanceled = false,
        isLoginRequire = false,
        isAuthRequire = false,
        alertMessage = '',
        confirmMessage = '';

    if (isStandby) {
        $('<div class="standby-modal-backdrop loading"/>').appendTo("body").show();
        $('<div class="animation loading"/>').appendTo(".standby-modal-backdrop.loading");
    }

    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function(json) {
            htmResult.empty();
            if (json.Success == 'true') {
                // 취소여부 확인
                try {
                    if (json.Canceled + '' == 'true')
                        isCanceled = true;
                }
                catch (e) { }

                // 로그인 여부 확인
                try {
                    if (json.LoginRequire + '' == 'true')
                        isLoginRequire = true;
                }
                catch (e) { }

                // 본인인증 여부 확인
                try {
                    if (json.AuthRequire + '' == 'true')
                        isAuthRequire = true;
                }
                catch (e) { }

                // alert 메세지 확인
                try {
                    alertMessage = json.AlertMessage;
                }
                catch (e) { }

                // confirm 메세지 확인
                try {
                    confirmMessage = json.ConfirmMessage;
                }
                catch (e) { }

                if (isCanceled == true) {
                    closePopBox();

                    if (isLoginRequire == true) {
                        if (confirm(confirmMessage) == true) {
                            go_login();
                        }
                    }
                    else if (isAuthRequire == true) {
                        if (confirm(confirmMessage) == true) {
                            location.href = '/account/AuthAdult.aspx?returnUrl=' + encodeURIComponent(location.href);
                        }
                    }
                    else if (alertMessage != '' && typeof alertMessage != "undefined") {
                        alert(alertMessage);
                    }
                    else if (confirmMessage != '' && typeof confirmMessage != "undefined") {   // 다시 한번 확인
                        isCanceled = confirm(confirmMessage) == true ? false : true;
                    }
                    else {
                        alert('구매가 제한된 상품 입니다.');
                    }

                    return;
                }

                if (isStandby) {
                    location.href = "/m/mbasket.aspx";
                    return;
                }

                if (json.Exist == 'true') {
                    if (json.EBookRent == 'true') {
                        htmResult.append("<ul class=\"bsk_list\"><li><span class=\"nm_bsk_t\">이미 대여상품이 장바구니에 담겨있습니다.</li></ul>");
                    }
                    else {
                        htmResult.append("<ul class=\"bsk_list\"><li><span class=\"nm_bsk_t\">이미 장바구니에 담았습니다.</li></ul>");
                    }
                }
                else {
                    
                    htmResult.append("<ul class=\"bsk_list\"><li><span class=\"nm_bsk_t\">선택된 상품이 장바구니에 담겼습니다.</li></ul>");
                }
            }
            else {
                $('.standby-modal-backdrop.loading').remove();
                alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $('.standby-modal-backdrop.loading').remove();
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
            closePopBox();
            return;
        }
    });

    GA4_Basket(isbn, qty);

    //와이즈트래커 코드 삽입
    $("#dvWiseTracker").html("<script type='wisetracker/text' id='wiseTracker'>WiseTracker.setGoalProduct('" + isbn + "');WiseTracker.setGoal('g3', 1 ); WiseTracker.sendTransaction();</script>");

}

function fn_basket_QtyChange(isbn) {
    var qty = $("#qty").val();
    if (typeof (qty) == 'undefined') qty = 1;

    var htmResult = $("div#addBasketResult");
    htmResult.empty();

    var query = 'method=basketaddwithexistcheck&isbn=' + isbn + '&qty=' + qty;
    //var rebindingPrice = $("#rebinding_select").val();
    var rebindingPrice = $(".hd_Rebinding_Price").val();
    if (rebindingPrice > 0) query = query + "&rebinding=1";

    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function (json) {
            htmResult.empty();
            if (json.Success == 'true') {
                try {
                    if (json.Canceled + '' == 'true') {
                        if (json.Message != null && json.Message != '')
                            alert(json.Message);
                        return;
                    }
                }
                catch (e) { }

                if (json.Exist == 'true') {
                    if (json.EBookRent == 'true') {
                        htmResult.append("<div class=\"feedtext\">이미 대여상품이 장바구니에 담겨있습니다.</div>");
                    }
                    else {
                        htmResult.append("<div class=\"feedtext\">" + qty + "개의 상품을 장바구니에 담았습니다.</div>");
                    }
                }
                else {
                    htmResult.append("<div class=\"feedtext\">" + qty + "개의 상품을 장바구니에 담았습니다.</div>");
                }
            }
            else {
                alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
            closePopBox();
            return;
        }
    });

    GA4_Basket(isbn, qty);

    //setTimeout('ShowBasketInfo("basket_info");', 2000);
}

function fn_addbasket_Product(isbn, isBasketList) {
    GetStandbyRequire(isbn, function cb(StandbyEnabled, title) {
        if (StandbyEnabled == 1) {
            NetfunnelSkinUtil.SetOption({ showlogo: true, title: title });
            NetFunnel_Action({ action_id: "product" }, function (ev, ret) {
                fn_addbasket_Product_origin(isbn, isBasketList, true);
            });
        } else {
            fn_addbasket_Product_origin(isbn, isBasketList, false);
        }
    });
}

function fn_addbasket_Product_origin(isbn, isBasketList, isStandby) {
    $("#basket_info").hide();
    var qty = $("#qty").val();
    if (typeof (qty) == 'undefined') qty = 1;
    if (typeof (isStandby) == 'undefined') isStandby = false;

    if (!fn_checkTabletTelecom()) return false;

    var htmResult = $("#addBasketResult");
    htmResult.empty();

    var divAddBasket = $("#addBasket")

    // 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
    // 리스트에서 사용된다. by radioni
    var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');

    if (footerTool.length == 1)
        divAddBasket.prependTo(footerTool);

    htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
    var query = 'method=basketaddwithexistcheck&isbn=' + isbn + '&qty=' + qty;
    //var rebindingPrice = $("#hd_Rebinding_Price").val();
    var rebindingPrice = $(".hd_Rebinding_Price").val();
    var rebinding = 0;
    if (rebindingPrice > 0) {
        rebinding = 1;
        query = query + "&rebinding=1";
    }

    if (isStandby) {
        $('<div class="standby-modal-backdrop loading"/>').appendTo("body").show();
        $('<div class="animation loading"/>').appendTo(".standby-modal-backdrop.loading");
    }

    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function (json) {
            htmResult.empty();
            if (json.Success == 'true') {
                ShowBasketInfo('basket_input');

                try {
                    if (json.Canceled + '' == 'true') {

                        if (json.Message != null && json.Message != '')
                            alert(json.Message);

                        return;
                    }
                }
                catch (e) { }

                if (isStandby) {
                    location.href = "/m/mbasket.aspx";
                    return;
                }

                if (json.Exist == 'true') {
                    if (json.EBookRent == 'true') {
                        htmResult.append("<div class=\"feedtext feedMsg\">이미 대여상품이 장바구니에 담겨있습니다.</div>");
                    }
                    else {
                        htmResult.append("<div class=\"feedtext feedMsg\">이미 장바구니에 담았습니다.</div>");
                    }
                }
                else {
                    htmResult.append("<div class=\"feedtext feedMsg\">장바구니에 담았습니다.</div>");
                    if ($("#option1").length > 0 || $("#option2").length > 0) {
                        
                    }
                    else if (json.BranchType == 9) {
                        htmResult.append("<div class=\"area_d1 feedMsg\"><span class=\"pdp_price\">" + json.Price + "</span></div>");
                    }
                    else {
                        if (isBasketList == 'True') {
                            if (rebindingPrice > 0) {
                                htmResult.append("<div class=\"pdp_fwb feedMsg\">" + json.RebindingOption + ", " + qty + "개</div>");
                            }
                            else {
                                htmResult.append("<div class=\"pdp_fwb feedMsg\">" + json.Title + ", " + qty + "개</div>");
                            }
                            htmResult.append("<div class=\"area_d1 feedMsg\"><span class=\"pdp_price\">" + json.Price + "</span></div>");
                            ExpectDeliveryDate(isbn, qty, rebinding, "addBasketResult", 0);
                        }                        else {
                            htmResult.append("<div class=\"area_d1 feedMsg\"><span class=\"pdp_price\">" + json.Price + ", " + qty + "개</span>&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"ShowBasketInfo('OrderQtyChange');\" class=\"pdp_gray2\"><u>수량변경</u></a></div>");
                            ExpectDeliveryDate(isbn, qty, rebinding, "addBasketResult", 0);
                        }
                    }                }
            }
            else {
                $('.standby-modal-backdrop.loading').remove();
                alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $('.standby-modal-backdrop.loading').remove();
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
            //closePopBox();
            return;
        }
    });

    setTimeout('autoCloseLayer("basket_info");', 2000);

    GA4_Basket(isbn, qty);

    //와이즈트래커 코드 삽입
    $("#dvWiseTracker").html("<script type='wisetracker/text' id='wiseTracker'>WiseTracker.setGoalProduct('" + isbn + "');WiseTracker.setGoal('g3', 1 ); WiseTracker.sendTransaction();</script>");
}

function fn_Crossaddbasket_Product(isbn, isCrossBasket) {
    fn_addbasketStandby(isbn, "False", "False", isCrossBasket);
}

function fn_addbasket_Product_v2(isbn, isBasketList, isEBookRent) {
    fn_addbasketStandby(isbn, isBasketList, isEBookRent, false);
}

function fn_addbasketStandby(isbn, isBasketList, isEBookRent, isCrossBasket) {
    GetStandbyRequire(isbn, function cb(StandbyEnabled, title) {
        if (StandbyEnabled == 1) {
            NetfunnelSkinUtil.SetOption({ showlogo: true, title: title });
            NetFunnel_Action({ action_id: "product" }, function (ev, ret) {
                fn_addbasket_Product_origin_v2(isbn, isBasketList, true, isEBookRent, isCrossBasket);
            });
        } else {
            fn_addbasket_Product_origin_v2(isbn, isBasketList, false, isEBookRent, isCrossBasket);
        }
    });
}

function fn_addbasket_Product_origin_v2(isbn, isBasketList, isStandby, isEBookRent, isCrossBasket) {
	$("#basket_info").hide();
	var qty = $("#qty").val();
	if (typeof (qty) == 'undefined') qty = 1;
	if (typeof (isStandby) == 'undefined') isStandby = false;

	if (!fn_checkTabletTelecom()) return false;

	var htmResult = $("#addBasketResult");
	htmResult.empty();

	//var divAddBasket = $("#addBasket")

	//// 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
	//// 리스트에서 사용된다. by radioni
	//var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');

	//if (footerTool.length == 1)
	//	divAddBasket.prependTo(footerTool);

	htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
	var query = 'method=basketaddwithexistcheck_v2&isbn=' + isbn + '&qty=' + qty;
	//var rebindingPrice = $("#hd_Rebinding_Price").val();
	var rebindingPrice = $(".hd_Rebinding_Price").val();
	var rebinding = 0;
	if (rebindingPrice > 0) {
		rebinding = 1;
		query = query + "&rebinding=1";
    }
    var rebindable = $("#Rebindable").val();
    if (isCrossBasket == true) {
        query = query + "&crossBasket=1";
    }

	if (isStandby) {
		$('<div class="standby-modal-backdrop loading"/>').appendTo("body").show();
		$('<div class="animation loading"/>').appendTo(".standby-modal-backdrop.loading");
	}

	$.ajax({
		type: "GET",
		url: "/shop/BasketAjax.aspx?" + query,
		contentType: "application/json; charset=utf-8",
		cache: false,
		dataType: "json",
		timeout: 3000,
		success: function (json) {
            htmResult.empty();
            
			if (json.Success == 'true') {
				//ShowBasketInfo('basket_input');

				try {
					if (json.Canceled + '' == 'true') {

						if (json.Message != null && json.Message != '')
							alert(json.Message);

						return;
					}
				}
				catch (e) { }

				if (isStandby) {
					location.href = "/m/mbasket.aspx";
					return;
				}

				if (json.Exist == 'true') {
					if (json.EBookRent == 'true') {
                        htmResult.append("<h3>이미 장바구니에 담았습니다.</h3><p>대여/구매 변경은 장바구니에서 해주세요.</p>");
					}
                    else {
                        if (isEBookRent == "True") {
                            htmResult.append("<h3>이미 장바구니에 담았습니다.</h3><p>대여/구매 변경은 장바구니에서 해주세요.</p>");
                        }
                        else if ((isCrossBasket == true && json.BranchType == 1 && rebindable > 0) || (isBasketList == "True" && rebindable > 0)) {
                            htmResult.append("<h3>이미 장바구니에 담았습니다.</h3><p>분철여부, 수량 변경은 장바구니에서 해주세요.</p>");
                        } 
                        else {
                            htmResult.append("<h3>이미 장바구니에 담았습니다.</h3>");
                            if (json.BranchType == 9 && isCrossBasket == true) {
                                if (json.CouponLink != null) {
                                    htmResult.append(`<p>사용 가능한 쿠폰이 있습니다. <a href="${json.CouponLink}"><button class="coupon_btn">${json.DCInfo}</button></a ></p >`);
                                }

                                if (json.EBookRentAble == "true") {
                                    htmResult.append("<p>대여/구매 변경은 장바구니에서 해주세요.</p>");
                                }
                            }
                        }
					}
				}
                else {
                    if (json.BranchType == 9) {
                        htmResult.append("<h3>전자책을 장바구니에 담았습니다.</h3>");
                        if (isCrossBasket == true && json.CouponLink != null) {
                            htmResult.append(`<p>사용 가능한 쿠폰이 있습니다. <a href="${json.CouponLink}"><button class="coupon_btn">${json.DCInfo}</button></a ></p >`);
                        }
                    }
                    else {
                        if (isCrossBasket == true && json.BranchType == 1) {
                            htmResult.append("<h3>종이책을 장바구니에 담았습니다.</h3>");
                        }
                        else {
                            htmResult.append("<h3>장바구니에 담았습니다.</h3>");
                        }
                    }
                    
					if ($("#option1").length > 0 || $("#option2").length > 0) {

					}
					else if (json.BranchType == 9) {
						//htmResult.append("<h3>" + json.Price + "</h3>");
					}
                    else {
                        if (isCrossBasket == true && json.BranchType == 1 && rebindable > 0) {
                            htmResult.append("<p>분철여부, 수량 변경은 장바구니에서 해주세요.</p>");
                        }
                        else {
                            htmResult.append("<p>수량 변경은 장바구니에서 해주세요.</p>");
                        }
                        
						//if (isBasketList == 'True') {
							//if (rebindingPrice > 0) {
								//htmResult.append("<h3>" + json.RebindingOption + ", " + qty + "개</h3>");
							//}
							//else {
								//htmResult.append("<h3>" + json.Title + ", " + qty + "개</h3>");
							//}
							//htmResult.append("<h3>" + json.Price + "</h3>");
							//ExpectDeliveryDate(isbn, qty, rebinding, "addBasketResult", 0);
						//}						//else {
							//htmResult.append("<p>수량 변경은 장바구니에서 해주세요.</p>");
							//htmResult.append("<h3>" + json.Price + ", " + qty + "개</span>&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"ShowBasketInfo('OrderQtyChange');\" class=\"pdp_gray2\"><u>수량변경</u></a></h3>");
							//ExpectDeliveryDate(isbn, qty, rebinding, "addBasketResult", 0);
						//}
					}
				}

                addBasketToggle(isCrossBasket);
			}
			else {
				$('.standby-modal-backdrop.loading').remove();
				alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
			}
		},
		error: function (xhr, ajaxOptions, thrownError) {
			$('.standby-modal-backdrop.loading').remove();
			var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
			alert(msg);
			//closePopBox();
			return;
		}
	});

	GA4_Basket(isbn, qty);

	//setTimeout('autoCloseLayer("basket_info");', 2000);

	//와이즈트래커 코드 삽입
	$("#dvWiseTracker").html("<script type='wisetracker/text' id='wiseTracker'>WiseTracker.setGoalProduct('" + isbn + "');WiseTracker.setGoal('g3', 1 ); WiseTracker.sendTransaction();<\/script>");
}



function fn_addbasket_rent(isbn) {
    $("#basket_info").hide();
    var qty = $("#qty").val();
    if (typeof (qty) == 'undefined') qty = 1;
    
    if (!fn_checkTabletTelecom()) return false;

    var htmResult = $("#addBasketResult");
    htmResult.empty();

    var divAddBasket = $("#addBasket");

    // 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
    // 리스트에서 사용된다. by radioni
    var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');

    if (footerTool.length == 1)
        divAddBasket.prependTo(footerTool);

    htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
    var query = 'method=basketrentadd&isbn=' + isbn;
    
    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function (json) {
            htmResult.empty();
            if (json.Success == 'true') {
                ShowBasketInfo('basket_input');

                try {
                    if (json.Canceled + '' == 'true') {
                        if (json.Message != null && json.Message != '')
                            alert(json.Message);

                        return;
                    }
                }
                catch (e) { }

                if (json.Exist == 'true') {
                    // 장바구니에 이미 아이템이 있음
                    if (json.EBookRent == 'true') {
                        htmResult.append("<div class=\"feedtext\">이미 장바구니에 담았습니다.</div>");
                    }
                    else {
                        htmResult.append("<div class=\"feedtext feedMsg\">이미 구매상품이 장바구니에 담겨있습니다.</div>");
                    }
                }
                else {
                    htmResult.append("<div class=\"feedtext\">대여상품을 장바구니에 담았습니다.</div>");
                    htmResult.append("<div class=\"pdp_fwb feedMsg\">" + json.EBookRentDay + "</div>");
                    htmResult.append("<div class=\"pdp_fwb feedMsg\">" + json.Title + "</div>");
                    htmResult.append("<div class=\"area_d1 feedMsg\"><span class=\"pdp_price\">" + json.Price + "</span></div>");
                }
            }
            else {
                alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
            closePopBox();
            return;
        }
    });

    GA4_Basket(isbn, qty);
    
    setTimeout('autoCloseLayer("basket_info");', 2000);
}

function fn_addbasket_rent_v2(isbn) {
	$("#basket_info").hide();
	var qty = $("#qty").val();
	if (typeof (qty) == 'undefined') qty = 1;

	if (!fn_checkTabletTelecom()) return false;

	var htmResult = $("#addBasketResult");
	htmResult.empty();

	//var divAddBasket = $("#addBasket");

	//// 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
	//// 리스트에서 사용된다. by radioni
	//var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');

	//if (footerTool.length == 1)
	//	divAddBasket.prependTo(footerTool);

	htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
	var query = 'method=basketrentadd&isbn=' + isbn;

	$.ajax({
		type: "GET",
		url: "/shop/BasketAjax.aspx?" + query,
		contentType: "application/json; charset=utf-8",
		cache: false,
		dataType: "json",
		timeout: 3000,
		success: function (json) {
			htmResult.empty();
			if (json.Success == 'true') {
				//ShowBasketInfo('basket_input');

				try {
					if (json.Canceled + '' == 'true') {
						if (json.Message != null && json.Message != '')
							alert(json.Message);

						return;
					}
				}
				catch (e) { }

				if (json.Exist == 'true') {
					// 장바구니에 이미 아이템이 있음
					if (json.EBookRent == 'true') {
						htmResult.append("<h3>이미 장바구니에 담았습니다.</h3>");
					}
					else {
						htmResult.append("<h3>이미 장바구니에 담았습니다.</h3><p>대여/구매 변경은 장바구니에서 해주세요.</p>");
					}
				}
                else {
                    htmResult.append("<h3>전자책을 장바구니에 담았습니다.</h3>");
					//htmResult.append("<h3>대여상품을 장바구니에 담았습니다.</h3>");
					//htmResult.append("<h3>" + json.EBookRentDay + "</h3>");
					//htmResult.append("<h3>" + json.Title + "</h3>");
					//htmResult.append("<h3>" + json.Price + "</h3>");
				}

				addBasketToggle();
			}
			else {
				alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
			}
		},
		error: function (xhr, ajaxOptions, thrownError) {
			var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
			alert(msg);
			closePopBox();
			return;
		}
	});

	GA4_Basket(isbn, qty);

	//setTimeout('autoCloseLayer("basket_info");', 2000);
}

function fn_QuickBuy(IsNaverPay)
{
    var _isbn = $(".hd_ISBN").val();
    if (_isbn.length < 1) {
        alert("상품을 선택해 주세요.");
        return;
    }
    
    if ( !fn_checkTabletTelecom() ) return false;

    var _qty = $("#qty").val();

    var url = '/order/worder_chk_order.aspx?CartType=4&ISBN=' + _isbn;
    if(_qty && parseInt(_qty) != 'NaN')
        url += "&OrderQty="+_qty;

    //var rebindingPrice = $("#hd_Rebinding_Price").val();
    var rebindingPrice = $(".hd_Rebinding_Price").val();
    if (rebindingPrice > 0) url = url + "&rebinding=1";

    //네이버페이인 경우
    //if (IsNaverPay == "1") { url += "&IsNaverPay=1"; }
    if (Number(IsNaverPay) > 0) { url += "&IsNaverPay=" + IsNaverPay; }

    GetStandbyRequire(_isbn, function cb(StandbyEnabled, title) {
        if (StandbyEnabled == 1) {
            NetfunnelSkinUtil.SetOption({ showlogo: true, title: title });
            NetFunnel_Action({ action_id: "product" }, function (ev, ret) {
                location.href = url + "&netfunnel_key=" + ret.data.key;
            });
        } else {
            location.href = url;
        }
    });
}

function fn_QuickBuyRent(IsNaverPay) {
    var _isbn = $(".hd_ISBN").val();
    if (_isbn.length < 1) {
        alert("상품을 선택해 주세요.");
        return;
    }

    if (!fn_checkTabletTelecom()) return false;

    var url = '/order/worder_chk_order.aspx?CartType=4&ebookrent=1&ISBN=' + _isbn;

    //네이버페이인 경우
    //if (IsNaverPay == "1") { url += "&IsNaverPay=1"; }
    if (Number(IsNaverPay) > 0) { url += "&IsNaverPay=" + IsNaverPay; }

    location.href = url;
}

function fn_addBasket_v2()
{
    var _isbn = $(".hd_ISBN").val();
    if (_isbn.length < 1) {
        alert("상품을 선택해 주세요.");
        return;
    }
    fn_addbasket_v1(_isbn);
}

function fn_addBasket_v3()
{
    var isbn = $("#basket_select > option:selected").val();
    fn_addbasket_v1(isbn);
}

//품절센터
function fn_addbasketos_v1(isbn) {
    closePopBox();
    var qty = 1;  //품절센터는 무조건1

    var htmResult = $("div#addBasketOSResult");
    htmResult.empty();

    var divAddBasketOS = $("div#addBasketOS");

    // 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
    // 리스트에서 사용된다. by radioni
    var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');

    if (footerTool.length == 1) {
        divAddBasketOS.prependTo(footerTool);
    }
    
    divAddBasketOS.show();

    htmResult.append("<ul style=\"text-align:center\"><img src='http://image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
    var query = 'method=basketaddwithexistcheck&isbn=' + isbn + '&qty=' + qty + '&pageCartType=5';

    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function (json) {
            htmResult.empty();
            if (json.Success == 'true') {
                try {
                    if (json.Canceled + '' == 'true') {
                        if (json.Message != null && json.Message != '')
                            alert(json.Message);

                        closePopBox();
                        return;
                    }
                }
                catch (e) { }

                if (json.Exist == 'true') {
                    htmResult.append("<span class=\"nm_book_t_g\">이미 품절도서센터 장바구니에 담았습니다.</span>");
                } else {
                    htmResult.append("<span class=\"nm_book_t_g\">품절도서센터 장바구니에 담았습니다.</span>");
                }

            }
            else {
                alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
            closePopBox();
            return;
        }
    });
}

//품절센터
function fn_addbasketos_v2(isbn)
{
    $("#basket_info").hide();
    var qty = 1;  //품절센터는 무조건1
    var htmResult = $("#addBasketOSResult");
    htmResult.empty();
  
    var divAddBasketOS = $("#addBasketOS");
    
    // 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
    // 리스트에서 사용된다. by radioni
    var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');
    
    if (footerTool.length == 1) {
        divAddBasketOS.prependTo(footerTool);
    }
    
    htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
    var query = 'method=basketaddwithexistcheck&isbn=' + isbn + '&qty='+ qty  + '&pageCartType=5';
    
    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function(json) {
            htmResult.empty();
            if (json.Success == 'true') {
                ShowBasketInfo('basketOS_input');

                try
                {
                    if (json.Canceled + '' == 'true')
                    {
                        if (json.Message != null && json.Message != '')
                            alert(json.Message);
                            
                        closePopBox();
                        return;
                    }
                }
                catch(e) {}
                
                if (json.Exist == 'true') {
                    htmResult.append("<div class=\"feedtext feedMsg\">이미 품절도서센터 장바구니에 담았습니다.</div>");
                } else {
                    htmResult.append("<div class=\"feedtext feedMsg\">품절도서센터 장바구니에 담았습니다.</div>");
                }
                htmResult.append("<div class=\"feedMsg\">결제 후 신청이 완료됩니다. </div>");
            }
            else {
                alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
            closePopBox();
            return;
        }
    });
    
    setTimeout('ShowBasketInfo("basket_info");', 2000);
}

function fn_addbasketos_v3(isbn) {
    closePopBox();
    var qty = 1;  //품절센터는 무조건1

    var htmResult = $("div#addBasketOSResult");
    htmResult.empty();

    var divAddBasketOS = $("div#addBasketOS");

    // 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
    // 리스트에서 사용된다. by radioni
    var footerTool = $('.asdf[isbn="' + isbn + '"]');

    if (footerTool.length == 1) {
        divAddBasketOS.prependTo(footerTool);
    }

    divAddBasketOS.show();

    htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
    var query = 'method=basketaddwithexistcheck&isbn=' + isbn + '&qty=' + qty + '&pageCartType=5';

    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 3000,
        success: function (json) {
            htmResult.empty();
            if (json.Success == 'true') {
                try {
                    if (json.Canceled + '' == 'true') {
                        if (json.Message != null && json.Message != '')
                            alert(json.Message);

                        closePopBox();
                        return;
                    }
                }
                catch (e) { }

                if (json.Exist == 'true') {
                    htmResult.append("<span class=\"nm_book_t_g\">이미 품절도서센터 장바구니에 담았습니다.</span>");
                } else {
                    htmResult.append("<span class=\"nm_book_t_g\">품절도서센터 장바구니에 담았습니다.</span>");
                }

            }
            else {
                alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
            alert(msg);
            closePopBox();
            return;
        }
    });
}

//품절센터
function fn_addbasketos_v4(isbn) {
	$("#basket_info").hide();
	var qty = 1;  //품절센터는 무조건1
	var htmResult = $("#addBasketResult");
	htmResult.empty();

	//var divAddBasketOS = $("#addBasketOS");

	//// 페이지내에 ItemListFooterTool 클래스와 isbn 속성이 일치하는 element가 있다면 그쪽으로 이동
	//// 리스트에서 사용된다. by radioni
	//var footerTool = $('.ItemListFooterTool[isbn="' + isbn + '"]');

	//if (footerTool.length == 1) {
	//	divAddBasketOS.prependTo(footerTool);
	//}

	htmResult.append("<ul style=\"text-align:center\"><img src='//image.aladin.co.kr/img/tablet/indicator.gif' style='height:30px;padding:0 42px 0 42px'/></ul>");
	var query = 'method=basketaddwithexistcheck&isbn=' + isbn + '&qty=' + qty + '&pageCartType=5';

	$.ajax({
		type: "GET",
		url: "/shop/BasketAjax.aspx?" + query,
		contentType: "application/json; charset=utf-8",
		cache: false,
		dataType: "json",
		timeout: 3000,
		success: function (json) {
			htmResult.empty();
			if (json.Success == 'true') {
				//ShowBasketInfo('basketOS_input');

				try {
					if (json.Canceled + '' == 'true') {
						if (json.Message != null && json.Message != '')
							alert(json.Message);

						closePopBox();
						return;
					}
				}
				catch (e) { }

				if (json.Exist == 'true') {
					htmResult.append("<h3>이미 품절도서센터 장바구니에 담았습니다.</h3>");
				} else {
					htmResult.append("<h3>품절도서센터 장바구니에 담았습니다.</h3>");
				}
				htmResult.append("<p>결제 후 신청이 완료됩니다. </p>");

				addBasketOSToggle();
			}
			else {
				alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
			}
		},
		error: function (xhr, ajaxOptions, thrownError) {
			var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
			alert(msg);
			closePopBox();
			return;
		}
	});

	//setTimeout('ShowBasketInfo("basket_info");', 2000);
}


function getMorePaper(cType, paperId) {
    $.get(Common.format("/ucl/m/product/ajax/m_ajax_morePaper.aspx?paperId={0}&CommunityType={1}", paperId, cType), function(data) {  
        $("div#paperAll_"+paperId).html(data);
    });
}



function AlarmOpen(authorId)
{
    var htmMessage = $("div#alarmMessage");
    var htmResult = $("div#alarmResult");
    var authorName = $(Common.format("a#a_{0}", authorId)).text();
    
    htmMessage.empty();
    htmResult.empty();
    htmResult.append("<ul style=\"text-align:center\"><img src=\"//image.aladin.co.kr/img/tablet/indicator.gif\" width=\"25\" height=\"25\"/></ul>");
    $("div#alarmApply").show();
    $.ajax({
        url: "/ucl/m/product/ajax/m_ajax_alarmApply.aspx",
        data: Common.format("AuthorId={0}", authorId),
        cache: false,
        success: function(data) {
            var result;
            eval("result = " + data);
            var htm = "";
            htmMessage.append("<ul class=\"bsk_list\"><li>"+ result.Message+ "</li></ul>");
            htmResult.empty();
            if (result.Result > 0)
            {
                htm += "<ul><li>저자아티스트 : <span class=\"nm_bsk_t\">"+authorName+"</span></li>";
                htm += "<li><input type=\"checkbox\" id=\"ckIsActiveMail\" "+ result.IsActiveMail +" /> 메일로 받기 </li>";
                htm += "<li><input type=\"checkbox\" id=\"ckIsActiveSms\" "+ result.IsActiveSMS +" /> 문자로 받기 </li>";
                htm += "</ul>";
                htmResult.append(htm);
                if(result.Result == 1) {
                    htmResult.next().html("<div style=\"text-align:center;\"><span style=\"width:140px;\"><a href=\"javascript:AlarmApply("+authorId+","+result.AlarmId+")\"><div class=\"bk_btn_basket_1\"> 신청하기 </div></a></span></div>")
                }
                else if(result.Result == 2) {
                    htmResult.next().html("<div style=\"width:265px;\"><div style=\"width:40%;float:left;\"><a href=\"javascript:AlarmApply("+authorId+","+result.AlarmId+")\"><div class=\"bk_btn_basket_1\"> 수신변경하기 </div></a></div><div style=\"width:40%;float:left;margin-left:10px;\"><a href=\"javascript:closeAlarmApply();\"><div class=\"bk_btn_keep_1\"> 닫기 </div></a></div></div><br/><br/>")
                    //htmResult.next().html("<a href=\"javascript:AlarmApply("+authorId+","+result.AlarmId+")\" ><img src=\"//image.aladin.co.kr/img/m/2010/btn_edit_popup.jpg\" /></a> <a href=\"javascript:closeAlarmApply()\" ><img src=\"//image.aladin.co.kr/img/m/2010/btn_close_popup.jpg\" /></a>");
                }
            }
            else
            {
                htmResult.hide();
                htmResult.next().html("<div style=\"text-align:center;\"><span style=\"width:140px;\"><a href=\"javascript:go_login();\"><div class=\"bk_btn_keep_1\"> 로그인 </div></a></span></div>")
            }
        }
    });
}

function go_login() {
    location.href = Common.format("https://www.aladin.co.kr/m/mlogin.aspx?returnUrl={0}",escape(location.href));
}

function AddFavoriteShop(shopcode) {
    $.ajax({
        url: "/ucl/m/product/ajax/m_ajax_common.aspx",
        data: Common.format("method={0}&shopcode={1}", "add_favoriteshop", shopcode),
        cache:false,
        success:function(json) {
            if(json.Success == 'true') {
                $("#AddFavoriteShop .bsk_list").html("<div style=\"text-align:center;padding:10px;\">단골 판매자로 등록되었습니다.</div>")
            } else {
            
            }
        }
    });
}

function AlarmApply(authorId, alarmId)
{
    var IsActiveMail = $("input[id='ckIsActiveMail'][type='checkbox']").is(':checked');
    var IsActiveSms = $("input[id='ckIsActiveSms'][type='checkbox']").is(':checked');
    
    var applyStep = 1;
    if(alarmId > 1)
        applyStep = 2;
    var htmMessage = $("div#alarmMessage");
    var htmResult = $("div#alarmResult");
    
    htmMessage.empty();
    htmResult.empty();
    
    $.ajax({
        url: "/ucl/m/product/ajax/m_ajax_alarmApply.aspx",
        data: Common.format("ApplyStep={0}&AuthorId={1}&AlarmId={2}&IsActiveMail={3}&IsActiveSms={4}", applyStep, authorId, alarmId, IsActiveMail, IsActiveSms),
        cache: false,
        success: function(data) {
            var result;
            eval("result = " + data);
            htmResult.text(result.Message);
            htmResult.next().html("<div style=\"text-align:center;\"><span style=\"width:140px;\"><a href=\"javascript:closeAlarmApply();\"><div class=\"bk_btn_keep_1\"> 닫기 </div></a></span></div>")
        }
    });
}

function closeAlarmApply()
{
    $("div#alarmApply").hide();
}



function FindZip()
{
    $("div#addressForm").show();
}

function AddressSearch(isbn){
    var postSearch = $("input[id='postSearch'][type='text']");
	if(!postSearch) return;
	
	if(postSearch.val().length < 1) {
	    alert("동/읍/면의 이름을 입력해 주세요");
	    postSearch.focus();
	    return;
	}
	var addressSummary = $("p#addressSummary");
	var addressResult = $("div#addressResult");
	
	addressResult.empty();
	addressSummary.text("검색중...");
	$.ajax({
            type: "POST",
            url: "/ucl/m/product/ajax/m_ajax_addressSearch.aspx",
            data: Common.format("postSearch={0}", escape(postSearch.val())),
            cache: false,
            success: function(data) {
                var result, list, listData;
                eval("result = " + data);
                list = result.List;
                
                addressSummary.text(result.Summary);
                
                var addressStr = "";
                $.each(list, function(index, address) {
                    addressStr += Common.format("<li><a href=\"javascript:saveZip({0},'{1}')\">{2}</a></li>", address.Param, isbn, address.Address);
                });
                addressResult.append("<div class=\"pop_box_conts3\"><ul>" + addressStr + "</ul></div>");
            }
    });
}

function getEvent(ev){
	return (ev ? ev : window.event);
}

function postSearch_onkeydown_2(ev,isbn){
	ev = getEvent(ev);
	if(ev.keyCode==13){
		AddressSearch(isbn);
		if(window.event){
			ev.cancelBubble = true; 
			ev.returnValue = false;
		} else {
			ev.stopPropagation();
			ev.preventDefault();
		}
		return false;
	}
	return;
}

function saveZip(zipCode, addr1, isbn)
{
	$.ajax({
            type: "POST",
            url: "/m/ajax/m_ajax_addressApply.aspx",
            data: Common.format("zipCode={0}&addr1={1}", zipCode, escape(addr1)),
            cache: false,
            success: function(data) {
                var result, list, listData;
                eval("result = " + data);

                if(result.Result == "True") {
                    location.href = "/m/mproduct.aspx?ISBN="+isbn;
                }
                else {
                    alert(result.Message);
                }
            }
    });
}
// 우편번호 5자 새로운 버전
function saveZipNew(zipCode, addr1, isbn, roadKey) {
    $.ajax({
        type: "POST",
        url: "/m/ajax/m_ajax_addressApply.aspx",
        data: Common.format("zipCode={0}&addr1={1}&roadKey={2}", zipCode, escape(addr1), roadKey),
        cache: false,
        success: function (data) {
            var result, list, listData;
            eval("result = " + data);

            if (result.Result == "True") {
                location.href = "/m/mproduct.aspx?ISBN=" + isbn;
            }
            else {
                alert(result.Message);
            }
        }
    });
}

function fn_go_letslook(isbn) {
    location.href=Common.format("/m/mletslooks.aspx?ISBN={0}#ItemCover",isbn);
}

function fn_paper_util(type, paperId) {
	$.ajax({
        type: "POST",
        url: "/ucl/m/product/ajax/m_ajax_paper_util.aspx",
        data: Common.format("Type={0}&PaperId={1}", type, paperId),
        cache: false,
        success: function(data) {
            var result, list, listData;
            eval("result = " + data);
            
            if(type != "recommend" && result.Result > 1) {
                location.href = Common.format("https://www.aladin.co.kr/m/mlogin.aspx?returnUrl={0}", escape(location.href));
            }
            else {

                if (type == "thanksto") {
                    if (result.Result == 1) {
                        $("#thanksToComment").html(result.Message);
                        $("#mask").show();
                        var top = ($(window).height() / 3) + $(window).scrollTop();
                        $("#thanksToLayer").css("top", top).show();

                    } else {
                        $("#paperComment").html(result.Message);
                        $("#paperLayer").slideDown();

                        //setTimeout('$("#paperLayer").slideUp();', 2000);
                    }
                } else if (type == "cancelthanksto") {
                    $("#paperComment").html(result.Message);
                    $("#paperLayer").slideDown();

                    //setTimeout('$("#paperLayer").slideUp();', 2000);

                    if (result.Result == 1) {
                        eval(result.ResultFunc);
                    }
                } else if (type == "recommend" || type == "cancelrecommend") {
                    if (result.Result == 1) {
                        $("#bt_recom_" + paperId).attr("href", "javascript:fn_paper_util('" + (type == "recommend" ? "cancelrecommend" : "recommend") + "'," + paperId + ");");
                        $("#ibt_recom_" + paperId).attr("src", "//image.aladin.co.kr/img/shop/m/re_like" + (type == "recommend" ? "_c_m" : "") + ".gif");
                    }
                    $("#cnt_recom_" + paperId).html(result.ResultData);
                    $("#paperComment").html(result.Message);
                    $("#paperLayer").slideDown();
                }
                else {
                    $("#paperComment").html(result.Message);
                    $("#paperLayer").slideDown();
                    //setTimeout('$("#paperLayer").slideUp();', 2000);
                }
            }
        },
        complete: function () {
            if($("#paperLayer").css("display") != "none") {
                setTimeout('$("#paperLayer").slideUp();', 2000);
            }
        }
	});
}

function fn_confirm_thanksto(communityType, itemId, paperId) {
    $('#thanksToLayer').hide();
    $("#mask").hide();

    fn_paper_refresh(communityType, itemId, paperId, 'confirm');
}

// ThanksTo는 아이템 단위로 적용되기 때문에 1개의 페이퍼에만 가능함
// 100자평, 마이리뷰, 마이페이퍼 전체 목록 새로고침
function fn_paper_refresh(communityType, itemId, paperId, action) {
    var isOrderer_CommentReview = $('#CommentReview_IsOrderer').val();
    var isOrderer_MyReview = $('#MyReview_IsOrderer').val();

    if (isOrderer_CommentReview == 1) {
        $('#tab_OrdererList').trigger('click');
    } else {
        $('#tab_TotalList').trigger('click');
    }

    if (isOrderer_MyReview == 1) {
        $('#tab_MyReviewOrderer').trigger('click');
    } else {
        $('#tab_MyReviewTotal').trigger('click');
    }

    var isConfirm = (typeof action === "undefined") ? false : true;

    // 마이페이퍼 목록 갱신 시, 오류 - 임시로 해당 페이지 UI 변경 조치
    $("#MyPaperUpdates a.bt_thanks_to").each(function (index, value) {
        var id = $(this).attr('id');

        if (id == ('bt_thank_' + paperId)) {
            $(this).find('img').attr('src', '//image.aladin.co.kr/img/shop/m/' + (isConfirm ? 're_thanks_c_m.gif' : 're_thanks.gif'));
            $(this).find('img').attr('width', (isConfirm ? '98px' : '70px'));
            $(this).attr('href', "javascript:fn_paper_util('" + (isConfirm ? 'cancelthanksto' : 'thanksto') + "'," + paperId.toString() + ');');
        } else {
            $(this).find('img').attr('src', '//image.aladin.co.kr/img/shop/m/re_thanks.gif');
            $(this).find('img').attr('width', '70px');
            $(this).attr('href', "javascript:fn_paper_util('thanksto'," + id.replace('bt_thank_', '').toString() + ");");
        }

    });
}

function fn_go_productSub(isbn, subType) {
    var url = "/m/mproductSub.aspx?ISBN={0}&SubType={1}";
    location.href=Common.format(url, isbn, subType);
}

function fn_go_productSub(isbn, subType, param) {
    var url = "/m/mproductSub.aspx?ISBN={0}&SubType={1}&{2}";
    location.href=Common.format(url, isbn, subType, param);
}

function fn_go_seriesSub(isbn, seriesId) {
    var url = "/m/mproductSub.aspx?ISBN={0}&SubType=Series&SRID={1}";
    location.href=Common.format(url, isbn, seriesId);
}

function fn_changISBN(isbn,title)
{
    if(title.length > 16)
        title = title.substring(0,15) + "..";
    $(".hd_ISBN").val(isbn);
    $("#SeletedItem").text(title);
    fn_helpLayer_Toggle('basketItemLayer')
}

function fn_changeISBN_v2(isbn) {
    BtnActiveSet(isbn);

    if (isbn.length < 1) {
        $(".hd_ISBN").val('');
        alert("상품을 선택해 주세요.");
        return;
    }

    $(".hd_ISBN").val(isbn);
}

function fn_changeISBN_v3(itemid) {
    if (itemid > 0) {
        var url = "/m/mproduct.aspx?ItemId={0}";
        location.href = Common.format(url, itemid);
    }
}

function BtnActiveSet(isbn) {
    if (isbn.length < 1) {
        $("#btnAddBasket > div").attr("class", "pdp_red_btn_big_off");
        $("#btnQuickBuy > div").attr("class", "pdp_red_btn_big_off");
        $("#btnNPay > div").attr("class", "pdp_npay_btn_big_off");
        $("#btnSafeBasket").attr("class", "pdp_love_btn_big_off");
    }
    else {
        $("#btnAddBasket > div").attr("class", "pdp_pink_btn_big");
        $("#btnQuickBuy > div").attr("class", "pdp_red_btn_big");
        $("#btnNPay > div").attr("class", "pdp_npay_btn_big ");
        $("#btnSafeBasket").attr("class", "pdp_love_btn_big");
    }
}

function Present() {
    var isbn = $(".hd_ISBN").val();
    if(isbn.length < 1) {
        alert("상품을 선택해 주세요.");
        return;
    }

    if ($("#addBasketGift").css("display") == "none") {
        var qty = $("#qty").val();
        if (typeof (qty) == 'undefined') qty = 1;

        if (!fn_checkTabletTelecom()) return false;
        var query = 'method=basketaddwithexistcheck&isgiftvoucher=1&isbn=' + isbn + '&qty=' + qty;

        var rebindingPrice = $(".hd_Rebinding_Price").val();
        var rebinding = 0;
        if (rebindingPrice > 0) {
            rebinding = 1;
            query = query + "&rebinding=1";
        }

        var htmResult = $("#addBasketGiftResult");

        $.ajax({
            type: "GET",
            url: "/shop/BasketAjax.aspx?" + query,
            contentType: "application/json; charset=utf-8",
            cache: false,
            dataType: "json",
            timeout: 3000,
            success: function (json) {
                htmResult.empty();
                if (json.Success == 'true') {
                    $("#mask").show();
                    $("#addBasketGift").show();
                    $("body").attr("style", "overflow:hidden");

                    try {
                        if (json.Canceled + '' == 'true') {
                            if (json.Message != null && json.Message != '')
                                alert(json.Message);

                            return;
                        }
                    }
                    catch (e) { }

                    if (json.Exist == 'true') {
                        if (json.EBookRent == 'true') {
                            htmResult.append("<div class=\"title-box1 feedMsg\" style=\"padding-bottom:20px;\" ><h3 class=\"title1\">이미 대여상품이 장바구니에 담겨있습니다.</h3></div>");
                        }
                        else {
                            htmResult.append("<div class=\"title-box1 feedMsg\" style=\"padding-bottom:20px;\"><h3 class=\"title1\">이미 장바구니에 담았습니다.</h3></div>");
                        }
                    }
                    else {
                        htmResult.append("<div class=\"title-box1 feedMsg\"><h3 class=\"title1\">선물하실 상품을 장바구니 담았습니다.</h3></div>");
                        htmResult.append("<div class=\"subtext-box1 feedMsg\">장바구니로 이동하신 후, 선물하실 상품을 선택하고 <font class=\"pdp_pink\">\"선택상품 선물하기\"</font>를 터치해주세요. </div>");
                    }
                }
                else {
                    alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
                alert(msg);
                //closePopBox();
                return;
            }
        });
    }
    else {
        $("#mask").hide();
        $("#addBasketGift").hide();
        $(".feedMsg").hide();
        $("body").removeAttr("style");
    }
    

    //var url = "/m/mbasket.aspx?AddBook={0}&IsGiftVoucher=1";
    //location.href=Common.format(url, _isbn);
}

function Present_v2() {
	var isbn = $(".hd_ISBN").val();
	if (isbn.length < 1) {
		alert("상품을 선택해 주세요.");
		return;
	}

	if ($("#addBasketLayer").css("display") == "none") {
		var qty = $("#qty").val();
		if (typeof (qty) == 'undefined') qty = 1;

		if (!fn_checkTabletTelecom()) return false;
		var query = 'method=basketaddwithexistcheck&isgiftvoucher=1&isbn=' + isbn + '&qty=' + qty;

		var rebindingPrice = $(".hd_Rebinding_Price").val();
		var rebinding = 0;
		if (rebindingPrice > 0) {
			rebinding = 1;
			query = query + "&rebinding=1";
		}

		var htmResult = $("#addBasketResult");

		$.ajax({
			type: "GET",
			url: "/shop/BasketAjax.aspx?" + query,
			contentType: "application/json; charset=utf-8",
			cache: false,
			dataType: "json",
			timeout: 3000,
			success: function (json) {
				htmResult.empty();
				if (json.Success == 'true') {
					//$("#mask").show();
					//$("#addBasketGift").show();
					//$("body").attr("style", "overflow:hidden");

					try {
						if (json.Canceled + '' == 'true') {
							if (json.Message != null && json.Message != '')
								alert(json.Message);

							return;
						}
					}
					catch (e) { }

					if (json.Exist == 'true') {
						if (json.EBookRent == 'true') {
                            htmResult.append("<h3>이미 장바구니에 담았습니다.</h3><p>대여/구매 변경은 장바구니에서 해주세요.</p>");
						}
						else {
							htmResult.append("<h3>이미 장바구니에 담았습니다.</h3>");
						}
					}
					else {
						htmResult.append("<h3>선물하실 상품을 장바구니에 담았습니다.</h3>");
						htmResult.append("<p>장바구니로 이동하여 선물하실 상품을 선택 후,<br><span class=\"pink_txt\">\"선물\"</span> 버튼을 터치해주세요.</p>");
					}

					giftbasketToggle();
				}
				else {
					alert('상품을 장바구니에 담는 동안 오류가 발생했습니다.\n잠시 후에 다시 시도해주세요.');
				}
			},
			error: function (xhr, ajaxOptions, thrownError) {
				var msg = 'xhr.status : ' + xhr.status + '\nthrownError : ' + thrownError;
				alert(msg);
				//closePopBox();
				return;
			}
		});
	}
	else {
		addBasketToggle();
	}
}

function ShowSNSLayer() {
    ToggleMaskLayer("SNSLayer");
    /*
    if ($("#SNSLayer").css("display") == "none") {
        $(".baket_remoteWrap").hide();
        $("#mask").show();
        $("#btn_floatNavi").hide();
        $("#SNSLayer").slideDown(150);
        $("body").attr("style", "overflow:hidden");
    }
    else {
        $("#SNSLayer").slideUp(150, function () {
            $(".baket_remoteWrap").show();
            $("#mask").hide();
            $("#btn_floatNavi").show();
            $("body").removeAttr("style");
        });
    }
    */
}

function ShowCartoonSNSLayer() {
    ToggleMaskLayer("CartoonSNSLayer");
    /*
    if ($("#CartoonSNSLayer").css("display") == "none") {
        $(".baket_remoteWrap").hide();
        $("#mask").show();
        $("#btn_floatNavi").hide();
        $("#CartoonSNSLayer").slideDown(150);
        $("body").attr("style", "overflow:hidden");
    }
    else {
        $("#CartoonSNSLayer").slideUp(150, function () {
            $(".baket_remoteWrap").show();
            $("#mask").hide();
            $("#btn_floatNavi").show();
            $("body").removeAttr("style");
        });
    }
    */
}

function ToggleMaskLayer(id) {
    var layerId = "#" + id;
    if ($(layerId).css("display") == "none") {
        $(".baket_remoteWrap").hide();
        $("#mask").show();
        $("#btn_floatNavi").hide();
        $(layerId).slideDown(250);
        $("body").attr("style", "overflow:hidden");
    }
    else {
        $(layerId).slideUp(150, function () {
            $(".baket_remoteWrap").show();
            $("#mask").hide();
            $("#btn_floatNavi").show();
            $("body").removeAttr("style");
        });
    }
}



function QuickBuyCheck(isbn)
{
    window.event.preventDefault();

    GetStandbyRequire(isbn, function cb(StandbyEnabled, title) {
        if (StandbyEnabled == 1) {
            NetfunnelSkinUtil.SetOption({ showlogo: true, title: title });
            NetFunnel_Action({ action_id: "product" }, function (ev, ret) {
                QuickBuyCheckOrigin(isbn, ret.data.key);
            });
        } else {
            QuickBuyCheckOrigin(isbn);
        }
    });
}

function QuickBuyCheckOrigin(isbn, key) {
    var query = 'method=quickbuycheck&isbn=' + isbn,
        isCanceled = false,
        isLoginRequire = false,
        isAuthRequire = false,
        alertMessage = '',
        confirmMessage = '';

    if (typeof (key) == 'undefined') key = "";
    
    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 5000,
        async: false,

        beforeSend: function (xhr) {

        },
        complete: function (xhr, status) {

        },

        success: function (json) {

            if (json.Success == 'true') {
                // 취소여부 확인
                try {
                    if (json.Canceled + '' == 'true')
                        isCanceled = true;
                }
                catch (e) { }

                // 로그인 여부 확인
                try {
                    if (json.LoginRequire + '' == 'true')
                        isLoginRequire = true;
                }
                catch (e) { }

                // 본인인증 여부 확인
                try {
                    if (json.AuthRequire + '' == 'true')
                        isAuthRequire = true;
                }
                catch (e) { }

                // alert 메세지 확인
                try {
                    alertMessage = json.AlertMessage;
                }
                catch (e) { }

                // confirm 메세지 확인
                try {
                    confirmMessage = json.ConfirmMessage;
                }
                catch (e) { }

                if (isCanceled == true) {
                    if (isLoginRequire == true) {
                        if (confirm(confirmMessage) == true) {
                            go_login();
                        }
                    }
                    else if (isAuthRequire == true) {
                        if (confirm(confirmMessage) == true) {
                            location.href = '/account/AuthAdult.aspx?returnUrl=' + encodeURIComponent(location.href);
                        }
                    }
                    else if (alertMessage != '' && typeof alertMessage != "undefined") {
                        alert(alertMessage);
                    }
                    else if (confirmMessage != '' && typeof confirmMessage != "undefined") {   // 다시 한번 확인
                        isCanceled = confirm(confirmMessage) == true ? false : true;
                    }
                    else {
                        alert('구매가 제한된 상품 입니다.');
                    }
                }
                else {
                    if (key != '') {
                        location.href = json.ReturnUrl + "&netfunnel_key=" + key;
                    }
                    else
                    {
                        location.href = json.ReturnUrl;
                    }
                }

            }

        },
        error: function (xhr, ajaxOptions, thrownError) {

        }
    });

    return isCanceled == true ? false : true;
}

function ExpectDeliveryDate(isbn, qty, isRebinding, tagId, isUpdate) {
    $.ajax({
        url: "/shop/ExpectDeliveryDate_Ajax.aspx",
        data: { ISBN: isbn, IsMobile: 1, Qty: qty, Rebinding: isRebinding },
        type: "Post",
        dataType: 'html',
        success: function (result) {
            if (isUpdate == 1) {
                $("#" + tagId).html(result);
            }
            else {
                $("#" + tagId).append("<div class=\"pdp_space\"></div><div class=\"area_a7\"><p class=\"shippingdate feedMsg\">" + result + "</p></div>");
            }
        },
        error: function (request, status, error) {
            alert("code:" + request.status + "\n" + "message:" + request.responseText + "\n" + "error:" + error);
        }
    });
}

function GetStandbyRequire(isbn, cb) {
    if(typeof(NetFunnel) != 'object'){ 
        cb(0);return;
    }

    var query = 'method=standbyrequire&isbn=' + isbn;

    $.ajax({
        type: "GET",
        url: "/shop/BasketAjax.aspx?" + query,
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        timeout: 5000,
        async: false,
        success: function (json) {
            if (json.Success == 'true') {
                cb(json.StandbyEnabled == 'true' ? 1:0, json.Title);
            }
        },
        error: function (xhr, status, error) {
            alert('잠시 후 다시 시도해주세요.');
        }
    });
}

function GA4_Basket(isbn, qty) {
	if (qty == undefined)
		qty = 1;

	GA4_Run("GA4_add_to_cart", isbn, qty);
}

function GA4_Wish(isbn) {
	GA4_Run("GA4_add_to_wishlist", isbn, 1);
}

function GA4_Run(type, isbn, qty) {
	var query = '&type=' + type + '&isbn=' + isbn + '&qty=' + qty;
	var url = "/Product/ItemInfo.aspx?" + query;

	jQuery.getScript(url);
}


/*
var ypPickUpStockTable = {
    itemId: 0,
    ISBN: "",
    _prevScrollTop: 0,
    stockTableLayerModal: false,
    fullLayer: false,
    init: function () {
        var url = "/shop/basket/YpPickupverify.aspx?f=product&mobile=1&ItemId=" + this.itemId;

        $("#pickUpStockTable_mobile").load(url, function (html) {
            if (html && html.length > 0) {
                ypPickUpStockTable._stockTableAjaxDone();
            }
        });
    },
    _stockTableAjaxDone: function () {
        // 레이어 크기
        // $("#pickUpStockTableLayer_mobile").height($(window).height());

        // 1시간 픽업 - 버튼 나오게
        var $utilBtnWrap = $(".btnHourPickUp").parents(".mp_book_btnwrap");
        $utilBtnWrap.removeClass("mp_book_btnwrap").addClass("mp_book_btnwrap3");
        $utilBtnWrap.find(".mg_right1").removeClass("mg_right1");
        $(".layerBtnHourPickUp").show();

        // 지점별 재고 확인 - 버튼 나오게
        var $utilBtnWrap2 = $(".btnShowPickUpStockTable").parents(".mp_book_btnwrap");;
        $utilBtnWrap2.removeClass("mp_book_btnwrap").addClass("mp_book_btnwrap3");
        $utilBtnWrap2.find(".mg_right1").removeClass("mg_right1");
        $(".layerBtnShowPickUpStockTable").show();

        $(".btnHourPickUp").click(function (e) {
            fn_addbasket_v1(ypPickUpStockTable.ISBN, true);
            //console.log("btnHourPickUp");
            return false;
        });

        $(".btnShowPickUpStockTable").click(function (e) {
            ypPickUpStockTable.showPickUpStockTable();
            //console.log("btnShowPickUpStockTable");
            return false;
        });

        $(".btnClosePickUpStockTable").click(function (e) {
            ypPickUpStockTable.closePickUpStockTable();
            return false;
        });

        this._initFullLayer();
    },
    showPickUpStockTable: function () {
        this.fullLayer.openLayer("#pickUpStockTableLayer_mobile");
    },
    closePickUpStockTable: function () {
        this.fullLayer.closeLayer("#pickUpStockTableLayer_mobile");
    },
    _initFullLayer: function () {
        this.fullLayer = (function (window, document, $) {
            var documentElement = document.documentElement,
                $win = $(window),
                $root = $(document),
                $html = $(documentElement);

            var ui = {},
                prevOffsetTop = 0;

            // 풀 레이어 본문 영역 조정
            var setFullLayerBodyHeight = function (layer) {
                layer
                    .find('.layer_body')
                    .css('height', $win.height() - layer.find('.layer_header').outerHeight() - layer.find('.layer_footer').outerHeight());
            }

            var getAddons = function (element) {
                var data = element.data('addons');

                if (data) {
                    return data.split(/\s+/);
                }
            }

            // 오버레이
            ui.layerAddons = {
                overlay: function (layer) {
                    var overlay = $('#overlay');

                    if (!overlay.length) {
                        overlay = $('<div />', {
                            'class': 'overlay',
                            'id': 'overlay'
                        });
                    }

                    var resizeOverlay = function () {
                        var htmlHeight = $html.height(),
                            winHeight = $win.height();

                        return overlay.css({
                            width: $win.width(),
                            height: winHeight > htmlHeight ? winHeight : htmlHeight
                        });
                    }

                    if (overlay && overlay.length) {
                        resizeOverlay().addClass('opened').insertBefore(layer);

                        $win.on('resize.overlay orientationchange.overlay', function () {
                            resizeOverlay();

                            window.setTimeout(resizeOverlay, 20);
                        });
                    }
                },
                center: function (layer) {
                    var windowHeight = $win.height(),
                        layerHeight = layer.outerHeight(),
                        posTop = 0;

                    if (layerHeight < windowHeight) {
                        posTop = $win.scrollTop() - layer.offsetParent().offset().top + ((windowHeight - layerHeight) / 2);
                        layer.css('top', posTop);
                    } else {
                        $win.scrollTop(0);
                    }
                }
            };

            // 레이어 제어(열기/닫기)
            ui.openLayer = function (element, className) {
                var layer = $(element),
                    addons = getAddons(layer),
                    scrollTop,
                    winHeight,
                    layerHeight;

                prevOffsetTop = $win.scrollTop();
                className = className || 'opened';

                layer.addClass(className);

                if (addons && addons.length) {
                    $.each(addons, function (i, addon) {
                        if ($.isFunction(ui.layerAddons[addon])) {
                            ui.layerAddons[addon](layer);
                        }
                    });
                }

                if (layer.hasClass('layer--full')) {
                    $html.addClass('layer--full--opened');
                    setFullLayerBodyHeight(layer);

                    $win.on('resize.fullLayer orientationchange.fullLayer', function () {
                        setFullLayerBodyHeight(layer);
                    });
                }
                layer.find(".layer_body").scrollTop(0);

                layer.trigger('layeropened');
            };
            ui.closeLayer = function (element, className) {
                var layer = $(element),
                    overlay = $('#overlay'),
                    scrollTop = layer.data('scrollTopBeforeOpen'); // layer가 닫힌 후, 바탕 페이지의 scroll top

                className = className || 'opened';

                layer.removeClass(className);

                if (overlay && overlay.length) {
                    overlay.remove();
                }

                if (layer.hasClass('layer--full')) {
                    $html.removeClass('layer--full--opened');

                    $win.off('.fullLayer');
                }

                if (layer.hasClass('layer--cover')) {
                    $html
                        .removeClass('layer--cover--opened')
                        .css('height', '');
                }
                if (scrollTop) {
                    $win.scrollTop(scrollTop);
                } else {
                    // scrollTopBeforeOpen 이 지정되어 있지 않으면, 이전 scroll유지
                    $win.scrollTop(prevOffsetTop);
                }

                layer.trigger('layerclosed');
            };
            ui.toggleLayer = function (element, className) {
                var layer = $(element);

                className = className || 'opened';

                if (layer.hasClass(className)) {
                    ui.closeLayer(element, className);
                } else {
                    ui.openLayer(element, className);
                }
            };

            return ui;
        }(window, document, $));

    }
};
*/