$(document).ready(function(){
	$('#objects #menu3>ul>li>a').each(function(){
		var $parent = $(this).parent();
		$(this).replaceWith('<span '+ ($(this).hasClass('active')?'class="active':'')+ ' href="'+$(this).attr('href')+'">' + $(this).text() + '</span>');
	});
	// services list in main page
	$('#services-list .service').each(function(){
		var $service = $(this);
		$('h3 a', this).click(function(){
			// задвигаем обратно прошлый
			$('.service', $service.parent()).each(function(){	
				$('.body', this).slideUp();
				$('h3 a', this).removeClass('important');
				$(this).removeClass('active');
				$(this).animate({left: '-30px'});
			});
			// анимируем текущий
			$(this).addClass('important');
			$(this).parent().parent().addClass('active');
			$(this).parent().parent().animate({left: '-60px'});
			$('.body', $service).slideDown();
			return false;
		});
	});
	$('#objects #menu3>ul>li>span').click(function(){
		var $this = $(this);
		var $objects = $this.parent().parent().parent().parent();
		$('.more', $objects).attr('href', $this.attr('href'));
		$('#objects .photos').each(function(){
			if ($(this).parent().hasClass('active')) {
				$(this).fadeOut('fast', function(){
					$('.photos', $this.parent()).fadeIn();
				});
			}
		});
		$('#objects .active').removeClass('active');
		$this.addClass('active');
		$this.parent().addClass('active');
		return false;
	}).hover(function(){
		$(this).addClass('hover');
	}, function(){$(this).removeClass('hover');});



	$("a.popup").lightbox();
	$("area").lightbox();
	ttmmpp = "";

	$("a.popup img").hover(function(){
		pop = $(this).attr("pop");
		ttmmpp = $(this).attr("src");
		if(pop) $(this).attr("src", pop);
	},
	function(){
		if(pop) $(this).attr("src", ttmmpp);
	});



})
