
// ===== Begin Cursor Coordinates ===== //
function fixedLlString(la,lo) {
  var s = "N";
  var w = "E";
  if (la < 0) {
	la = -la;
	s = "S";
  }
  if(lo < 0) {
	lo = -lo;
	w = "W";
  }
	
  var lai = Math.floor(la);
  var laf = Math.round((la-lai)*1000000);
  var lais = lai.toString();
  while(lais.length < 2)
	lais = "0" + lais;
  var lafs = laf.toString();
  while(lafs.length < 6)
	lafs = "0" + lafs;

  var loi = Math.floor(lo);
  var lof = Math.round((lo-loi)*1000000);
  var lois = loi.toString();
  while(lois.length < 3)
	lois = "0" + lois;
  var lofs = lof.toString();
  while(lofs.length < 6)
	lofs = "0" + lofs;

  return dlat(s + lais + "." + lafs) + "  " + dlon(w + lois + "." + lofs);
}

function MapCursorControl() {
}

MapCursorControl.prototype = new GControl();

MapCursorControl.prototype.initialize = function(map) {
  var container = document.createElement("div");
  container.style.fontFamily='Arial';
  container.style.fontSize='XX-Small';

  var ptr = document.createElement("INPUT");
  ptr.style.width = "380px";
  ptr.type = "Text";
  ptr.readOnly = true;
  ptr.id = "txtPtr";
  ptr.title = "Latitude, Longitude / Range, Bearing";
  container.appendChild(ptr);
      
  GEvent.addListener(map, "mousemove", function(point) {
    var ptr = document.getElementById('txtPtr');
    var mc = fixedLlString(point.lat(),point.lng()); 
    var rb = '';
    if (LLat != null) {
      var ptlat = point.lat().toFixed(7);
	  var ptlon = point.lng().toFixed(7);
      rbCompute(LLat, LLon, ptlat, ptlon);
      rb = '/ '+units(FTR)+' '+dms(FTB); 
    }
    ptr.value = mc+' '+rb;
  });
  map.getContainer().appendChild(container);
  return container;
}

MapCursorControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10, 10));
}
// =========== End of Cusor Coordinates =============== //
