	$(document).ready(function() {
		
		// Чекбокс "Искать в найденном" в форме поиска
		var sfo_replacer_checked = false;
		$('#search-found-only').css('display', 'none');
		$('#search-found-only').before('<span id="search-found-only-replacer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;');
		if ($('#search-found-only').attr('checked'))
		{
			$('#search-found-only-replacer').addClass('checked');
			sfo_replacer_checked = true;
		}
		$('#search-found-only-replacer, #search-found-only-label').click(function(){
			if (sfo_replacer_checked)
			{
				$('#search-found-only-replacer').removeClass('checked');
				$('#search-found-only').removeAttr('checked');
				sfo_replacer_checked = false;
			}
			else
			{
				$('#search-found-only-replacer').addClass('checked');
				$('#search-found-only').attr('checked','checked');
				sfo_replacer_checked = true;
			}
			return false;
		}); 
		//
		
		// Панель Задать свой вопрос
		var ask_question_visible = false;
		$('#ask-question-btn, #ask-question-bear').click(function(){
			if (online_interview_visible)
			{
				// $('#online-interview-content').animate({width: 'toggle'});
				$('#online-interview-content').toggle();
				online_interview_visible = !online_interview_visible;
			}
			// $('#ask-question-content').animate({width: 'toggle'});
			$('#ask-question-content').toggle();
			ask_question_visible = !ask_question_visible;
		});
		if ($('.center-top').length > 0)
		{
			//$('#ask-question-wrap').css('top','490px');
		}
		//
		
		// Панель Online опрос
		var online_interview_visible = false;
		$('#online-interview-btn, #online-interview-bear').click(function(){
			if (ask_question_visible)
			{
				// $('#ask-question-content').animate({width: 'toggle'});
				$('#ask-question-content').toggle();
				ask_question_visible = !ask_question_visible;
			}
			// $('#online-interview-content').animate({width: 'toggle'});
			$('#online-interview-content').toggle();
			online_interview_visible = !online_interview_visible;
		});
		var heght_is_more = true;
		function SetPanelsPosition()
		{
			if ($(window).height() < 564 && heght_is_more)
			{
				$('#ask-question-wrap').css({'top':'20px','bottom':'auto','position': 'absolute'});
				$('#online-interview-wrap').css({'top':'292px','bottom':'auto','position': 'absolute'});
				heght_is_more = false;
			}
			if ($(window).height() >= 564 && !heght_is_more)
			{
				$('#ask-question-wrap').css({'bottom':'292px','top':'auto','position': 'fixed'});
				$('#online-interview-wrap').css({'bottom':'20px','top':'auto','position': 'fixed'});
				heght_is_more = true;
			}
		}
		
		SetPanelsPosition();
		$(window).resize(SetPanelsPosition);
		
		//
		
		// Подподменю
		$('.vertmenu-submenu-item').each(function(ind, el){
			
			//$(el).children('.vertmenu-subsubmenu').addClass('separate')
			$(el).hover(function(){
				$(this).children('.vertmenu-subsubmenu').show();
			},function(){
				$(this).children('.vertmenu-subsubmenu').hide();
			});
		});
		//
		
		// Чекбокс "Выбрать для сравнения" в списке товаров
		var clch_replacers_checked = new Array();
		$('.catalog-list-chooser').each(function(ind, elem){
			origId = $(elem).attr('id');
			$('#'+origId+'-label').attr('ind', ind);
			$(elem).css('display', 'none')
				.attr('id','chooser-'+ind+'-chbx');
			
			theClass = 'catalog-list-chooser-replacer';
			if ($(elem).attr('checked'))
			{
				theClass += ' checked';
				clch_replacers_checked[ind] = true;
			}
			div = '<div id="chooser-'+ind+'-replacer" class="'+theClass+'" ind="'+ind+'">&nbsp;</div>';
			$(elem).before(div);
		});
		$('.catalog-list-chooser-label, .catalog-list-chooser-replacer').click(function(){
			clickInd = $(this).attr('ind');
			if (clch_replacers_checked[clickInd])
			{
				$('#chooser-'+clickInd+'-replacer').removeClass('checked');
				$('#chooser-'+clickInd+'-chbx').removeAttr('checked').change();
				clch_replacers_checked[clickInd] = false;
			}
			else
			{
				$('#chooser-'+clickInd+'-replacer').addClass('checked');
				$('#chooser-'+clickInd+'-chbx').attr('checked','checked').change();
				clch_replacers_checked[clickInd] = true;
			}
			return false;
		});
		//
		
		// Селект выбора размера одежды
		$('.size-select').each(function(ind, elem){
			var params = {
				changedEl: "#"+ $(elem).attr('id')
			}
			cuSel(params);
		});
		//
		
		// Вкладки и ссылка "изменить" на странице "Мой счет"
			var thisId = null;
			var currId = $('.account-tabs td.active').attr('id');
			$('.user-account-page .account-tabs td').addClass('pointer').click(function(){
				thisId = $(this).attr('id');
				if (thisId != currId)
				{
					$('#' + currId + ', #' + currId + '-details, #' + currId + '-edit').removeClass('active');
					currId = thisId;
					$('#' + currId + ', #' + currId + '-details, #' + currId + '-edit').addClass('active');
					//$('.account-edit-content').removeClass('active');
				}
			});
            $('.user-account-page .account-tabs a').addClass('noline').click(function(){
				$(this).parent().click();
				return false;
			});
            
			$('.user-account-section .account-tabs td').addClass('pointer').click(function(){
				window.location.replace($(this).children('a').attr('href'));
			});
		
/**
 * 			$('.account-edit-link a').click(function(){
 * 				$(this).parent().siblings('.account-edit-content').toggleClass('active');
 * 				return false;
 * 			});
 */		//
		
		// Форма входа на сайт
		$('#auth-form-login').focus(function(){
			if ($(this).val() == 'Логин')
			{
				$(this).val('').addClass('left');
			}
		}).blur(function(){
			if ($(this).val() == '')
			{
				$(this).val('Логин').removeClass('left');
			}
		});
		$('#auth-form-passtxt').focus(function(){
			$(this).hide();
			$('#auth-form-pass').show().focus();
		});
		$('#auth-form-pass').blur(function(){
			if ($(this).val() == '')
			{
				$(this).hide();
				$('#auth-form-passtxt').show();
			}
		});
		//
		
		// Почта в новостном блоке
		$('#subscribe-email').focus(function(){
			if ($(this).val() == 'Email')
			{
				$(this).val('').addClass('input');
			}
		}).blur(function(){
			if ($(this).val() == '')
			{
				$(this).val('Email').removeClass('input');
			}
		});
		//
		
		// $('.text-item img').each(function(ind, el){
			// $(el).css({float: 'none', margin: '0px'});
			// $(el).before('<div class="image-wrap"><div class="image-wrap-top"><div class="image-wrap-top2"></div></div><div class="image-wrap-main"><div class="zero-height">&nbsp;</div><div id="iw_'+ind+'" class="image-wrap-main-inn"><div class="image-wrap-main-inn-tl"></div><div class="image-wrap-main-inn-tr"></div><div class="image-wrap-main-inn-bl"></div><div class="image-wrap-main-inn-br"></div></div></div><div class="image-wrap-bottom"><div class="image-wrap-bottom2"></div></div></div>');
			// $('#iw_'+ind).append(el);
			
		// });
		// $('.text-item img').load(function(){
			// $('.image-wrap-main').height($('.image-wrap-main').height() -7);
		// });
		
		// $('.basket table').width($('.basket-content-table-wrap4').width() - 1);
		
		// Скругленные рамки у изображений
		$(".articles-list-item-image img").imgr({size:"3px",color:"#9FDCFF",radius:"10px"});
		$(".our-products-image img").imgr({size:"3px",color:"#30A9EE",radius:"10px"});
		$(".catalog-list-categories img").imgr({size:"3px",color:"#30A9EE",radius:"10px"});
		$(".price-list-category-title img").imgr({size:"3px",color:"#30A9EE",radius:"10px"});
		$(".catalog-list-item-image img").imgr({size:"3px",color:"#9FDCFF",radius:"10px"});
		$(".catalog-item-mainimage .img-link img").imgr({size:"3px",color:"#9FDCFF",radius:"10px"});
		$(".catalog-item-moreimages img").imgr({size:"3px",color:"#9FDCFF",radius:"10px"});
		$(".recommend-image img").imgr({size:"3px",color:"#9FDCFF",radius:"10px"});
		$(".articles-item-content img").not('.noborder').imgr({size:"3px",color:"#9FDCFF",radius:"10px"});
		$(".text-page-content img").not('.noborder').imgr({size:"3px",color:"#9FDCFF",radius:"10px"});
		//
        $('.img-link').fancybox();
        $('.catalog-item-mainimage-glass').fancybox();
		
	});

