$(function() { //mala mapa $('.smallmap area').mousemove(function() { var offset = ($(this).attr('class')).replace('smallarea', ''); $(this).closest('.imgwrap').css('background-position', '0 -' + (offset*103) + 'px'); } ).mouseout(function() { $(this).closest('.imgwrap').css('background-position', '0 0'); }); //velka mapa $('.bigmap area').mousemove(function() { var offset = ($(this).attr('class')).replace('bigarea', ''); $(this).closest('.imgwrap').css('background-position', '0 -' + (offset*295) + 'px'); $(this).closest('.bigmap').find('.areas span.bigarea'+offset+' a').addClass('hover'); } ).mouseout(function() { var offset = ($(this).attr('class')).replace('bigarea', ''); $(this).closest('.imgwrap').css('background-position', '0 0'); $(this).closest('.bigmap').find('.areas span.bigarea'+offset+' a').removeClass('hover'); }); $('.areas span').hover( function() { var offset = ($(this).attr('class')).replace('bigarea', ''); $(this).closest('.bigmap').find('.imgwrap').css('background-position', '0 -' + (offset*295) + 'px'); }, function() { $(this).closest('.bigmap').find('.imgwrap').css('background-position', '0 0'); } ); $('.bigmap area, .bigmap .areas a').click(function(e) { e.preventDefault(); var area = $(this).attr('href'); area = parseInt(area.substr(area.lastIndexOf('area=')+5)); $.post( 'ajax/bankomaty_kraj.php', {area:area}, function(data) { $('.cashomats .data').html(data.htmlData); $('.cashomats h2').html(data.areaName); $('.bigmap .areas a').removeClass('active'); $('.bigmap .areas a[href$="area='+data.areaId+'"]').addClass('active'); }, 'json' ); }); });