	$(document).ready(function(){	

		/* РАСКРЫТИЕ И ЗАКРЫТИЕ ПОИСКА */
		$("#full_search").hide();	// скрываем поиск
		
		$("#show_full_search").click(function(){
			$("#full_search").toggle();
			return false;
		});


		$("input.inpcompare").click(function(){
			var checkCount=0;
			$("input.inpcompare").each(function(i){
				if ($(this).attr('checked')) {
					checkCount=checkCount+1;
				}
			});

			if (checkCount>1) {
				$("input.inpcompare").each(function(i){
					if ($(this).attr('checked')) {
						$(this).next().addClass('checked');
						$(this).next().html('Сравнить')
					} else {
						$(this).next().removeClass('checked');
						$(this).next().html('Добавить к сравнению')
					}
				});
			} else {
				$("input.inpcompare").each(function(i){
					$(this).next().removeClass('checked');
					$(this).next().html('Добавить к сравнению')
				});
			}
		});
		

		$("label.lblcompare").click(function(){
			if ($(this).html()=='Сравнить') {
				compareComps();
				return false;
			}
		});
				

		/* ОБРАТНЫЙ ЗВОНОК */
		$("#back").click(function(){					
			$("#callback").hide();
		});

		$("#label_call").click(function(){				
			$("#callback").animate({"width": "toggle", "opacity": "toggle"}, { duration: "fast" });
		});

		$('#close_call').click(function(){
			$("#callback").hide();
		});

		$('form[name=callback]').submit(function(){
			var result=true;
			$('form[name=callback] input.nesc').each(function(i){
				if (!$(this).val()) {
					result=false;
					alert('Не заполнено поле "'+$(this).attr('title')+'"');
					$(this).focus();
					return false;
				}
			});
			if (result) {
				var data="doit=callme&"+$('form[name=callback]').serialize();
				var answer = jQuery.ajax({
					type: "POST",
					url: "/ajax.php",
					data: data,
					async: false
				}).responseText;

				alert('Спасибо '+$('#callback_user').val()+', мы обязательно свяжемся с Вами!')
				$("#callback").hide();
			}
			return false;
		});
		var my_left=($('body').width()/2)-300;
		$('#callback').css('left', my_left);
	});		
