function phonetype(target,type){
	if (target=='1'){
		var phonetype = $('#user_phone_brand').val();
	}
	else {
		var phonetype = $('#user_search_phone_brand').val();
	}
	var opt = '';
	$.ajax({
		type: "GET",
		url: "index.php?index/phonetype/"+phonetype,
		dataType:'json',
		success: function(data){
			if (target=='1'){
				$("#user_phone_type").empty();
			}
			else {
				$("#user_search_phone_type").empty();
			}
			for (i in data){
				if (target=='1'){
					if ($.cookie('cookie_phone_type') == data[i].id){
						opt = '<option value="'+data[i].id+'" selected>'+data[i].name+'</option>';
					}
					else {
						opt = '<option value="'+data[i].id+'">'+data[i].name+'</option>';
					}
					$(opt).appendTo("#user_phone_type");
				}
				else {
					if (type == data[i].id){
						opt = '<option value="'+data[i].id+'" selected>'+data[i].name+'</option>';
					}
					else {
						opt = '<option value="'+data[i].id+'">'+data[i].name+'</option>';
					}
					$(opt).appendTo("#user_search_phone_type");
				}
			}
		}
	});
}

function setmyphome(){
	var brand = $('#user_phone_brand').val();
	var type = $('#user_phone_type').val();
	if (brand == '-1' || type == '-1'){
		alert('请先选择手机品牌和型号');
	}
	else {
	$.ajax({
		type: "GET",
		url: "index.php?index/setmyphone/"+brand+"/"+type,
		dataType:'json',
		success: function(data){
			
		}
	});
	}
}

function dosearch(){
	var user_search_phone_brand = $('#user_search_phone_brand').val();
	var user_search_phone_type = $('#user_search_phone_type').val();
	if (user_search_phone_brand!='-1'){
		if(user_search_phone_type=='-1' || typeof(user_search_phone_type)=='object'){
			alert('请选择手机型号!');
			return false;
		}
	}
	return true;
}




$().ready(function(){
	phonetype(1);
	//phonetype(2);
});

