/**
 * @requires OpenLayers/Control.js
 */

if (typeof(MyRoute) == "undefined")
{
	MyRoute = OpenLayers.Class({CLASS_NAME: "MyRoute"});
}
if (typeof(MyRoute.Control) == "undefined")
{
	MyRoute.Control = OpenLayers.Class({CLASS_NAME: "MyRoute.Control"});
}
/**
 * Class: MyRoute.Control.Logo
 * `
 * Inherits from:
 *  - <OpenLayers.Control>
 */
MyRoute.Control.Logo = OpenLayers.Class(OpenLayers.Control, {
    
    /** 
     * Property: element 
     * {DOMElement}
     */
    element: null,
    
    imageUrl: '',
	imageSize: null,

    /**
     * Constructor: MyRoute.Control.Logo
     *
     * Parameters: 
     * imageUrl - {String}
     * element - {DOMElement} 
     * options - {Object} options to the control. 
     */
    initialize: function(imageUrl, imageSize, options) {
        OpenLayers.Control.prototype.initialize.apply(this, [options]);
		this.imageUrl = imageUrl;
		this.imageSize = imageSize;
    },

    /**
     * APIMethod: destroy
     */
    destroy: function()  {
        OpenLayers.Control.prototype.destroy.apply(this, arguments); 
    },

    /**
     * Method: setMap
     * Set the map property for the control. 
     * 
     * Parameters:
     * map - {<OpenLayers.Map>} 
     */
    setMap: function(map) {
        OpenLayers.Control.prototype.setMap.apply(this, arguments);
    },

    /**
     * Method: draw
     *
     * Returns:
     * {DOMElement}
     */    
    draw: function() {
        OpenLayers.Control.prototype.draw.apply(this, arguments);
          
        if (!this.element) {
            this.div.className = this.displayClass;
			this.div.style.width = this.imageSize.w + "px";
			this.div.style.height = this.imageSize.h + "px";
			this.div.style.backgroundImage = "url(" + this.imageUrl + ")";
			this.div.style.backgroundRepeat = "no-repeat";
        }
        
        return this.div;
    },

    CLASS_NAME: "MyRoute.Control.Logo"
});

