<?php
//require_once("../global/checkuser2.php");
?>

<!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=utf-8" />
<title>发邮件</title>
<link rel="stylesheet" href="addmodify.css" />
<script charset="utf-8" src="../kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="../kindeditor/lang/zh_CN.js"></script>
<script>
        var editor;
        KindEditor.ready(function(K) {
                editor = K.create('#content');
        });
</script>

<script>
function addreceive(obj){
var receive=document.getElementById("receive").value;
if(receive.split(obj.innerHTML.replace(/\s+/g,"")).length>1)
return false;
if(receive=="")
receive +=obj.innerHTML.replace(/\s+/g,"");
else
receive +=","+obj.innerHTML.replace(/\s+/g,"");
document.getElementById("receive").value=receive;
}

function check(){
var receive=document.getElementById("receive").value;
var title=document.getElementById("title").value;
var content=document.getElementById("content").value;
if(receive==""){
alert("收件人不能为空");
return false;
}
if(title==""){
alert("标题不能为空");
return false;
}
}
</script>
</head>

<body>
<div class="bigdiv">
<table cellspacing="0" cellpadding="0" style="font-size:14px;"><tr><td style="text-align:left;border-left:none;">您的位置：<a href="receive.php">邮件系统</a>/<a href="add.php">发送邮件</a></td><td style="text-align:right;border-left:none;"><a href="receive.php">返回</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>
<div class="list">
<form action="function.php?mod=add" method="post" onsubmit="return check()">
<div class="content">
<table cellspacing="0" cellpadding="0" style="width:100%;">
<?php
if(isset($_GET['mod'])){
if($_GET['mod']=='huifu'){?>
<tr><td style="width:10%;">收件人：</td><td style="width:89%;border-left:none;"><input type="text" id="receive" name="receive" value="<?=$_POST['receive']?>" style="width:98%;height:20px;line-height:20px;"></td></tr>
<tr><td>&nbsp;</td><td style="text-align:left;color:#666666;">添加多个收件人时用","隔开</td></tr>
<tr><td style="width:10%;">标&nbsp;&nbsp;&nbsp;&nbsp;题：</td><td style="width:89%;border-left:none;"><input type="text" id="title" name="title" value="回复：<?=$_POST['title']?>" style="width:98%;height:20px;line-height:20px;"></td></tr>
<?php
}
}else{
?>
<tr><td style="width:10%;">收件人：</td><td style="width:89%;border-left:none;"><input type="text" id="receive" name="receive" value="" style="width:98%;height:20px;line-height:20px;"></td></tr>
<tr><td>&nbsp;</td><td style="text-align:left;color:#666666;">添加多个收件人时用","隔开</td></tr>
<tr><td style="width:10%;">标&nbsp;&nbsp;&nbsp;&nbsp;题：</td><td style="width:89%;border-left:none;"><input type="text" id="title" name="title" value="" style="width:98%;height:20px;line-height:20px;"></td></tr>
<?php
}?>
<tr><td>&nbsp;</td></tr>
<tr><td style="width:10%;">内&nbsp;&nbsp;&nbsp;&nbsp;容：</td><td style="width:89%;border-left:none;"><textarea id="content" name="content" style="width:98%;height:450px;"></textarea></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="发送" class="btn"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="btn" type="button" value="取消" onclick="window.location.href='receive.php'"/></td></tr>
</table>
</div>
</form>
<div class="content" style="width:10%;margin-left:5%;overfollow:hidden;border:1px solid #ccc;">
<ul>
<li style="text-align:center;border-bottom:1px solid #ccc;">添加收件人</li>
<?php
require_once("../global/connect.php");
$sql=mysql_query("select * from user");
while($row=mysql_fetch_array($sql)){
echo "<li style='padding-left:5px;' onclick='addreceive(this)'>".$row['name']."</li>";
}
?>
</ul>
</div>
</div>
</div>
</body>
</html>
