<?php
# Name: PHP版程氏音乐CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
include_once("../../lib/cs_label.php");
include_once("../loginstate.php");
SystemPer('2_2');
$ac=CS_Request("ac");
?>
<!doctype html>
<html>
<head>
<meta charset="gbk">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>csdjcms management</title>
<link href="../res/css/admin_style.css" rel="stylesheet" />
<script language="javascript" src="../res/js/jquery.js"></script>
<style> 
body{width:440px;}
</style>
<script language="javascript">
$(document).ready(function(){
	$("#addtags").click(function(){
		var CS_Name=$("#CS_Name").val();
		var CS_CID=$("#CS_CID").val();
	$("#CS_Name").css("border-color","#666 #ccc #ccc #666");
	$("#CS_CID").css("border-color","#666 #ccc #ccc #666");
	if(CS_Name==""){
		$("#CS_Name").css("border","1px solid red");
		$("#Msg").text("请填写标签名称！").css("color","red");
		return false;
		}
	else if(CS_CID=="0"){
		$("#CS_CID").css("border","1px solid red");
		$("#Msg").text("请选择标签分类！").css("color","red");
		return false;
		}
	});
});

function dhcolok(){
    this.parent.$('.webox').css({display:'none'});
    this.parent.$('.background').css({display:'none'});
}
</script>
</head>
<body class="body_none">
<div>
<!-- mod start -->
<form method="post" class="J_ajaxForm" action="?ac=edit" data-role="edit">
<div class="pop_cont pop_table2">
	<table width="100%" style="table-layout:fixed;">
		<col width="90" />
		<col />
		<tr>
			<th>标签名称</th>
			<td>
				<span class="must_red">*</span>
				<input type="text" id="CS_Name" name="CS_Name" class="input input_hd length_5" value="">
			</td>
		</tr>
		<tr>
			<th>标签分类</th>
			<td>
				<span class="must_red">*</span>
				<div class="mb5"><select id="CS_CID" name="CS_CID" class="select_5"><option value="0">选择分类</option>
                                       <option value="1">按年代</option>
                                       <option value="2">按曲风</option>
                                       <option value="3">按心情</option>
                                       <option value="4">按地域</option>

                                </div>
			</td>
		</tr>
	</table>
</div>
<!-- mod end -->
<div class="pop_bottom">
    <div class="tips_error" id="Msg"></div>
	<button class="btn fr" onclick="dhcolok();" type="button">取消</button>
	<button class="btn btn_submit J_ajax_submit_btn mr10 fr" id="addtags" type="submit">提交</button>
</div>
</form>
<!-- end -->
</div>
<?php
if($ac=='edit'){
    $CS_Name=CS_Request("CS_Name");
    $CS_CID=CS_Request("CS_CID");

    if(empty($CS_Name)||empty($CS_CID)) exit("<script>document.getElementById('Msg').innerHTML='请把资料填写完整!';</script>");

    $sql="Insert ".Getdbname('tags')."  (CS_Name,CS_CID) values ('".$CS_Name."',".$CS_CID.")";

    if($db->query($sql)){
        echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,添加成功!").css("color","#026E12");</script>';
	echo "<script>setTimeout(\"this.parent.$('.webox').css({display:'none'});this.parent.$('.background').css({display:'none'});window.parent.location.reload();\",2000);</script>";
    }else{
        echo '<script>$("#Msg").text("抱歉,添加失败!").css("color","red");</script>';
        echo "<script>setTimeout(\"window.location='javascript:history.go(-1);'\",2000);</script>";
    }
}
?>
</body>
</html>