$(document).ready(function(){
	
	$('#phone_handset').change(function(){
				//alert($('#phone_handset').val());
			/**
			$.post("Class/Mobitone_HandSet.php",{handset:$('#phone_handset').val()},function(feedback){
				//alert(feedback);

					$('#sr').text(feedback);
				$.each(feedback,function(){

					alert(this);
				});	
			});
			return false;

				});
				**/
				$.ajax({
					type:"POST",
					url:"Class/Mobitone_HandSet.php",
					data:"handset="+$('#phone_handset').val(),
					cache:false,
					dataType:"json",
					success:function(msg){
						$('#series option').remove();
						$('#s_font').remove();
$('#series').show();
		$('#series').before("<span id='s_font' class=\"bold\">手機機型:</span>");


								$('#series').append("<option value=''>--</option>");	
						$.each(msg,function(k,v){

							$('#series').append("<option value='"+v.handset_id+"'>"+v.handset_id+"</option>");	
						
						});
						
																}
				});
				});
		$('#series').change(function(){
					$.ajax({
					type:"POST",
					url:"Class/Mobitone_Series.php",
					data:"handset="+$('#phone_handset').val()+"&handsetid="+$('#series').val(),
					cache:false,
					dataType:"json",
					error:function (xhr, ajaxOptions, thrownError){
					        alert(xhr.status);
						alert(xhr.statusText);
						alert(thrownError);
																			                                                 		}, 
					success:function(msg){
						//alert(msg);
						//$('#series option').remove();
						$.each(msg,function(k,v){
							//alert(v.format_id);
							//$('#form1').append("<input value='"+v.handset_id+"' type='hidden' name='handsetid'>");	
							$('#brand').val(v.brand);
							$('#handsetid').val(v.handset_id);
							$('#handsetstr').val(v.handset_str);
							$('#formatid').val(v.format_id);
							//alert(v.format_id);

						document.form1.submit();
						});
						
																}
				});
			
		});

	}
);

