// Ñìåíà öåíû â ñîîòâ. ñ îïöèåé
$().ready(function(){
	$('.products-options input, .products-options select').change(function(){
		var form = $(this).closest('form');
		var good_id = $(form).attr('id').substr(5);

		var request = '';
		var options = $(form).find('input:checked');
		$(options).each(function(){
			request += (request.length ? '&' : '') + $(this).attr('name') + '=' + $(this).val();
		});
		
		var options = $(form).find('option:selected');
		$(options).each(function(){
			request += (request.length ? '&' : '') + $(this).parent().attr('name') + '=' + $(this).val();
		});
		
		jQuery.post(
			'/categories/?get-price=yes',
			(request.length<3 ? 'good_id=' + good_id : request),
			function(price){
				$('#price_' + good_id + '').html(price);
				//alert(price);
			},
			'text');
			
		if (request.length<3)
		{
			$('#tocart_' + good_id).attr('href', '/basket/?add=' + good_id);
		} else {
			$('#tocart_' + good_id).attr('href', 'javascript:void(0)').click(function(){
				$('#form_' + good_id).submit();
			});
		}
	});
});

/*
// Ñìåíà öåíû â ñîîòâ. ñ îïöèåé
$().ready(function(){
	$('.products-options input, .products-options select').change(function(){
		var form = $(this).parent().parent().parent().parent().find('form');
		var good_id = $(form).attr('id').substr(5);

		var request = '';
		$(form).find('input:checked').each(function(){
			request += (request.length ? '&' : '') + $(this).attr('name') + '=' + $(this).val();
		});
		
		jQuery.post(
			'/categories/?get-price=yes',
			(request.length<3 ? 'good_id=' + good_id : request),
			function(price){
				$('#price_' + good_id + '').html(price);
				//alert(price);
			},
			'text');
			
		if (request.length<3)
		{
			$('#tocart_' + good_id).attr('href', '/basket/?add=' + good_id);
		} else {
			$('#tocart_' + good_id).attr('href', 'javascript:void(0)').click(function(){
				$('#form_' + good_id).submit();
			});
		}
	});
});
//*/