<!--#include file="conn.asp"-->
<%if session("nyeee_admin")="" then
response.redirect "login.asp"
end if

dim theid,dtitle,dcolor,dbgcolor1,dcu,dlei,dispic,dpic,dtext,dstop,dtop,dmoney,sql,rs
theid=request("id")
if isnumeric(theid)=false then
response.write "<script>alert('参数错误，关闭窗口！');window.close();</script>"
response.end
end if

dtitle=HtmlEncode(trim(request.form("dtitle")))
dcolor=HtmlEncode(trim(request.form("dcolor")))
dbgcolor1=HtmlEncode(trim(request.form("dbgcolor1")))
dcu=HtmlEncode(trim(request.form("dcu")))
dlei=HtmlEncode(trim(request.form("dlei")))
dispic=HtmlEncode(trim(request.form("dispic")))
dpic=HtmlEncode(trim(request.form("dpic")))
dtext=HtmlEncode2(request.form("dtext"))
dusername=HtmlEncode(trim(request.form("dusername")))
dcardid=HtmlEncode(trim(request.form("dcardid")))
dtel=HtmlEncode(trim(request.form("dtel")))
dstop=HtmlEncode(trim(request.form("dstop")))
dtop=HtmlEncode(trim(request.form("dtop")))
shouye=HtmlEncode(trim(request.form("shouye")))
dmoney=HtmlEncode(trim(request.form("dmoney")))

if dmoney<>"" then
  if isnumeric(dmoney)=false then
  response.write "<script>alert('广告费用请填写数字，立即返回！');history.back();</script>"
  response.end
  end if
end if

sql="select * from nyeee_data where adid="&theid
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if dtitle<>"" then
rs("title")=dtitle
rs("color")=dcolor
rs("bgcolor1")=dbgcolor1
rs("cu")=dcu
rs("type")=dlei
rs("ispic")=dispic
rs("pic")=dpic
rs("text")=dtext
rs("username")=dusername
rs("cardid")=dcardid
rs("tel")=dtel
rs("stop")=dstop
rs("top")=dtop
if dmoney = "" then dmoney = 0
rs("money")=dmoney
rs("time")=request.form("time")
rs("mark")=request.form("mark")
rs("shouye")=request.form("shouye")
rs.update
rs.close  
set rs=nothing                                                                                     
'conn.close   
'set conn=nothing
response.redirect "editadok.asp"
end if%>

<html>
<head>
<style type="text/css">
<!-- 
td           { font-size: 12px; line-height: 17px }
body         { font-size: 12px; line-height: 17px }
p            { margin-top: 1; margin-bottom: 1 }
a:link       { text-decoration: none; color: black }
a:visited    { text-decoration: none; color: black }
a:active     { text-decoration: none }
a:hover      { text-decoration: underline; color: red }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>修改广告</title>
<SCRIPT LANGUAGE="JavaScript">
<!--//
function checkadd()
{   

                   //检查年月日是否是合法日期

                   function isdate(intYear,intMonth,intDay){ 

                      if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay)) return false;     

                      if(intMonth>12||intMonth<1) return false;  

                      if ( intDay<1||intDay>31)return false;  

                      if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30)) return false;  

                      if(intMonth==2){  

                         if(intDay>29) return false;    

                         if((((intYear%100==0)&&(intYear%400!=0))||(intYear%4!=0))&&(intDay>28))return false;  

                        }  

                      return true;  

                   }  

 

                   //检查身份证是否是正确格式

                   function checkCard(dcardid) 

                   {

                       var pattern;

                            if (dcardid.length==15)

                            {

                                 pattern= /^\d{15}$/;//正则表达式,15位且全是数字

                                 if (pattern.exec(dcardid)==null)

                                 {

                                    alert("15位身份证号码必须为数字！")


                                      return false;

                                 }

                                 if (!isdate("19"+dcardid.substring(6,8),dcardid.substring(8,10),dcardid.substring(10,12)))

                                 {

                              alert("身份证号码中所含日期不正确") 

                                 return false;}

                                 

                            }

                            else     if (dcardid.length==18)

                            {

                                pattern= /^\d{17}(\d|x|X)$/;//正则表达式,18位且前17位全是数字，最后一位只能数字,x,X

                                 if (pattern.exec(dcardid)==null)

                                 {

                                            alert("18位身份证号码必须为数字！")

                                          return false;

                                 }

                                 if (!isdate(dcardid.substring(6,10),dcardid.substring(10,12),dcardid.substring(12,14)))

                                 {

                                        alert("身份证号码中所含日期不正确")  

                                 return false;

                                 }

                                 var strJiaoYan  =[  "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];

                                 var intQuan =[7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];

                                 var intTemp=0;

                                 for(i = 0; i < dcardid.length - 1; i++)

                                 intTemp +=  dcardid.substring(i, i + 1)  * intQuan[i];  

                                 intTemp %= 11;

                                 if(dcardid.substring(dcardid.length - 1,dcardid.length).toUpperCase()!=strJiaoYan[intTemp])

                                 {

                                        alert("身份证末位验证码失败！")

                                 return false;

                                 }

                            }

                            else

                            {

                            alert("身份证号长度必须为15或18！")

                            return false;

                            }

                    return true;   

                   }
 
    if (document.postart.dtitle.value.length<1)
	{
        alert("请填写广告标题！");
        document.postart.dtitle.focus();
        return false;
    }
    if (document.postart.dlei.value=="选择广告类别")
	{
        alert("请选择广告类别！");
        document.postart.dlei.focus();
        return false;
    }
    if (document.postart.dtext.value.length>1500)
	{
        alert("请把广告内容的字数控制在1500以内！");
        document.postart.dtext.focus();
        return false;
    }
	if (document.postart.dusername.value.length == 0) {
		alert("请您填写联系人姓名！");
		document.postart.dusername.focus();
		return false;
	}
//	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,./'[]{}`1234567890-=\~!@#$%^&*()_+|?><:";
//	var errorChar
//	errorChar = isCharsInBag(postart.dusername.value,str)
//	if (errorChar != "" )
//	{
//		alert('联系人姓名必须是中文！');
//		postart.dusername.focus();
//		return false;
//	} 
//function isCharsInBag (s, bag)
//{ 
//var i,c;
//for (i = 0; i < s.length; i++)
//{ 
//c = s.charAt(i);//字符串s中的字符
//if (bag.indexOf(c) > -1) 
//return c;
//}
//return "";
//}
	
//	    if(document.postart.dusername.value.length<2||document.postart.dusername.value.length>4){
//		alert("联系人姓名不能少于2字多于4字！");
//		document.postart.dusername.focus();
//		return false;
//	}	
//	if (document.postart.dcardid.value.length == 0) {
//		alert("请填写您的身份证号！");
//		document.postart.dcardid.focus();
//		return false;
//	}
//		if(checkCard(document.postart.dcardid.value)==false)
//		{
//			document.postart.dcardid.focus(); 
//			return false; 
//		} 
	
    if (document.postart.dtel.value.length<1)
	{
        alert("请填写您的联系电话！");
        document.postart.dtel.focus();
        return false;
    }

if (isNaN(postart.dtel.value)){
alert('电话号码必须是数字');
postart.dtel.focus();
return false;
}
    if (document.postart.dstop.value=="选择有效期")
	{
        alert("请选择有效期！");
        document.postart.dstop.focus();
        return false;
    }
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">      
<!-- Begin
maxLen = 1500;
function checkMaxInput(form) {
if (form.dtext.value.length > maxLen)
form.remLen.value = 0;
else form.remLen.value = maxLen - form.dtext.value.length;
}
//  End -->
</script>
<script language="javascript" type="text/javascript">
<!--
function changeColor(o) {
    document.getElementById("colorBox").style.color = o.value;
}
//-->
</script>
<script language="javascript" type="text/javascript">
<!--
function changeColor1(o) {
    document.getElementById("colorBox1").style.background = o.value;
}
//-->
</script>
</head>

<body background="images/background.gif">
 <div align="center">
  <form action="" method="post" name="postart" onsubmit="return checkadd()">
  <table border="0" width="100%" cellspacing="0" cellpadding="0"> 
    <tr align="center">
       <td height="30" colspan="3"><font color="#FF0000">编 辑 广 告</font></td>
    </tr>
    <tr>
      <td width="27%" height="26" align="right">广告标题：</td>
      <td height="26" colspan="2"><input type="text" name="dtitle" size="20" maxlength="10" value="<%=rs("title")%>"> 
        <font color="#FF0000">*<%=rs("ip")%></font></td>                                                                                          
    </tr>                                                                                          
    <tr>                                                                                          
      <td align="right" height="26">是否加粗：</td>                                                                                         
      <td height="26" colspan="2"><input type="radio" value="no" <%if rs("cu")="no" then%>checked<%end if%> name="dcu">否&nbsp;                                                                                        
        <input type="radio" value="yes" name="dcu" <%if rs("cu")="yes" then%>checked<%end if%>>是</td>                                                                                           
    </tr>                                                                                           
    <tr bgcolor="#FFFFFF">
      <td align="right" bgcolor="#FFFFFF">标题颜色：</td>
      <td width="160" height="26" bgcolor="#FFFFFF"><input name="dcolor" type="text" id="dcolor" onchange="changeColor(this);" value="<%=rs("color")%>" size="8" />
          <input type="button" name="Submit" value="选择颜色" onclick="window.open('../colorpicker.html', 'colorPicker', 'width=200, height=160');" />
      </td>
      <td rowspan="2" bgcolor="#FFFFFF"><table width="182" height="24" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td align="center" style="BORDER-RIGHT: #dd91a5 1px dotted; BORDER-TOP: #dd91a5 1px dotted; BORDER-LEFT: #dd91a5 1px dotted; BORDER-BOTTOM: #dd91a5 1px dotted" <%if rs("bgcolor1")<>"" then%>bgcolor="<%=rs("bgcolor1")%>"<%else%>bgColor="#ffe8e8"<%end if%>>
              <table width="166" border="0" cellspacing="0" cellpadding="0" height="5">
                <tr>
                  <td></td>
                </tr>
              </table>
              <div><font style="font-size:14px" color="<%if rs("color")<>"" then%><%=rs("color")%><%else%>#000000<%end if%>"><b>原来的标题和背景颜色</b></font></div></td>
        </tr>
      </table>
      <table width="180" height="24" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td align="center" style="BORDER-RIGHT: #dd91a5 1px dotted; BORDER-TOP: #dd91a5 1px dotted; BORDER-LEFT: #dd91a5 1px dotted; BORDER-BOTTOM: #dd91a5 1px dotted" bgcolor="#ffe8e8"><div id="colorBox1" style="width: 180px;height: 24px"><table width="166" border="0" cellspacing="0" cellpadding="0" height="5">
                  <tr>
                    <td></td>
                  </tr>
                </table>
                <div id="colorBox"><font style="font-size:14px"><b>修改后标题和背景颜色</b></font></div>
            </div></td>
          </tr>
      </table></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td align="right" bgcolor="#FFFFFF">标题背景：</td>
      <td height="26" bgcolor="#FFFFFF"><input name="dbgcolor1" type="text" id="dbgcolor1" onchange="changeColor1(this);" value="<%=rs("bgcolor1")%>" size="8" />
          <input type="button" name="Submit" value="选择颜色" onclick="window.open('../colorpicker1.html', 'colorPicker', 'width=200, height=160');" />
      </td>
    </tr>                                                                                           
    <tr>                                                                           
      <td align="right" height="26">广告类别：</td>                                                                                    
      <td height="26" colspan="2">                                                                          
      <select name="dlei" size="1"><option selected value="<%=rs("type")%>"><%=rs("type")%></option>                                                                                                                                                                                                 
            <%set rs_lei = server.createobject("adodb.recordset")                                                                                                                                                                                                 
			sql = "select * from nyeee_type"                                                                                                                                                                                                 
			rs_lei.open sql,conn,1,1                                                                                                                                                                                                 
			do while not rs_lei.eof%>                                                                                                                                                                                                 
          <option value="<%=rs_lei("name")%>"><%=rs_lei("name")%></option>                                                                                                                                                                                                 
		  <%rs_lei.movenext                                                                                                                                                                                                 
		  loop                                                                                                
		  rs_lei.close                                                                                                                                                                                                 
		  set rs_lei = nothing%>                                                                                                                                                                                                 
         </select>                                                                                   
      </td>                                                                                    
    </tr>                                  
    <tr>                                                                                      
      <td align="right" height="26">广告形式：</td>                                                                                      
      <td height="26" colspan="2"><input type="radio" value="no" name="dispic" <%If rs("ispic")="no" Then%>checked<%End If%>>文字广告&nbsp;                                    
        <input type="radio" value="yes" name="dispic" <%If rs("ispic")="yes" Then%>checked<%End If%>>图片广告</td>                                                                                      
    </tr>                                     
    <tr>                                                                                      
      <td align="right" height="26">图片名称：</td>                                                                                      
      <td height="26" colspan="2">
	  <script language="Javascript">
function openScript(url, width, height){
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=no,menubar=no,frameborder=0,status=yes' );
}
function openem()
{ 
openScript('../uploadad.asp',300,60); 
}
</script>
	  <input type="text" name="dpic" size="30" value="<%=rs("pic")%>">
[<a href="JavaScript:openem()">上传图片</a>] <font color="#FF0000">支持gif、jpg格式</font></td>                                                                                  
    </tr>                                                                                                                         
    <tr>                                                                                       
      <td align="right" height="26" rowspan="2">广告内容：</td>                                                                                        
      <td colspan="2"><textarea rows="6" name="dtext" cols="50" onKeyDown="checkMaxInput(this.form)" onKeyUp="checkMaxInput(this.form)"><%if rs("text")<>"" then%><%=replace(rs("text"),"<br>",vbcrlf)%><%end if%></textarea> 
      <font color="#FF0000">*&nbsp;</font>                                                                            
      </td>                                                                                       
    </tr>                                                                                               
    <tr>           
      <td height="26" colspan="2"><font color="#FF0000">目前还可写 <input readonly type=text name=remLen size=4 maxlength=4 style="border: 1 solid #888888">                                            
        个字！</font>                                                                                    
      </td>                                                                                       
    </tr>  
    <tr>
      <td height="26" align="right">联系人：</td>
      <td height="26" colspan="2"><input name="dusername" type="text" id="dusername" value="<%=rs("username")%>" size="20" maxlength="20">
        <font color="#FF0000">* </font></td>
    </tr> 
	    <tr>
	      <td height="26" align="right">身份证号：</td>
      <td height="26" colspan="2"><input name="dcardid" type="text" id="dcardid" value="<%=rs("cardid")%>" size="20" maxlength="18">
        <font color="#FF0000">* </font></td>
    </tr> 
	    <tr>
	      <td height="26" align="right">联系电话：</td>
      <td height="26" colspan="2"><input name="dtel" type="text" id="dtel" value="<%=rs("tel")%>" size="20" maxlength="20">
        <font color="#FF0000">* </font></td>
    </tr>       
    <tr>                                                                                     
      <td align="right" height="26">生效日期：</td>   <td height="26" colspan="2"><input name="time" size="15" maxlength="50" value="<%=rs("time")%>"> <font color="#FF0000">（格式如：2004-10-1）</font></td> </tr>                                                     
    <tr>                                                                                     
      <td align="right" height="26">有效期至：</td>                                                                                      
      <td height="26" colspan="2"><input name="dstop" size="15" maxlength="50" value="<%=rs("stop")%>">                                                     
        <font color="#FF0000">（格式如：2004-10-1）</font></td>                                                                                    
    </tr>                                                        
    <tr>                                                                                     
      <td align="right" height="26">是否固顶：</td>                                                                                    
      <td height="26" colspan="2"><input type="radio" value="0" name="dtop" <%if rs("top")="0" then%>checked<%end if%>>否&nbsp;                                                    
        <input type="radio" value="1" name="dtop" <%if rs("top")="1" then%>checked<%end if%>>是</td>                                                                                      
    </tr>   
	
    <tr>                                                                                     
      <td align="right" height="26">是否首页显示：</td>                                                                                    
      <td height="26" colspan="2"><input type="radio" value="0" name="shouye" <%if rs("shouye")="0" then%>checked<%end if%>>否&nbsp;                                                    
        <input type="radio" value="1" name="shouye" <%if rs("shouye")="1" then%>checked<%end if%>>是</td>                                                                                      
    </tr>  







    <tr>                                                                                                 
      <td align="right" height="26">广告费用：</td>                                                                                                  
      <td height="26" colspan="2"><input name="dmoney" size="15" maxlength="50" value="<%=rs("money")%>">                                                                                                
        元                                                                                               
      </td>                                                                                                
    </tr>                                                          
	<tr>                                                                                     
      <td align="right" height="26">是否发布：</td>                                                                                      
      <td height="26" colspan="2"><input name="mark" type="radio" value="no" <%If rs("mark")="no" Then%>checked<%End If%>>                                                           
          尚未发布                                                            
          <input type="radio" name="mark" value="yes" <%If rs("mark")="yes" Then%>checked<%End If%>>                                                           
          已经发布</td>                                                                                      
    </tr>                                                                                       
    <tr>                                                                                       
      <td align="right" height="30">                                                                                       
      </td>                                                                                                                      
      <td height="30" colspan="2" align="right">                                                                                       
        <p align="left"><input type="submit" value="修改" name="submit">&nbsp;                                                                                   
        <input type="reset" value="取消" name="reset">&nbsp; <input type="button" value="返回" name="back" onclick="javascript:history.back()"></td>                                                                                          
    </tr>                                                                                                 
  </table>                                                                                       
  </form>                                                                                      
</div>                                                                                         
<br>                                                                                                                       
</body>
</html>                    
<%rs.close                      
set rs=nothing                                                                                                         
conn.close                       
set conn=nothing%>