/*
	map.setLoadingMessage(div)
	map.startDelicateProcedure()
	map.endDelicateProcedure()
  map.inDelicateProcedure()

map.setLoadingMessage(div)
  This sets a div to be displayed at the start of a delicate procedure.
  This would be something like "Loading...". This will be hidden again
    after the map.endDelicateProcedure() is called.
  A good way to do this is to create a BpControl, and then set this to ctrl.getDiv().
    That way, the position of the message is managed for you.

map.startDelicateProcedure(bool)
  This:
    1) shows the loading message, if there is one
    2) changes the map cursor to "wait" for the map if (!IE || bool)
    3) calls map.disableDragging()
    4) calls map.disableZooming()

map.endDelicateProcedure()
  This:
    1) hides the loading message, if there is one
    2) changes the map cursor to what it was (if changed)
    3) calls map.enableDragging()
    4) calls map.enableZooming()


TODO:
    getLoadingMessage()
    isInDelicateProcedure()
    make it so calling start...() does nothing if it's already in a dp.
        returns true if entering one, false if nothing happened
    make it so that calling end...() does nothing unless it's in one.
        return values similar to start...()

*/

(function(){
  GMap2.prototype.setLoadingMessage = function(div) {
    this.__loadingMessage = div;
  };

  GMap2.prototype.startDelicateProcedure = function(changeIeCursor) {
    // show the message
    if(this.__loadingMessage)
      this.__loadingMessage.style.display = '';

    // change the cursor
    if(BpBrowser.type != BpBrowser.MSIE || changeIeCursor) {
      this.__delicateCursorChanged = true;
      this.__delicateProcedureCursor = this.getContainer().style.cursor;
      this.getContainer().style.cursor = 'wait';
    }

    // disable zooming
    this.disableZooming();

    // disable dragging
    this.disableDragging();
  };

  GMap2.prototype.endDelicateProcedure = function() {
    // hide the message
    if(this.__loadingMessage)
      this.__loadingMessage.style.display = 'none';

    // change the cursor
    if(this.__delicateCursorChanged) {
      this.getContainer().style.cursor = this.__delicateProcedureCursor;
      delete this.__delicateProcedureCursor;
      delete this.__delicateCursorChanged;
    }

    // enable zooming
    this.enableZooming();

    // enable dragging
    this.enableDragging();
  };
})()
