$(document).ready(function() {
	function update_count(e, sku, data) {
		//$('#item_count').text(data.items.length);
		// they want exact qty count
	    //    $('#item_count').load('/cart/ajax/cart-item-count/');
	    refresh_item_count();   // from common.js
	}
	$('body').bind('addbasket', update_count).bind('removebasket', update_count);
        $('.product .closer').click(function() {
                $(this).parent().hide();
                return false;
        });

        //if(!($.browser.msie && $.browser.version=="6.0")){
        $('.product .quick_buy').click(function() {
                $('.product .quick_add').hide();
		        var quick_add = $(this).parents('.product').find('.quick_add');
	            quick_add.find('.added_to_cart_btn').hide();
		        quick_add.find('.add_to_cart_btn').show();
		        quick_add.find('.quantity.quickadd, .qty_txt').show();
                //quick_add.show();
                quick_add.show();
                return false;
        });
        //}
        $('.product .quick_add form').submit(function() {
		var $this = $(this);
		//$this.find('.add_to_cart_btn').hide("slow");
                $.post('/cart/ajax/add-to-cart/', $this.serialize(), function(data) {
			$this.find('.add_to_cart_btn').hide();
			$this.find('.quantity.quickadd, .qty_txt').hide();
			$this.find('.quick_price').hide();
			$this.find('.added_to_cart_btn').show()//"fast");
                        setTimeout('$(".quick_add").hide()',5000);
			$('body').trigger('addbasket', [$this.find('[name="sku"]').val(), data]);
                }, "json");
                return false;
        });
});

