<!--#include file="error.asp"-->
<!--#include file="conn.asp"-->
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加文章</title>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<script type="text/javascript" src="js/admin.js"></script>
<script LANGUAGE="javascript">
  subcity = new Array();
<%Dim counti
  set rs4=server.createobject("adodb.recordset")
  sql="Select * From bigclass"
  rs4.open sql,conn,3,3
  counti=0
  Do While Not rs4.Eof
  Response.Write "subcity[" & counti & "] = new Array(""" &rs4("typeid") & """,""" &rs4("classname") & """,""" &rs4("id") & """);" & Chr(10)
  counti=counti+1
  rs4.MoveNext
  Loop
%>
 function mychange(provalue) {					
 document.myform.bigclassid.length = 0;				
 document.myform.bigclassid.options[0] = new Option('请选择小类','0');
 var i; 
 for (i=0;i < subcity.length; i++)				
 { 
 if (subcity[i][0] == provalue)			
 {  
 document.myform.bigclassid.options[document.myform.bigclassid.length] = new Option(subcity[i][1],subcity[i][2]); 
 }         
 } 
}    
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr  bgcolor="#353c44">
        <td height="24" width="18" valign="middle" align="center"><img src="images/tb.gif" width="14" height="14" /></td>
        <td><span class="STYLE1">添加文章</span></td>
      </tr>
    </table></td>
  </tr>
  <tr bgcolor="#FFFFFF" align="center">
    <td>
          <table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#a8c7ce">
              <form id="myform" name="myform" method="post" onsubmit="return test()" action="news_set.asp?action=add">
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">
                  <td width="10%">所属专题：</td>
                  <td width="90%"  align="left" colspan="3">
                     <select name="SpecialID" size="1" class="INPUT">
                            <%			
                            set rs3=server.CreateObject ("ADODB.RecordSet")
                            rs3.Source="select * from Special"
                            rs3.Open rs3.source,conn,1,1			
                            %>
                        <option value=0>不属于任何专题</option>
                            <%if rs3.EOF then %>
                        <option value=0>暂无任何专题</option>
                            <%else
                              while not rs3.EOF
                            %>
                        <option value="<%=rs3("ID")%>"><%=trim(rs3("title"))%></option>
                            <%
                            rs3.MoveNext
                            wend
                            end if
                            rs3.close	
                            %>
                     </select>                  
                  </td>
              </tr>
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">  
                  <td width="10%">新闻标题：</td>
                  <td width="20%" align="left"><input type="text" name="title" size="50" /></td>
                  <td width="10%">所属栏目：</td>
                  <td width="60%" align="left">
                     <select name="typeid" onChange="mychange(this.options[this.selectedIndex].value);">
                        <option value="">请选择大类</option>
                            <%
                            set rs=server.createobject("adodb.recordset")
                            sql="select * from type order by morder"
                            rs.open sql,conn,1,1
                            do until rs.eof
                            %>
                        <option value="<%=rs("id")%>"><%=rs("typetitle")%></option>
                            <%
                            rs.movenext
                            loop
							rs.close
							set rs=nothing
                            %>
                    </select>     &nbsp; 
                    <select name="bigclassid">
                    <option value="0">请选择小类</option>
                    </select>                  
                  </td>  
              </tr>  
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">
                  <td width="10%">外链地址：</td>
                  <td width="20%" align="left"><input type="text" name="links" size="50" /></td>
                  <td align="left" colspan="2">&nbsp; &nbsp; <span class="red">提示：</span>即点击新闻标题后转向的地址，此处填写则正文不需要填写</td>
              </tr>  
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">
                  <td width="10%">其他信息：</td>
                  <td colspan="3" align="left">
                  作者：<input name="author" type="text" id="author" value="Fyblogs" />&nbsp;&nbsp;
                  来源：<input name="comefrom" type="text" value="Fyblogs" />&nbsp;&nbsp;
                  时间：<input name="addtime" type="text" value="<%=Now()%>" />&nbsp;&nbsp;
                  点击：<input name="hits" type="text" value="" />&nbsp;&nbsp;
                  <input name="add_user" type="hidden" value="<%=request.cookies("usrname")%>" />&nbsp;&nbsp;
                  </td>
              </tr>  
              <tr bgcolor="#ffffff">
                  <td colspan="4" align="left">
					  <script charset="utf-8" src="../kindeditor/kindeditor.js"></script>
                      <script>
                              KE.show({
                                      id : 'content',
                                      shadowMode : false,
                                      allowPreviewEmoticons : false,
                                      resizeMode: 0,
                                      urlType : 'relative',
                                      cssPath : '../../skins/editor.css',
                                      allowUpload: false,
                                      filterMode : false,
                                      allowFileManager : true,
                                      fileManagerJson : '../../asp/file_manager_json.asp'
                              });
                      </script>
                      <textarea id="content" name="content" cols="100" rows="8" style="width:700px;height:300px;"></textarea>                  
                  </td>
              </tr>  
              <tr bgcolor="#ffffff" height="30">   
                  <td width="10%">文件上传：</td>
                  <td colspan="3" align="left"><iframe src="kupload.asp" width="100%" height="24"  scrolling="no" border="0" frameborder="0" marginwidth="0" marginheight="0"></iframe></td>                                         
              </tr>  
              <tr bgcolor="#ffffff" height="30">  
                  <td width="10%">图片新闻：</td>
                  <td  align="left" colspan="3"><input name="IsPic" type="checkbox" id="IsPic" onClick="javascript:ChkIsPic();" value="1"/>
                  &nbsp; &nbsp;<span id="DisIsPic" style="display:none;"><input name="PicFile" type="text" id="PicFile" size="50" value="" /><a href="#" onClick="Get_Img();">设置当前选中图片</a></span></td>
              </tr>  

              <tr>
                  <td align="center" bgcolor="#ffffff" colspan="4"><input type="submit" name="Submit"  value="提&nbsp;交" /> &nbsp; &nbsp;
                  <input type="reset" name="Submit2" value="重&nbsp;置" />
                  </td>
              </tr> 
              </form>           
          </table>
    </td>
  </tr>
</table>
<script language="JavaScript" type="text/javascript">
	function test() 
{   
if  (document.myform.title.value.length  ==  0)  {   
alert("请输入标题!"); 
document.myform.title.focus(); 
return  false; 
} 
if  (document.myform.typeid.value.length  ==  0)  {   
alert("请选择大类!"); 
document.myform.typeid.focus(); 
return  false; 
}


if(myform.IsPic.checked && document.myform.PicFile.value.length  ==  0)
{
  alert("文章属性选择了图片，但还没有选择图片,请选择");
  document.myform.PicFile.focus();
  return false;
}

}

function ChkIsPic()
{
	obj = document.getElementById("DisIsPic");
	var _IsPic = document.getElementById("IsPic").checked;
	if(_IsPic)

	{
		obj.style.display = "";
	}
	else
	{
		obj.style.display = "none";
	}
}

function Get_Img()
{	
	  function  getimgsrc(htmlstrimg){
		  var reg=/<img.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim;
		  var arr = [];
		  while(tem=reg.exec(htmlstrimg)){
			  arr.push(tem[2]);
		  }
		  return arr;
	  }
	var htmlStrimg=KE.selectedHtml('content'); 
    var imgs=getimgsrc(htmlStrimg); 
    	if(imgs!="")
	{
	  myform.PicFile.value = imgs;
	}
	else
	{
		alert('没有选择任何图片');
	}
}

ChkIsPic();
</script>
</body>
</html>
              