<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionSubmit.aspx.cs" Inherits="Webdisk.QuestionSubmit" %>
<%@ 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" method="POST" id="formId">
            <input type="text" class="input1" id="txtSearchName" name="searchName" placeholder="请输入搜索的内容..." style="width: 725px;"/>
            <input type="hidden" name="cmd" value="search" />
            <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 icon3">
        		<div class="title">提出您的问题</div>
        		<input type="text" value="" id="txtQuestion" class="textarea mt10" style="height:35px;line-height:35px;" placeholder="请在这里描述您的问题"/>
        		<span class="label_text" style="color:#333;">问题补充(选填)</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="submitQ();" value="提交回答" />
                <span class="font1 floatR" id="error"></span>
        	</div>
        </div>
            <input type="hidden" id="hiddenUser" value ='<%=Session["username"]==null?"":Session["username"].ToString() %>'/>
    </div>
    <!-- Content End -->
    <!-- Footer Start -->
    <uc:uc2 ID="bootom" runat="server" />
    
    <!-- Footer End -->
<script type="text/javascript">
setHeadMenu(7);
setPalceHolder($("#txtQuestion"));
setPalceHolder($("#txtSearchName"));
setPalceHolder($("#txtRemark"));
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 submitQ(){
    var _question = $.trim($("#txtQuestion").val());
    var _error = $("#error").html("");
	var _remark = $.trim(document.getElementById("Editor").contentWindow.window.frames["HtmlEditor"].document.getElementsByTagName("body")[0].innerHTML) ;
    if(_question == ""){
        _error.html("问题不能为空");
        return false;
    }
    $.ajax({
        url : "QuestionHandler.ashx?cmd=AddQuestion",
        data : {type:1,question:encodeURI(_question),user:encodeURI($("#hiddenUser").val()),remark:encodeURI(_remark)},
        type:"post",
		cache:false,
        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();location.href="QuestionLayout.aspx#tab02";},2000);
                $("#txtQuestion,#txtRemark").val("");
            }else{
                error.html(data.msg);
            }
        }
    });
}
</script>
</body>
</html>

