
var stop_
$(document).ready(function(){
	
	
	$('a.compare_zakaz, a.ma_link, a.ma_basket_link, .cat_prod').bind('click',function(e){//, a.ma_link
		var id = parseInt($(this).attr('id'));
//		alert(id);
		if (empty(id)) {
			var id = parseInt($(this).attr('lang'));
			var button_mode = true;
			
//			$(this).unbind().unbind('click');
		}
//			alert('hi '+id);
//		alert(id);
//		if (e.preventDefault)	e.preventDefault();	if (e.stopPropagation)	e.stopPropagation();	e.cancelBubble = true;	e.returnValue = false;
		
		if (id > 0) {
			
			$(this).removeAttr('href');
			//добавляем в корзину товар с помощью ajax
			//'hr_gate.php?test=500&r='+Math.random(),
			//'../ims/logic/hr_prod_in_basket.php?test=500&r='+Math.random(),
			JsHttpRequest.query(
				'hr_gate.php?test=500&r='+Math.random(),
				{
					'sp': "prod_in_basket"
					,'add_id': id
				},
				function(result, errors) {
					if (errors) alert(errors);
					if (result) {
						//alert("fg")
						if (result.count_prod && result.total_sum) update_count_basket(result.count_prod,result.total_sum);
					}
				},
				true  //disable caching
			);
			$(this).replaceWith('<a class="a_prod_in_cart" href="?p=ordering">Товар<br>в корзине</a>');
			$(this).attr('title','Перейти к корзине');
		}
		if (button_mode) {
//			$(this).unbind().click(function(){location.href='?p=ordering';});			$(this).hide();
			$('a#'+id).remove();
//			alert('hi '+id);
			return false;
		} else {
			$('button[lang='+id+']').remove();//.hide();
		}
	});

		
});


