general.namespace('SW.Controls');

(function () {

        var NoMarkersAlertControl = SW.Controls.NoMarkersAlertControl = function (tooltip) {
            this.tooltip = tooltip;
            this.type = '';
        };
        if (typeof GMap !== 'undefined') {
            NoMarkersAlertControl.prototype = new GControl(); 
        }
        NoMarkersAlertControl.prototype.constructor = NoMarkersAlertControl;

        /* part of GControl interface */
        NoMarkersAlertControl.prototype.printable = function () {
            return false; // not printable
        };
        
        /* * part of GControl interface */
        NoMarkersAlertControl.prototype.selectable = function () {
            return false; // no selectable text in the control
        };
                
        /**/
        NoMarkersAlertControl.prototype.initialize = function (map) {
            
            var div = this.div = $createEl('div');
            var img = $createEl('img', div);
            div.style.display = 'none';
            img.src = '/assets/images/no-marker.gif';
            
            var me = this;
            
            GEvent.addListener(map, "movestart", function () {
                me.hide();
            });
            GEvent.addDomListener(img, "mouseover", function (evt) {
                me.tooltip.setMessage('No ' + me.type + ' available in this area.<br/>Pan and/or zoom out to find markers elsewhere.'); 
                me.tooltip.show();
            });
            GEvent.addDomListener(img, "mouseout", function (evt) {
                me.tooltip.hide(); 
            });                        
            
            map.getContainer().appendChild(div);
            return div;
        };
                
        /**/
        NoMarkersAlertControl.prototype.getDefaultPosition = function () {
            return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(212, 11));
        };
        
        /**/
        NoMarkersAlertControl.prototype.show = function (type) {
            this.type = type;
            this.div.style.display = 'block';
        };
        
        /**/
        NoMarkersAlertControl.prototype.hide = function () {
            this.div.style.display = 'none';
        };
})();
