	function addCar(pid,num){
	   if(isNaN(pid) || isNaN(num)){
	   		alert('產品或數量格式錯誤');
			return false;
	   }
	   var data = 'pid='+pid+'&num='+num;
	   var action= '/products/add.php';
	   $.ajax({
		   type: "POST",
		   url: action,
		   cache: false,
		   data: data,
		   beforeSend:function(){
//		  		$.blockUI({message:'<h1>資料傳輸中...</h1>'});
		   },
		   success: function(response){
		   
		   		if(response=="addfalse"){
					alert("此產品現在庫存不足或已下架");				
				}else{
//					alert('已加入購物車');
					$("#message").html(response).dialog('open');
				}//else{
				//	alert("此產品現在庫存不足或已下架");
				//}
		   },
		   error:function(response,status,error){		   
			  alert("已產品現在庫存不足或已下架");
		   }
	   });
	}
	
	function delCar(pid){
	   if(isNaN(pid)){
	   		alert('產品格式錯誤');
			return false;
	   }
	   var data = 'pid='+pid;
	   var action= '/products/del.php';
	   $.ajax({
		   type: "POST",
		   url: action,
		   cache: false,
		   data: data,
		   beforeSend:function(){
//		  		$.blockUI({message:'<h1>資料傳輸中...</h1>'});
		   },
		   success: function(response){
		   	
		   		if(response=="addok"){
					alert('已從購物車移除');
				}else{
					alert("已從購物車移除");
				}
				location.reload(); 
		   },
		   error:function(response,status,error){		   
			  alert("已從購物車移除");
			  location.reload(); 
		   }
	   });
	}
	
	function order(){
		document.getElementById("carform").action="order.php";
		document.getElementById("carform").submit();
	}
