<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="../head.asp"-->
   <!--#include file="../checkrole.asp"-->
 <%
     call checkuser("ly")

%>
<script Language="JavaScript">
function check()
{
  if (trim(form1.touser.value)=="") {
		alert("对方的会员登陆名不能为空！");
		form1.touser.focus();		
		    return (false);
  }   if (trim(form1.verifycode.value)=="") {
		alert("请输入验证码！");
		form1.verifycode.focus();		
		    return (false);
  }
  
  if (trim(form1.messageTitle.value)=="") {
		alert("主题不能为空！");
		form1.messageTitle.focus();		
		    return (false);
  }

  if (trim(form1.messageContent.value)=="") {
		alert("主要内容不能为空！");
		form1.messageContent.focus();		
		    return (false);
  }
 
}
//-->
function trim(inputString) {
	   
              if (typeof inputString != "string") { return inputString; }
              var retValue = inputString;
              var ch = retValue.substring(0, 1);
              while (ch == " ") { 
	          //检查字符串开始部分的空格
                  retValue = retValue.substring(1, retValue.length);
                  ch = retValue.substring(0, 1);
              }
              ch = retValue.substring(retValue.length-1, retValue.length);
              while (ch == " ") {
                 //检查字符串结束部分的空格
                 retValue = retValue.substring(0, retValue.length-1);
                 ch = retValue.substring(retValue.length-1, retValue.length);
              }
              while (retValue.indexOf("  ") != -1) { 
	         //将文字中间多个相连的空格变为一个空格
                 retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
              }
              return retValue;
           } 

//--> 
</script>
<%
	if issession=0 then
	username=Replace_Text(request.Cookies("Yxmember"))
	gsid=Replace_Text(request.Cookies("Yxmemberid"))
	else
	username=session("user")
	gsid=session("id")
	end if 
 %>
<TABLE width=778 border=0 align="center" cellPadding=0 cellSpacing=0>
  <TBODY>
  <TR>
    <TD 
    style="BACKGROUND-POSITION: right 50%; BACKGROUND-IMAGE: url(i../mages/bg1.gif); BACKGROUND-REPEAT: repeat-y; BACKGROUND-COLOR: #ffffff" 
    vAlign=top align=middle>
      <TABLE cellSpacing=0 cellPadding=0 width=100% border=0>
        <TBODY>
        <TR>
          <TD width="16%"><IMG height=32 src="../images/sendmessage.gif" width=124 
            border=0></TD>
          <TD width="84%" background="../images/info_bg.gif">&nbsp;</TD>
        </TR></TBODY></TABLE>
      <TABLE class=content_border cellSpacing=0 cellPadding=0 width=100% 
border=0>
        <TBODY>
        <TR>
          <TD align=middle>
   <%
				
				
secuser=Replace_Text(request.form("selected_friend_id"))
secuser=replace(replace(replace(secuser,"-1+",""),"0+",""),"1+","")

'''''''''''''''''''''''''''''''''
getuser=Replace_Text(request.QueryString("ui"))
	 if getuser<>"" then
				 secuser=getuser
				end if
				
 ''''''''''''''''''''''''''''''''''''''''''

				
Verifycode=Replace_Text(request("Verifycode"))
sendButton=request("sendButton")

if issession=0 then 
safecode=Replace_Text(request.Cookies("safecode"))
else
safecode=Session("SafeCode")
 end if
if sendButton<>"" then

'对验证码的判断操作^^^^^^^^^^^^^^^^^^^^^^^^^^^^
if Verifycode<>"" and Replace_Text(request.form("messageContent"))<>"" then 
if not isnumeric(Verifycode) then
 response.Write("<script>alert('请输入正确的验证码!');history.back(-1);</script>")
 response.end()
end if


if cstr(Verifycode)<>cstr(safecode) then 
 
response.write"<script>alert(' 亲爱的会员，您的验证码输入错误，请再试一下');history.back(-1);</script> "
 
response.End()

end if
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 


'验证接受的对象'''''''''''''''''''''''''''''
touser=Replace_Text(request.form("touser"))


'''''''''''''''''''''''''''''''''''''''''''
getouser=Replace_Text(request.QueryString("ui"))
				if getouser<>"" then
				 touser=getouser
				end if
				
	''''''''''''''''''''''''''''''''''''''''''			
				
set rs=conn.execute("select id,user from Websen_corporation where flag=1 and  [user]='"&touser&"' and id<>"&gsid&"")
if rs.eof or rs.bof then
  response.write"<SCRIPT language=JavaScript>alert('您填写的对方会员登陆名不正确或会员登陆名是您自己！');"
  response.write"javascript:history.go(-1)</SCRIPT>"
  response.end
else
mycid=rs("id")
end if
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
'对留言进行处理^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
title=Replace_Text(request.form("messageTitle"))
content=Replace_Text(request.form("messageContent"))
sendemail=Replace_Text(request.form("sendemail"))
saveSendMessage=Replace_Text(request.form("saveSendMessage"))
sendContact=Replace_Text(request.form("sendContact"))
if title="" then
response.Write("<script>alert('请输入留言的主题!');history.back(-1);</script>")
response.End()
end if

if content="" then
response.Write("<script>alert('请输入留言的内容!');history.back(-1);</script>")
response.End()
end if


if saveSendMessage<>"" then
set rs1=server.createobject("adodb.recordset")
sql1="select * from Websen_getprice1 where (id is null)" 
rs1.open sql1,conn,1,3
rs1.addnew
rs1("title")=title
rs1("content")=content

if sendemail<>"" then rs1("sendemail")=1

if sendContact<>"" then rs1("sendcontact")=1

rs1("mycid")=mycid
rs1("sendcid")=gsid
rs1("datetime")=now()
rs1.update
end if

set rs=server.createobject("adodb.recordset")
sql="select * from Websen_getprice where (id is null)" 
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content

if sendemail<>"" then rs("sendemail")=1
if sendContact<>"" then rs("sendcontact")=1

rs("mycid")=mycid
rs("sendcid")=gsid
rs("datetime")=now()
if saveSendMessage<>"" then 
rs("getprice1id")=rs1("id")
rs1.close
set rs1=nothing
end if
rs.update

rs.close
set rs=nothing
response.write"<SCRIPT language=JavaScript>alert('恭喜！新留言发送成功！');"
response.write"this.location.href='sendnewmessage.asp'</script>"
end if
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 	if issession=0 then 
	 response.Cookies("safecode")=""
	else
	 Session("SafeCode")=""
	end if

end if 
%>
                	
<SCRIPT language=JavaScript>
function changeFriend() {
    document.form1.touser.value = document.form1.friend.options[document.form1.friend.selectedIndex].value;
}
</script>	  
<FORM name=form1 action="" method=post onSubmit="return check();">
		 <TABLE cellSpacing=1 cellPadding=2 width="100%" border=0>

		  <TBODY>
		  
		  <TR>
			<TD 
			width="25%" align=right vAlign=top bgColor=#eff7ff class=C style="PADDING-TOP: 6px">发送给<B>：</B></TD>
			<TD class=lh15 width="75%" bgColor=#EFF7FF><INPUT 
			  name=touser value="<%=secuser%>" size=15 maxlength="50"> <SELECT onChange="javascript: changeFriend()" 
			  size=1 name=friend> <OPTION value="" 
				selected>从商业伙伴中选取</OPTION> 
	  <%
 sql2="select Websen_memberRelation.secuser,Websen_corporation.name from Websen_memberRelation,Websen_corporation where Websen_memberRelation.[user]='"&username&"' and Websen_memberRelation.relation<>-1 and Websen_corporation.[user]=Websen_memberRelation.secuser order by Websen_memberRelation.id desc"		
				set rs2=conn.execute(sql2)
				if rs2.eof or rs2.bof then 
				response.write""
				else 
				do while not rs2.eof 
				response.write"<OPTION value='"&rs2("secuser")&"'>"&rs2("name")&"（"&rs2("secuser")&"）</OPTION>"
				rs2.movenext
				loop
				end if
				rs2.close
				set rs2=nothing
				conn.close
				set conn=nothing%>
						
				</SELECT> &nbsp;<a href="../myfriend/addfriend_new.asp">添加我的商业伙伴</a><BR><SPAN 
			  class=note>（请填写对方的会员登录名或从商业伙伴中选取）</SPAN> </TD>
		  </TR>
			<TR>
			<TD align="right" bgColor=#eff7ff class=C>附加码<B>： </B></TD>
			<TD bgColor=#EFF7FF><INPUT name=verifycode   onKeyUp="value=value.replace(/[^\d]/g,'') " size=8 maxlength="5" tonbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" > 
			  请在附加码框中输入：  <img src="<%=HOPE_InstallDir%>vCode.asp?" onClick="this.src+=Math.random()" alt="图片看不清？点击重新得到验证码" style="cursor:hand;" /></TD>
			</TR>
			
	
	<TR>
	  <TD align="right" bgColor=#eff7ff class=C>主题<B>：</B></TD>
	  <TD bgColor=#EFF7FF><INPUT maxLength=50 size=50 name=messageTitle></TD>
	</TR>
	<TR bgColor=#ffffff>
	  <TD align="right" bgColor=#eff7ff class=C>主要内容：</TD>
	  <TD bgColor=#EFF7FF><TEXTAREA name=messageContent rows=10 cols=60></TEXTAREA></TD>
	</TR>
	
	<TR bgColor=#ffffff>
	  <TD class=C bgColor=#eff7ff>&nbsp; </TD>
	  <TD bgColor=#EFF7FF><!---<INPUT type=checkbox CHECKED value=true
		name=sendEmail>发到对方的电子邮箱中--><BR>
	    <INPUT type=checkbox disabled CHECKED value=1 
		name=sendMessage>
					  发到对方的“我收到的留言”中<BR>
					  <INPUT type=checkbox 
		CHECKED value=true name=saveSendMessage>
					  保存到我的“我发出的留言”中<BR>
					  <INPUT 
		type=checkbox CHECKED value=true 
	name=sendContact>发送我的联系方式<BR></TD></TR>
			   

		  </TBODY></TABLE><BR> 
		
		<BR> <TABLE width=300 border=0 align="center" cellPadding=4 cellSpacing=0>
		<TBODY>
<TR align=middle>
<TD noWrap><INPUT type=submit value="  发送  " name=sendButton   > 
</TD>
<TD noWrap><INPUT type=reset value="  重填  " name=resetButton> 
</TD></TR>

</TBODY></TABLE>
		<TABLE width=100% border=0 cellPadding=0 cellSpacing=0 bgColor=#ffffff>
		<TBODY>
<TR>
  <TD align=left bgcolor="#F9F9F9">&nbsp;</TD>
</TR></TBODY></TABLE><BR>
	 </FORM> 
   <BR><BR></TD></TR> </TBODY></TABLE><BR>
  <BR></TD></TR>
</TABLE>