function page_pop(url, fn)
{
	var _div=$("<div class=\"foto_drag_div\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"page_pop_table\">      <tr>        <td class=\"foto_t_l\"><img src=\"box/spacer.gif\" width=\"3\" height=\"1\" /></td>        <td class=\"foto_t\"><div class=\"foto_drag_zag\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td class=\"foto_drag_zag_td pop_h1\" nowrap=\"nowrap\">&nbsp;</td><td class=\"foto_drag_zag_td\" nowrap=\"nowrap\" align=\"right\"><img src=\"img/foto_close.jpg\" border=0 width=16 height=16 class=\"foto_close\" align=\"absmiddle\" /></td></table></div></td>        <td class=\"foto_t_r\"><img src=\"box/spacer.gif\" width=\"4\" height=\"1\" /></td>      </tr>      <tr>        <td class=\"foto_l\"><img src=\"box/spacer.gif\" width=\"1\" height=\"1\" /></td>        <td class=\" \"><div class=\"page_pop_center page_div\"></div></td>        <td class=\"foto_r\"><img src=\"box/spacer.gif\" width=\"1\" height=\"1\" /></td>      </tr>      <tr>        <td><img src=\"box/spacer.gif\" width=\"1\" height=\"1\" /></td>        <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">  <tr>    <td class=\"foto_b_l\"><img src=\"box/spacer.gif\" width=\"1\" height=\"1\" /></td>    <td class=\"foto_b\"><img src=\"box/spacer.gif\" width=\"1\" height=\"1\" /></td>  </tr></table></td>        <td class=\"foto_b_r\"><img src=\"box/spacer.gif\" width=\"1\" height=\"1\" /></td>      </tr>    </table></div>");
	$(_div).page_pop_get(url, fn);
	$("body").prepend(_div);
	page_i++;
	if (page_i>10) { page_i=1; }
	$(_div).css('top', getBodyScrollTop()+30+30*page_i);
	$(_div).css('left', 30*page_i+220);
	page_z_index++;
	$(_div).css('z-index', page_z_index);
	$(_div).bind('mousedown', function()
		{
			page_z_index++;
			$(_div).css('z-index', page_z_index);
		}
	);
	$(_div).find("img.foto_close").click(function()
		{
			$(_div).remove();
		}
	);
	$(_div).find("img.foto_close").hover(
		function()
		{
			$(this).attr('src', 'img/foto_close1.jpg');
		},
		function()
		{
			$(this).attr('src', 'img/foto_close.jpg');
		}
	);
	var _w=body_w()-200; if (_w>900) { _w=900; }
	var _h=body_h()-200;
	$(_div).draggable().css("max-width", _w).css("max-height", _h);
	
}

jQuery.fn.page_pop_get=function (url, fn)
{
	$(this).each(function ()
	{
		var _div=$(this);
		$(_div).find(".page_div").load_big();
		$.getJSON(url, function (ob)
		{
			ob_to_pop(ob, _div, fn);
		});
	});
	return this;
};

function ob_to_pop(ob, _div, fn)
{
	if (ob.html!=undefined)
	{
		var _center=$(_div).find(".page_pop_center");
		$(_center).html(ob.html).find("a").click(function ()
		{
			if ($(this).attr("_del")==1)
			{
				if (!confirm("Удалить?"))
				{
					return false;
				}
			}
			var _href=$(this).attr("href");
			if (_href.search(/javascript/)!=-1) { return true; }
			if (_href.search(/mailto/)!=-1) { return true; }
			if ($(this).attr("_no_ajax")==1) { return true; }
			$(_div).page_pop_get($(this).attr("href"), fn);
			return false;
		});
		var _h1=$(_div).find("h1");
		if ($(_h1).length)
		{
			ob.h1=$(_h1).html();
			$(_h1).remove();
		}
		if (ob.width!=undefined)
		{
			$(_center).width(ob.width);
		}
	}
	if (ob.h1!=undefined)
	{
		$(_div).find(".pop_h1").html(ob.h1);
	}
	$(_div).find("form.forma").forma_site();
	if (fn!=undefined)
	{
		fn(ob);
	}
	if (ob.sc!=undefined)
	{
		eval(ob.sc);
	}
}