$(function(){

/*
Europe, CSS & jQuery Clickable map - 560px | http://winstonwolf.pl/css,europe.html
script version: 2.1 by Winston Wolf | http://winstonwolf.pl
(C) 2010 Winston_Wolf
Creative Commons - GNU General Public License | http://creativecommons.org/licenses/GPL/2.0/
*/
  $('#map').prepend('<span id="loader">Loading ...</span>').addClass('script'); $('#map').find('li').hide();
  var mapUrl=$('#eu').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
/* takes a path to a file with a map, in case of problems with loading the image, replace the direct path to the image:
  var mapUrl='http://example.com/images/eu-560px.png'; 
*/
  var mapImg=new Image();
  $(mapImg).load(function(){$('#loader').fadeOut(); $('#map').find('li').fadeIn(); $('#eu').find('a').prepend('<span class="map" />');
   for(var i=1;i<20;i++){ $('#eu .map').append('<span class="s'+i+'" />'); }
   if($('#map').hasClass('tooltip')){$('#eu').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});});$('#eu 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('No map!'); $('#eu span').hide(); $('#map,#eu').css({'height':'auto','left':'0','margin':'0 auto'});
    }).attr('src',mapUrl);
  var loaderPos=$('#loader').outerWidth()/-2; $('#loader').css('margin-left',loaderPos);
// end of the map



/* OPTIONAL: 

// Activation of the country without going to a page in the link:

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

    // plus an event for the active country

     return false;
   });


// Activation of the country by URL (np: example.com/#germany activates Germany on the map)

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

      // plus an event for the active country

     }
   });

*/
});
