<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=upload}-->
<!--{include file=elements/header.js.html type=valid}-->
<style type="text/css">
div.button {
	font-size:12px;
	color:#00f;
	line-height:25px;
	text-align:center;
	float:left;
	margin-left:5px;
}
div.button.hover{
	color:#f00;
}
.anchorbutton{
	font-size:12px;
	color:#00f;
	text-align:center;
	float:left;
	margin-left:5px;
	cursor:pointer;
}

.anchorbuttonon{
	color:#f00;
}
</style>
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>模块管理&nbsp;&gt;&nbsp;音乐模块&nbsp;&gt;&nbsp;内容管理
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=Music.musiclist" class="link">内管管理</a>
				<a href="index.php?r=SiteSet.musicset" class="link">属性设置</a>
				<a href="index.php?r=Music.musicListLayout" class="link">列表页布局</a>
					<a href="index.php?r=Music.musicPageLayout" class="link">内容页布局</a>
				<a href="index.php?r=Music.categorylist" class="link">风格</a>
				<a href="index.php?r=Music.languagelist" class="link">语种</a>
				<a href="index.php?r=Music.singerarealist" class="link">地区</a>
				<a href="index.php?r=Music.singerlist" class="link">歌手</a>
				<a href="index.php?r=Music.albumlist" class="nolink">专辑</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent">
					<form id="editForm" action="index.php?r=Music.editalbum" method="post">
						<input type="hidden" name="data[MusicAlbum][id]" value="<!--{$data.id}-->"/>
						<input type="hidden" name="returnParams" value="<!--{$returnParams}-->"/>
						<table class="tbl_edit" width="100%">
							<tr>
								<td class="td_name">专辑名<span class="red">*</span></td>
								<td class="td_content"><input type="text" class="text" id="album_name" name="data[MusicAlbum][album_name]" value="<!--{$data.album_name}-->" maxlength='64'/><span id="span_album_name"></span></td>
							</tr>
							<tr>
								<td class="td_name">歌手</td>
								<td class="td_content"><input type="text" class="text" id="singer_name" name="data[MusicAlbum][singer_name]" autocomplete="off" value="<!--{$data.singer_name}-->" maxlength='32'/><input type="hidden" id="singer_id" name="data[MusicAlbum][singer_id]" value="<!--{$data.singer_id}-->"/><div id="singerlist" class="hidden"></div></td>
							</tr>
							<tr>
								<td class="td_name">封面图片地址</td>
								<td class="td_content">
									<div style="float:left;"><input type="text" class="text" id="image_url" name="data[MusicAlbum][cover_img_url]" value="<!--{$data.cover_img_url}-->" maxlength='256'/></div>
									<div style="float:left;" class="button" id="uploadclick">上传图片</div>
									<div style="float:left;line-height:25px;">&nbsp;<span id="main_img"></span></div>
								</td>
							</tr>
							<tr>
								<td class="td_name">人气</td>
								<td class="td_content"><input type="text" id="click_count" class="number" name="data[MusicAlbum][click_count]" value="<!--{$data.click_count}-->"/><span id="span_click_count"></span></td>
							</tr>
							<tr>
								<td class="td_name">发行日期</td>
								<td class="td_content"><input type="text" id="publish_date" class="text" name="data[MusicAlbum][publish_date]" value="<!--{$data.publish_date}-->" maxlength='32'/><span id="span_publish_date"></span></td>
							</tr>
							<tr>
								<td class="td_name">简介</td>
								<td class="td_content"><textarea class="textarea" name="data[MusicAlbum][introduction]"><!--{$data.introduction}--></textarea></td>
							</tr>
							<tr>
								<td class="noborder"></td>
								<td class="noborder"><button type="submit" class="butsubmit">提交</button>&nbsp;&nbsp;<button type="button" class="but2font" onClick="window.location.href='index.php?<!--{$returnParams}-->'">返回</button></td>
							</tr>
						</table>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
new AjaxUpload($("#uploadclick"), {
	action: "index.php?r=Music.uploadalbumimage",
	name: "image_file",
	onSubmit: function(file, ext){
		$("#main_img").html("<img src=\"images/ajax.gif\"/>");
		this.disable();
	},
	onComplete: function(file, response){
		this.enable();
		var data = eval("("+response+")");
		if (data.flag == 1) {
			$("#image_url").val(data.name);
			$("#main_img").html(file);
		} else if (data.flag == -1) {
			$("#main_img").html("");
			alert("不能上传" + data.fileext + "文件!");
		} else if (data.flag == -2) {
			$("#main_img").html("");
			alert("文件大小超出指定范围!");
		} else {
			$("#main_img").html("");
			alert("文件上传失败!");
		}
	}
});

$("#editForm").validate({
	rules: {
		'data[MusicAlbum][click_count]':{
			'number': true,
			'digits' : true
		},
		'data[MusicAlbum][publish_date]':{
			date:true
		},
		"data[MusicAlbum][album_name]": "required"
	},
	messages: {
		'data[MusicAlbum][click_count]':{
			'number': '人气值必须为正整数',
			'digits':'人气值必须为正整数'
		},
		'data[MusicAlbum][publish_date]':{
			'date': '非有效的日期格式'
		},
		"data[MusicAlbum][album_name]": "专辑名不能为空"
	},
	errorPlacement: function(error, element){
		$("#span_" + element.attr("id")).html(error).attr("class", "error");
	},
	submitHandler: function(form){
		setDisabled("button", window.document);
		form.submit();
	},
	errorClass: "invalid",
	success: function(label){
		label.parent().html("&nbsp;").attr("class", "valid");
	},
	onkeyup: false
});

var singer_name = $("#singer_name").val();
$("#singer_name").keyup(function(e){
	if (!e) e = window.event;
	if ($(this).val() != singer_name) {
		singer_name = $(this).val();
		$("#singer_id").val("");
		if (singer_name == "") {
			$("#singerlist").html("");
			$("#singerlist").attr("class", "hidden");
		} else {
			$.ajax({
				type: "get",
				url: "index.php?r=Music.getsinger",
				data : {
					singer_name : $("#singer_name").val()
				},
				cache: false,
				dataType: "json",
				success: function(data){
					var singer_index = 0;
					for (var e in data) {
						singer_index++;
					}
					if (singer_index > 0) {
						var str = "";
						for (var i = 0; i < singer_index; i++) {
							str += "<a class=\"automatch_list\">[" + data[i].id + "]" + data[i].singer_name + "</a>";
						}
						str += "<a class=\"automatch_close\">关闭</a>";
						$("#singerlist").html(str);
						$(".automatch_list").each(function(){
							$(this).click(function(){
								$("#singer_id").val($(this).html().substring($(this).html().indexOf("[")+1, $(this).html().indexOf("]")));
								$("#singer_name").focus();
								$("#singer_name").val($(this).html().substring($(this).html().indexOf("]")+1));
								singer_name = $("#singer_name").val();
								$("#singerlist").attr("class", "hidden");
							});
						});
						$(".automatch_close").click(function(){
							$("#singer_id").val("");
							$("#singerlist").html("");
							$("#singerlist").attr("class", "hidden");
						});
						$("#singerlist").attr("class", "automatch");
					} else {
						$("#singer_id").val("");
						$("#singerlist").html("");
						$("#singerlist").attr("class", "hidden");
					}
				}
			});
		}
	}
});
</script>
</html>