function CustomControlsTypeMap() {

}
var ruta = 'http://www.singuladerm.com/wp-content/plugins/store-locator/images/controls/';

CustomControlsTypeMap.prototype = new GControl();


CustomControlsTypeMap.prototype.initialize = function(map) {
  var container = document.createElement("div");
  var me = this;

  var satDiv = me.createButton_("Satellite");
  var mapDiv = me.createButton_("Map");
  var hybDiv = me.createButton_("Hybrid");

 
  me.assignButtonEvent_(satDiv, map, G_SATELLITE_MAP, [mapDiv, hybDiv]);
  me.assignButtonEvent_(hybDiv, map, G_HYBRID_MAP, [satDiv, mapDiv]);
  me.assignButtonEvent_(mapDiv, map, G_NORMAL_MAP, [satDiv, hybDiv]);
  
  GEvent.addListener(map, "maptypechanged", function() {
    if (map.getCurrentMapType() == G_NORMAL_MAP) {
      GEvent.trigger(mapDiv, "click"); 
    } else if (map.getCurrentMapType() == G_SATELLITE_MAP) {
      GEvent.trigger(satDiv, "click");
    } else if (map.getCurrentMapType() == G_HYBRID_MAP) {
      GEvent.trigger(hybDiv, "click");
    }
  });



  container.appendChild(satDiv);
  container.appendChild(mapDiv);
  container.appendChild(hybDiv);

  map.getContainer().appendChild(container);
  
  return container;
}


CustomControlsTypeMap.prototype.createButton_ = function(text) {
  var buttonDiv = document.createElement("div");
  buttonDiv.mapType = text;
  this.setButtonStyle_(buttonDiv, text);
  buttonDiv.style.cssFloat = "left";
  buttonDiv.style.styleFloat = "left";
  buttonDiv.style.marginTop = "10px";
  buttonDiv.style.marginRight = "6px";
  return buttonDiv;
}


CustomControlsTypeMap.prototype.assignButtonEvent_ = function(div, map, mapType, otherDivs) {
  var me = this;

  GEvent.addDomListener(div, "click", function() {
    for (var i = 0; i < otherDivs.length; i++) {
      me.toggleButton_(otherDivs[i], false);
    }
		
    me.toggleButton_(div, true);
    map.setMapType(mapType);
  });
}


CustomControlsTypeMap.prototype.toggleButton_ = function(div, boolCheck) {
  var add = boolCheck ? "_On" : "";

  div.style.background = "url('"+ruta + 'es_' + div.mapType + add + ".png')";
}

CustomControlsTypeMap.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 0));
}

CustomControlsTypeMap.prototype.setButtonStyle_ = function(button, label) {

  button.style.background = "url('"+ruta+ 'es_' + label + ".png')";
  button.style.width = "61px";
  button.style.height = "24px";
  button.style.cursor = "pointer";
}


