/**
 * Override : Hack that avoid the 150 dpi bug (possibly, to confirm)
 */
Map.prototype.selectionBox = function(aDisplay, ajaxAction) {
  this.resetMapEventHandlers();

  this.setCurrentLayer('drawing');
  this.getDisplay(aDisplay).setTool('sel.box');
  //added 
  //nasty hack (sorry...) that avoid Export PDF bugs
  this.onSelBox = function(x1, y1, x2, y2) {
      
    if(x1 == x2 && y1==y2 && ajaxAction == 'Query.Perform') {
        var currentScale = $('currentScale').innerHTML;
        var currentScale = currentScale.substring(2,currentScale.length);
        var currentScale = currentScale.replace(new RegExp("'", "g"),'');
        var currentScale = parseInt(currentScale);
        var x1tmp = x1-(currentScale/450);
        var y1tmp = y1-(currentScale/450);
        var x2tmp = x1+(currentScale/450);
        var y2tmp = y1+(currentScale/450);
        myform.selection_coords.value = x1tmp + "," + y1tmp + ";" + x2tmp + "," + y2tmp;
    }  else {
         myform.selection_coords.value = x1 + "," + y1 + ";" + x2 + "," + y2;
    }
    myform.selection_type.value = "rectangle";
    storeFeatures();
    CartoWeb.trigger(ajaxAction, "doSubmit()");
  }
};

/**
 * Override : different styling
 */
Map.prototype.linkit = function(aDisplay) {
    var linkbox = xGetElementById('linkItBox');
    if (linkbox.style.display == 'none') {
        // warning: requires prototypejs lib
        new Ajax.Request(linkItRequestUrl, {
          method: 'get',
          onSuccess: function(transport) {
            linkbox.innerHTML = transport.responseText;

            $('linkItUrl').select();
            $('linkItUrl').select(); /* !!!!!!!!!!!!! very important because IE doesnt react to the first call at once */           
          }
        });

        linkbox.style.width = $('map').style.width;
        linkbox.style.display = 'block';
    }
}
