Show image based on number then reset when total reached.

Show image based on number then reset when total reached.

Hi, I'm new to jQuery and I'll probably be hanging around these forums quite a bit .

I'm building a website that will log how far individual people have walked then add all individuals together to get a total distance. I'd like to be able to represent this total as distance around the UK.

To test I have to code below. This works but what I'd like to do is when the uk_distance has been reached set times_round_uk to 1 and start the images from the beginning but keep adding to the Total distance and when the distance is reached again set time around to two etc.

e.g.

Distance around the UK = 100 miles
Total distance walked = 435 miles
Times around UK = 4
Show stage 4 of the map

  1.       uk_distance = 100;
          times_round_uk = 0
           
            if (group_sum >= 10 && group_sum < 20) {
                 $("#map").attr("src","/images/maps/map-stage02.gif");
            } else if (group_sum >= 20 && group_sum < 30) {
                $("#map").attr("src","/images/maps/map-stage03.gif");
            } else if (group_sum >= 30 && group_sum < 40) {
                 $("#map").attr("src","/images/maps/map-stage04.gif");
            } else if (group_sum >= 40 && group_sum < 50) {
                 $("#map").attr("src","/images/maps/map-stage05.gif");
            } else if (group_sum >= 50 && group_sum < 60) {
                 $("#map").attr("src","/images/maps/map-stage06.gif");
            } else if (group_sum >= 60 && group_sum < 70) {
                 $("#map").attr("src","/images/maps/map-stage07.gif");
            } else if (group_sum >= 70 && group_sum < 80) {
                 $("#map").attr("src","/images/maps/map-stage08.gif");
            } else if (group_sum >= 80 && group_sum < 90) {
                 $("#map").attr("src","/images/maps/map-stage09.gif");
            } else if (group_sum >= 90 && group_sum > uk_distance) {
                 $("#map").attr("src","/images/maps/map-stage10.gif");
            };
This is how I get the total
  1.         var group_sum = 0;
            $("#activity .group_hours").each(function(){
                var value =  $(this).data("distance");
                group_sum = group_sum + value;
       
                $("#activity #group_hours").text(group_sum);
            });
Could someone please help me with a solution?

Cheers

Wayne