
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionLayout.aspx.cs" Inherits="Webdisk.QuestionLayout" %>
<%@ Register TagPrefix="uc" TagName="uc1" Src="~/Top.ascx" %>
<%@ Register TagPrefix="uc" TagName="uc2" Src="bottom.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<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/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 -->
    <div>
        <uc:uc1 ID="top" runat="server" />
    </div>
     <!-- Header End -->
       <!-- Content Start -->
    <div class="content">
        <div class="">
            <input type="text" class="input1" id="txtSearchName" name="searchName" placeholder="请输入搜索的内容..." runat="server" 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;"/>
            <input type="hidden" id="hiddenCmd" name="search"  runat="server"/>
            <input type="hidden" id="hiddenSearchName" name="searchName"  runat="server"/> 
        </div>
        <div>
            <ul class="menu_tabM mt20"  id="usual2">
                <li><a class="selected" href="#tab01">全部</a></li>
                <li><a href="#tab02">我的提问</a></li>
                <li><a href="#tab03">热门</a></li>
                <li><a href="#tab04">零回答</a></li>
            </ul>
            <div class="menu_tabC" id="tab01C">
                <div class="contentC" data-tab = "1"></div>                
                 <div class="pageList" id="page1"></div>
            </div>
            <div class="menu_tabC" id="tab02C">
                <div class="contentC" data-tab = "2"></div>
                 <div class="pageList" id="page2"></div>
            </div>
            <div class="menu_tabC" id="tab03C">
                <div class="contentC" data-tab = "3"></div>
                 <div class="pageList" id="page3"></div>
            </div>
            <div class="menu_tabC" id="tab04C">
                <div class="contentC" data-tab = "4"></div>
                 <div class="pageList" id="page4"></div>
            </div>
        </div>
    </div>
    <!-- Content End -->
    <!-- Footer Start -->
    <uc:uc2 ID="bootom" runat="server" />
    
    <!-- Footer End -->
</body>
</html>
<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;
    }
	var tag = $("#tab01C .contentC");
    ajax(0,function(){
			var maxlength = parseInt($("#H_itemtCount").val());
            var current = parseInt($("#H_currentPage").val());
            var pageSize = parseInt($("#H_pagesize").val());
            $("#page1").pagination(maxlength, {
                prev_text: '< 上一页',
                next_text: '下一页 >',
                items_per_page: pageSize,
                num_display_entries: 5,
                current_page: current,
                num_edge_entries: 2,
                link_to: "javascript:void(0);",
                callback: function (page_id, panel) {
                    var self = this;
                    ajax(page_id, function (vdata) {
                        self.maxentries = parseInt($("#H_itemtCount").val());
                    });
                }
            });
    });
    function ajax(pageIndex,callback){
        var d = dialog().showModal();
        $.ajax({
            url : "QuestionMng.aspx",
			cache:false,
            data : {tab:1,pageIndex:pageIndex,cmd:"search",searchName:encodeURI(_searchName)},
            dataType : "html",
            type:"post",
            success : function(data){
                d.close().remove();
                tag.empty().append(data);
                typeof callback == "function" && callback();
            }
        });
    }
}
function initTab(tag){
    tag.find("a").click(function(){
        $(this).addClass("selected").parent().siblings().find("a").removeClass("selected");
        ajaxPage($(".menu_tabC").hide().filter($(this).attr("href")+"C").show());
    });
    var id = location.hash ? location.hash : tag.find("a.selected").attr("href");
    if($(id).size() == 0 ){
        $(tag.find("a.selected").attr("href")+"C").show();
		ajaxPage($(tag.find("a.selected").attr("href")+"C"));
    }else{
        $(id).show();
		if( $.trim($("#txtSearchName").val()) !="" && id=="#tab01"){
			searchQ();
		}else{
        $("a[href='"+id+"']").click();
		}
    } 
}
function ajaxPage(tag){
   // var d = dialog();
    tag = tag.find(".contentC");
    if($.trim(tag.html()) == ""){
        ajax(0,function(){
            var maxlength = parseInt($("#H_itemtCount").val());
            var current = parseInt($("#H_currentPage").val());
            var pageSize = parseInt($("#H_pagesize").val());
            $("#page"+tag.data("tab")).pagination(maxlength, {
                prev_text: '< 上一页',
                next_text: '下一页 >',
                items_per_page: pageSize,
                num_display_entries: 5,
                current_page: current,
                num_edge_entries: 2,
                link_to: "javascript:void(0);",
                callback: function (page_id, panel) {
                    var self = this;
                    var d = dialog().showModal();
                    ajax(page_id, function (vdata) {
                        self.maxentries = parseInt($("#H_itemtCount").val());
                        d.close().remove();
                    });
                }
            });
        });
    }
    function ajax(pageIndex,callback){
        $.ajax({
            url : "QuestionMng.aspx",
			cache:false,
            data : {pageIndex:pageIndex,tab : tag.data("tab")},
            dataType : "html",
            success : function(data){
                tag.empty().append(data);
                typeof callback == "function" && callback();
            }
        })
    }
}
initTab($("#usual2"));
</script>