	function hideCallbackPopup(){
		setTimeout(function(){$('#callback').fadeOut()}, 2000);
	}

$(document).ready(function(){
	$count=$('.gallery .lightbox').size();
	$('.gallery .next').click(function(){
		$current=$('.gallery .lightbox:visible');
		if($current.attr('rel')*1+2==$count)$(this).hide();
		$current.hide(0, function(){ 
		if($current.attr('rel')*1+1>0)$('.gallery .prev').show();
		$current.next().show();});
		$('.gallery .comment').text($current.next().children().attr('alt'))
		return false;
	});
	$('.gallery .prev').click(function(){
		$current=$('.gallery .lightbox:visible');
		if($current.attr('rel')*1-1==0)$(this).hide();
		$current.hide(0, function(){ 
		if($current.attr('rel')*1+1==$count)$('.gallery .next').show();
		$current.prev().show();});
		$('.gallery .comment').text($current.prev().children().attr('alt'))
		return false;
	});
	
	$('.welcome .box').click(function(){
		welcomeClose();	
		return false;
	});
	setTimeout(function(){welcomeClose();}, 4000);
	function welcomeClose (){
			$('.welcome').fadeOut(2000);
		}
	var boxHeight=$(window).height()-$('.footer').height()-$('.header').height();
	$('.content').css('minHeight', boxHeight-120);
	
	$('#callback-link').click(function(){
		$('#callback').show();								   
	});
	
	$('.popup .close').click(function(){
		$(this).parents('.popup').hide();							  
	});
	$('.ajax-form .submit a').click(function(){
		$(this).parents('form').submit();
		return false;
	});
	$('.search .submit').click(function(){
		$(this).parents('form').submit();
		return false;
	});
	$('.search-form, .search form').submit(function() {	
		var val = $(this).find('input').val().replace(/\s\s+/g, ' ');
		if(val=='') return false;
		window.location.href = $(this).attr('action') + val;
		return false;
	});
	$('.world').click(function(){
		$('.world .hover').hide();
	});
	$('.world .point').mousemove(function(){
		$data=$(this).attr('rel');
		$data= eval('(' + $data + ')');
		$('.world .hover').css('bottom', $(this).css('bottom')).css('left', $(this).css('left')).show();
		$('.world .hover h2').html($data.title);
		$('.world .hover .address').html($data.address);
		$('.world .hover .phone').html($data.phone);

	});
	$('.map-popup .close').click(function(){
		$(this).parents('.map-popup').css('visibility', 'hidden');
		return false;
	});
	$('.submenu .box').hover(function(){
		$(this).find('.list').stop(true, true).show();							   
	}, 
	function(){
		$(this).find('.list').stop(true, true).hide();	
		
	})
	$('#callback label').click(function(){
		$(this).hide().next().focus();
		
	});
	$('#callback input').click(function(){
		$(this).prev().hide();
		
	});
	$('.feedback label').click(function(){
		$(this).animate({left:'-'+($(this).width()+10)+'px'}, 'fast').next().focus();
		
	});
	$('.feedback input, .feedback textarea, .feedback select').click(function(){
		$(this).prev().animate({left:'-'+($(this).prev().width()+10)+'px'}, 'fast');
		
	});
	$('.toggle a').click(function(){
		$(this).next().stop(true, true).slideToggle();
		return false;
	});
	
	$('.footer .catalogue').hover(function(){
		$(this).find('ul').stop(true, true).slideToggle();
		$(this).find('.status').toggleClass('minus');
	});
	
	$('.search .submit').click(function(){
		$(this).parents('form').submit();
	});
	$('.search input').click(function(){
		
		$(this).addClass('type');
		if($(this).val()=='поиск')$(this).val('');
	});
});

