<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionDetail.aspx.cs" Inherits="Webdisk.QuestionDetail" %>
<%@ Register TagPrefix="uc" TagName="uc1" Src="~/Top.ascx" %>
<%@ Register TagPrefix="uc" TagName="uc2" Src="bottom.ascx" %>
<!DOCTYPE html >

<html>
<head runat="server">
    <title></title>
     <link href="css/common.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
    <script src="js/plugins/jquery.pagination.js" type="text/javascript"></script>
    <link rel="stylesheet" href="js/artDialog/css/ui-dialog.css" />
    <script src="js/artDialog/dist/dialog-plus.js" type="text/javascript"></script>

</head>
<body>
    <!-- Header Start -->
    <uc:uc1 ID="top" runat="server" />
     <!-- Header End -->
       <!-- Content Start -->
    <div class="content">
        <form action="QuestionLayout.aspx?cmd=search" method="POST" id="formId">
            <input type="text" class="input1" id="txtSearchName" name="searchName" placeholder="请输入搜索的内容..." style="width: 725px;"/>
            <span class="but3" onclick="searchQ();" style="vertical-align: bottom;margin-left: -5px;margin-right: 25px"></span>
            <input type="button" class="but2" onclick="location.href='QuestionSubmit.aspx';" value="我要提问" style="vertical-align: bottom;"/>
        </form>
        <div class="block01 mt20">
        	<div class="qusC icon1">
        		<div class="title">【问题】<asp:Label ID="lblQuestion" runat="server" Text=""></asp:Label></div>
        		<div class="tabs"><span class="name"> <asp:Label ID="lblQuestionUser" runat="server" Text=""></asp:Label></span>
        		<span class="split">|</span><span class="text">解答<asp:Label ID="lblAnswerCount" runat="server" Text=""></asp:Label>次</span></div>
        		<div class="deltails">
                    <asp:Label ID="lblRemark" runat="server" Text=""></asp:Label>
        		</div>
        		<span class="label_text">我要回答问题</span><br>
        		<textarea class="textarea" id="content" name="content" placeholder="" style="margin-bottom:5px;display:none;"></textarea>
				<iframe ID="Editor" name="Editor" src="HtmlEditor/index.html?ID=content" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:225px;width:100%;"></iframe>
        		<input type="button" class="but1 floatR" onclick="submitA();" value="提交回答" />
                <span class="font1 floatR" id="error"></span>
            <input type="hidden" id="hiddenUser" value ='<%=Session["username"]==null?"":Session["username"].ToString() %>'/>
            <input type="hidden" id="hiddenQuestionId" value ='' runat="server"/>
        	</div>
        </div>
        <div class="block01 mt20" >
        	<div class="qusC icon2" id="quesC">
				<div class="title">【解答】<span class="quesNum">(<asp:Label ID="lblCount" runat="server" Text=""></asp:Label>)</span></div>
      <asp:Repeater id="rptAnswer" runat="server">
            <ItemTemplate>
              <div class="tabs">
                <span class="name"><%# DataBinder.Eval(Container.DataItem, "AnswerUser")%></span><span class="split">|</span>
                <span class="text"><%# DataBinder.Eval(Container.DataItem, "AnswerDateTime")%></span>
               </div>
        		<div class="deltails">
        			<%# DataBinder.Eval(Container.DataItem, "Answer")%>
        		</div>
            </ItemTemplate>
        </asp:Repeater>
        	</div>
        </div>
    </div>
    <!-- Content End -->
    <!-- Footer Start -->
    <uc:uc2 ID="bootom" runat="server" />
    
    <!-- Footer End -->
<script type="text/javascript">
setHeadMenu(7);
setPalceHolder($("#txtSearchName"));
function setPalceHolder(tag){
	if(typeof Worker === "undefined"){
		tag.val(tag.attr("placeholder")).css({color:"#cecece"});
		tag.focus(function(){
			if($(this).val() == tag.attr("placeholder")){
				$(this).val("").css({color:""});
			}
		}).blur(function(){
			if($(this).val() == ""||$(this).val() == tag.attr("placeholder")){
				$(this).val(tag.attr("placeholder")).css({color:"#cecece"});
			}
		});
	}
}
function searchQ(){
    var _searchName = $.trim($("#txtSearchName").val());
    if(_searchName == ""){
        var d= dialog().content('搜索内容不能为空').showModal();
        setTimeout(function(){d.close().remove();},2000);
        return false;
    }
    $("#formId").submit();
}
function submitA(){
    var _error = $("#error").html("");
    var _answer = $.trim(document.getElementById("Editor").contentWindow.window.frames["HtmlEditor"].document.getElementsByTagName("body")[0].innerHTML);
    if(_answer == ""){
        _error.html("回答不能为空");
        return false;
    }
    $.ajax({
        url : "QuestionHandler.ashx?cmd=AddAnswer",
		cache:false,
        data : {questionid : $("#hiddenQuestionId").val(),user:encodeURI($("#hiddenUser").val()),answer:encodeURI(_answer)},
        dataType : "json",
        success : function(data){
            if(data.code == "0"){
                var d= dialog().content('<div style="font-size: 16px;font-weight: bold;" ><img src="images/ico_38.png" style="vertical-align: middle;"/>您的回答已提交，请耐心等待...</div>').showModal();
                setTimeout(function () { d.close().remove(); }, 2000);
                $("#quesC").find(".title").after('<div class="tabs"><span class="name">'+$("#hiddenUser").val()+'</span><span class="split">|</span><span class="text">时间</span></div><div class="deltails">'+_answer+' </div>').find(".quesNum").html("("+$("#quesC .deltails").size()+")");
                document.getElementById("Editor").contentWindow.window.frames["HtmlEditor"].document.getElementsByTagName("body")[0].innerHTML="";
            }else{
                _error.html(data.msg);
            }
        }
    })
}
</script>
</body>
</html>
