$( document ).ready(function() { //$(function(){ var r = Raphael('map_spb', '100%', '100%'), attributes = { fill: '#bcbec0', fill_checked: '#3c9805', stroke: '#fff', 'stroke-width': 1.2, 'stroke-linejoin': 'round', viewBox: '0 0 300 300' }, arr = new Array(); for (var country in paths) { var obj = r.path(paths[country].path); obj.attr(attributes); arr[obj.id] = country; obj.hover(function(){ this.animate({fill: '#1669AD'}, 300); //document.location.hash = arr[this.id]; var point = this.getBBox(0); $('#map_spb').next('.point').remove(); $('#map_spb').after($('
').addClass('point')); $('.point') .html(paths[arr[this.id]].name) .css({ left: point.x+(point.width/2)-60, top: point.y+(point.height/2)-40 }) .fadeIn(); }, function(){ this.animate({ fill: attributes.fill // fill: '#ff0000' }, 300); }) .click(function(){ // var url=paths[arr[this.id]].url; // window.open(paths[arr[this.id]].url, "", ""); }); $('.point').find('.close').on('click', function(){ var t = $(this), parent = t.parent('.point'); parent.fadeOut(function(){ parent.remove(); }); return false; }); if ( window.location.pathname==paths[country].url) { obj.attr ( 'fill', attributes.fill_checked ); } } });