// Ok, inheritance and subclassing has been a real pain here.
// We're going to do this the hard way.  Make an instance,
// and stuff the things we want to add into that instance.

function MarsTileLayer(host, levels, copyright) {
	var layer = new GTileLayer(new GCopyrightCollection(), 0, levels);
	// layer.baseUrl_ = "http://" + host + "/kh?n=404&";
	layer.baseUrl_ = "http://" + host + "/";

	layer.getTileUrl = MarsTileLayer.prototype.getTileUrl;
	return(layer);
}

MarsTileLayer.prototype.getTileUrl = function(tile, zoom) {
  var bound = Math.pow(2, zoom);
  var x = tile.x;
  var y = tile.y;

  var qstr = 't';
  for (var z = 0; z < zoom; z++) {
    bound = bound / 2;
    if (y < bound) {
      if (x < bound) {
        qstr += 'q';
      } else {
        qstr += 'r';
        x -= bound;
      }
    } else {
      if (x < bound) {
        qstr += 't';
        y -= bound;
      } else {
        qstr += 's';
        x -= bound;
        y -= bound;
      }
    }
  }

  return this.baseUrl_ + qstr + ".jpg";
}
