	$(function() {
	
	
		$('#content .tab_text_today').each(function(el) {		
		var map_block_div = $(this).find('.map_block').remove();
		map_block_div.appendTo('#maps').show();		
		});
		
		$('#content .map_block a, #content .map_block div').clone().appendTo('#y_111');
		
		$('#content_content').css({'position':'relative'});
		$('.map_block').css({'position':'absolute','width':'635px','height':'394px','top':'15px','left':'-5px','display':'block'});
		
		$('.map_block a').each(function(el) {	
			var pos=$(this).attr('rel').split(',');
			var X_pos=pos[0];
			var Y_pos=pos[1];
			
			$(this).css({'position':'absolute','left':X_pos-6+'px','top':Y_pos-6+'px'});	
					
			var ID_name=$(this).attr('id');
			
			//$('#'+ID_name+'_flag').css({'position':'absolute','left':X_pos-6+'px','top':Y_pos-35+'px'});
			$(this).parent('.map_block').find('#'+ID_name+'_flag').css({'position':'absolute','left':X_pos-6+'px','top':Y_pos-35+'px'});
			
			//$('#'+ID_name+'_flag').html($('#'+ID_name+'_flag').html().split(',')[0]);			
			$(this).parent('.map_block').find('#'+ID_name+'_flag').html($('#'+ID_name+'_flag').html().split(',')[0]);			
			
		});
	

		$('.map_block a').hover(function(){
			var ID_name=$(this).attr('id');
			//$('#'+ID_name+'_flag').css({'z-index':'101'}).show();
			$(this).parent('.map_block').find('#'+ID_name+'_flag').css({'z-index':'101'}).show();
			$(this).css({'z-index':'102'});
		},
		function(){
			var ID_name=$(this).attr('id');
			//$('#'+ID_name+'_flag').css({'z-index':'1'}).hide();
			$(this).parent('.map_block').find('#'+ID_name+'_flag').css({'z-index':'1'}).hide();
			$(this).css({'z-index':'100'});
		});
	
 
		$('#maps div.map_block').hide();
		//alert($('#sponsors #tabs div.tab_active a').attr('id'));
		$('#content div#y_'+$('#content #tabs div.tab_active a').attr('id')).show();
		
		
		// Сразу открывается последняя вкладка на карте
		var thisId=$('#container .tab_text_today:last a').attr('id');
		//alert(thisId);
		//$('not(#container) #content .tab_text_today:last').addClass('tab_active tab_big');
		$('.map_tabs .tab_text_today:last').addClass('tab_active tab_big');
		$('#content div.map_block').hide();
		$('#content div#y_'+thisId).show();
		
		
		$('#content #tabs a').click(function(){
			var $parent=$(this).parent(); 
			if($parent.hasClass('tab_text_future')){
				
				}
			else{
		
				
				var thisId=$(this).attr('id');
				
				
				$('#content #tabs div.tab_active').removeClass('tab_active');
				$('#content #tabs div.tab_big').removeClass('tab_big')
				.addClass('tab_normal');
				$parent.addClass('tab_active tab_big');
				$('#content div.map_block').hide();
				$('#content div#y_'+thisId).show();
				//alert();
			}
				return false;
		});
		
		
		//sponsors
				
		$('#sponsors .tab_text_today').each(function(el) {		
		var map_block_div = $(this).find('.sponsors_block');
		$(".sponsors_block:not(:has('.subpartners'))").addClass('subpartners');
		map_block_div.remove().appendTo('#sponsors_list');		
		});
		
		$('#sponsors_list div.sponsors_block').hide();
		
		//alert($('#sponsors #tabs div.tab_active a').attr('id'));
		
		$('#sponsors .tab_text_today:first').addClass('tab_active tab_big');
	
	
		
	
		$(window).load(function() {
		
		
			$.fn.equalHeights = function() { 
			 var currentTallest = 0; 
			 $(this).each(function(){			 
			  if ($(this).height() > currentTallest) {currentTallest = $(this).height(); } 
			 }); 
			 $(this).css({'min-height': currentTallest});  
			 return this; 
			}; 

			$('.sponsors_block').each(function() {
			display=$(this).css('display');	
			$(this).css({'position':'absolute','visibility':'hidden','display':'block'}); 			
			$(this).find(".sponsor").equalHeights();
			$(this).css({'position':'static','visibility':'visible','display':display});	 			
			});

			$('.valign').each(function() {
				display=$(this).parents('.sponsors_block').css('display');	
				$(this).parents('.sponsors_block').css({'position':'absolute','visibility':'hidden','display':'block'});
				this.style.marginTop = $(this).parent().height()/2-$(this).height()/2 + 'px';
				$(this).parents('.sponsors_block').css({'position':'static','visibility':'visible','display':display});				
			});
			
		});

		var thisId=$('#sponsors .tab_text_today:first a').attr('id');	

		//var thisId=$('#sponsors .tab_text_today').eq(0).find('a').attr('id');	
		$('#sponsors_list div#y_'+thisId).show();
		
		$('#sponsors #tabs a').click(function(){
			var thisId=$(this).attr('id');
			var $parent=$(this).parent(); 
			
			$('#sponsors #tabs div').removeClass('tab_active tab_big')
			.addClass('tab_normal');
			$parent.addClass('tab_active tab_big');
			$('#sponsors_list div.sponsors_block').hide();
			$('#sponsors_list div#y_'+thisId).show();
			//alert();
			return false;
		});

	
	});
