$(document).ready(function()
{
	$('span.ruble').empty().append('<span class="nd">&ndash;</span><span class="ru">p</span>');
	
	/* Tabs */
	$('.tabs_contents .round_block .show_layer:first').show();
	$('.tabs li:first').addClass('active');
	var url_str = document.location;
	if(/section/.test(url_str))
	{
		$('.tabs li:eq(2)').siblings().removeClass('active').end().addClass('active');
		$('.tabs_contents .round_block .show_layer').hide().eq(2).show(); 
		$('.list_floors_house').show();
	}	
	$('.tabs li').click(function(){
		$(this).siblings().removeClass('active').end().addClass('active');
		$('.tabs_contents .round_block .show_layer').hide().eq($('.tabs li').index(this)).show();
		if ($('.tabs li').index(this) == 2)
		{
			$('.list_floors_house').show();
		}
		else
		{
			$('.list_floors_house').hide();
		}
	});
	
	/* Vacancies */
	$('.vanancy_item .name span').click(
	function()
	{
		$(this).parent().toggleClass('name_active');
		$(this).parent().parent('.vanancy_item').find('.full_info').slideToggle(500);
	}
	);
	
	/* photo gallery  */

	$('.list_big_photo .big_photo:first').show();
	$('.photogallery ins:first').addClass('active');
	
	$('.photogallery ins').click(
	function()
	{
		$(this).siblings().removeClass('active').end().addClass('active');
		$('.list_big_photo .big_photo').hide().eq($('.photogallery ins').index(this)).show();
	}
	);
	
	$('.big_photo .next_link').click(
	function()
	{
		var cur = $('.photogallery ins.active');
		if ($(cur).next().length!=0)
		{
			$('.photogallery ins').removeClass('active');
			$(cur).next().addClass('active');
			$('.list_big_photo .big_photo').hide().eq($('.photogallery ins').index($('.photogallery ins.active'))).show();
		}
	}
	);

	$('.big_photo .prev_link').click(
	function()
	{
		var cur = $('.photogallery ins.active');
		if ($(cur).prev().length!=0)
		{
			$('.photogallery ins').removeClass('active');
			$(cur).prev().addClass('active');
			$('.list_big_photo .big_photo').hide().eq($('.photogallery ins').index($('.photogallery ins.active'))).show();
		}
	}
	);	
	
	$('.big_photo .next_link').hover(
	function()
	{
		$(this).addClass('next_link_active');
	},
	function()
	{
		$(this).removeClass('next_link_active');
	}
	);
	
	$('.big_photo .prev_link').hover(
	function()
	{
		$(this).addClass('prev_link_active');
	},
	function()
	{
		$(this).removeClass('prev_link_active');
	}
	);
	
	/* tbl_flats */
	$('.tbl_flats tr').hover(
	function()
	{
		$(this).find('td').addClass('td_hover');
	},
	function()
	{
		$(this).find('td').removeClass('td_hover');
	}
	);
	
	$('.tbl_flats tr').click(function()
	{
		if (!$(this).hasClass('header_line'))
		{
			var index = $('.tbl_flats tr').index($(this));
			$('.list_kvartirs .kvartira_able').removeClass('kvartira_sel_act');
			$('.list_kvartirs .kvartira_able').eq(index-1).addClass('kvartira_sel_act');

			$('.list_desc_flat .desc_flat_item').hide().eq(index-1).show();
			
			$('.tbl_flats tr').removeClass('tr_active');
			$(this).addClass('tr_active');
		}
	});
	
	$('.kvartira_sel').click(function()
	{
		var kvartira = $(this);
		if ($(kvartira).hasClass('kvartira_able'))
		{
			var index = $('.list_kvartirs .kvartira_able').index($(kvartira));
			$('.tbl_flats tr').removeClass('tr_active');
			$('.tbl_flats tr').eq(index+1).addClass('tr_active');
			
			$('.list_desc_flat .desc_flat_item').hide().eq(index).show();
			
			$('.kvartira_sel').removeClass('kvartira_sel_act');
			$('.list_kvartirs .kvartirs_line_padd').removeClass('kvart_line_act');
			$(this).parents('.kvartirs_line_padd').addClass('kvart_line_act');
			$(this).addClass('kvartira_sel_act');
		}
	});
    $('.floors a:first').addClass('active');
    $('.floors_plans .floors_plan:first').show();
    $('.floors a').click(function()
       {
			$(this).siblings().removeClass('active').end().addClass('active');
			$('.floors_plans .floors_plan').hide().eq($('.floors a').index(this)).show();
       }
       );
	
});

