<%@ 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;
	protected void Page_Load(object sender, EventArgs e)
	{
		id = Utils.StrToInt(KSCMS.S("id"));
		nowIndex = Utils.StrToInt(KSCMS.S("nowIndex"));
	}


</script>
<%
	if (!isLoadPage) return;
%>


 <link href="/admin/weixin/images/style.css" rel="stylesheet" />
  <script>
  	jQuery(document).ready(function () {
  		DoClasstype(0);
  		DoClass(1,0)
  		$('.style-inner').on('click', 'li', function () {
  			$(this).addClass('current').siblings().removeClass('current');
  		});

  	});
  	function DoClass(costype, classid) {

  		var key = jQuery("#TxtKey").val();

  		$.ajax({
  			url: "/plus/course/wxajax.aspx?action=getclass&costype=" + costype + "",
  			context: document.body,
  			type: "Post",
  			success: function (data) {
  			//	alert(data);
  				$("#getclassid").show();
  				$("#getclassid").html(data);
  				loaddata('courselist', key, costype, classid, 1);
  			}
  		});
  	}
  	
  	function DoClasstype(id,signal){
  		//	DoClass(jQuery("#costype").val(), 0);
  		if (!signal) {
  			loaddata('courselist', jQuery("#TxtKey").val(), jQuery("#costype").val(), id, 2);
  		}
  		else {
  			DoClass(jQuery("#costype").val(), 0);
  			loaddata('courselist', jQuery("#TxtKey").val(), jQuery("#costype").val(), id, 2);
  		}
  	}
  	function onserch() {
  		var key = jQuery("#TxtKey").val();
  		var costype = jQuery("#costype").val();
  		var classid = jQuery("#classid").val();
  		loaddata('courselist', key, costype, classid, 1);
  	}
  	function loaddata(action, key, costype, classid, page) {
  		$.ajax({
  			url: "/plus/course/wxajax.aspx?action=" + action + "&rnd=" + Math.random() + "&key=" + key + "&costype=" + costype + "&classid=" + classid + "&page=" + page + "&userid=<%=new TemporaryVar().UserID%>",
  			context: document.body,
  			type: "GET",
  			success: function (data) {
  				if (action == "courselist") {
  					$("#LoadData").html(data);
  				}
  			}
  		});
  	}


    </script>
<script>
	function SetClassUrl() {

		var v = '';
		v = $('.style-inner  li.current').find("input[name='titleid']").val();
		var 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"))) { %>
			
			top.frames["iframemain<%=Utils.StrToInt(KSCMS.S("id"))%>"].document.getElementById("<%=KSCMS.S("fieldID").Trim() %>").value = v;
			
			<%}%>
			$(top.frames["iframemain<%=KSCMS.S("id")%>"].document.getElementById("myshoppic")).html("<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>");
		
			top.frames["iframemain<%=KSCMS.S("id")%>"].document.getElementById("CosType").value = $("#costype").val();
			<%if (KSCMS.S("action") == "keyword" || KSCMS.S("action") == "attention" || KSCMS.S("action") == "qunfa" || KSCMS.S("action") == "automaticreply")
              { %>
			top.document.getElementById("TxtCourseID").value = v;
			top.document.getElementById("CosType").value = $("#costype").val();
			var str = "<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>";
			$(top.document.getElementById("ShowTxtShop0")).val(str);

			<% }
	  
            if (KSCMS.S("action") =="sendmsg")
              {%>
			top.document.getElementById("TxtCourseID<%=KSCMS.S("id")%>").value = v;
			top.document.getElementById("CosType<%=KSCMS.S("id")%>").value = $("#costype").val();
			var str = "<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>";

			$(top.document.getElementById("ShowTxtShop<%=KSCMS.S("id")%>")).val(str);

			<%}
                 if (KSCMS.S("action")=="sucai")
              {%>
			<%if (!string.IsNullOrEmpty(KSCMS.S("fieldID"))) { %>
			
			top.frames["iframemain<%=KSCMS.S("nowIndex")%>"].document.getElementById("<%=KSCMS.S("fieldID").Trim() %>").value = v;
			<%}%>
			$(top.frames["iframemain<%=KSCMS.S("nowIndex")%>"].document.getElementById("myshoppic")).html("<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>");
		
			top.document.getElementById("TxtcourseID<%=KSCMS.S("nowIndex")%>").value = v;
			
			top.document.getElementById("CosType<%=KSCMS.S("nowIndex")%>").value = $("#costype").val();
		
			var str = "<ul class='style-inner'><li>" + $('.style-inner  li.current').html() + "</li></ul>";
			$(top.document.getElementById("ShowTxtcourse<%=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_course<%=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 = 2;
			<%}
               %>
			<%if (KSCMS.S("fieldID")!=""){ %>
			top.box.close();
			<%}else{%>
			<%} %>
		}
	}
</script>
<style type="text/css">
.style-inner .style-inner-item{padding: 15px;border-radius: 0;border: 1px solid #ddd;}
.style-inner .style-versions { text-align:left;}
.table td, .table th { border:none;}
.article_title{ font-weight:bold; color:#666;}
.font_color{ color:#AD6E1D !important;}
.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_GetShop") %>" 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="searcher">
							<select onchange="DoClasstype(this.value,'change')" name="costype" id="costype">
							<option value="1" selected="selected">点播课程</option>
							<option value="5">直播课程</option>
							<option value="0">面授课程</option>
							</select>
                                <span id="getclassid"></span>
                               <input name="TxtKey" type="text" id="TxtKey" class="searchbox" />
                              <input id="Button2" type="button" value="" onclick="onserch()"  class="searchbtn"/>

                            </div>
							
							<div class="cb h5"></div>
							
							<div class="cb vtab-content" >
                                <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>


