function set_woj(id)
{
$('#pl').find('a').each(function(){
    $(this).removeClass('active');
    if($(this).attr('id')==id){
      $(this).addClass('active');

      // plus zdarzenie dla aktywnego województwa

     }
   });
}

$(function(){

  $('#mapa').prepend('<span id="loader"><img src="images/ajax-loader.gif" /></span>').addClass('script'); $('#mapa').find('li').hide();
  var mapUrl=$('#pl').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
  var mapImg=new Image();
  $(mapImg).load(function(){$('#loader').fadeOut(); $('#mapa').find('li').fadeIn(); $('#pl').find('a').prepend('<span class="map" />');
   for(var i=1;i<11;i++){ $('#pl .map').append('<span class="s'+i+'" />'); }


    $('#pl').find('li').each(function(){ var tooltipName=$(this).children('a').text(); var tooltipLeft=$('.tt').outerWidth()/-2; 


    var tooltipTop=$('.tt').outerHeight()/-2; 
    $(this).append('<span class="tt">'+tooltipName+'</span>');
    $('.tt').css({'display':'none','margin-left':tooltipLeft,'margin-top':tooltipTop});});
    $('#pl li').hover(function(){$(this).children(".tt:visible").hide(); $(this).children(".tt").show(); 
    $(this).children("a").removeAttr('title');},function(){$(this).children(".tt").hide();});


   }).error(function(){$('#loader').text('Brak mapy!'); $('#pl span').hide(); $('#mapa,#pl').css({'height':'auto','left':'0','margin':'0 auto'});
    }).attr('src',mapUrl);
  var loaderPos=$('#loader').outerWidth()/-2; $('#loader').css('margin-left',loaderPos);
 $('#pl').find('li').click(function(){window.location.href=$(this).children('a').attr('href');});
// koniec mapy
});


