/*
 * Copyright 2008 Institut Geographique National France, released under the
 * BSD license.
 */
/*
 * @requires Geoportal/Control.js
 * @requires Geoportal/Util.js
 */
/**
 * Class: Geoportal.Control.PermanentLogo
 * The Geoportal logo class.
 * Allow to add permanent logo on the map
 *
 * Inherits from:
 * - {<Geoportal.Control>}
 */
Geoportal.Control.PermanentLogo=
    OpenLayers.Class( Geoportal.Control, {

    /**
     * APIProperty: permanent logo url
     * The path to the image.
     */
    permaLogo: null,

    /**
     * APIProperty: permanent logo href
     * The URL the logo is pointing at.
     */
    permaURL: null,

    /**
     * Constructor: Geoportal.Control.PermanentLogo
     * Build the control.
     *
     * Parameters:
     * options - {DOMElement} Options for control.
     */
    initialize: function(options) {
        Geoportal.Control.prototype.initialize.apply(this, arguments);
        if (!this.permaLogo) {
            this.permaLogo= Geoportal.Util.getImagesLocation()+'logo_gp.gif';
        }
        if (!this.permaURL) {
            this.permaURL= 'http://www.geoportail.fr/';
        }
    },

    /**
     * APIMethod: draw
     * Call the default draw, and then draw the control.
     *
     * Parameters:
     * px - {<OpenLayers.Pixel>} the position where to draw the control.
     *
     * Returns:
     * {DOMElement} the control's div.
     */
    draw: function(px) {
        Geoportal.Control.prototype.draw.apply(this, arguments);
        var imgLogo= OpenLayers.Util.createImage(null,null,null,this.permaLogo,null,null,null,false);
        if (this.permaURL!=null) {
            var aLogo= document.createElement("a");
            aLogo.setAttribute("href", this.permaURL);
            aLogo.setAttribute("target", "_blank");
            aLogo.appendChild(imgLogo);
            this.div.appendChild(aLogo);
        } else {
            this.div.appendChild(imgLogo);
        }
        return this.div;
    },

    /**
     * Constant: CLASS_NAME
     * {String} *"Geoportal.Control.PermanentLogo"*
     */
    CLASS_NAME: "Geoportal.Control.PermanentLogo"
});
