$(function () {
	$("#mobile_brand").change(function () {
		var mobile_brand = $("#mobile_brand").val();
		$("#mobile_type").attr("options").length = 0;
		if(mobile_brand) {
			$.ajax({
				type: "post",
				url : "index.php",
				dataType:'json',
				data: {execute_action:"getmobiletype", mobile_brand:mobile_brand},
				success: function(json) {
					for (var i = 0; i < json.html.length; i++) {
						$("#mobile_type").append("<option value='" + json.html[i][0] + "'>" + json.html[i][1] + "</option>");
					}
				},
				error: function() {
					alert('数据返回有错');
				}
			});
		} else {
			$("#mobile_type").append("<option value=''>选择型号</option>");
		}
	});
	
	$("#searchButton").click(function () {
		var mobile_brand = $("#mobile_brand").val();
		var mobile_type = $("#mobile_type").val();
		var item_name = $("#item_name").val();
		if(mobile_brand == "" && item_name == "") {
			alert("请填写搜索内容");
			return false;
		} else {
			if(mobile_brand != "") {
				$("#hd_mobile_brand").val(mobile_brand);
				$("#hd_mobile_type").val(mobile_type);
			}
			$("#searchForm").submit();
		}
	});
});