//--------------------------------------------------------
//function check_count_of_goods(_id_, counter, price)
function add_goods_to_basket(_id_, counter, price)
{
	
	var value = $('#'+_id_).val();
	
	jQuery('title').html(value);
	$('#'+_id_).val('');
	if(!((jQuery.browser.msie)&&(jQuery.browser.version<8)))
	{
        	$('#'+_id_).attr('disabled','disabled');
		$('#'+_id_).css('background','url(/img/loader.gif) no-repeat center');
	}
 	jQuery.post('/ajax/session_set.php',{id:_id_,count:value,price:price},
		function(_data){
				$('#basket').load('/ajax/basket.php?ajax='+Math.random());
				if(!((jQuery.browser.msie)&&(jQuery.browser.version<8))) {
					$('#'+_id_).attr('disabled','');
	 				$('#'+_id_).css('background','');	
					} else window.location.reload();
				
				}
		);
}

function add_goods_to_basket_mlt(_id_, counter, price, mlt)
{
	var value = $('#'+_id_).val();
	

	

	if(parseInt(mlt) == 0) 
		var r = 0;
	else
		r = parseInt(value) % parseInt(mlt);
		
	//alert(r+" "+mlt);	
		
	if(r == 0)
	{
	
		$('#'+_id_).val('');
		if(!((jQuery.browser.msie)&&(jQuery.browser.version<8)))
		{
			$('#'+_id_).attr('disabled','disabled');
			$('#'+_id_).css('background','url(/img/loader.gif) no-repeat center');
		}
		jQuery.post('/ajax/session_set.php',{id:_id_,count:value,price:price},
			function(_data){
					$('#basket').load('/ajax/basket.php?ajax='+Math.random());
					if(!((jQuery.browser.msie)&&(jQuery.browser.version<8))) {
						$('#'+_id_).attr('disabled','');
						$('#'+_id_).css('background','');	
						} else window.location.reload();
					
					}
			);
	}else
		alert('Количество заказываемых единиц товара должно быть кратно '+mlt)
}



function delcookie_basket(_id_){
		jQuery.post('/ajax/session_set.php',{del:_id_},
		function(_data){
				window.location.reload();
				}
		);
}

var oldValue=false;

function stateCount(obj){
	oldValue = $(obj).val();
}

function reCalculate(id,obj){
	var value = $(obj).val();
	if(oldValue!=value) {
		$(obj).attr('disabled','disabled');
		$(obj).css('background','url(/img/loader.gif) no-repeat center');	
 		$(obj).val('');
 		jQuery.post('/ajax/session_set.php',{id:id,newcount:value},
			function(_data){
					$(obj).css('background','');	
					window.location.reload();
					}
			);

	}
}

function get_total_sum()
{
	var sum = jQuery('#total_sum').html();
	var min_s = jQuery('#min_s').html();
	sum = sum.split('.')[0].replace(' ','');
	if(parseInt(sum)>=parseInt(min_s)) 
	{
		//alert("сумма заказа больше минимальной");
		jQuery('#of_zakaz').attr('disabled','');
		jQuery('#message_z').hide();
		
	}
	else
	{
		jQuery('#message_z').show();
		jQuery('#of_zakaz').attr('disabled','true');
	}	
	return false;
}
