var MI = {
    markers:null,
    provinceBounds: null,


    bringPoint2Center: function(x,y,zoomScale){
    	 	eGV.getMap().zoomToScale(zoomScale);
        eGV.getMap().panTo(new OpenLayers.LonLat(x,y));
       
    },
    
    bringExtent2Center: function(minx, miny, maxx, maxy){
        eGV.getMap().zoomToExtent(new OpenLayers.Bounds(minx, miny, maxx, maxy),false);
    },
    
    zoomToProvince: function(){
        eGV.getMap().zoomToExtent(MI.provinceBounds);
    },

    createOverViewMap: function(){
        var refArray = Array(

            refFons = new OpenLayers.Layer.WMS(
                "topo50m",
                "http://shagrat.icc.es/lizardtech/iserv/ows",
                {
                    "layers":"mtc250m,mtc250m",
                    "format":"image/png",
                    "exceptions":"application/vnd.ogc.se_xml"
                },
                {buffer:0, transitionEffect:'resize', baseLayer:true,singleTile:true}
            )
        );

		
       var overviewMap = eGV.addControl(new eGV.Control.OverviewMap("divOverviewMap",{staticMap:true,size:[150,100],layers:refArray,id:"eGVOverviewMap"}),"eGVOverviewMap");
    },

    /**
     * Method: showHideLayer
     * Shows or hides the given layer accordingly
     *
     * Parameters:
     * layer_id - {String} the id of the layer
     * forceShow - {Boolean} whether to force the displaying of the layer,
     *              if true, the layer will be always displayed
     */
    showHideLayer: function(layer_id, forceShow){
        if(forceShow == 'undefined' || forceShow == null)
            forceShow = false;
        var map = eGV.getMap();
        for(var i=0, len=map.connections.length; i<len; i++){
            var layer = map.connections[i].getLayer(layer_id);
            if(layer != null){
                if(forceShow && layer.isVisible())
                    return layer.isVisible();
                else{
                    layer.changeDisplayed();
                    return layer.isVisible();
                }
            }
        }
        return null;
    },

     /**
     * Method: getLayerLegend
     * Returns the URL for the image of the layer's legend
     *
     * Parameters:
     * layer_id - {String} the id of the layer
     */
    getLayerLegend: function(layer_id){
        var map = eGV.getMap();
        for(var i=0, len=map.connections.length; i<len; i++){
            var layer = map.connections[i].getLayer(layer_id);
            if(layer != null){
                return layer.getLegendURL();
            }
        }
        return null;
    },


      /**
     * Method: minimizeControl
     * Set the display properties of the control to make it disappear.
     *
     * Parameters:
     * evt - {Event}
     */
    hideLoadingBar: function(evt) {
        this.div.style.display = "none";
        this.maximized = false;

        if (evt != null) {
            OpenLayers.Event.stop(evt);
        }
    },

    /**
     * Method: maximizeControl
     * Make the control visible.
     *
     * Parameters:
     * evt - {Event}
     */
    showLoadingBar: function(evt) {
        this.div.style.display = "block";
        this.maximized = true;

        if (evt != null) {
            OpenLayers.Event.stop(evt);
        }
    }

    
}

function initializeMapInterface(){
	return initialize();
}

window.addEvent('domready', initializeMapInterface);

