 function _cart_ttc_()
	{
		if(document.cookie)
		{
		  var cookieParts = document.cookie.split(/;\s/g);
		  var len = 0;
		  var product_cart_totalCount=0;
		  	for(var i=0, len=cookieParts.length; i < len; i++)
		  	{
		  		cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
		  		if(cookieNameValue instanceof Array)
		  		{ 
		  			try{
		  				cookieName = cookieNameValue[1];
		  				if(cookieName == '_product_cart_totalCount_') product_cart_totalCount=decodeURIComponent(cookieParts[i].substring(cookieNameValue[1].length+1));
		        	}catch(ex){ }
		      }
		    }
		    if(product_cart_totalCount!=null)
		    {
		    	document.getElementById("totalCount").innerHTML=product_cart_totalCount;
		    }
		  }else{
		  	document.getElementById("totalCount").innerText=0;
		  }
	}
function initcart()
	{
		if(document.cookie)
		{
		  var cookieParts = document.cookie.split(/;\s/g);
		  var len = 0;
		  	for(var i=0, len=cookieParts.length; i < len; i++)
		  	{
		  		cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
		  		if(cookieNameValue instanceof Array)
		  		{ 
		  			try{
		  				cookieName = cookieNameValue[1];
		  				if(cookieName =='_cart_item_detail'){		  					
		  					var cart = decodeURIComponent(cookieParts[i].substring(cookieNameValue[1].length+1)).replace(/(")*/g,'');
		  					show_dyna_cart(cart);
		  					return;
		  				}
		        	}catch(ex){ }
		      }
		    }
	}
		writeHtml(0,0);	
	}
	function writeHtml(count,price){
		document.getElementById("totalCount").innerHTML=count;
		document.getElementById('cart_top').innerHTML=writePartDiv(count,price);
	}
	
	function writePartDiv(totalNum,totalPrice){
		return '<div class="keep_allprice">共&nbsp;<span>'+totalNum+'</span>&nbsp;件礼品&nbsp;&nbsp;&nbsp;&nbsp;总计<span>￥'+totalPrice+'</span>元</div><div class="gotobuy"><a href="/shoppingcart.do?_methodName=view" class="gotobuy_button">去购物车并结算</a></div>';
	}
	function show_dyna_cart(cart){
		var callback ={
			success: cartSuccess, 
		    failure: cartCartFailure,
		    timeout: 8000
		}
		var href = "/shoppingcart.do?_methodName=dynaCart&cart="+cart;
	   var data =  YAHOO.util.Connect.asyncRequest('post',href,callback);
	}
	
	function cartSuccess(o){
		var response = eval('('+o.responseText+')')
		if(response.result == 1){
			var totalNum = response.totalNum;
			var totalPrice = response.totalPrice;
			var divHtml="";
			try{
			for(var i=0;i<response.items.length;i++){
				var itemId = response.items[i].itemId;
				var itemType = response.items[i].itemType;
				var productID = response.items[i].productID;
				var smallPic = response.items[i].smallPic;
				var customType = response.items[i].customType;
				var productName = response.items[i].productName;
				var price = response.items[i].price;
				var num = response.items[i].num;			
			   divHtml+='<div class="keep"><div class="keep_left"><div class="keep_tu">'+
				        '<a href="/giftview'+productID+'.html"><img src="'+smallPic+'" /></a></div>'+
	                    '<div class="keep_title"><a href="/giftview'+productID+'.html">'+productName+'</a></div>'+
	                    '</div><div class="keep_right"><b>￥'+price+'元 X '+num+'</b><br /><a href="javascript:deleteCart('+productID+','+itemId+','+customType+','+itemType+')">删除</a></div>'+
	                    '<div class="clear"></div></div>';			
			}
			var lastDiv = writePartDiv(totalNum,totalPrice);
			divHtml+=lastDiv;
			document.getElementById("totalCount").innerHTML=totalNum;
			document.getElementById('cart_top').innerHTML=divHtml;
			}catch(e){
				var lastDiv = writePartDiv(totalNum,totalPrice);
			divHtml+=lastDiv;
			document.getElementById("totalCount").innerHTML=totalNum;
			document.getElementById('cart_top').innerHTML=divHtml;
			}
			
		}else{
			writeHtml(0,0);	
		}
	}
	function cartCartFailure(){}
function tishidi()
{

	var currentDiv=document.getElementById("gouwu_di");
	if(choose())
	{
		currentDiv.innerHTML=currentDiv.innerHTML+'<li><a href="msnim:chat?contact=services@liyi99.com"><img id="_btn_msn" src="/images/MSN333.gif" width="86" height="20" border="0" /></a></li>'
	}
	else
	{
		currentDiv.innerHTML=currentDiv.innerHTML+'<li><a href="msnim:chat?contact=services1@liyi99.com"><img id="_btn_msn" src="/images/MSN333.gif" width="86" height="20" border="0" /></a></li>'
	}
	currentDiv.innerHTML=currentDiv.innerHTML+'<li><a href="http://b.qq.com/webc.htm?new=0&sid=800015575&o=www.liyi99.com&q=7" target="_blank"><img id="_btn_qq1" src="/images/QQ333.gif" width="86" height="23" border="0" /></a></li><li><a href="http://b.qq.com/webc.htm?new=0&sid=800015575&o=www.liyi99.com&q=7"><img id="_btn_qq2" src="/images/QQ444.gif" width="86" height="23" border="0" /></a></li>'
}

  function choose()
  {
  	var number=Math.ceil(Math.random()*10);
    number=number%2;
    if(number==0)return true;
    else return false;
  }
  function show_cart_detail(){
  	document.getElementById('cart_top').style.display="block";
  }
  function hidden_cart_detail(){
  	document.getElementById('cart_top').style.display="none";
  }
  function deleteCart(product,item,customType,itemType){
  	if(customType == '9'){
  		alert('自选花包装不能删除');
  		return;
  	}
  	if(customType == '5' && itemType == 1){
	  	 if(!confirm('此项为自选花主材质，若被删除，您定制的鲜花将有可能因为条件不足而不能生成订单')){
	  	 	return;
	  	 }
  	}
  	var callback=
	{
		success: deleteCartSuccess, 
		failure: deleteCartFailure,
		timeout: 8000
	}
	var href = "/shoppingcart.do?_methodName=deleteline&remove_product_id="+product+"&item="+item+"&type=nofresh";
	YAHOO.util.Connect.asyncRequest('post',href,callback);
  }
  
  function deleteCartSuccess(o){
  	initcart();
  }
  function deleteCartFailure(){}
