$(function(){

/*
Polska, klikalna mapa województw | http://winstonwolf.pl/css,polska.html
script version: 2.1 by Winston Wolf | http://winstonwolf.pl
Copyright (C) 2010 Winston_Wolf
Creative Commons - GNU General Public License | http://creativecommons.org/licenses/GPL/2.0/

Edited by Keenic keenic@gmail.com
*/
  $('#mapa').prepend('<span id="loader">Loading ...</span>').addClass('script'); $('#mapa').find('li').hide();
  var mapUrl=$('#pl').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
/* pobiera ścieżkę do pliku z mapką; w razie problemów z ładowaniem obrazka zastąp bezpośrednią ścieżką do obrazka:
  
*/
  var mapUrl='http://agmar.eu/images/pl-350px.png'; 
  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<17;i++){ $('#pl .map').append('<span class="s'+i+'" />'); }
   if($('#mapa').hasClass('tooltip')){$('#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);
// koniec mapy



/* OPCJONALNIE: 

// Aktywacja województwa bez przechodzenia do strony w odnośniku:

  $('#pl').find('li').click(function(){
    $('.active').removeClass();
    $(this).find('a').addClass('active');

    // plus zdarzenie dla aktywnego województwa

     return false;
   });


// Aktywacja województwa przez adres strony (np: twoja-strona.pl/#mazowieckie aktywuje województwo mazowieckie)

  $('#pl').find('a').each(function(){
    if($(this).attr('href')===window.location.hash){
      $(this).addClass('active');

      // plus zdarzenie dla aktywnego województwa

     }
   });

*/

});

$(function() { 
$('a').each(function() { 
	var $this = $(this); 
	if ($.support.hrefNormalized) { // IE
		$this.data('woj',
		$this.attr('href').substring($this.attr('href').indexOf('#')+1));
	} else { 
		$this.data('woj',
		$this.attr('href').substring(1)); 
	} 
 }).click(function() {
	$('div.woj').slideUp('fast')
	$('div#' + $(this).data('woj')).toggle();
	return false; 
 }); 
 });
