﻿// optimazed jquery 1.3.2

function GetCommentList() {
    if ($jq("#idx").val() == "") {
        alert("댓글을 가져올 수 없습니다. 관리자에게 문의해주세요. #error:2010");
        return;
    }
    $jq.get("/WebService/WSMedicalinfo.asmx/GetCommentList", { type: $jq("#mtype").val(), sequence: $jq("#idx").val(), bds : $jq("#bds").val() }, function(xml) {
        var htmls = "";
        var aaa = "";
        $jq(xml).find("CommentData").each(function(i, data) {
            htmls += "<ul>";
            htmls += "<li class='name'><b>" + $jq(data).find("Name").text() + "</b>(<img src='http://www.kormedi.com/uploadfiles/orgfiles/grade/" + $jq(data).find("GradeImg").text() + "' /> 등급)</li>";
            htmls += "<li class='date'>" + $jq(data).find("RegDate").text() + "</li>";
            htmls += "<li class='txt'>" + $jq(data).find("Comment").text() + ($jq(data).find("IsAuth").text() == "true" ? "<a href='javascript:DelComment(" + $jq(data).find("Sequence").text() + ");'><img src='http://img.kormedi.com/renewal/community/btn_del.gif'></a>" : "" ) + "</li>";
            htmls += "<li class='line'></li>";
            htmls += "</ul>";
            
        });
        $jq("#comment_re").html(htmls);
        
    });
}
/*
function SetComment() {
    if ($jq("#txtComment").val() == "" || $jq("#txtComment").val() == '(400자 이내)') {
        alert("댓글을 입력해 주세요.");
        return;
    }

    WorkComment($jq("#mtype").val(), 0, $jq("#idx").val(), $jq("#txtComment").val(), 0, $jq("#bds").val());
}
*/
function SetComment() {
    if ($jq("#txtComment").val() == "" || $jq("#txtComment").val() == '(400자 이내)') {
        alert("댓글을 입력해 주세요.");
        return;
    }
    
    $jq.getJSON("/WebService/CommandAccessDeny.aspx", function(data) {
            if (data.check != 0) {
                alert("불량회원이나 제한IP사용자 입니다.");    
                return;
            }
            else {
                WorkComment($jq("#mtype").val(), 0, $jq("#idx").val(), $jq("#txtComment").val(), 0, $jq("#bds").val());        
            }
        });
}
function DelComment(sequence) {
    if (sequence == 0) {
        alert("댓글 번호를 확인해 주세요.");
        return;
        }
        
    WorkComment($jq("#mtype").val(), sequence, $jq("#idx").val(), "", 1, 0);
}

function WorkComment(type, sequence, parentSequence, comment, workType, sunjungcode) 
{
    $jq.ajax({
        type: "post",
        url: "/WebService/WSMedicalinfo.asmx/WorkComment",
        data: { type: type, sequence: sequence, parentSequence: parentSequence, comment: escape(comment), workType: workType, bds: sunjungcode },
        success: function(msg) {
            $jq("#txtComment").val("");
            GetCommentList(type, parentSequence);
        }
    });
}

function Scrap() {
    w = screen.availWidth / 2 - 200;
    h = screen.availHeight / 2 - 150;
    window.open('/popup/ScrapArticle.aspx', 'scrap_win', 'top=' + h + ',left=' + w + ',toolbar=no,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width=289,height=364');
}

function Print() {
    window.open('/medicalinfo/DoctorPrint.aspx', 'print_win', 'top=10,left=10,toolbar=no,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=670,height=500');
}

function HPrint() {
    window.open('/medicalinfo/HospitalPrint.aspx?', 'print_win', 'top=10,left=10,toolbar=no,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=670,height=500');
}

function PopHCommentModify(hidx)
{
    window.open("/medicalinfo/CommentModify.aspx?type=hospital&idx=" + hidx, "PopCommentModify", "width=800,height=700,scrollbars=yes")
}

function PopDCommentModify(hidx)
{
    window.open("/medicalinfo/CommentModify.aspx?type=doctor&idx=" + hidx, "PopCommentModify", "width=800,height=700,scrollbars=yes")
}