<!--#include file="Cls_JS.asp" -->
<%
'==============================================================================
'软件名称：风讯网站信息管理系统
'当前版本：Foosun Content Manager System 2.0 
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
    Dim Types,NewsID,RsNewsObj
	If Request("NewsID")<>"" and Request("Types")<>"" then
	   NewsID = Cstr(Request("NewsID"))
	   Types = Cstr(Request("Types"))
	else
		Response.Write("<script>alert(""参数传递错误"");dialogArguments.location.reload();window.close();</script>")
		Response.End
	end if

%>
<html>
<head>
<link href="../Inc/ModeWindow.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加新闻到自由JS</title>
</head>
<script language="JavaScript" src="../JS/PublicJS.js"></script>
<body leftmargin="0" topmargin="0">
<%If Types = "PicJs" then %>
<form action="" name="ToPicJsForm" method="post" > 
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr> 
      <td width="7%" height="5">&nbsp;</td>
      <td width="16%" height="5">&nbsp;</td>
      <td width="77%" height="5">&nbsp;</td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td>图片JS名称</td>
      <td><select name="JSName" id="JSName" style="width:90%" onChange=ChooseJsName(this.options[this.selectedIndex].value)>
          <option value="" <%If Request("JSEName")="" then Response.Write("selected") end if%>> </option>
	  <%
	    Dim PicJsObj
		Set PicJsObj = Conn.Execute("Select EName,CName,Manner from FreeJS where Type=1 order by AddTime desc")
	    While Not PicJsObj.eof 
	  %>
		<option value="<%=PicJsObj("EName")&"***"&PicJsObj("Manner")%>" <%If Cstr(Request("JSEName")) = Cstr(PicJsObj("EName")) then Response.Write("selected") end if%>><%=PicJsObj("CName")%></option>
	  <%
		PicJsObj.MoveNext
		Wend
	    PicJsObj.Close
		Set PicJsObj = Nothing
	  %>
        </select>
        <input name="Manner" type="hidden" id="Manner">
        <input name="JSEName" type="hidden" id="JSEName"></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td>图片 地址</td>
      <td><input name="PicPath" type="text" id="PicPath" size="28" value="<%=Request("PicPath")%>">
        <input type="button" name="PicChooseButton" value="选择图片" onClick="OpenWindowAndSetValue('../inc/SelectPic.asp?CurrPath=/<% = UpFiles %>',550,300,window,document.ToPicJsForm.PicPath);"></td>
    </tr>
    <tr> 
      <td height="5">&nbsp;</td>
      <td height="5">&nbsp;</td>
      <td height="5">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="3"><div align="center">
          <input type="button" name="Submit2" value=" 确 定 " onClick="ChoosePicPath();">
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="action" type="hidden" id="action" value="trues">
          <input type="button" name="Submit3" value=" 取 消 " onClick="window.close();">
        </div></td>
    </tr>
  </table>
  </form>
  <%elseif Types = "WordJs" then%>
  <form action="" name="ToWordJsForm" method="post">
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr> 
      <td width="7%" height="5">&nbsp;</td>
      <td width="16%" height="5">&nbsp;</td>
      <td width="77%" height="5">&nbsp;</td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td>文字JS名称</td>
      <td><select name="JSName" id="JSName" style="width:90%" onChange=ChooseWordJsName(this.options[this.selectedIndex].value)>
          <option value="" <%If Request("JSName")="" then Response.Write("selected") end if%>> </option>
	  <%
	    Dim WordJsObj
		Set WordJsObj = Conn.Execute("Select EName,CName,Manner from FreeJS where Type=0 order by AddTime desc")
	    While Not WordJsObj.eof 
	  %>
		<option value="<%=WordJsObj("EName")&"***"&WordJsObj("Manner")%>" <%If Cstr(Request("JSName")) = Cstr(WordJsObj("EName")) then Response.Write("selected") end if%>><%=WordJsObj("CName")%></option>
	  <%
		WordJsObj.MoveNext
		Wend
	    WordJsObj.Close
		Set WordJsObj = Nothing
	  %>
        </select>
        <input name="Manner" type="hidden" id="Manner"> 
        <input name="JSEName" type="hidden" id="JSEName"></td>
    </tr>
    <tr> 
      <td height="5">&nbsp;</td>
      <td height="5">&nbsp;</td>
      <td height="5">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="3"><div align="center"> 
          <input type="submit" name="Submit22" value=" 确 定 ">
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          <input name="action" type="hidden" id="action2" value="trues">
          <input type="button" name="Submit32" value=" 取 消 " onClick="window.close();">
        </div></td>
    </tr>
  </table>
</form>
<%End if%>
</body>
</html>
<script>
function ChoosePicPath()
{
  if (document.ToPicJsForm.Manner.value!='12'&&document.ToPicJsForm.Manner.value!='16')
    {
	  if (document.ToPicJsForm.PicPath.value=='')
		 {
		  alert('图片地址不能为空');
		  return;
		  }
	 }
  document.ToPicJsForm.submit();
 }
 
function ChooseWordJsName(TempString)
{
   var TempArr=TempString.split("***");
   document.ToWordJsForm.Manner.value=TempArr[1];
   document.ToWordJsForm.JSEName.value=TempArr[0];
 }
 
function ChooseJsName(TempStr)
 {
   var TempArray=TempStr.split("***");
   document.ToPicJsForm.Manner.value=TempArray[1];
   document.ToPicJsForm.JSEName.value=TempArray[0];
   if (TempArray[1]=='12'||TempArray[1]=='16')
     {
	   document.ToPicJsForm.PicPath.disabled=true;
	   document.ToPicJsForm.PicChooseButton.disabled=true;
	  }
   else
     {
	   document.ToPicJsForm.PicPath.disabled=false;
	   document.ToPicJsForm.PicChooseButton.disabled=false;
	  }
  }
</script>
<%
  If Request.Form("action")="trues" then
  Dim JsFileObj,JsFileSql,TFFlagObj,NewsIDArray,Rt_i,RsNewsTFObj
  If Request.Form("JSEName")="" or isnull(Request.Form("JSEName")) then
	  Response.Write("<script>alert(""请选择自由JS"");</script>")
	  Response.End
  End if
  NewsIDArray = Array("")
  NewsIDArray = Split(NewsID,",")
  For Rt_i = 0 to UBound(NewsIDArray)
  Set RsNewsTFObj = Conn.Execute("Select FileName from FreeJsFile where JSName='"&Request.Form("JSEName")&"' and FileName=(Select FileName from News where NewsID='"&NewsIDArray(Rt_i)&"')")
	  If RsNewsTFObj.eof then
	  Set RsNewsObj = Conn.Execute("Select Title,FileName,ClassID,AddDate from News where HeadNewsTF=0 and NewsID='"&NewsIDArray(Rt_i)&"'")
		 If Not RsNewsObj.eof Then
			  Set JsFileObj = Server.Createobject("adodb.recordset")
			  JsFileSql="select * from FreeJsFile where 1=0"
			  JsFileObj.open JsFileSql,Conn,3,3
			  JsFileObj.AddNew
			  JsFileObj("Title") = RsNewsObj("Title")
			  JsFileObj("JSName") = Request.Form("JSEName")
			  JsFileObj("FileName") = RsNewsObj("FileName")
			  If Request.Form("PicPath")<>"" then
				  JsFileObj("PicPath") = Request.Form("PicPath")
			  End if
			  JsFileObj("ClassID") = RsNewsObj("ClassID")
			  JsFileObj("NewsTime") = RsNewsObj("AddDate")
			  JsFileObj("ToJsTime") = Now()
			  JsFileObj.Update
			  JsFileObj.Close
			  Set JsFileObj = Nothing
		 End if
		 RsNewsObj.Close
		 Set RsNewsObj = Nothing
	 End If
	 RsNewsTFObj.Close
	 Set RsNewsTFObj = Nothing
	 Next
  
  '----------------生成JS文件-------------
  Select case Request.Form("Manner")
     case "1"   WCssA Request.Form("JSEName"),True
     case "2"   WCssB Request.Form("JSEName"),True
     case "3"   WCssC Request.Form("JSEName"),True
     case "4"   WCssD Request.Form("JSEName"),True
     case "5"   WCssE Request.Form("JSEName"),True
     case "6"   PCssA Request.Form("JSEName"),True
     case "7"   PCssB Request.Form("JSEName"),True
     case "8"   PCssC Request.Form("JSEName"),True
     case "9"   PCssD Request.Form("JSEName"),True
     case "10"   PCssE Request.Form("JSEName"),True
     case "11"   PCssF Request.Form("JSEName"),True
     case "12"   PCssG Request.Form("JSEName"),True
     case "13"   PCssH Request.Form("JSEName"),True
     case "14"   PCssI Request.Form("JSEName"),True
     case "15"   PCssJ Request.Form("JSEName"),True
     case "16"   PCssK Request.Form("JSEName"),True
     case "17"   PCssL Request.Form("JSEName"),True
   End Select
  
  '----------------   Over   -------------
  
  Response.Write("<script>alert(""所选新闻已经成功添加到自由JS"");dialogArguments.location.reload();window.close();</script>")
  Response.End
  end if
%>