jQuery(function(){

/*
South Africa, CSS & jQuery Clickable map | http://winstonwolf.pl/css,south-africa.html
script version: 2.4 by Winston Wolf | http://winstonwolf.pl
*/
  jQuery('#map').prepend('<span id="loader">Loading ...</span>').addClass('script'); jQuery('#map').find('li').hide();

  var mapUrl=jQuery('#za').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/za-240px.png'; 

*/
  var mapImg=new Image();
  jQuery(mapImg).load(function(){jQuery('#loader').fadeOut(); jQuery('#map').find('li').fadeIn(); jQuery('#za').find('a').prepend('<span class="map" />');
   for(var i=1;i<34;i++){ jQuery('#za .map').append('<span class="s'+i+'" />'); }
   if(jQuery('#map').hasClass('tooltip')){jQuery('#za').children('li').each(function(){ var tooltipName=jQuery(this).children('a').text(); var tooltipLeft=jQuery('.tt').outerWidth()/-2; var tooltipTop=jQuery('.tt').outerHeight()/-2; jQuery(this).append('<span class="tt">'+tooltipName+'</span>'); jQuery('.tt').css({'display':'none','margin-left':tooltipLeft,'margin-top':tooltipTop});});jQuery('#za li').hover(function(){jQuery(this).children(".tt:visible").hide(); jQuery(this).children(".tt").show(); jQuery(this).children("a").removeAttr('title');},function(){jQuery(this).children(".tt").hide();});}
   }).error(function(){jQuery('#loader').text('No map!'); jQuery('#za').find('span').hide(); jQuery('#map,#za').css({'height':'auto','left':'0','margin':'0 auto'});
    }).attr('src',mapUrl);
  var loaderPos=jQuery('#loader').outerWidth()/-2; jQuery('#loader').css('margin-left',loaderPos);
  jQuery('#za').children('li').click(function(){window.location.href=jQuery(this).children('a').attr('href');});
// end of the map


	var location = querySt('l');
	
	if (location) { 
	
  jQuery('#za').find('a').each(function(){
    if(jQuery(this).hasClass(location)) {
      jQuery(this).addClass('active');
	}
   });
   
   }

/* OPTIONAL: 

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

  jQuery('#za').find('li').click(function(){
    jQuery('.active').removeClass();
    jQuery(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)

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

      // plus an event for the active country

     }
   });

*/
});


function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}
