function MAMCustomControl(type) {
  this.type = type
}

MAMCustomControl.prototype = new GControl();

MAMCustomControl.prototype.initialize = function(map) {
  customMap = map;
  var container = document.createElement("div");
  controlDiv = document.createElement("img");
  if(this.type == "zoom_in") {
    controlDiv.src = "http://prod.static.myapartmentmap.com/images/test_zoom_in.gif";
  } else if (this.type == "zoom_out") {
    controlDiv.src = "http://prod.static.myapartmentmap.com/images/test_zoom_out.gif";
  } else if (this.type == "pan_up") {
    controlDiv.src = "http://prod.static.myapartmentmap.com/images/pan_up.gif";
  } else if (this.type == "pan_down") {
    controlDiv.src = "http://prod.static.myapartmentmap.com/images/pan_down.gif";
  }  else if (this.type == "pan_left") {
    controlDiv.src = "http://prod.static.myapartmentmap.com/images/test_pan_left.gif";
  } else if (this.type == "pan_right") {
    controlDiv.src = "http://prod.static.myapartmentmap.com/images/pan_right.gif";
  } else if (this.type == "clear") {
    MAMCustomControl.prototype.clearDiv = controlDiv;
    controlDiv.src = "http://prod.static.myapartmentmap.com/images/clear_off.gif";
  }

  container.appendChild(controlDiv);
  
  if(this.type == "zoom_in") {
    GEvent.addDomListener(controlDiv, "click", function() { map.zoomIn();  });
  } else if (this.type == "zoom_out") {
    GEvent.addDomListener(controlDiv, "click", function() { map.zoomOut();  });
  } else if (this.type == "pan_up") {
    GEvent.addDomListener(controlDiv, "click", function() { map.panDirection(0,+1);  });
  } else if (this.type == "pan_down") {
    GEvent.addDomListener(controlDiv, "click", function() { map.panDirection(0,-1);  });
  } else if (this.type == "pan_left") {
    GEvent.addDomListener(controlDiv, "click", function() { map.panDirection(+1,0);  });
  } else if (this.type == "pan_right") {
    GEvent.addDomListener(controlDiv, "click", function() { map.panDirection(-1,0);  });
  } else if (this.type == "clear") {
    GEvent.addDomListener(controlDiv, "click", function() { lFactory.clear(); mControl.clearOff();  });
  }
    
  map.getContainer().appendChild(container);
  return container;
}
MAMCustomControl.prototype.clearOff = function() {
  MAMCustomControl.prototype.clearDiv.src = "http://prod.static.myapartmentmap.com/images/clear_off.gif"; 
}

MAMCustomControl.prototype.clearOn = function() {
  MAMCustomControl.prototype.clearDiv.src = "http://prod.static.myapartmentmap.com/images/clear_on.gif";
}


MAMCustomControl.prototype.getDefaultPosition = function() {
  if(this.type == "zoom_in") {
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
  } else if (this.type == "zoom_out") {
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 50));
  } else if (this.type == "pan_up") {
    var width = customMap.getSize().width;
    var offset = (width /2) - 17;
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset, 7));
  } else if (this.type == "pan_down") {
    var width = customMap.getSize().width;
    var offset = (width /2) - 17;
    return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset, 7));
  } else if (this.type == "pan_left") {
    var height = customMap.getSize().height;
    var offset = (height /2) - 17;
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, offset));
  } else if (this.type == "pan_right") {
    var height = customMap.getSize().height;
    var offset = (height /2) - 17;
    return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, offset));
  } else if (this.type == "clear") {
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50, 7));
  }


}


