<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Date_Qi.ascx.cs" Inherits="Mvcb2b.admin.controls.Date_Qi" %>
<%if (Isadd==1){ %>
<div id="date_qi" class="sel_add" style="float:left;">
<div class="qi1" style="float:left;">
<select id="qi_sel" name="qi_sel">
<option value="">选择刊期</option>
</select>&nbsp;
</div>
<div class="sel_box" style="float:left;">筛选：<select id="qi_year" name="qi_year">
<option value="">年份</option>
</select>
<select id="qi_month" name="qi_month">
<option value="">月份</option>
</select>
</div>
</div>
<%
  }else {%>
<div id="date_qi" style="float:left;">
<select id="qi_year" name="qi_year">
<option value="">年份</option>
</select>
<select id="qi_month" name="qi_month">
<option value="">月份</option>
</select>
<select id="qi_sel" name="qi_sel">
<option value="">选择刊期</option>
</select>
</div>
<%} %>
<script src="images/allqi.js" type="text/javascript"></script>
<script type="text/javascript">
        var nowqi = "<%=Qi%>";
        var noweditionid="<%=Editionid%>";
        var nowpagename="<%=Pagename%>";
        var pageurl="jquery/Eachqipage.aspx";
        var ldate_qi = document.getElementById("date_qi");
        var yearurl = "jquery/Year.aspx";
;
        var monthurl = "jquery/Month.aspx";
        var qiurl = "jquery/Monthqi.aspx";    
        var selyear = document.getElementById("qi_year");
        var selmonth = document.getElementById("qi_month");
        var selqi = document.getElementById("qi_sel");        
        var nowyear = "<%=Year%>";
        var nowmonth = "<%=Month%>";
        var isadd = "<%=Isadd%>";
        var isnews = "<%=Isnews%>";
    $(function () {        
        var initqi = new Startgetqi();
        //加载年份
        initqi.loadyear(selyear, nowyear, yearurl);
        //加载月份
        initqi.loadmonth(selmonth, nowyear, nowmonth, monthurl);
        //加载刊期       
        if (isadd == "1") {             
            selqi.options.length = 0;
            opt(selqi, "选择刊期", "", 0);
            initqi.loadqi(selqi, nowyear, nowmonth, nowqi, qiurl, isadd,isnews);
        }
        else
        {
            initqi.loadqi(selqi, nowyear, nowmonth, nowqi, qiurl, isadd,isnews);
         }

        $("#qi_year").change(function () {
            var tempy =  $(this)[0].options[this.selectedIndex].value; //this.options[this.selectedIndex].value;
            if (tempy != "") {
                //月份变化;  
                selmonth.options.length = 0;
                opt(selmonth, "月份", "", 0);
                initqi.loadmonth(selmonth, tempy, nowmonth, monthurl);
                //刊期变化
                selqi.options.length = 0;
                opt(selqi, "选择刊期", "", 0);
                initqi.loadqi(selqi, tempy, "", nowqi, qiurl, isadd,isnews);
            }
        });
        $("#qi_month").change(function () {
            var tempy = selyear.options[selyear.selectedIndex].value;
            var tempm = $(this)[0].options[this.selectedIndex].value;//this.options[this.selectedIndex].value;
            if (tempy != "" && tempm != "") {
                //刊期变化;
                selqi.options.length = 0;
                opt(selqi, "选择刊期", "", 0);
                initqi.loadqi(selqi, tempy, tempm, nowqi, qiurl, isadd,isnews);
            }
        });
        <%if (Isnews==1){%>       
        var selpage=document.getElementById("eachpage"); 
        $("#qi_sel").change(function () {
            var tempm = $(this)[0].options[this.selectedIndex].value;//$(this).val();
            if (tempm != "") {
                //版面变化;
                selpage.options.length = 0;
                opt(selpage, "选择版面", "", 0);
                initqi.loadedition(selpage,tempm,noweditionid,pageurl,isadd);
                           //本期之下 版面已选择值
                            if (tempm == nowqi && noweditionid != "0" && noweditionid != "") {
                                var pagename = document.getElementById("pagename");
                                var pagevalue = document.getElementById("pagevalue");
                                pagename.value = nowpagename;
                                pagevalue.value = noweditionid;
                                //添加到信息显示
                                var showdiv = document.getElementById("edition_div")
                                var showmsg = "";
                                var arr = noweditionid.split(',');
                                var arrtext =nowpagename.split(',');
                                if (arr.length > 0 && arr[0] != "") {
                                    for (i = 0; i < arr.length; i++) {
                                        if (showmsg == "")
                                            showmsg = arrtext[i] + "(<a href=\"javascript:delpage(" + arr[i] + ",'" + arrtext[i] + "');\">删除</a>)";
                                        else
                                            showmsg += ", " + arrtext[i] + "(<a href=\"javascript:delpage(" + arr[i] + ",'" + arrtext[i] + "');\">删除</a>)";
                                    }
                                }
                                showdiv.innerHTML = showmsg;
                            }
                            else
                            {
                                //版面已选择值初始化
                                var pagename = document.getElementById("pagename");
                                var pagevalue = document.getElementById("pagevalue");
                                pagename.value = "";
                                pagevalue.value = "";
                                var showdiv = document.getElementById("edition_div")
                                showdiv.innerHTML = "<span style=\"color:Red;\">没有选择任何<%=Mvcbll.Share.BkType.Pagename%>!</span>";
                            }

                <%if (Mvcbll.Share.BkType.Id == 8)
                  { %>
                 //刊期变化导致目录分类变化
                 loadqiclass(nowqiclid,tempm);

                <%} %>
            }
        });
       <%} %>
    });   
</script>

