$(document).ready(
	function ()
		{
		
		$('.cc_show').click(
			function ()
			{
				id = '#' + this.id.replace('spn', 'tbl');
				
				if ('none' == $(id).css('display'))
				{
					$(id).show();
					$(this).text('[-]');
				}
				else
				{
					$(id).hide();
					$(this).text('[+]');
				}
			}	
		);
		
		
		$('.select_city_button').click(
			function ()
				{
				cities_opened=false;
				$('.select_city').slideDown(400, function () {cities_opened=true});
				}
		);

		var pos = $('.select_city_button span').offset();
		$('.select_city').css('left',pos.left-6).css('top',pos.top-7).mouseout(
			function()
				{
				$(document.body).click(function(){$('.select_city').hide()})
				}
			);

		$('.list_city td').mouseover(
			function()
				{
				$('.list_city td').removeClass('selected_city');
				$(this).addClass('selected_city');
				}
			);

		/* Создание уникальных OL списков по дизайну */
		$('.content > ol > li').each(
			function (i, el)
				{
				$(el).html('<span style="color: black; font-weight: normal;">'+$(el).html()+'</span>');
				}
			);

		/* Таблицы под дизайн */
		
		//$('.content > table > tbody > tr').each(
		$('.content > table > tbody > tr').each(
			function (i,element)
				{
				//alert($(element).parent().html());
				//return;
				// стили таблицы
				if ($(element).parent().parent().hasClass('clear')) return;
				if ($(element).parent().hasClass('clear')) return;
				if ($(element).hasClass('clear')) return;
				if ($(element).parent().parent().hasClass('dec_table')) return;
				if ($(element).parent().hasClass('noclear')) return;
				
//				$(element).parent().parent().css('border-bottom','1px solid #e5e5e5');
				$(element).parent().parent().css('background','#e5e5e5');

				/* Стили шапки таблицы */
				var len = $(element).find('th').length;				
				$(element).find('th').each(
					function (i, el)	
						{
						if (i==0) $(el).addClass('table_header_first');
						if (i==len-1) $(el).addClass('table_header_last');
						if (i>0 && i<len-1) $(el).addClass('table_header_middle');
						}
					);

				/* Стили первых и последних ячеек в каждой строке тела бальицы */
				var len = $(element).find('td').length;	 
				$(element).find('td').each(
					function(i,el)
						{
						/* Стиль для всех ячеек */
						$(el).addClass('content_table_td');
						$(el).css('padding','5px');
						
						/* Стили определенных ячеек*/
						/*
						if (i==0) $(el).css('padding-left','20px');
						if (i==len-1) $(el).css('padding-right','20px');
						*/
						}
					);
				}
			);	
		
		/* генерация меню */	
		$("table.menu_main td.top_menu_item").mouseover(
			function()
				{
				//$("table.menu_main td.top_menu_item").removeClass('selected_menu');
				
				$("table.menu_main td.top_menu_item").each(function(i){
					if (!$(this).hasClass("pin"))
						$(this).removeClass('selected_menu');
				});
				
				$(this).addClass('selected_menu');
				}
		).click(
			function()
				{
				location.href=$(this).find('a').attr('href');
				}
		).mouseout(
			function()
				{
				$("table.menu_main td.top_menu_item").each(function(i){
					if (!$(this).hasClass("pin"))
						$(this).removeClass('selected_menu');
				});
				}
		);	
			
	}	
)