/* Copyright (c) 2006-2007 MetaCarta, Inc., published under the BSD license.
 * See http://svn.openlayers.org/trunk/openlayers/release-license.txt 
 * for the full text of the license. */

/**
 * @requires OpenLayers/Control.js
 *
 * Class: OpenLayers.Control.Email
 * FREAC control that will bring up the email script to allow sending an email of the map
 * <OpenLayers.Control.Panel>.
 * 
 * Inherits from:
 *  - <OpenLayers.Control>
 */
OpenLayers.Control.Email = OpenLayers.Class(OpenLayers.Control, {
    /**
     * Property: type
     * TYPE_BUTTON.
     */
    type: OpenLayers.Control.TYPE_BUTTON,
    
    /**
     * Constructor: OpenLayers.Control.Email 
     * Fires a user defined function with the URL of the WMS request for current extent
     */
    initialize: function(func, options) {
        OpenLayers.Control.prototype.initialize.apply(this, [options]);
        this.userFunction = func;
    },
    
    userFunction: function(url){
    },
    
    /*
     * Method: trigger
     */
    trigger: function() {
        if (this.map) {
            bbox = this.map.getExtent().toBBOX();
            bl = this.map.baseLayer;
            size = this.map.getSize();
            newparams = {
               'BBOX': bbox,
               'width': size.w,
               'height': size.h
            }
            url = bl.getFullRequestString(newparams);
            this.userFunction(url);
        }
    },
    
    

    CLASS_NAME: "OpenLayers.Control.Email"
});
