function addToCart(id){
	var checkHtml = '<div title="购物车">确定把这个物品添加到购物车?</div>';
	$(checkHtml).dialog({
		modal: true,
		buttons: {
		'取消': function() {
			$(this).dialog('close');
		},
		'确定': function() {
			$(this).dialog('close');
				var pluginID = id;
				var img = $("img#plugin_img_"+id).attr("src");
				var name = $("a#plugin_type_"+id).html()+$("a#plugin_name_"+id).html();
				var price = $("input#plugin_price_"+id).val();
				$.post("./?mod=cart&ac=do&op=check",{id: pluginID},	function(responseText){
				if(responseText == 0){
				$.post("./?mod=cart&ac=do&op=add",{id: pluginID, img: img , name: name, price: price},
						function(responseText){
							var html = '<div title="购物车">'+responseText+'</div>';
				    		$(html).dialog({
								modal: true,
								buttons: {
								'查看购物车': function() {
									window.location.href = './?mod=cart&ac=manage';
								},
								'确定': function() {
									$(this).dialog('close');
								}
							}
							});
			 		 });
				}else if(responseText == 1){
					var html = '<div title="购物车">该物品已经存在于购物车</div>';
					$(html).dialog({
							modal: true,
							buttons: {
							'查看购物车': function() {
								window.location.href = './?mod=cart&ac=manage';
							},
							'确定': function() {
								$(this).dialog('close');
							}
						}
					});
				}else if(responseText == 2){
					var html = '<div title="购物车">请登录</div>';
					$(html).dialog({
							modal: true,
							buttons: {
							'登录': function() {
								window.location.href = './';
							},
							'确定': function() {
								$(this).dialog('close');
							}
						}
					});					
				}
			});
		}
	}
	});
}
$(document).ready(function(){
	$("ul.main_list").find('a.buy').each(function(){
	$(this).bind("click",function(){
		var answer = confirm("确定购买该物品 ?");
		if (answer){
			return true;
		}else{
			return false;
		}	
	});
});
});


