var Market = {
	init : function() {
		$('#buy-form').submit(function(e){
			e.preventDefault();
			$('#buy-product-btn').replaceWith('<span id="wait">Подождите...</span>');
			
			$(this).ajaxSubmit({
					dataType : 'json',
					success: function(response){
						$('#wait').replaceWith('В корзине');
						$('.for-buy').hide();
						if (response.content){
							$('#in-basket').html(response.content);
						} else {		
							alert('Ошибка! Не удалось добавить товар в корзину');
						}
					}
			});
			
			return false;
		});
	},
	updateBasketBlock : function() {
		 $.get("basket_show.php", {},
		 	function (result) {
		 		$('#in-basket').html(result.content);		 	
		 	}, 'json'
		 );
	}
}

$(document).ready(function(){
	Market.init();
})
