I need help editing a script used for ease of play on an online game. I received the original script from a friend who no longer plays and who doesn't know how to fix it with the game design having changed. The script string that needs edited is as follows:

function unocc_list(arr) {
var html= "";

var user_coords = [];
user_coords = xy_from_id(_current_planet.substr(0,6));

var data = new Array();
var i =0;
while (arr[i]) {
var c = arr[i];
var z = c.id;
var y = c.system;
var link = "";
link += "http://speed.imperion.org/fleetBase/mission/1/planetId/";
link += z;
link += "/m/301/ships/,0,25,0,0,0,0,0,0,0,0,0,0"; // XEN, Mylons
// link += "/m/301/ships/,0,0,1,0,0,0,0,0,0,0,0,0"; // TITAN, Large Transports
// link += "/m/301/ships/,0,4,0,0,0,0,0,0,0,0,0,0"; // TERRAN, Small Transports

var this_planet_coords = xy_from_id(c.system);
var d = distance_between (user_coords, this_planet_coords);

var raw_time = c.lastAttackTime;

var tt = raw_time.split(".");
var dx = tt[0]+ "."+tt[1]+".20"+tt[2];
var t1 = Date.parse(dx);
var now = new Date();
var time_delta = (now - t1) /(60 *60* 1000);
time_delta = Math.floor(time_delta);
var a ="";
switch (true) {
case (time_delta < 10):
a = "<span style='background: hsl(0,00%,70%); text-align: right;' title='Last attacked over "+time_delta+" hours ago'>"+time_delta+"</span>";
break;
case (time_delta >= 10 && time_delta < 100 ):
a = "<span style='background: hsl("+time_delta+",70%,70%); text-align: right;' title='Last attacked over "+time_delta+" hours ago'>"+time_delta+"</span>";
break;
case (time_delta > 99):
a = "<span style='background: hsl(100,70%,70%); text-align: right;' title='Last attacked over "+time_delta+" hours ago'>"+time_delta+"</span>";
break;
}

var q = c.quality.toFixed(2)+"\t";
if (c.quality > 1) {
if (c.quality > 1.15) {
q = "<b>"+q+"</b>";
}
q = "<span title='"+c.typeName+"'>"+q+"</span>";
} else {
q = "<span style='opacity: 0.4;'>"+q+"</span>";
}
data[i] = {};

data[i].dist = d;
data[i].code = "\n"+q+a+"\t<a href='"+link+"'>"+ z +"</a>\t("+this_planet_coords["x"] + "|" + this_planet_coords["y"]+") \tDistance: "+d;
i++;
}
data.sort(cmp_d);

var j = 0;
while (data[j]){
html += data[j].code;
j++;
}

open_pop_up (html, "boo", "[*] UnAnnexed/UnOcc Planets");

The code is supposed to pull up a list of all 'planets' in the game(for a certain distance) that are noT currently occupied or annexed by any other players. It however won't even recognize that there are any. I have the full script available if anyone wishes to look at it. As well as source code from the game itself. I'm not sure how much of the source code is even relevant so Instead of posting the four page blah blah blah Anyone who wants to help I can send a saved copy of it to them.

Here are a series of screen shots I took to give you an idea of whats going on.
Frame 1
Frame 2
Frame 3