if (!window['Folia']) {
  window['Folia'] = {};
}


function CustomMapRoad(opt_opts){

  Folia.tileBounds = new Array();

  //bounch hvor der er custom rettelser
  Folia.tileBounds.push(new GLatLngBounds(new GLatLng(57.0231,9.86240),new GLatLng(57.0256,9.86858)));


  opt_opts = opt_opts || {};
  opt_opts.mapType = (opt_opts.mapType != undefined ? opt_opts.mapType : "map");
  opt_opts.mapObj = (opt_opts.mapObj != undefined ? opt_opts.mapObj : Folia.map);
  this.copyCollection = new GCopyrightCollection('Folia A/S');
  this.copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, "©2009 Folia.dk");
  this.copyCollection.addCopyright(this.copyright);
  this.tilelayer = new GTileLayer(this.copyCollection);
  this.tilelayer.getTileUrl = function(tile,z){

  //var proj = opt_opts.mapObj.getCurrentMapType().getProjection();
  //var p1 = proj.fromPixelToLatLng(new GPoint(tile.x*256,tile.y*256),z);
  //var p2 = proj.fromPixelToLatLng(new GPoint((tile.x+1)*256,(tile.y+1)*256),z);

  var url ="";
  var subdomain=(tile.x+tile.y)%4;

  if(z>13){
   // if(Folia.tileBounds[0].intersects(new GLatLngBounds(p2, p1))){
      //url = "http://d1zqutybffyvms.cloudfront.net/tiles/"+opt_opts.mapType+"/z"+z+"/x"+tile.x+"/y"+tile.y+".png";
      url = "http://tiles"+subdomain+".folia.dk/tiles/"+opt_opts.mapType+"/z"+z+"/x"+tile.x+"/y"+tile.y+".png";
      //GLog.write(url);
   // }
  }
  return url;
};
this.tilelayer.isPng = function() { return true;};
this.tilelayer.getOpacity = function() { return 1.0; }
return new GTileLayerOverlay(this.tilelayer);
}



try{Folia.CustomMapRoadInit();}catch(err){}