$(document).ready(function() {

  $('.mapcontainer a').mouseover(function() {
	$('.mapcontainer a').removeClass('a2');
	url = this;
	title = this.title;
	id = this.id;
	$(this).addClass('a2');
	$(".maplink").replaceWith('<a href="'+url+'" class="maplink" id="'+id+'_2" target="_blank">'+title+'</a>');
  });
  
  
  /*(57 coordinates)*/
var  spots = 57;//ajust 57 to real total of spots
  
  $('.mapleft').click(function(){
	  id = $('.maplink').attr('id');
	  id = id.replace('_2','');
	  if(id == 'm1'){prev = spots;}
	  else {prev = id.replace('m','');prev = parseInt(prev)-1;}
	  prevId = '#m'+prev;
	  prevTitle = $(prevId).attr('title');
	  prevUrl = $(prevId).attr('href');
		  $(".maplink").replaceWith('<a href="'+prevUrl+'" class="maplink" id="m'+prev+'_2" target="_blank">'+prevTitle+'</a>');
		  $('.mapcontainer a').removeClass('a2');
		  $(prevId).addClass('a2');
  });
  $('.mapright').click(function(){
	  id = $('.maplink').attr('id');
	  id = id.replace('_2','');
	  if(id == 'm'+spots){next = 1;}
	  else {next = id.replace('m','');next = parseInt(next)+1;}
	  nextId = '#m'+next;
	  nextTitle = $(nextId).attr('title');
	  nextUrl = $(nextId).attr('href');
		  $(".maplink").replaceWith('<a href="'+nextUrl+'" class="maplink" id="m'+next+'_2" target="_blank">'+nextTitle+'</a>');
		  $('.mapcontainer a').removeClass('a2');
		  $(nextId).addClass('a2');
  });


});

