﻿function Opencommend(productId, productName, divID) {
    var content = "";
    content = content + "<div style=\"width: 600px; padding: 5px 5px 5px 5px; font-size: 12px;";
    content = content + "    line-height: 30px; color: #333333\">";
    content = content + " <form name=\"commendForm\" action='' method=\"post\">   <input id=\"commendProductId\" name=\"commendProductId\" value=\"";
    content = content + productId;
    content = content + "\" type=\"hidden\" \/>";
    content = content + "    <span style=\"font-size: 14px; color: #db2800\">我要推荐";
    content = content + productName;
    content = content + ".....<\/span>";
    content = content + "    <hr width=\"98%\" \/>";
    content = content + "    推荐理由：";
    content = content + "  ";
    content = content + "        <input type=\"checkbox\"  name=\"commendReason\" value=\"12e75c83-1790-45ed-9263-59e2fca0bf4f\" \/>";
    content = content + "        听朋友介绍";
    content = content + "        <input type=\"checkbox\"   name=\"commendReason\" value=\"874de566-7284-4cda-a262-5ad79f6138f3\" \/>";
    content = content + "        看杂志介绍";
    content = content + "        <input type=\"checkbox\"   name=\"commendReason\" value=\"f768ed92-84c2-4f5c-8e8e-05d9e79a61e2\" \/>";
    content = content + "        我自己用过";
    content = content + "    其他";
    content = content + "    <input name=\"commendReasonOther\" id=\"commendReasonOther\" type=\"text\" value=\"\" \/>";
    content = content + "    <br \/>";
    content = content + "";
    content = content + "        <div align=\"center\">";
    content = content + "            <input type=\"button\"  name=\"commendClick\" onclick=\"commendSend(2)\" value=\"提交\" \/>";
    content = content + "            &nbsp;&nbsp;&nbsp;";
    content = content + "            <input type=\"button\" name=\"commendCancel\" onclick=\"CloseMessageBox()\" value=\"取消\" \/>";
    content = content + "        <\/div>";
    content = content + "";
    content = content + "<\/form><\/div>";
    $("#" + divID).html(content);
    //document.getElementById(divID).innerHTML=content;
}


function Openwould(productId, productName, divID) {
    var content = "";
    content = content + "<div style=\"width: 600px; padding: 5px 5px 5px 5px; font-size: 12px;";
    content = content + "    line-height: 30px; color: #333333\">";
    content = content + " <form name=\"commendForm\" method=\"post\">   <input id=\"commendProductId\" name=\"commendProductId\" value=\"";
    content = content + productId;
    content = content + "\" type=\"hidden\" \/>";
    content = content + "    <span style=\"font-size: 14px; color: #db2800\">我想用";
    content = content + productName;
    content = content + ".....<\/span>";
    content = content + "    <hr width=\"98%\" \/>";
    content = content + "  ";
    content = content + "        <input type=\"checkbox\"  name=\"commendReason\" value=\"2c79e23b-66f7-4873-a15e-a381e264a10f\" \/>";
    content = content + "        打折时候我会买";
    content = content + "        <input type=\"checkbox\"   name=\"commendReason\" value=\"43491406-1eb6-4d4a-995f-0f1e107f40b8\" \/>";
    content = content + "        用的时候我在买";
    content = content + "        <input type=\"checkbox\"   name=\"commendReason\" value=\"a2239158-f457-40a9-890d-1fe7f276b03e\" \/>";
    content = content + "        晚点我会买";
    content = content + "    其他";
    content = content + "    <input name=\"commendReasonOther\" id=\"commendReasonOther\" type=\"text\" value=\"\" \/>";
    content = content + "    <br \/>";
    content = content + "";
    content = content + "        <div align=\"center\">";
    content = content + "            <input type=\"button\"  name=\"commendClick\" onclick=\"commendSend(1)\" value=\"提交\" \/>";
    content = content + "            &nbsp;&nbsp;&nbsp;";
    content = content + "            <input type=\"button\" name=\"commendCancel\" onclick=\"CloseMessageBox()\" value=\"取消\" \/>";
    content = content + "        <\/div>";
    content = content + "";
    content = content + "<\/form><\/div>";
    content = content + "";
    $("#" + divID).html(content);
    // document.getElementById(divID).innerHTML=content;

}

function OpewReview(productId, productName, divID) {
    var content = "";
   content = content + "<div class=\"center2\"  style=\" width:600px; padding:5px 5px 5px 5px; font-size:12px; line-height:30px; color:#333333\"><span style=\"font-size:14px; color:#db2800\">我要评价"
    content = content + productName;
    content = content + ".....<\/span>";
    content = content + "<hr  width=\"98%\"\/> <div id='isChangeReview'  style='margin-bottom:-25px;'>&nbsp;</div> <div>  <form id=\"form1\" name=\"form1\" method=\"post\" action=\"\"> <input id=\"ReviewProductId\" name=\"ReviewProductId\" value=\""
    content = content + productId;
    content = content + "\" type=\"hidden\" \/>  <div align=\"left\" style=\"margin-left:20px\">    <div style=\"line-height:1.5\" >      <div align=\"left\" style=\"margin:5px 0 5px 0\">        <div align=\"left\"  style=\"margin:10px 0 0 0; width: auto;\">        ";
    content = content + "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    content = content + "  <tr>";
    content = content + "    <td colspan=\"2\"><strong><strong>评价:<\/strong>品&nbsp; 质<\/strong>";
    content = content + "      <select name=\"txtReviewLevel\" id=\"txtReviewLevel\">";
    content = content + "        <option value=\"5\" style=\"color:red\">★★★★★<\/option>";
    content = content + "        <option value=\"4\" style=\"color:red\">★★★★<\/option>";
    content = content + "        <option value=\"3\" style=\"color:red\">★★★<\/option>";
    content = content + "        <option value=\"2\" style=\"color:red\">★★<\/option>";
    content = content + "        <option value=\"1\" style=\"color:red\">★<\/option>";
    content = content + "      <\/select>";
    content = content + "      <strong>外&nbsp; 观<\/strong>";
    content = content + "      <select name=\"txtServer\" id=\"txtServer\">";
    content = content + "        <option value=\"5\" style=\"color:red\">★★★★★<\/option>";
    content = content + "        <option value=\"4\" style=\"color:red\">★★★★<\/option>";
    content = content + "        <option value=\"3\" style=\"color:red\">★★★<\/option>";
    content = content + "        <option value=\"2\" style=\"color:red\">★★<\/option>";
    content = content + "        <option value=\"1\" style=\"color:red\">★<\/option>";
    content = content + "      <\/select>";
    content = content + "&nbsp;<strong>性价比 <\/strong>";
    content = content + "<select name=\"txtpriceratio\" id=\"txtpriceratio\">";
    content = content + "  <option value=\"5\" style=\"color:red\">★★★★★<\/option>";
    content = content + "  <option value=\"4\" style=\"color:red\">★★★★<\/option>";
    content = content + "  <option value=\"3\" style=\"color:red\">★★★<\/option>";
    content = content + "  <option value=\"2\" style=\"color:red\">★★<\/option>";
    content = content + "  <option value=\"1\" style=\"color:red\">★<\/option>";
    content = content + "<\/select><\/td>";
    content = content + "    <\/tr>";
    content = content + "  <tr>";
    content = content + "    <td width=\"50%\">产品特点：";
    content = content + "      <input onclick=\"GettagName('" + productId + "',3)\" name=\"txtcharacteristic\" id=\"txtcharacteristic\"  type=\"text\" value=\"\" size=\"30\" \/><\/td>";
    content = content + "    <td width=\"50%\" rowspan=\"4\" valign=\"top\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    content = content + "      <tr>";
    content = content + "        <td><strong  style=\"color:#666666\" id=\"tagNameTitle\">产品特点的常用Tag：<\/strong><\/td>";
    content = content + "      <\/tr>";
    content = content + "      <tr>";
    content = content + "        <td id=\"tagName\"><\/td>";
    content = content + "      <\/tr>";
    content = content + "    <\/table><\/td>";
    content = content + "  <\/tr>";
    content = content + "  <tr>";
    content = content + "    <td>产品用途：";
    content = content + "      <input name=\"txtuse\"  onclick=\"GettagName('" + productId + "',4)\" id=\"txtuse\" type=\"text\" value=\"\" size=\"30\" \/><\/td>";
    content = content + "    <\/tr>";
    content = content + "  <tr>";
    content = content + "    <td>您的感受：";
    content = content + "      <input name=\"txtreceptive\" id=\"txtreceptive\"  onclick=\"GettagName('" + productId + "',5)\"  type=\"text\" value=\"\" size=\"30\" \/><\/td>";
    content = content + "    <\/tr>";
    content = content + "  <tr>";
    content = content + "    <td>总&nbsp;&nbsp;&nbsp;&nbsp;评：";
    content = content + "      <input name=\"txttotal\"  id=\"txttotal\"  onclick=\"GettagName('" + productId + "',6)\"  type=\"text\" value=\"\" size=\"30\" \/><\/td>";
    content = content + "    <\/tr>";
    content = content + "<\/table>";
    content = content + "<\/div>      ";
    content = content + "<\/div>    <\/div>    <strong>评论：<\/strong> 您还有什么要补充的吗？请注意不要超过500个汉字哦<br \/>      <textarea name=\"txtReviewContent\" id=\"txtReviewContent\" cols=\"60\" rows=\"5\"><\/textarea>     <br \/>    <div  style=\" margin:5px 0 5px 0\" align=\"center\">      <input type=\"button\" name=\"butSubmit\" value=\" 评论 \" onClick=\"reviewdSend()\" id=\"butSubmit\" \/>          <input type=\"reset\" name=\"Submit22\" value=\" 重写 \" \/>          <br \/>      <label>      <\/label><\/div>  <\/div>  <\/form> </div> <\/div>";
    $("#" + divID).html(content);
    detailReview(productId)
    // document.write(content);
    // document.getElementById(divID).innerHTML=content;
}


function detailReview(productId) {
    $.ajax({ type: "POST", url: "/webservice/service.asmx/GetDetailReview", data: "ID=" + productId, success: function(xml) {
        $(xml).find("T_DetailReview").each(function() {

            $("#txtReviewLevel").val($(this).children("ReviewLevel").text());
            $("#txtServer").val($(this).children("server").text());
            $("#txtpriceratio").val($(this).children("priceratio").text())
            $("#txtReviewContent").val($(this).children("ReviewContent").text());
            $("#isChangeReview").html("您现在正在修改以前的评价");
        });

        $(xml).find("T_Oyego_Review").each(function() {
            endow(parseInt($(this).children("tagType").text()), $(this).children("tagName").text());

        });

    }
    });
}


function commendSend(Classify) {
    var Reason = "";
    var ProductId = "";
    var ReasonOther = "";

    $("input[type=checkbox][checked]").each(function() { //由于复选框一般选中的是多个,所以可以循环输出
        Reason = Reason + ($(this).val()) + ",";
    });
    ProductId = $("#commendProductId").attr("value");
    ReasonOther = $("#commendReasonOther").attr("value");

    if (ProductId != "undefined") {

        $.ajax({ type: "POST", url: "/Product/createCommend.html", data: "Reason=" + Reason + "&ProductId=" + ProductId + "&ReasonOther=" + ReasonOther + "&Classify=" + Classify, success: function(xml) {

            alert(eval(xml));
            CloseMessageBox();

        }
        });

    }
    else {
        alert("出错错误")
    }
}






function reviewdSend() {
    var ProductId;
    var ReviewLevel;
    var priceratio;
    var ReviewContent;
    var Total;
    var characteristic;
    var vuse;
    var receptive;
    var server;

    ProductId = $("#ReviewProductId").attr("value");
    ReviewLevel = $("#txtReviewLevel").val()
    priceratio = $("#txtpriceratio").val()
    ReviewContent = $("#txtReviewContent").attr("value");
    Total = $("#txttotal").attr("value");
    characteristic = $("#txtcharacteristic").attr("value");
    vuse = $("#txtuse").attr("value");
    receptive = $("#txtreceptive").attr("value");
    vserver = $("#txtServer").attr("value");
    if (ProductId != "undefined") {
        $.ajax({ type: "POST", url: "/Review/Create.html", data: "ReviewLevel=" + ReviewLevel + "&ProductId=" + ProductId + "&priceratio=" + priceratio + "&ReviewContent=" + ReviewContent + "&Total=" + Total + "&characteristic=" + characteristic + "&receptive=" + receptive + "&use=" + vuse + "&Server=" + vserver, success: function(xml) {
            alert(eval(xml));
            CloseMessageBox();
        }
        });

    }
    else {
        alert("错误")
    }
}

function GettagName(productId, tagType) {

    if (productId != "undefined") {
        var content = "";
        $.ajax({ type: "POST", url: "/TagWarehouse/getClassTag/" + productId + ".html", data: "tagType=" + tagType + "&topN=" + 20, success: function(xml) {
          
          var data=eval(xml)
            $.each(data,function(i,n) {
                content = content + "<a href='#' onclick=\"endow(" + tagType + ",'" + n.tagName + "')\" >" + n.tagName + "<\/a> &nbsp;";

            });
            $("#tagName").html(content);
            switch (tagType) {
                case 3:
                    $("#tagNameTitle").html("产品特点的常用Tag");

                    break;
                case 4:
                    $("#tagNameTitle").html("产品用途的常用Tag");

                    break;
                case 5:
                    $("#tagNameTitle").html("产品感受的常用Tag");

                    break;
                case 6:
                    $("#tagNameTitle").html("产品总评的常用Tag");

                    break;
            }

        }
        });

    }
    else {
        alert("出错错误")
    }
}


function endow(tagType, tagName) {

    switch (tagType) {
        case 3:

            $("#txtcharacteristic").val($("#txtcharacteristic").val() + tagName + " ");

            break;
        case 4:
            $("#txtuse").val($("#txtuse").val() + tagName + " ");

            break;
        case 5:
            $("#txtreceptive").val($("#txtreceptive").val() + tagName + " ");

            break;
        case 6:
            $("#txttotal").val($("#txttotal").val() + tagName + " ");

            break;
    }
}