var SpaceInfo;
var SpaceInfoContainer;
var Local = false;

$(document).ready(function(e)
{
	$(window).resize(resize);
	resize();
	
	$(document).scroll(function (e)
	{
		e.preventDefault();
		$(document).scrollTo(0,0);
		return false;
	});
	
	
	//test2("VisitorId: "+VisitorId);
	
	
	// Пробел - Передвижение
		if (noSpaceInfo != 1)
		{
			SpaceInfoContainer = $("<div id=\"space_info_container\"></div>");
			SpaceInfo = $("<div id=\"space_info\"></div>").append("<div class=\"space_info_img\"></div>");
			$(SpaceInfoContainer).append(SpaceInfo);
			
			// Del
				var SpaceInfoDel = $("<div class=\"del_lit\" title=\"Убрать это сообщение\"></div>").click(function ()
				{
					AddLoadAction({
						name: "DelSpaceInfo",
						value: 1
					});
					
					$(SpaceInfo).remove();
				});
				$(SpaceInfo).append(SpaceInfoDel);
			
			$("body").append(SpaceInfoContainer);
		}
	
	
	// Document Over
		$(document).hover(function ()
		{
			DocumentOver = true;
		},
		function ()
		{
			DocumentOver = false;
			ActiveDot = null;
		});
	
	
	// IE
		if ($.browser.msie)
		{
			$("#page").addClass("ie");
		}
	
	(function($){var a=$.ui.mouse.prototype._mouseMove;$.ui.mouse.prototype._mouseMove=function(b){if($.browser.msie&&document.documentMode>=9){b.button=1};a.apply(this,[b]);}}(jQuery));
});


// Temp Img
	temp_img("img/lupa_minus_over.png");
	temp_img("img/lupa_plus_over.png");
	temp_img("img/paint_but_over.png");
	temp_img("img/slider_cursor_over.png");
	temp_img("img/blok_shad_tl.png");
	temp_img("img/blok_shad_tl2.png");
	temp_img("img/blok_shad_t.png");
	temp_img("img/blok_shad_tr2.png");
	temp_img("img/blok_shad_tr.png");
	temp_img("img/blok_shad_lt2.png");
	temp_img("img/blok_shad_rt2.png");
	temp_img("img/blok_shad_l.png");
	temp_img("img/blok_shad_r.png");
	temp_img("img/blok_shad_lb2.png");
	temp_img("img/blok_shad_rb2.png");
	temp_img("img/blok_shad_b_l.png");
	temp_img("img/blok_shad_bl2.png");
	temp_img("img/blok_shad_b.png");
	temp_img("img/blok_shad_br2.png");
	temp_img("img/blok_shad_br.png");
	temp_img("img/text_menu_over.png");
	temp_img("img/DotLoading.png");
	temp_img("img/other_over.png");
	temp_img("img/shad2_t_l.png");
	temp_img("img/shad2_t.png");
	temp_img("img/shad2_t_r.png");
	temp_img("img/shad2_l.png");
	temp_img("img/shad2_c.png");
	temp_img("img/shad2_r.png");
	temp_img("img/shad2_b_l.png");
	temp_img("img/shad2_b.png");
	temp_img("img/shad2_b_r.png");
	temp_img("img/register_ok.png");
	temp_img("img/register_no.png");
	temp_img("img/params.png");
	temp_img("img/params_over.png");
	temp_img("img/dot_del.png");
	temp_img("img/dot_del_over.png");
	temp_img("img/dot_return.png");
	temp_img("img/dot_return_over.png");
	temp_img("img/white_text_a_bg.png");
	temp_img("img/white_text_a_bg_over.png");
	temp_img("img/but_del_over.png");
	temp_img("img/dot_blok.png");
	temp_img("img/dot_blok_over.png");
	temp_img("img/dot_blok_ok.png");
	temp_img("img/dot_fav.png");
	temp_img("img/dot_fav_over.png");
	temp_img("img/dot_fav_ok.png");
	temp_img("img/grey_dots.png");
	temp_img("img/direction_bg.png");
	temp_img("img/mac_minimize.png");
	temp_img("img/mac_minimize_over.png");
	temp_img("img/but_bevel.png");
	temp_img("img/but_bevel_over.png");
	/*temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");
	temp_img("img/");*/
	
	temp_img("img/pop_t.png");
	temp_img("img/pop_t_l.png");
	temp_img("img/pop_move.png");
	temp_img("img/pop_l.png");
	temp_img("img/pop_close.png");
	temp_img("img/pop_close_over.png");
	temp_img("img/pop_t_r.png");
	temp_img("img/pop_r.png");
	temp_img("img/pop_b.png");
	temp_img("img/pop_b_r.png");
	temp_img("img/pop_b_l.png");
	temp_img("img/pop_t_text_bg.png");
	temp_img("img/pop_mac_close.png");
	temp_img("img/pop_mac_close_over.png");


// Resize
	function resize()
	{
		X0 = $(window).width()/2;
		Y0 = $(window).height()/2;
		
		$(".dot").DotPos();
		
		update_avatars_canvas();
	}


// Blok Shad
	function blok_shad(text)
	{
		var table = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>";
		
			// 1
				table += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>";
					table += "<td class=\"blok_shad_tl\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
					table += "<td class=\"blok_shad_tl2\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
					table += "<td class=\"blok_shad_t\"></td>";
					table += "<td class=\"blok_shad_tr2\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
					table += "<td class=\"blok_shad_tr\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
				table += "</tr></table>";
			
			// 2
				table += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
					table += "<tr>";
						table += "<td class=\"blok_shad_lt2\"></td>";
						table += "<td class=\"blok_shad_c\" rowspan=\"2\">"+text+"</td>";
						table += "<td class=\"blok_shad_rt2\"></td>";
					table += "</tr>";
					table += "<tr>";
						table += "<td class=\"blok_shad_l\"><img src=\"img/blok_shad_l.png\" height=\"100%\" width=\"5\" class=\"blok_shad_l_img\" /><div class=\"blok_shad_lb2\"></div></td>";
						table += "<td class=\"blok_shad_r\"><img src=\"img/blok_shad_r.png\" height=\"100%\" width=\"5\" class=\"blok_shad_r_img\" /><div class=\"blok_shad_rb2\"></div></td>";
					table += "</tr>";
					/*table += "<tr>";
						table += "<td class=\"blok_shad_lb2\" height=\"5\"></td>";
						table += "<td class=\"blok_shad_rb2\" height=\"5\"></td>";
					table += "</tr>";*/
				table += "</table>";

			// 3
				table += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>";
					table += "<td class=\"blok_shad_bl\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
					table += "<td class=\"blok_shad_bl2\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
					table += "<td class=\"blok_shad_b\"></td>";
					table += "<td class=\"blok_shad_br2\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
					table += "<td class=\"blok_shad_br\"><img src=\"box/spacer.gif\" width=\"5\" /></td>";
				table += "</tr></table>";
		table += "</td></tr></table>";
		
		return table;
	}


// Blok Shad2
	function blok_shad2(text)
	{
		var table = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			table += "<tr>";
				table += "<td class=\"shad2_t_l\"><img src=\"box/spacer.gif\" width=\"10\" /></td>";
				table += "<td class=\"shad2_t\"></td>";
				table += "<td class=\"shad2_t_r\"><img src=\"box/spacer.gif\" width=\"10\" /></td>";
			table += "</tr>";
			table += "<tr>";
				table += "<td class=\"shad2_l\"></td>";
				table += "<td class=\"shad2_c\">"+text+"</td>";
				table += "<td class=\"shad2_r\"></td>";
			table += "</tr>";
			table += "<tr>";
				table += "<td class=\"shad2_b_l\"></td>";
				table += "<td class=\"shad2_b\"></td>";
				table += "<td class=\"shad2_b_r\"></td>";
			table += "</tr>";
		table += "</table>";
		
		return "<div class=\"shad2\">"+table+"</div>";
	}


// Blok Shad Size
	jQuery.fn.blok_shad_size = function ()
	{
		$(this).each(function ()
		{
			var _h = $(this).find(".blok_shad_c").height() - 10;
			$(this).find(".blok_shad_l_img").height(_h);
			$(this).find(".blok_shad_r_img").height(_h);
		});
		
		return this;
	};



// Test
	function test(str)
	{
		if (true)
		{
			if (typeof str == 'object')
			{
				str = str_replace(',', ',<BR>', $.toJSON(str));
			}
			
			$("#test").html(str+"<BR>"+Math.random());
		}
	}
// Test2
	function test2(str)
	{
		if (true)
		{
			if (typeof str == 'object')
			{
				str = str_replace(',', ',<BR>', $.toJSON(str));
			}
			
			$("#test2").html(str+"<BR>"+Math.random());
		}
	}

// Metrika
	function metrika(text, _http)
	{
		if (_http==null)
		{
			_http=window.location;
		}
		try
		{
			yaCounter2971318.hit(_http, text);
		}
		catch (e)
		{
			
		}
	}












