// JavaScript Document

	var map;
    var geocoder;
    function load() {
      if (GBrowserIsCompatible()) {
        geocoder = new GClientGeocoder();
        map = new GMap2(document.getElementById('map'));
	    CustomGetTileUrl=function(a,b){
          var f;
		  if(b>11){f = "http://crmap.com/maps/"+(a.x)+"_"+(a.y)+"_"+(b)+".gif";}
		  else {f = G_PHYSICAL_MAP.getTileLayers()[0].getTileUrl(a,b);}
		  return f;	  
	    }
//create the GTileLayer
      var tilelayers = [new GTileLayer(new GCopyrightCollection("MapCR.com"),7,16)];
      tilelayers[0].getTileUrl = CustomGetTileUrl;
      tilelayers[0].getCopyright = function(a,b) {
	  var copy;
	  if(b>11) {copy = {prefix:"Map: ", copyrightTexts:["&copy;2008 ToucanMaps"]};}
	  else {copy = {prefix:"Map data ", copyrightTexts:["&copy;2008 LeadDog Consulting, Europa Technologies"]};}
	    return copy;
      }
//create the GMapType based on G_SATELLITE_MAP
      var custommap = new GMapType(tilelayers, G_SATELLITE_MAP.getProjection(), "Map");
      map.addMapType(custommap);
// == Add logo as a custom control
      var logoposition = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(2,32));
      logoposition.apply(document.getElementById("logo"));
      map.getContainer().appendChild(document.getElementById("logo"));
	  map.addMapType(G_PHYSICAL_MAP);
      map.removeMapType(G_HYBRID_MAP);
      map.removeMapType(G_NORMAL_MAP);

      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
	  
	  var omc_size = new GSize(160, 110);
	  var omc = new GOverviewMapControl(omc_size);
      omc.setMapType(custommap);
      map.addControl(omc);
      map.addControl(new GMapTypeControl());
	  map.setCenter(new GLatLng(10.01894, -84.2134), 8, custommap);
	  

// == Listen for map click and show local markers
	  var lastmarker;
	  // == Add showall button as a custom control
      var showall = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(2,396));
      showall.apply(document.getElementById("showall"));
      map.getContainer().appendChild(document.getElementById("showall"));

//      GEvent.addListener(map,"click",function(overlay,point){if (!overlay) {showlocalMarker(point);	}   });
	
      }// could be the end of the if (GBrowserIsCompatible())
	  else {alert("Sorry, the Google Maps API is not compatible with this browser");}


// Before we go looking for the passed parameters, set some defaults 
	var starting = '';
// If there are any parameters at the end of the URL, they will be in  location.search
// skip the first character, we are not interested in the "?"
      var query = location.search.substring(1);

// split the rest at each "&" character to give a list of  "argname=value"  pairs
      var pairs = query.split("&");
      for (var i=0; i<pairs.length; i++) {
        // break each pair at the first "=" to obtain the argname and value
	    var pos = pairs[i].indexOf("=");
	    var argname = pairs[i].substring(0,pos).toLowerCase();
	    var value = pairs[i].substring(pos+1).toLowerCase();

// process each possible argname
        if (argname == "start_coll") {
		  starting = (value);
//		  alert (starting);
		  var starting_collection = startingLocations(starting);
		  }//end if (argname == "start_coll") 
//        if (argname == "type") {
//          if (value == "m") {maptype = G_NORMAL_MAP;}
//          if (value == "k") {maptype = G_SATELLITE_MAP;}
//          if (value == "h") {maptype = G_HYBRID_MAP;}
//        }
      }// end for (var i=0; i<pairs.length; i++) 
    }//end of load()
