var GMapTypeOptions = new Object();
GMapTypeOptions.minResolution = minZoom;
GMapTypeOptions.maxResolution = maxZoom;
GMapTypeOptions.errorMessage = "No map data available";

var copyrightCollection = new GCopyrightCollection('');
var copyright = new GCopyright(1, 
                               new GLatLngBounds(new GLatLng(-90, -180), 
                               new GLatLng(90, 180)), 
                               1, 
                               "&copy;  2009 protistcentral.org");
copyrightCollection.addCopyright(copyright);

var tilelayers = [new GTileLayer(copyrightCollection , 0, 17)];
tilelayers[0].getTileUrl = customGetTileUrl;

function customGetTileUrl(a,z) {
  var f = "http://www.odonatacentral.org/test/maps/tiles/z"+z+"x"+a.x+"y"+a.y+".png";      
  return f;
}

var custommap = new GMapType(tilelayers, new GMercatorProjection(19), "Map", GMapTypeOptions);


////////////////////////////////////////////////////////////////////////////////


var geoTileUrl = "http://www.odonatacentral.org/views/geotiles/Z";

function getGeoTileUrl(a, b)
{
    if ( b == 5 && a.x >= 6 && a.x <= 7 && a.y >= 12 && a.y <= 13 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png"; 
    }
    else if ( b == 6 && a.x >= 13 && a.x <= 15 && a.y >= 24 && a.y <= 27 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png"; 
    }
    else if ( b == 7 && a.x >= 26 && a.x <= 30 && a.y >= 49 && a.y <= 54 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png"; 
    }
    else if ( b == 8 && a.x >= 52 && a.x <= 61 && a.y >= 99 && a.y <= 108 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png"; 
    }
    else if ( b == 9 && a.x >= 104 && a.x <= 123 && a.y >= 199 && a.y <= 217 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png"; 

    }
    else if ( b == 10 && a.x >= 208 && a.x <= 246 && a.y >= 398 && a.y <= 435 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png";
    }
    else if ( b == 11 && a.x >= 417 && a.x <= 492 && a.y >= 797 && a.y <= 871 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png";
    }
    else if ( b == 12 && a.x >= 834 && a.x <= 984 && a.y >= 1594 && a.y <= 1743 )
    {
        return geoTileUrl + b + "/" + a.y + "/" + a.x + ".png";
    }

    return G_PHYSICAL_MAP.getTileLayers()[0].getTileUrl(a,b);
}




// Create the copyright collection
var geoCopyrightCollection = new GCopyrightCollection('Texas Natural Science Center,');
var geoCopyright = new GCopyright(1, new GLatLngBounds(new GLatLng(25.7998912, -106.8750000), new GLatLng(37.1603165, -93.1640625)), 0, "PaleoCentral");
geoCopyrightCollection.addCopyright(geoCopyright);

// Setup the tile layers
var tilelayers = new Array();
tilelayers[0] = G_PHYSICAL_MAP.getTileLayers()[0];
tilelayers[1] = new GTileLayer(geoCopyrightCollection, 3, 12 );
tilelayers[1].getTileUrl = getGeoTileUrl;
tilelayers[1].getOpacity = function () {return 1.00;};//of the non transparent part
tilelayers[1].isPng = function() {return true;}; 

var minZoom = 3;
var maxZoom = 12;
// Setup the options for our map layer


GMapType.prototype.getMinimumResolution = function(latlng) {
    return minZoom;
}

GMapType.prototype.getMaximumResolution = function(latlng) {
    return maxZoom;
}

// Create our custom map layer
var geologymap = new GMapType(tilelayers, new GMercatorProjection(19), "PaleoCentral", GMapTypeOptions);
geologymap.getTextColor = function() {return "#000000";};
