// JScript 文件
var strMemName = $("#HidMemInfo").val();
var isLogin = $("#hidIslogin").val();//是否登录
var strMbCd = $("#HidMbCd").val();
var strImgDoMain = strFelissimo_ImgDomain;//图片站点域名
$(function(){
    GetMemberShowList();
    GetGdsComment();
    //鼠标悬停小图时，弹出层
    $(".commuProductPic img").live("mouseover",
        function() {
            $("#loading").show();
            $("#imgMidPic").css("border","none")
            //商品的品牌、大类
//            var strBrandNo = $(this).attr("brand-no");
//            var strBreedNo = $(this).attr("breed-no");
//            if (String(strBrandNo) == "60"){ strBrandNo = "SUNNY CLOUDS";
//            } else if (String(strBrandNo) == "106") {  strBrandNo = "HARAPPA";
//            } else {
//                var _strBreedNo = String(strBreedNo);
//                if (_strBreedNo != "1" && _strBreedNo != "3" && _strBreedNo != "10") {
//                    strBrandNo = "kraso";
//                } else { strBrandNo = "FELISSIMO"; }
//            }
            //img的位置
            var currImgPos = $(this).position();
            $(".listMidPicSlide").css("left", currImgPos.left +100);
            $(".listMidPicSlide").css("top", currImgPos.top - 100);
            var midPicPath = $(this).attr("mid-pic");
            var loadingPicPaht = strImgDoMain + "/images_v7/NewIndex/loading.gif";
            $(".listMidPicSlide img:last").removeAttr("src");
            $(".listMidPicSlide").stop(true, true).fadeIn("normal");
            
            $(".listMidPicSlide img:last").attr("src", midPicPath);
            //$(".listMidPicSlide p:eq(0)").html(strBrandNo);
            $(".listMidPicSlide p:eq(2)").html($(this).parent().attr("title1"));
     });
     //评论回复
     CommentReply();
     //弹出登陆框
     popLogin();
     //查看全部点评
     $("#aViewAllCommuniy").live("click",function(){
            $("#divMemShow").hide();
            $("#divGdsComment").hide();
               $.ajax({
                type: "POST",
                url: "/AjaxRequest/AqCustomersDiscussList.aspx",
                data: "CurrentPage=1&PageSize=5000&Flag=2&CurrMbName="+escape(strMemName) ,
                dataType: "html",
                beforeSend:function(){
                        $("#divCommentListLoading").show();
                },
                success: function(msg){
                    if(msg == "nothing"){
                        $(".commuLeft").html("<p>暂时没有评论</p>");
                    }
                    else{
                     $("#divCommentListLoading").hide();
                     $("#divGdsComment").html(msg);
                     $("#divGdsComment").html($("#divGdsComment #tag").html());
                     $("#divGdsComment").show();
                     $("#aViewAllCommuniy").parent().hide();
                    }
                }                  
            });    
     });
     //查看全部会员秀
     $("#aViewAllMemberShow").live("click",function(){
            $("#divMemShow").hide();
            $("#divGdsComment").hide();
            $.ajax({
                type: "POST",
                url: "/AjaxRequest/AqCustomersMemShowList.aspx",
                data: "CurrentPage=1&PageSize=5000&Flag=2&CurrMbName="+escape(strMemName)+"&CurrMbCd="+escape(strMbCd) ,
                dataType: "html",
                beforeSend:function(){
                        $("#divCommentListLoading").show();
                },
                success: function(msg){
                    if(msg == "nothing"){
                        $(".commuLeft").html("<p>暂时没有会员秀</p>");
                    }
                    else{
                     $("#divCommentListLoading").hide();
                     $("#divMemShow").html(msg);
                     $("#divMemShow").html($("#divMemShow #tag").html());
                     $("#divMemShow").show();
                     $("#aViewAllMemberShow").parent().hide();
                    }
                }                  
            });    
     });
     
     
     
});

/***************************/
//描述:显示会员秀列表			
/***************************/
function GetMemberShowList()
{
   //alert(CurrMbName+"#"+CurrMbCd);
   $.ajax({
        type: "POST",
        url: "/AjaxRequest/AqCustomersMemShowList.aspx",
        data: "CurrentPage=1&PageSize=5&Flag=2&CurrMbName="+escape(strMemName)+"&CurrMbCd="+escape(strMbCd) ,
        dataType: "html",
        beforeSend:function(){
                $("#divCommentListLoading").show();
        },
        success: function(msg){
            if(msg == "nothing"){
                $("#divMemShow").html("<p><strong>暂时没有会员秀</strong></p><br />");
                $("#divCommentListLoading").hide();
            }
            else{
             $("#divCommentListLoading").hide();
             $("#divMemShow").html(msg);
             $("#divMemShow").html($("#divMemShow #tag").html());
            }
        }                  
    });    
}	

/***************************/
//描述:显示商品点评列表			
/***************************/
function GetGdsComment()
{
   $.ajax({
        type: "POST",
        url: "/AjaxRequest/AqCustomersDiscussList.aspx",
        data: "CurrentPage=1&PageSize=5&Flag=2&CurrMbName="+escape(strMemName) ,
        dataType: "html",
        success: function(msg){
            if(msg == "nothing"){
                $("#divGdsComment").html("<p><strong>暂时没有评论</strong></p>");
            }
            else{
             $("#divGdsComment").html(msg);
             $("#divGdsComment").html($("#divGdsComment #tag").html());
            }
        }                  
    });    
}	
/***************************/
//描述:鼠标悬停小图时，弹出层的loading
/***************************/
function hideLoading() {
  $("#loading").hide();
  $("#imgMidPic").css("border","1px solid #ccc");
  $("#imgMidPic").show();
}
/***************************/
//描述:鼠标离开小图时，隐藏弹出层			
/***************************/
function HideMidPic()
{
  var obj = document.getElementById("PopMidPic");
  obj.style.display= "none";
}
/***************************/
//描述:评论回复相关		
/***************************/
var CommentReply =function(){

    if (isLogin == "1") //登陆状态下
    {
        $("#divReply tr:lt(3)").addClass("hide");
    }
    //评论回复
    $("a[group='replyButton']").live("click",
    function() {
        var isNoReply = $.trim( $(this).attr("no-reply") );
        if(isNoReply!="1")
        {
            $(this).parent().next().html($("#divReply").html()).show();
            $(this).parent().next().find("p[class='commentGo fly'] a").attr("key", $(this).attr("key")).attr("data-value",$(this).attr("data-value")).attr("type",$(this).attr("type"));
        }
        else
        {
             $(this).parent().next().html("<p class=redAlert>此贴已被管理员设置为禁止回复</p>").show();
        }
    });
    //取消回复
    $(".commentCancle a").live("click",
    function() {
        //$(this).parent().parent().parent().parent().parent().slideUp("slow");
        $(this).parent().parent().parent().parent().parent().parent().hide();
    });
    //发表回复
    $("p[class^='commentGo'] a").live("click",
    function() {
        var strMbShowId = $(this).attr("key");
        var strEmail = $.trim($(this).parent().parent().parent().parent().siblings().find("input[name='txtEmail']").val()); //邮箱
        var strName = $.trim($(this).parent().parent().parent().parent().siblings().find("input[name='txtName']").val()); //昵称
        var strContent = $.trim($(this).parent().parent().parent().parent().siblings().find("textarea[name='txtReplyContent']").val()); //回复内容
        var strTitle = $(this).attr("data-value");
        var srType = $(this).attr("type");

        if (isLogin == "1") //已登录
        {
            if (strContent == "") {
                alert("请填写回复内容!");
                return;
            }
        } else //未登录
        {
            if (strEmail == "") {
                alert("请填写您的邮箱地址!");
                return;
            } else {
                var myRegex = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
                if (!myRegex.test(strEmail)) {
                    alert("电子邮箱格式不正确!");
                    return;
                }
            }
            if (strName == "") {
                alert("请填写您的昵称!");
                return;
            }
            if (strContent == "") {
                alert("请填写回复内容!");
                return;
            }
        }
        if (strContent.length > 500 ) {
            alert("回复内容过长!");
            return;
        }
        
        if(srType=="ms")
        {
            $.ajax({
                type: "POST",
                url: "/AjaxRequest/AqMemShowCommentReply.aspx",
                data: "MbShowId="+escape(strMbShowId)+"&IsLogin=" + escape(isLogin) + "&MkUser="+escape(strName)+"&Email=" + escape(strEmail) + "&Title="+escape(strTitle)+"&Content="+escape(strContent) ,
                dataType: "text",
                success: function(msg) {
                    if (msg == "error") {
                        alert("服务器正忙，请稍后再试!");
                    } else {
                        document.location = "/MemberShow/"+strMbShowId+"/?co=mbShowId"+strMbShowId;
                    }
                }
            });
        }
        else
        {
            $.ajax({
                type: "POST",
                url: "/AjaxRequest/AqProductCommentReply.aspx",
                data: "CommentId=" + escape(strMbShowId) + "&IsLogin=" + escape(isLogin) + "&Email=" + escape(strEmail) + "&Name=" + escape(strName) + "&Content=" + escape(strContent),
                dataType: "html",
                success: function(msg) {
                    if (msg == "error") {
                        alert("服务器正忙，请稍后再试!");
                    } else {
                        document.location = "/CustomersCommunit/CommunityTopic.aspx?CommentID="+strMbShowId;
                    } 
                }
            });
        }

    });
}