$(document).ready(function(){	$('a.make_order').click(function(){		var title = $(this).attr('title');		if (title != '') {			$(this).attr('title', '');			$(this).css('text-decoration', 'none');			$(this).css('cursor', 'default');			$.ajax({				type: "POST",				url: "/mods/cart/show_form.php",				success: cart_form_response			});		}	});	$('a.basket').click(function(){		var temp = $(this).attr('id');		var id = parseInt(temp.substr(4));		$.ajax({			type: "POST",			url: "/mods/cart/add_to_cart.php",			data: "id="+id,			success: cartResponse		});	});	$('a.del').click(function(){		var temp = $(this).attr('id');		var id = parseInt(temp.substr(3));		$.ajax({			type: "POST",			url: "/mods/cart/update_cart.php",			data: "mode=delete&id="+id,			success: deleteResponse		});	});	var tmp = 0;	function changeCost(id, count) {		var cost = parseInt($('table.cart tbody tr td#cost'+id).html());		$('table.cart tbody tr td#summ'+id).html(count*cost);	}	$('table.cart input.i_cnt').keydown(function(){		tmp = $(this).val();	});	$('table.cart input.i_cnt').keyup(function(){		var temp = $(this).attr('id');		var id = temp.substr(3);		var value = parseInt(parseFloat($(this).val()));		if (isNaN(value)) value = tmp;		if ($(this).val() == '') value = 0;		$(this).val(value);		if (tmp != value) {			changeCost(id, value);			var temp = $(this).parent().attr('id');			var id = temp.substr(1);			$.ajax({				type: "POST",				url: "/mods/cart/update_cart.php",				data: "mode=update&id="+id+"&count="+value,				success: updateResponse			});		}	});	function cart_form_response(response) {		$('div#order_form').html(response);		$("form#order_form").validate({			rules: {				name: {required: true},				phone: {required: true},				captcha: {					required: true,					remote: "/template/common/captcha/process.php",					onkeyup: false				}			}		});	}	function cartResponse(response) {		var temp = response.split('||');		$('.total_basket_info span#b_count').html(temp[0]);		$('.total_basket_info span#b_total').html(temp[1]);	}	function deleteResponse(response) {		var temp = response.split('||')		$('table.cart tbody tr#line'+temp[0]).remove();		if (parseInt(parseFloat(temp[1])) > 0) {			$('table.cart tbody tr td#total_cost').html(temp[1]);		} else {			$('table.cart').css('display', 'none');			$('table.cart').after('Ваша корзина пуста.');		}		$('.total_basket_info span#b_total').html(temp[1]);		$('.total_basket_info span#b_count').html(temp[2]);	}	function updateResponse(response) {		var temp = response.split('||');		$('table.cart tbody tr td#total_cost').html(temp[0]);		$('.total_basket_info span#b_total').html(temp[0]);		$('.total_basket_info span#b_count').html(temp[1]);	}});
