<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="Kesion.Weixin" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server" type="text/C#">
	dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
	private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
	bool isLoadPage = true;  //定义页面是否加载
	DataRow dr = null;

	public int id = 0;
	public int nowIndex = 0;
	public static int ChannelId = 1;
	protected void Page_Load(object sender, EventArgs e)
	{
		id = Utils.StrToInt(KSCMS.S("id"));
		nowIndex = Utils.StrToInt(KSCMS.S("nowIndex"));
		ChannelId = Utils.StrToInt(KSCMS.S("channelID"), 1);
	}
	public static string GetModel(string caozuo)
	{
		string str = string.Empty;
		//获取机构新闻分类
		str = " <select onchange=\"DoClasstype(this.value)\" style=\"float:left;\"><option value='0'>全部</option>";
		if (caozuo == "infolist")
		{
			string sqlStr = "select ClassID,ClassName from KS_EnterPriseNewsClass where userid=" +new TemporaryVar().UserID + " and IsShow=1 order by classid";
			using (DataTable dt = DataFactory.GetDataTable(sqlStr))
			{
				if (dt.Rows.Count > 0)
				{
					foreach (DataRow dr in dt.Rows)
					{
						str+="<option value='" + dr["classID"].ToString() + "' >" + dr["ClassName"].ToString() + "</option>";
					}
				}
			}
		}
	
		str += "</select>";
		return str;
	}

</script>
<%
	if (!isLoadPage) return;
%>
<link href="/SysImg/teacher/css/newswx.css" rel="stylesheet" />
    <script>
    	jQuery(document).ready(function () {
    		DoClasstype(0);
    		$('.style-inner').on('click', 'li', function () {
    			$(this).addClass('current').siblings().removeClass('current');
    		});
    		
    	});
    	function DoClasstype(id) {
    	
    		loaddata('infolist', jQuery("#TxtKey").val(), 0, id, 2);
    	}
    	function onserch() {
    		var key = jQuery("#TxtKey").val();
    		var channelid = 0;
    		var classid = jQuery("#classid").val();
        	loaddata('infolist', key, channelid, classid, 1);
        }
    	function loaddata(action, key, channelid, classid, page) {
        	$.ajax({
        		url: "/plus/course/wxajax.aspx?action=" + action + "&rnd=" + Math.random() + "&key=" + key + "&channelid=" + channelid + "&classid=" + classid + "&page=" + page+"&userid=<%=new TemporaryVar().UserID%>",
        		context: document.body,
        		type: "GET",
        		success: function (data) {
        			if (action == "infolist") {
        				$("#LoadData").html(data);
        			}
        		}
        	});
        }

    </script>
<script>
	function SetClassUrl() {
		var title = '';
		var v = '';
		v = $('.style-inner  li.current').find("input[name='titleid']").val();
		title = $('.style-inner  li.current').find("input[name='tuwentitle']").val();
		var defaultpic = $('.style-inner  li.current').find("input[name='tuwendefaultpic']").val();

		if (v == '' || v == undefined) KesionJS.Alert('请选择文章!');
        else {
			<%if (!string.IsNullOrEmpty(KSCMS.S("fieldID").Trim())) { %>
		
			top.frames["iframemain<%=Utils.StrToInt(KSCMS.S("id"))%>"].document.getElementById("<%=KSCMS.S("fieldID").Trim() %>").value = v;
			
			<%}%>
			
			$(top.frames["iframemain<%=Utils.StrToInt(KSCMS.S("id"))%>"].document.getElementById("mycontentpic")).html("<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>");
			
            <%if (KSCMS.S("action") == "keyword" || KSCMS.S("action") == "attention" || KSCMS.S("action") == "qunfa" || KSCMS.S("action") == "automaticreply")
              { %>
        	top.document.getElementById("TxtTuWenID").value = v;
        	var str = "<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>";
        	$(top.document.getElementById("MyTuwendetail")).html(str);
			$(top.document.getElementById("ShowTxtTuWen0")).val(str);

			<% }
             if (KSCMS.S("action") =="sendmsg")
              {%>
			top.document.getElementById("TxtTuWenID<%=Utils.StrToInt(KSCMS.S("id"))%>").value = v;
        	var str = "<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>";
        	$(top.document.getElementById("ShowTxtTuWen<%=KSCMS.S("id")%>")).val(str);
        	<%}
               if (KSCMS.S("action")=="sucai")
              {%>
			<%if (!string.IsNullOrEmpty(KSCMS.S("fieldID").Trim())) { %>
			
			top.frames["iframemain<%=Utils.StrToInt(KSCMS.S("nowIndex"))%>"].document.getElementById("<%=KSCMS.S("fieldID").Trim() %>").value = v;

            <%}%>
			$(top.frames["iframemain<%=KSCMS.S("nowIndex")%>"].document.getElementById("mycontentpic")).html("<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>");
			top.document.getElementById("TxtTuWenID<%=KSCMS.S("nowIndex")%>").value = v;
			var str = "<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>";
        	$(top.frames.document.getElementById("ShowTxtTuWen<%=KSCMS.S("nowIndex")%>")).val(str);
			top.document.getElementById("default_title<%=KSCMS.S("nowIndex")%>").value = title;
			top.document.getElementById("default_img<%=KSCMS.S("nowIndex")%>").value = defaultpic;
			top.document.getElementById("default_tuwen<%=KSCMS.S("nowIndex")%>").value = v;
			top.document.getElementById("defaulttitle<%=KSCMS.S("nowIndex")%>").innerText = title;
			top.document.getElementById("img_box<%=KSCMS.S("nowIndex")%>").src = defaultpic;
			$(top.document.getElementById("default_content<%=KSCMS.S("nowIndex")%>")).val(str);
			top.document.getElementById("keytype<%=KSCMS.S("nowIndex")%>").value = 1; 
        	<%}
              %>
            <%if (KSCMS.S("fieldID")!=""){ %>
        	top.box.close();
        	<%}else{%>
        	<%} %>
        }
    }
</script>
<style type="text/css">
.style-inner .style-inner-item{padding:0px;border: 1px solid #eee;}
.style-inner .style-versions {padding:0 10px; text-align:left;}
.table td, .table th { border:none;}
.article_title{ font-weight:bold; color:#666;}

.vtab .searcher {margin-bottom: 10px;border-bottom: 1px dashed #ddd;padding-bottom: 15px;}
.style-column{ border-bottom:1px dashed #ddd;}
.button{background:#69b7e4;border: none;color: #fff;width: 120px;height: 35px;font-size: 16px;display: block;margin:10px auto 0;}
</style>

<form name="myForm" method="post" action="<%=BasicField.GetUserUrl("wx/wx_GetTuWen") %>" id="myForm">
<div class="content-inner" style="height:500px">

	<div class="table">
		<table>
			<tr>
				<td>
					  <div class="style-column" id="tempsList">
					  	<div class="vtab tempsbox chooses">
							<div  class="search_group">
                               <%=GetModel("infolist") %>
                               <span id="getclassid"> </span>
                               <div class="search">
								 <input name="TxtKey" type="text" id="TxtKey" class="search_box" />
                                 <input id="Button2" type="button" value=""   onclick="onserch()"  class="search_btn"/>
                               </div>
                            </div>
							
							<div class="cb h5"></div>
							<div class="cb vtab-content" id="styleList">
							
                            <ul class="style-inner clearfix item" id="LoadData">
                            
                            </ul>
        
						    </div>
					    </div>
					  </div>
				</td>
			</tr>
		</table>
	</div>
	
     <Input class="button" type="button" value=" 确 定 " name="Submit"  onclick="SetClassUrl();">
		
</div>
 
  </form>


