$.fn.addBasket = function(){

	$(this).click(function (){
		id = $(this).attr("id");
		id = parseInt(id.substring(9, id.length));
		if(!id){
			alert('error');
			return false;
		}

		price = parseFloat($('#price_' + id).html());
		
		var loading = $('<img src="/images/small-loading.gif"/>');
		$(this).parent().append(loading);
		$(this).attr('disabled','disabled');

		var el = $(this);

		$.get("/" + LANG + "/shop/add-basket/id/"+id,
		function(data){
		    loading.remove();
		    el.removeAttr('disabled');
			if(data == 'error'){
			    alert('Error');
			    document.location.href = '/';
			}else{		    
			$.refrashBasket();	
			}		
		}
		);



	});
}

$.refrashBasket = function(){
    $("#basket").html('<img src="/images/loading.gif" />');
    $("#basket").load("/" + LANG + "/shop/get-basket");    
}
