	$(document).ready(function(){
		var order_list_html=$(".order_list").html();
		if(order_list_html!=null&&$.trim(order_list_html)!=""){	
			total_yh_before();
			expand_box();
		}else{
			fold_box();
		}
		$(".mode_detail").click(function(){
			var pid=$(this).attr("pid");
			before_to_cart(pid);
			return false;
		});
	
		$(".removeProduct").click(function(){
			$(this).parents(".prod").remove();
			var pyid=$(this).prevAll(".productid").attr("alt");
			if(pyid>0){
				$("#person_yh").html("<input type='hidden' id='person_yh_id' name='person_yh_id' value='0'>").hide();
			}
	   		if($(".productid").length==0){
	   			$(".shop").remove();
	   			$("#delivery_fee").empty();
	   			$(".myyh").empty();
	   		}
			setTimeout("total_yh_before()",100);
		}); 
						
		$(".amount").keypress(function(event){
			var key = event.keyCode || event.which || event.charCode;
			if(key>=48&&key<=57){             
				var amount=this;
				setTimeout(function() {   
				amount.value=($(amount).val());  
				total_yh_before();
				}, 100 );
			}else{
				return false;
			}
		}); 
		
		$(".order_empty").click(function(){
			$.get("/order/clearcart/");
			$(".shop_order").html("");
			$(".myyh").html("");
			total_yh_before();
			return false;
		});
		
		$(".carthide").mouseover(function(){
			$(".myshoppingboxtitleord").css("background-image","url(http://www.lianxi123.com/images/menu3_03-03-over.png)");
		});
		
		$(".cartshow").mouseover(function(){
			$(".myshoppingboxtitleord").css("background-image","url(http://www.lianxi123.com/images/menu3_03-03-over.png)");
		});
		
		$(".carthide").mouseout(function(){
			$(".myshoppingboxtitleord").css("background-image","url(http://www.lianxi123.com/images/menu3_03-03.png)");
		});
		
		$(".cartshow").mouseout(function(){
			$(".myshoppingboxtitleord").css("background-image","url(http://www.lianxi123.com/images/menu3_03-03.png)");
		});
		
		$(".carthide").click(function(){
			fold_box();
		});
		$(".cartshow").click(function(){
			expand_box();
		});
	});
	
	/**
	* 计算商品数量和价格
	*/
	function total_yh_before()
	{
		var total_amount=0,before_money=0;
		var amounts=$(".amount");
		var productAmounts=$(".productAmount");
		var productids=$(".productid");
		var prices=$(".price");
		var wm_fees=$(".wm_fee");
		for(var i=0;i<amounts.length;i++)
		{
			var amount=Number(amounts[i].value);
			var price=Number(prices[i].value);
			total_amount+=amount;
			before_money+=amount*price;
		}
		$(".order_totnum").html(total_amount);	
		$(".order_total").html(before_money+'.00');	
	}
	
	/**
	* 显示购物车内容
	*/
	function fold_box(){
		$(".cartshow").show();
		$(".carthide").hide();
		$(".order").hide();
		$(".cont").css("padding-bottom","5px");
	}
	
	/**
	* 隐藏购物车内容
	*/
	function expand_box(){
		$(".cartshow").hide();
		$(".carthide").show();
		$(".order").show();
		$(".cont").css("padding-bottom","0px");
	}
		
