
document.onkeyup=function(e)
{ 
   if(e.which == 16) 
      document.getElementById('useShift').value = false;
   if(e.which == 17) 
      document.getElementById('useCtrl').value = false;
} 
  
document.onkeydown=function(e)
{ 
   if(e.which == 16) 
      document.getElementById('useShift').value = true;
   if(e.which == 17) 
      document.getElementById('useCtrl').value = true;
} 

Map.prototype.select_by_point = function(aDisplay) {
  this.selectionPoint(aDisplay, 'selectLayerLoader.Perform');
  this.getDisplay(aDisplay).docObj.style.cursor = "help";
};

Map.prototype.select_save = function(aDisplay) {
	CartoWeb.trigger('selectLayerLoader.Save');
};

Map.prototype.select_by_bbox = function(aDisplay) {
  this.selectionBox(aDisplay, 'selectLayerLoader.Perform');
  this.getDisplay(aDisplay).docObj.style.cursor = "help";
};
  
Map.prototype.select_by_polygon = function(aDisplay) {
  this.resetMapEventHandlers();
  this.setCurrentLayer('drawing');
  this.getDisplay(aDisplay).setTool('draw.poly');

  this.onNewFeature = function(aFeature) {
      this.onToolUnset();
  };
  this.onFeatureInput = this.onFeatureChange = function(aFeature) {
    fillForm(aFeature);
    CartoWeb.trigger('selectLayerLoader.Perform', "doSubmit()");
  };
  this.onToolUnset = function() {
    //clear the outline_poly's display layer
    this.getDisplay(aDisplay).clearLayer('drawing');
    this.onCancel();
  };
  this.onCancel = function() {
    emptyForm();
  };
};

Map.prototype.select_by_clear = function(aDisplay) {
   CartoWeb.trigger('selectLayerLoader.Clear', "doSubmit()");
};

Map.prototype.select_by_circle = function(aDisplay) {
  this.resetMapEventHandlers();
  this.setCurrentLayer('drawing');
  this.getDisplay(aDisplay).setTool('draw.circle');

  this.onNewFeature = function(aFeature) {
      this.onToolUnset();
  };
  this.onFeatureInput = this.onFeatureChange = function(aFeature) {
    fillForm(aFeature);
    CartoWeb.trigger('selectLayerLoader.Perform', "doSubmit()");
  };
  this.onToolUnset = function() {
    //clear the outline_poly's display layer
    this.getDisplay(aDisplay).clearLayer('drawing');
    this.onCancel();
  };
  this.onCancel = function() {
    emptyForm();
  };
};

AjaxPlugins.selectLayerLoader = {
  
    handleResponse: function(pluginOutput) {
    }  
};

/*
 * Images plugin's Actions
 */
 
AjaxPlugins.selectLayerLoader.Actions = {};

AjaxPlugins.selectLayerLoader.Actions.Perform = {
    buildPostRequest: function(argObject) {
        return AjaxHandler.buildPostRequest();
    }
};

AjaxPlugins.selectLayerLoader.Actions.Save = {
    buildPostRequest: function(argObject) {
        return 'selectSave=' + salvarComo + '&';
    }
};

AjaxPlugins.selectLayerLoader.Actions.Clear = {
    buildPostRequest: function(argObject)
    {
      return 'select_clear=select_clear' + '&';
    },onAfterAjaxCall: function(argObject)
    {
      AjaxHandler.updateDomElement(AjaxPlugins.Tables.tablesResultId,'innerHTML', '');
    }
};

