function sortImagePrepareData(tdNode, innerText) {
	var img = tdNode.getElementsByTagName('img');
	return img.length ? img[ 0 ].alt : "";
}


 // Uses the data prepared in “sortImagePrepareData”
function sortImage(a, b) {
	// Get the data for the current column from the
	// two arrays passed in as arguments like so…
	var aa = a[fdTableSort.pos];
	var bb = b[fdTableSort.pos];

	// Sort the data 
	if(aa == bb) return 0;
	if(aa < bb)  return -1;
	return 1;
}


/*
   sortIPAddress
   -------------

   This custom sort function correctly sorts IP addresses i.e. it checks all of the address parts and not just the first.

   The function is "safe" i.e. non-IP address data (like the word "Unknown") can be passed in and is sorted properly.
*/
var sortIPAddress = fdTableSort.sortNumeric;

function sortIPAddressPrepareData(tdNode, innerText) {
        // Get the innerText of the TR nodes
        var aa = innerText;

        // Remove spaces
        aa = aa.replace(" ","");

        // If not an IP address then return -1
        if(aa.search(/^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$/) == -1) return -1;

        // Split on the "."
        aa = aa.split(".");

        // If we don't have 4 parts then return -1
        if(aa.length != 4) return -1;

        var retVal = "";

        // Make all the parts an equal length and create a master integer
        for(var i = 0; i < 4; i++) {
                retVal += (String(aa[i]).length < 3) ? "0000".substr(0, 3 - String(aa[i]).length) + String(aa[i]) : aa[i];
        }

        return retVal;
}
