<!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">
<script type="text/javascript">
$().ready(function(){
	$("#editForm").validate({
		rules: {
			'data[MobilePhone][mobile_brand_id]' : 'required',
			'data[MobilePhone][agent]' : 'required',
			'data[MobilePhone][show_order]' : {
				'required' : true,
				'digits' : true,
				'range' : [1,99999]
			}
		},
		messages: {
			'data[MobilePhone][mobile_brand_id]' : '请选择手机品牌',
			'data[MobilePhone][agent]' : '手机机型不能为空',
			'data[MobilePhone][show_order]' : {
				'required' : '排列顺序不能为空',
				'digits' : '排列顺序必须为整数',
				'range' : '排列顺序必须在1-99999之间'
			}
		},
		errorPlacement: function(error, element){
			$("#span_" + element.attr("id")).html(error).attr("class", "error");
		},
		submitHandler: function(form){
			var flag;
			$.ajax({url:"./index.php",
					data:{r:"MobileSet.checkphone",
						  agent:$("#MobilePhone_agent").val(),
						  mobileBrandId:$("#mobileBrandId").val(),
						  phoneId:$("#MobilePhone_id").val()
						  },
					cache:false,
					async:false,
					type:"GET",
					success:function(datastr){
					   	flag = datastr;
					}
			});
			if(flag == "false"){
				$("#span_MobilePhone_agent").html("机型" + $("#MobilePhone_agent").val() +"已存在，请重新输入").attr("class", "error");
				return;
			}
			setDisabled(":button",window.document);
			form.submit();
		},
		errorClass: "invalid",
		success: function(label){
			label.parent().html("&nbsp;").attr("class", "valid");
		}
	});

	$("#MobilePhone_mobile_brand_id").change(function(){
		$.post("index.php?r=MobileSet.getSerial", {bid : $("#MobilePhone_mobile_brand_id").val()}, function(data){
			var serials = eval("("+data+")");
			$("#MobilePhone_mobile_serial_id").empty();
			$("<option value=\"\">请选择游戏系列</option>").appendTo("#MobilePhone_mobile_serial_id");
			for(i=0; i<serials.length; i++){
				$("<option value=\""+serials[i].id+"\">"+serials[i].serial+"</option>").appendTo("#MobilePhone_mobile_serial_id");
			}
		});
	})
});
</script>
</head>
<body>
<form action="index.php?r=MobileSet.editphone" method="post" id="editForm">
<input type="hidden" name="data[MobilePhone][id]" id="MobilePhone_id" value="<!--{$data.id}-->"/>
<input type="hidden" name="returnParams" value="<!--{$returnParams}-->"/>
<input type="hidden" id="mobileBrandId" value="<!--{$data.mobile_brand_id}-->"/>
<table class="tbl_edit" width="100%">
	<tr>
		<td class="td_name">手机品牌<span class="red">*</span></td>
		<td class="td_content"><!--{$data.brand_name}--></td>
	</tr>
	<tr>
		<td class="td_name">游戏系列</td>
		<td class="td_content"><!--{$data.serial}--></td>
	</tr>
	<tr>
		<td class="td_name">软件平台</td>
		<td class="td_content"><!--{$data.platform_name}--></td>
	</tr>
	<tr>
		<td class="td_name">屏幕大小</td>
		<td class="td_content"><!--{$data.screen_size}--></td>
	</tr>
	<tr>
		<td class="td_name">手机机型<span class="red">*</span></td>
		<td class="td_content"><input type="text" name="data[MobilePhone][agent]" id="MobilePhone_agent" class="text" value="<!--{$data.agent}-->" maxlength='30'/><span id="span_MobilePhone_agent"></span></td>
	</tr>
	<tr>
		<td class="td_name">是否热门机型</td>
		<td class="td_content">
			<!--{if $data.hot_flag == 1}-->
			是&nbsp;<input type="radio" name="data[MobilePhone][hot_flag]" id="MobilePhone_hot_flag" value="1" checked="checked"/>&nbsp;&nbsp;&nbsp;否&nbsp;<input type="radio" name="data[MobilePhone][hot_flag]" id="MobilePhone_hot_flag" value="0"/>
			<!--{else}-->
			是&nbsp;<input type="radio" name="data[MobilePhone][hot_flag]" id="MobilePhone_hot_flag" value="1" />&nbsp;&nbsp;&nbsp;否&nbsp;<input type="radio" name="data[MobilePhone][hot_flag]" id="MobilePhone_hot_flag" value="0" checked="checked"/>
			<!--{/if}-->
		</td>
	</tr>
	<tr>
		<td class="td_name">排列顺序<span class="red">*</span></td>
		<td class="td_content"><input type="text" name="data[MobilePhone][show_order]" id="MobilePhone_show_order" class="text" value="<!--{$data.show_order}-->" maxlength='5'/><span id="span_MobilePhone_show_order"></span></td>
	</tr>
	<tr>
		<td class="noborder"></td>
		<td class="noborder"><button type="submit" class="butsubmit">修改</button></td>
</tr></table>
</form>
</body>
</html>