	$(document).ready(function() {
		var num;
		
		$('#topmenu>li').hover(function(){
			if($(this).children().is('.nm_sub1')==true){
				num=$("#topmenu>li").index($('#topmenu .tm2curr'));
				//alert(num);
				$(this).children('.nm_sub1').show();
				$('#topmenu>li').removeClass('tm2curr');
				$(this).addClass('tm2curr');
			}
		}, function(){
			if($(this).children().is('.nm_sub1')==true){	
				$(this).children('.nm_sub1').hide();
				$(this).removeClass('tm2curr');
				
				if(num!=-1){
					$('#topmenu>li').eq(num).addClass('tm2curr');
				}
				num="";
			}
		});
		
		
		$('#lb-map').lightBox();
		$('.otziv-title').lightBox();
		
		
		
		
		allwidth=$('#myscroll-div').width();
		elmwidth=Math.round( allwidth / $('#myscroll-div a').length );
		

		$('#myscroll-left').click(function(){
			left=$('#myscroll-div').css('left').replace('px','');
			if(left=='auto'){
				left=0;
			}
			view_width=$('#myscroll').width();
			pos=parseInt(left)+parseInt(elmwidth);
			if(left > elmwidth*-1){
				pos=0;
			}
			if(left>=0){
				pos=((allwidth-view_width)*-1);
			}
			$('#myscroll-div').animate({'left': (pos)+'px'}, 'slow'); 
			
			return false;
		});
		
		$('#myscroll-right').click(function(){
			left=$('#myscroll-div').css('left').replace('px','');
			if(left=='auto'){
				left=0;
			}
			view_width=$('#myscroll').width();
			pos=left-elmwidth;
			
			if(left-elmwidth < (allwidth-view_width)*-1){
				pos=((allwidth-view_width)*-1);
			}
			if(left<=(allwidth-view_width)*-1){
				pos=0;
			}
			$('#myscroll-div').animate({'left': (pos)+'px'}, 'slow'); 
			
			return false;
		});


		
		$('#samara-href').click(function(){
			$('#moscow-block').hide();
			$('#samara-block').show();
			return false;
		});
		$('#moscow-href').click(function(){
			$('#samara-block').hide();
			$('#moscow-block').show();
			return false;
		});
		$('.all-href').click(function(){
			$('#samara-block').hide();
			$('#moscow-block').hide();
			return false;
		});
		$('body').click(function(){
			$('#samara-block').hide();
			$('#moscow-block').hide();
		});





		/* Табы соц сетей */
		var heightComments = 0,
			idCommentsBlock = 0,
			commentsFlag = true;
			
		$('.comments_tab ul li').click(function() {
			$('.comments_tab ul li').removeClass('comments_active');
			$(this).addClass('comments_active');
			$('.comments_block').hide();
			
			idCommentsBlock = $(this).attr('id').substr(10);
			$('#comments_block_' + idCommentsBlock).show();
			
			if (commentsFlag)
			{
				if (idCommentsBlock == 1) heightComments = 115;
				else heightComments = 125;
				$('.comments_block_padding').css('height', heightComments + 'px');
			}
		});
		
		
		/* Открыть и закрыть комментарии из соцсетей */
		//Если commentsFlag == true - при нажатии на элемент комментарии открываются
		$('.comments_open').click(function() {
			if (commentsFlag == true)
			{
				$('.comments_block').css({'height' : 'auto', 'overflow' : 'none'});
				$('.comments_block_padding').css({'height' : 'auto', 'overflow' : 'none'});
				$(this).css('background', 'url(/img/arrow_top.jpg) no-repeat 0px 5px');
				$(this).children('span').html('Скрыть оставленные комментарии');
				commentsFlag = false;
			}
			else
			{
				if (idCommentsBlock && idCommentsBlock == 1) heightComments = 115;
				else heightComments = 125;
				
				$('.comments_block').css({'height' : '125px', 'overflow' : 'hidden'});
				$('.comments_block_padding').css({'height' : heightComments + 'px', 'overflow' : 'hidden'});
				$(this).css('background', 'url(/img/arrow_bottom.jpg) no-repeat 0px 5px');
				$(this).children('span').html('Показать оставленные комментарии');
				commentsFlag = true;
			}
		});
		
		
		
		//подробный текст
		var hg=$('.celi-block').height();
		var minhg=52;
		if(hg>minhg){
			$('.celi-block').height(minhg);
			$('.celi-block-a').text('Показать весь текст');
			$('.celi-block-a').show();
		}
		
		$('.celi-block-a').click(function(){
			if($('.celi-block').height()==minhg){
				$('.celi-block').height(hg);
				$('.celi-block-a').hide();
			}
			else{
				$('.celi-block').height(minhg);
			}
			return false;
		});

	});



	function settop(n){
		document.getElementById('block0').style.display='none';
		document.getElementById('block1').style.display='none';
		document.getElementById('block2').style.display='none';
		document.getElementById('block3').style.display='none';
		
		document.getElementById('t1').className='';
		document.getElementById('t2').className='';
		document.getElementById('t3').className='';
		
		
		document.getElementById('block'+n).style.display='block';
		document.getElementById('t'+n).className='topcur';
	}


	function filter(n){
		document.getElementById('ss1').style.display='block';
		document.getElementById('ss1').style.left=document.getElementById('ss1s').offsetLeft+'px';
	}
