var Cart={
    checkout:{
		setCurrency:function(o){
			if(o.value){
				new Ajax(Shop.url.payment,{method:'post',onComplete:function(){
						if($('shipping_'+Cart.shipping_id).getAttribute('has_cod') == 1){
							$('_pay_cod').style.display = '';
						}
					},update:'payment',data:'cur='+o.options[o.selectedIndex].value+'&d_pay='+Cart.d_pay+'&payment='+Cart.payment
					,onComplete:function(a,b,c){
						$ES('input.x-payMethod','payment').addEvent('click',Cart.checkout.setPayment);
					}.bind(this)}
					).request();
			}
			Cart.payment = 0;
			return;
		},
		setPayment:function(o,b){
			Cart.payment = new Event(o).target.value;
			Cart.checkout.total();
		},
		total:function(){
			var data = 'payment='+Cart.payment;
			new Ajax(Shop.url.total,{
				method:'post',
				update:$('amountInfo'),
				'data':data,onComplete:function(a,b,c){
					if(window.ie){
						$('amountInfo').setHTML(a);
					}
				}
			}).request();
		}
	}
}
if($('form-cart')){
  

    $ES('.quiet','form-cart').each(function(item){
        item.addEvent('click',function(e){
            e=new Event(e).stop();
            var ipt=e.target;
            for(obj=ipt.getParent(); !obj.getAttribute('urlremove'); obj=obj.getParent()){;}
            var url = obj.getAttribute('urlremove');
            obj.remove();
            new Ajax(url,{method:'post',update:'cartTotal',data:$('form-cart')}).request();
        });
    });
}
if($('clearCart')){
	$('clearCart').addEvent('click',function(e){

		e=new Event(e).stop();
        if(window.confirm('确定要清空吗?')){
            var ipt=e.target;
            var url = ipt.getAttribute('url');
            $('form-cart').empty();
            new Ajax(url,{method:'post',data:'a=a',onComplete:function(a){
                            $('cart-none-msg').style.display = 'inline';
                            }}).request();
        }
	});
}

window.addEvent('domready',function(){
    if($$('.cart-number')&&$$('.cart-number').length){
      $$('.cart-number').setText(Cookie.get('QIHANG[CART_COUNT]')?Cookie.get('QIHANG[CART_COUNT]'):0);
    }
	
});
	
	