<%@ Language="VBScript" %>
<% option explicit %>
<%
dim webGen
webGen = True
%>
<!--#include file="../inc/dbconn.inc.asp"-->
<%
dim uploadFileSize

sql = "SELECT uploadFileSize FROM bs_fileSize"
set rs = conn.Execute(sql)
if not rs.EOF then
	uploadFileSize = rs("uploadFileSize")
end if
rs.Close

if Request("target") = "" then
%>
<html>
<head>
<title>图片修改</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<frameset rows="0,*" frameborder="NO" border="0" framespacing="0"> 
  <frame name="top" scrolling="NO" noresize src="space.html" >
  <frame name="main" src="fileUpload.asp?currentType=<% =Request("currentType") %>&target=main&id=<% =Request("id") %>">
</frameset>
<noframes>
  <body>
  </body>
</noframes>
</html>
<%
else
	dim src
	
	if Request("fileName") <> "" then
		if Request("currentType") = "bigDesktop" then
			sql = "update web_photos set bigImg='"& Request("fileName") &"' where id="& Request("id")
		else
			sql = "update bs_"& Request("currentType") &" set img='"& Request("fileName") &"' where id="& Request("id")
		end if
		conn.Execute(sql)
		Response.Write "<script language=""javascript"">"& vbCrLf
		Response.Write "<!--//"& vbCrLf
		Response.Write "	parent.imgInformation=null;"& vbCrLf
		Response.Write "	parent.window.close();"& vbCrLf
		Response.Write "//-->"& vbCrLf
		Response.Write  "</script>"& vbCrLf
	else
		if Request("currentType") = "bigDesktop" then
			sql = "select bigImg from web_photos where id="& Request("id")
		else
			sql = "select img from bs_"& Request("currentType") &" where id="& Request("id")
		end if
		set rs = conn.Execute(sql)
		if not rs.Eof then
			if trim(rs(0)) <> "" then
				src = SystemUploadURL & rs(0)
			end if
		end if
	end if
%>
<html>
<head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  <link rel="stylesheet" type="text/css" href="images/pop.css">
  <script language="JavaScript" src="images/DhtmlEdit.js"></script>
  <script language="JavaScript">
  <!--//
  window.focus();
  function Syrise_CheckIt()
  {
	fileSuffix = ""+ document.edit.fileUp.value;
	fileSuffix = fileSuffix.substring(fileSuffix.length-3,fileSuffix.length);
	fileSuffix = fileSuffix.toLowerCase();
	if ((fileSuffix!="jpg")&&(fileSuffix!="gif")&&(fileSuffix!="swf"))
	{
		alert("请选择jpg或gif格式的图片");
		sel_staus = false;
	}
	else
	{
		sel_staus = true;
	}
	return sel_staus;
  }

  function Syrise_Check()
  {
	sel_ok = Syrise_CheckIt();
	if (sel_ok)
	{
		goedit_withouttxt();
	}
  }

  function Syrise_PreShow()
  {
	if(document.forms["edit"].elements["fileUp"].value!="")
	{
		sel_ok = Syrise_CheckIt();
		if (sel_ok)
		{
			fileSuffix=""+document.forms["edit"].elements["fileUp"].value;
			fileSuffix=fileSuffix.substring(fileSuffix.length-3,fileSuffix.length);
			fileSuffix=fileSuffix.toLowerCase();
			if (fileSuffix == "swf")
			{
				imgInfo.document.body.innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\"><param name=movie value=\""+ document.forms["edit"].fileUp.value +"\"><param name=quality value=high><embed src=\""+ document.forms["edit"].fileUp.value +"\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"></embed></object>";
			}
			else
				imgInfo.document.body.innerHTML = "<img src='"+document.forms["edit"].fileUp.value+"'>";
		}
	}
  }
  function Syrise_SavePic()
  {
	document.edit.imgFile.value = document.forms["edit"].fileUp.value;
	document.edit.submit();
  }

  function Syrise_Exit()
  {
	parent.window.returnValue=null;
	parent.window.close();
  }
  //-->
  </script>
</head>
<body bgcolor="MENU" leftmargin="5" marginwidth="5" topmargin="1" marginheight="1">
<link rel="stylesheet" type="text/css" href="images/edit.css">
<table cellpadding="0" cellspacing="0" border="0" width="450" class="Syrise_Body">
  <form name="edit" action="saveImg.asp" method="post" enctype="multipart/form-data">
  <input type="hidden" name="imgFile">
  <input type="hidden" name="parentWIN" value="fileUpload">
  <input type="hidden" name="tag" value="<%=Request("id")%>">
  <input type="hidden" name="currentType" value="<%=Request("currentType")%>">
  <input type="hidden" name="uploadFileSize" value="<%=uploadFileSize%>">
  <tr>
    <td>
      <fieldset style="width:100%;margin-bottom:0;margin-left:0;margin-right:3;margin-top:3;" title="工具栏">
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr class="yToolbar">
          <td width="120px" class="Syrise_Btn">
            <input type="file" name="fileUp" size="42" onFocus="Syrise_PreShow()" value="">
          </td>
          <td width="6px" class="Syrise_Btn">
            <div class="toolbarExplode"></div>
          </td>
          <td class="Syrise_Btn" title="预览" language="javascript" onClick="Syrise_PreShow();this.className='Syrise_TabOn';" onMouseOver="this.className='Syrise_BtnMouseOverUp';" onMouseOut="this.className='Syrise_Btn';">
            <img class="Syrise_Ico" src="images/imgPreview.gif" width="16" height="16">
          </td>
          <td class="Syrise_Btn"><img src="images/separator.gif"></td>
          <td class="Syrise_Btn" title="保存" language="javascript" onClick="Syrise_SavePic();this.className='Syrise_TabOn';" onMouseOver="this.className='Syrise_BtnMouseOverUp';" onMouseOut="this.className='Syrise_Btn';">
            <img class="Syrise_Ico" src="images/save.gif" width="16" height="16">
          </td>
          <td class="Syrise_Btn"><img src="images/separator.gif"></td>
          <td class="Syrise_Btn" title="退出" language="javascript" onClick="Syrise_Exit();this.className='Syrise_TabOn';" onMouseOver="this.className='Syrise_BtnMouseOverUp';" onMouseOut="this.className='Syrise_Btn';">
            <img class="Syrise_Ico" src="images/exit.gif" width="16" height="16">
          </td>
        </tr>
      </table>
      </fieldset>
    </td>
  </tr>
  <tr>
    <td>
      <table cellpadding="0" cellspacing="0" border="0" width="330">
        <tr>
          <td colspan="3" class="Syrise_Body">图片预览框(图片大小最好不要超过 <% =uploadFileSize %> KB)</td>
        </tr>
      </table>
      <fieldset style="width:100%;margin-top:3;" title="预览区">
        <iframe style="width:100%;height:195px;" id="imgInfo" marginheight="0" marginwidth="0" border="0" frameborder="1"></iframe>
      </fieldset>
    </td>
  </tr>
</form>
</table>
<%
if src <> "" then
	Response.Write "<script language=""javascript"">"& vbCrLf &"	document.all[""imgInfo""].src='"& src &"'"& vbCrLf &"</script>"
end if
%>
</body>
</html>
<%
end if
%>