﻿function openGoodWindow(id,page){
	object_view(id);
}

function object_view(id){
	$.get('?id='+id,function(data){
		object_close();
		$('body').append('<div class="maska" style="height:'+$(document).height()+'px"></div><div style="top:50px" class="object-view"><div class="content">'+data+'</div></div>');
	})
}

function object_img(src){
	$('#object_img')[0].src=src;
}

function object_close(){
	$('.maska,.object-view').remove();
}

$(document).ready(function(){
	if($('.menu-full').length>0){
		$('.HeightMenu').css('padding-bottom','30px');
		$('.object-page .title').css({'overflow':'hidden','height':$('#menu_height').height()+35});
		$('.menu1').click(function(){
			if($('.submenu:animated,.menu3:animated').length==0){
				var next=$(this).parents('.menu-full').next('.submenu:hidden');
				if(next.length==1){
					$('.submenu:not(:hidden),.menu3:not(:hidden)').slideUp();
					next.slideDown();
					next.children(':first').nextUntil('.menu2').slideDown(function(){
						$('.object-page .title').css('height',$('#menu_height').height()+35);
					});
				}
			}
			return false;
		});
		$('.menu2').click(function(){
			if($('.submenu:animated,.menu3:animated').length==0){
				var next=$(this).nextUntil('.menu2').not(this).filter(':hidden');
				if(next.length>0){
					$(this).parent().children('.menu3:not(:hidden)').slideUp();
					next.slideDown(function(){
						$('.object-page .title').css('height',$('#menu_height').height()+35);
					});
				}
			}
			return false;
		});
	}

	if($('.empty_category,.empty_category_right').length>0){
		$('.empty_category,.empty_category_right').unbind('click').click(function(e){
			var cat=$(this);
			if(!cat.data('popup')){
				cat.data('popup',true);
				var el=$(document.createElement('div'));
				if(cat.hasClass('empty_category_right')) el.css({right:$(document).width()-e.pageX+10});
				else el.css({left:e.pageX+10});
				el.html('В этой категории<br />объектов нет').css({
					'z-index':10000,
					cursor:'default',
					textAlign:'center',
					position:'absolute',
					top:e.pageY-10,
					background:'#fff',
					color:'#771108',
					border:'1px solid #771108',
					padding:'4px 6px',
					'border-radius':'5px',
					'-moz-border-radius':'5px',
					'-webkit-border-radius':'5px',
					'box-shadow':'0 0 5px #771108',
					'-moz-box-shadow':'0 0 5px #771108',
					'-webkit-box-shadow':'0 0 5px #771108'
				}).hide();
				$(document.body).append(el);
				el.fadeIn(function(){
					setTimeout(function(){
						el.fadeOut(function(){
							el.remove();
							cat.data('popup',false);
						});
					},3000);
				});
			}
			return false;
		});
	}

if($('.empty_link,.empty_link_right').length>0){
		$('.empty_link,.empty_link_right').unbind('click').click(function(e){
			var cat=$(this);
			if(!cat.data('popup')){
				cat.data('popup',true);
				var el=$(document.createElement('div'));
				if(cat.hasClass('empty_link_right')) el.css({right:$(document).width()-e.pageX+10});
				else el.css({left:e.pageX+10});
				el.html('В настоящий момент этот<br />раздел недоступен').css({
					'z-index':10000,
					cursor:'default',
					textAlign:'center',
					position:'absolute',
					top:e.pageY-10,
					background:'#fff',
					color:'#771108',
					border:'1px solid #771108',
					padding:'4px 6px',
					'border-radius':'5px',
					'-moz-border-radius':'5px',
					'-webkit-border-radius':'5px',
					'box-shadow':'0 0 5px #771108',
					'-moz-box-shadow':'0 0 5px #771108',
					'-webkit-box-shadow':'0 0 5px #771108'
				}).hide();
				$(document.body).append(el);
				el.fadeIn(function(){
					setTimeout(function(){
						el.fadeOut(function(){
							el.remove();
							cat.data('popup',false);
						});
					},3000);
				});
			}
			return false;
		});
	}

	if($('.maska').length==1){
		$('.maska').css('height',$(document).height());
	}
});

