function alignblocks() {
   b1 = document.getElementById('page-left');
   b2 = document.getElementById('page-right');
   if (!b1 || !b2) return;
   h1 = b1.offsetHeight;
   h2 = b2.offsetHeight;
   if (h1 > h2) {
      b1.style.minHeight = (h1 - 50) + 'px';
      b2.style.minHeight = (h1 - 50) + 'px';
   } else if (h1 < h2) {
      b1.style.minHeight = (h2 - 50) + 'px';
      b2.style.minHeight = (h2 - 50) + 'px';
   }
}

var timer

var mapTU = new Array()
mapTU[1] = new Array('Центральном', '39', '/directories/tc/8/')
mapTU[2] = new Array('Западном', '60', '/directories/tc/7/')
mapTU[3] = new Array('Поволжском', '39', '/directories/tc/11/')
mapTU[4] = new Array('Северо-Западном', '42', '/directories/tc/2/')
mapTU[5] = new Array('Северном', '50', '/directories/tc/1/')
mapTU[6] = new Array('Северо-Восточном', '43', '/directories/tc/3/')
mapTU[7] = new Array('Юго-Восточном', '23', '/directories/tc/6/')
mapTU[8] = new Array('Отрадненское', '34', '/directories/tc/10/')
mapTU[9] = new Array('Кинельском', '28', '/directories/tc/9/')
mapTU[10] = new Array('Южном', '26', '/directories/tc/4/')
mapTU[11] = new Array('Юго-Западном', '77', '/directories/tc/5/')
mapTU[12] = new Array('Самарском', '178', '/directories/tc/12/')
mapTU[13] = new Array('Тольяттинском', '94', '/directories/tc/13/')

$(function(){
	$('#gia-link').click(function(){
		$('.ege-element').add(this).fadeOut(100)
		setTimeout(function(){$('.gia-element').add('#ege-link').fadeIn(100)}, 200)
		return false;
	})
	
	$('#ege-link').click(function(){
		$('.gia-element').add(this).fadeOut(100)
		setTimeout(function(){$('.ege-element').add('#gia-link').fadeIn(100)}, 200)
		return false;
	})
	
	$('#accordion .noactive').next('.accordion-body').hide();
	$('.accordion-head').click(function(){
		if ($(this).hasClass('active')) {
			$(this).removeClass('active').addClass('noactive').next('.accordion-body').slideUp();
		} else {
			$('#accordion .active').removeClass('active').addClass('noactive').next('.accordion-body').slideUp(200);
			$(this).removeClass('noactive').addClass('active').next('.accordion-body').slideDown(200);
			setTimeout(function(){alignblocks()}, 300);
		}
	})
									
	$(window).load(function(){alignblocks()})
	
	$('#mapimg').maphilight({
		fade: false,
		strokeColor: 'ffffff',
		fillColor: '000000',
		fillOpacity: 0.2
	});
	
	$('map area').click(function(){
		num = $(this).attr('rel')
		$('#mapimg').attr('src', '/i/map/map'+ num  +'.png').maphilight({
			fade: false,
			strokeColor: 'ffffff',
			fillColor: '000000',
			fillOpacity: 0.2
		})
		$('#OU-num').html(mapTU[num][1]);
		$('#OU-title').html('<a href="'+ mapTU[num][2] +'">в '+ mapTU[num][0] +'<br />территориальном<br />управлении</a>');
		return false;
	})
	
	$(".light a img").hover(
		function(){$(this).stop().animate({opacity:'.6'}, 300)},
		function(){$(this).stop().animate({opacity:'1.0'})})
	
});
