function ToCart(tid) { 
	if(tid=='remove') 
		mssg='<h1>Корзина товаров очищена</h1>';
	else 
		mssg='<h1> Товар добавлен в корзину</h1>';
		$.blockUI({
		message: mssg,
		css: {  
        color:          '75D503',  
        border:         '3px solid #75D503', 
        backgroundColor:'#fff',
		opacity: 		'.7',
        cursor:         'wait' 
    	}
	}); 

 	$.post(	'/cart/add/',{ tid:tid	}, ToCartOK); 
}
function DelFromCart(tid){
	ReCountCart(tid);
}


function ReCountCart(tid){
	$('div.cartlist').animate({height: 'hide'}, 500, function()
	{
		
		var params = {};
		$(this).find("input[type='text']").each(function() {
		      params[this.name] = this.value;
		    });
		if (tid>0)
		params['delete']=tid;
		$.post('/cart/recount/', params, recountOK); 
	});	
}


function recountOK(data){
	$('div.cartlist').empty();
	$('div.cartlist').append(data);
	$('div.cartlist').animate({height: 'show'}, 500)
	
}
function ToCartOK(xml){
	setTimeout($.unblockUI, 300); 
	item1 = $("#1", xml);
	$("#tovarTotal").empty();
	$("#tovarTotal").append(item1.text());
	$("#tovarTotal").show();
	
	item2= $("#2", xml);
	$("#sumTotal").empty();
	$("#sumTotal").append(item2.text());
	$("#sumTotal").show();
	
	if(item1.text()==0){
		$("#removeLonk").css({'visibility' : 'hidden'});
		$("#orderLink").css({'visibility' : 'hidden'});
	}else{
		$("#removeLonk").css({'visibility' : 'visible'});
		$("#orderLink").css({'visibility' : 'visible'});
	}
	
}
