$(document).ready(function(){
	$('.planes tr td h3').parent().parent().addClass('nameCat');
	$('.planes tr').not('.nameCat').not('.headCat').addClass('linesCat');
	$('.linesCat:even').addClass('sel_gr');
	$('.login').click(function(){
		$('#WebLoginLayer0').animate({opacity:0},10, function(){
			$(this).css('display','block').animate({opacity:1},1000)
		});
	})
	
	$('.but-send').click(function(){
		$('#send-to-email').animate({opacity:0},10, function(){
			$(this).css('display','block').animate({opacity:1},1000)
		});
	})
	
	// закрыть окно Послать на email
	$('#closeSendToEmail').click(function(){
		$('#send-to-email').animate({opacity:0});
	})
	
	// показ с прелодером картинки компанвки салона
	$('#preloader').addClass('showPreloader');
	$('.salon').animate({opacity: 0},10).find('img').bind('load',function(){
		$(this).parent().animate({opacity:1},1000, function(){
			$('#preloader').removeClass('showPreloader');	
		});
	})
	
	// первоначальная загрузка минигалереи
	$('#preloaderInterier').addClass('showPreloader');
	//alert('показали прелодер');
	$('.interier').animate({opacity: 0}, 10, function(){
		//alert('потушили');
		$(this).find('img').bind('load', function(){
				// и показываем его
				//alert('изображение загрузилось');
				$(this).parent().animate({opacity: 1},1000);
				//alert('показали контейнер');
				// скрываем прелоадер
				$('#preloaderInterier').removeClass('showPreloader');	
				//alert('скрыли прелодер');
		});
	})
	
	// мини галерея. реализация
	// отлавливаем клик по миниатюре
  $('.thumbs img').click(function(){
	  //alert('кликнули по миниатюре');
		var pathMax = $(this).parent().attr('href');
		//alert('записали в переменную значение пути к большому изображению: '+pathMax);
		$('#preloaderInterier').animate({opacity: 0},10,function(){
			$(this).addClass('showPreloader').animate({opacity: 1},300);
		})	
    // скрываем контейнер для большого изображения
		$('.interier').animate({opacity: 0},1000,function(){
		  // запихиваем в конейнер для большого изображение большое изображение для кликнутой миниатюры
      $(this).html('<img src=' + pathMax + ' />')
			// дожидаемся полной загрузки большого изображения
        .find('img').bind('load',function(){
				// показываем контейнер с уже запихнутым в него большим изображением
					$(this).parent().animate({opacity: 1},1000);
					$('#preloaderInterier').removeClass('showPreloader');
				});
    });
  return false;
  });	
});
