var cash_gorod, cash_gorod_zag;
var gorod_id=0;
$(document).ready(function ()
{
	resize_objects=$(".width");
	resize();
	$(window).resize(resize);
	
	$(".menu_td").hoverClass("menu_td_over").click(function ()
	{
		window.location=$(this).attr("_http");
	});
	
	// Week Skobka
		week_skobka();
	// Week Skobka End
	
	// Cash Gorod
		cash_gorod=$(".cash_gorod");
		cash_gorod_zag=$(".cash_gorod_zag");
		$(".cash_gorod_zag").click(function ()
		{
			$(cash_gorod).hide();
			var _vis=".cash_corod_"+$(this).attr("_n");
			$(_vis).removeClass("hid").show();
			
			$(".cash_gorod_zag").removeClass("cash_gorod_selected");
			$(".cash_gorod_zag_"+$(this).attr("_n")).addClass("cash_gorod_selected");
		});
		$('.cash_gorod_zag_'+gorod_id).click();
	// Cash Gorod End
	
	$(".services").css('opacity', 0.7).hover(function ()
	{
		$(this).css('opacity', 1);
	}, 
	function ()
	{
		$(this).css('opacity', 0.7);
	}).click(function ()
	{
		popup($(this).attr("_http"));
	});
	
	$(".calendar").calendar();
	
	
	// Выбор города
		$('.gorod_select_index_a_div').find('.a').click(function ()
		{
			var but_gorod_id = Number($(this).attr('_gorod_id'));
			
			if (but_gorod_id == gorod_id)
			{
				$("#select_gorod_index").remove();
			}
			else
			{
				$(this).parent().load();
				$.getJSON('gorod_select_ajax.php?gorod_id='+but_gorod_id, function ()
				{
					window.location = window.location;
				});
				
			}
		});
});

// Week Skobka
	function week_skobka()
	{
		$(".week_skobka_td").each(function ()
		{
			$(this).find(".week_skobka_bg").height('auto');
			var _h=Math.round(($(this).height()-14)/2);
			$(this).find(".week_skobka_bg").height(_h);
		});
	}
// Week Skobka End

// Resize
	var resize_objects;
	function resize()
	{
		var _w=$('body').width();
		_w=Math.round(_w*0.8);
		if (_w<889) { _w=889; }
		if (_w>1100) { _w=1100; }
		
		$(resize_objects).width(_w);
	}
// Resize End

// Resize Menu
	function resize_menu()
	{
	}
// Resize Menu End

// Calendar
	jQuery.fn.calendar=function ()
	{
		$(this).each(function ()
		{
			var _div=$(this).parent();
			var _gorod_id=$(this).attr("_gorod_id");
			
			$(this).find(".calendar_td").calendar_td();
			
			// Другие месяца
				$(this).find(".calendar_m_a").click(function ()
				{
					var _y=$(this).attr("_y");
					var _m=$(this).attr("_m");
					$(_div).load();
					
					$.getJSON("calendar_ajax.php?y="+_y+"&m="+_m+"&gorod_id="+_gorod_id, function (ob)
					{
						$(_div).html(ob.html).find('.calendar').calendar();
					});
				});
			// Другие месяца End
			
		});
		
		return this;
	};

// Calendar End

// Calendar Td
	jQuery.fn.calendar_td=function ()
	{
		$(this).each(function ()
		{
			var _this=this;
			
			// Есть
				if ($(this).is('.calendar_mesto_1'))
				{
					$(this).hoverClass("calendar_mesto_1_over").hover(function ()
					{
						$(this).find(".calendar_hidden").removeClass("hid").show();
					},
					function ()
					{
						$(this).find(".calendar_hidden").hide();
					});
				}
			// Есть End
		});
		
		return this;
	};
// Calendar Td End

