	$(function(){
		$('dl.tabs dt').click(function(){
			$(this)
				.siblings().removeClass('selected').end();
				if($(this).nextAll('div').size())
					$(this).next().next().next().addClass('selected');
				else
					$(this).next().next().addClass('selected');
				$(this).addClass('selected');
		});
		$('a.add2basket').click(function(){
			var o=this;
			var input=$(this).parents('.product-row').find('.kolvo');
			var name=input.attr("name");
			var val=input.val();
			$.get("./?response=xml&"+name+"=%2B"+val+"", {}, function(xml) {
				$(".basket-cnt").html($(xml).find("cnt").text());
				$(".basket-sum").html($(xml).find("sum").text());
				$(o).html("Добавлен в корзину");
				location.href='#';
				var intervalID = window.setInterval(function(){$("#korzina").toggleClass("baskethl").toggleClass("basket");}, 500)
				//$(o).empty();
				//input.parents(".prodcut-row").find(".product-itog").html($(xml).find("itog").text());
			});
			return false;
		});
		
		$(".productsinbasket").keyup(function(e) {
			var input=$(this);
			var name=input.attr("name");
			var val=input.val();
			$.get("./?response=xml&"+name+"="+val+"", {}, function(xml) {
				$(".basket-cnt").html($(xml).find("cnt").text());
				$(".basket-sum").html($(xml).find("sum").text());
				input.parents(".prodcut-row").find(".product-itog").html($(xml).find("itog").text());
			});
		});
		$("#inp1").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inp2").html(data);
			});
		});
		$("#inp2").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inp3").html(data);
			});
		});
		$("#inp3").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inp4").html(data);
			});
		});
		$("#inpd1").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inpd2").html(data);
			});
		});
		$("#inpd2").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inpd3").html(data);
			});
		});
		$("#inpd3").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inpd4").html(data);
			});
		});
		$("#inpdd1").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inpdd2").html(data);
			});
		});
		$("#inpdd2").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inpdd3").html(data);
			});
		});
		$("#inpdd3").change(function() {
			$.get("/selection-by-auto/?podbor="+this.value, {}, function(data) {
				$("#inpdd4").html(data);
			});
		});
		$("#podbor-form").submit(function() {
			if(!$('#inp4').value()) {
				alert('Выберите вашу модель авто!');
				return false;
			}
		});
		$(".sel-by-auto").toggle(function() {
			$(".sel-by-auto-wnd").prev().hide();
			$(".sel-by-auto-wnd").show();
			$(this).html("Подбор по размеру");
		}, function() {
			$(".sel-by-auto-wnd").prev().show();
			$(".sel-by-auto-wnd").hide();
			$(this).html("Подбор по авто");
		});
		$("div#makeMeScrollable").smoothDivScroll({scrollingSpeed: 12, mouseDownSpeedBooster: 3, autoScroll: "onstart", autoScrollDirection: "right", autoScrollSpeed: 2, visibleHotSpots: "onstart", hotSpotsVisibleTime: 9, startAtElementId: "startAtMe"});
		jQuery(document.body).imageZoom();
	});
