/*
 * $Id: FIMap.js 31955 2008-01-29 20:40:41Z jbucher $
 * $URL: https://build/subversion/DestinationSearch/edfi/trunk/src/main/webapp/js/FIMap.js $
 */

/**
 * map with features specifically for Fonecta
 * @class LMI.Mapping.FIMap
 * @extends LMI.Mapping.InteractiveMap
 */
LMI.Mapping.FIMap = (function() {
    // shortcut vars
    var Y = YAHOO.util,
        $E = Y.Event,
        _E = LMI.Element;

    /**
     * @param {String|HTMLElement} map
     * @param {Object} options
     * @constructor
     */
    var FIMap = function( map, options ) {
        this.init( map, options );
    };
    FIMap.Defaults = {
        overviewWidth: 110,
        overviewHeight: 110
    };

    YAHOO.lang.extend( FIMap, LMI.Mapping.InteractiveMap, {
        /**
         * @method initOptions
         */
        initOptions: function( options ) {
            var i, o = FIMap.Defaults;
            if( options ) {
                for( i in options ) {
                    if( options.hasOwnProperty( i ) ) {
                        o[i] = options[i];
                    }
                }
            }
            FIMap.superclass.initOptions.call( this, o );
        },
        /**
         * uses DS_LARGE_CONTROLS as the default and saves the state of the overview map
         * @method addControls
         */
        addControls: function( type ) {
            if( !type ) {
                type = LMI.Mapping.Controls.DS_LARGE_CONTROLS;
            }
            FIMap.superclass.addControls.call( this, type );
        }

    } );
    return FIMap;
})();

LMI.Mapping.Controls.DS_LARGE_CONTROLS = function( imageBase ) {
    if( typeof imageBase === 'undefined' ) {
        imageBase = LMI.Mapping.Map.Defaults.imageBase;
    }

    var M = LMI.Mapping.InteractiveMap.prototype,
        o = { left: 10, top: 10, zIndex:100 }; // base control position
    return {
        zoom: {
            zoomIn: [ imageBase + 'large_controls/map_zoom_in.png',
                      { left: o.left + 21, top:o.top + 86, zIndex: o.zIndex, width: 24, height: 23 },
                      { click: M.zoomIn } ],
            zoomOut: [ imageBase + 'large_controls/map_zoom_out.png',
                      { left: o.left + 21, top: o.top + 277, zIndex: o.zIndex, width:24, height:22 },
                      { click: M.zoomOut }],
            slider: [ imageBase + 'large_controls/map_zoom_slider.png',
                      {left: o.left + 21, top: o.top + 111, zIndex: o.zIndex, width:24, height:162, horizontal: false, invert: false} ],
            thumb: [ imageBase + 'large_controls/map_zoom_thumb.png',
                      {left: -3, top: o.top + 205, zIndex: o.zIndex + 1, width: 30, height: 17} ]
        },
        misc: [
            [ imageBase + 'fonecta_large_controls/map_pan_n.png', 'pan', 'Pan North',
              { left: o.left + 21, top: o.top, zIndex: o.zIndex, width: 19, height: 21 },
              { click: M.panNorth } ],
            [ imageBase + 'fonecta_large_controls/map_pan_ne.png', 'pan', '',
              { left: o.left + 40, top: o.top, zIndex: o.zIndex, width: 24, height: 21 },
              {} ],
            [ imageBase + 'fonecta_large_controls/map_pan_nw.png', 'pan', '',
              { left: o.left, top: o.top, zIndex: o.zIndex, width: 21, height: 21 },
              {} ],
            [ imageBase + 'fonecta_large_controls/map_pan_s.png', 'pan', 'Pan South',
              { left: o.left + 21, top: o.top + 40, zIndex: o.zIndex, width: 19, height: 24 },
              { click: M.panSouth } ],
            [ imageBase + 'fonecta_large_controls/map_pan_se.png', 'pan', '',
              { left: o.left + 40, top: o.top + 40, zIndex: o.zIndex, width: 24, height: 24 },
              {} ],
            [ imageBase + 'fonecta_large_controls/map_pan_sw.png', 'pan', '',
              { left: o.left, top: o.top + 40, zIndex: o.zIndex, width: 21, height: 24 },
              {} ],
            [ imageBase + 'fonecta_large_controls/map_pan_e.png', 'pan', 'Pan East',
              { left: o.left + 40, top: o.top + 21, zIndex: o.zIndex, width: 24, height: 19 },
              { click: M.panEast } ],
            [ imageBase + 'fonecta_large_controls/map_pan_w.png', 'pan', 'Pan West',
              { left: o.left, top: o.top + 21, zIndex: o.zIndex, width: 21, height: 19 },
              { click: M.panWest } ],
            [ imageBase + 'fonecta_large_controls/map_pan_center.png', 'pan', 'Best Fit',
              { left: o.left + 21, top: o.top + 21, zIndex: o.zIndex, width: 19, height: 19 },
              { click: LMI.Mapping.Map.prototype.bestFitEventHandler } ],
            [ imageBase + 'fonecta_large_controls/map_circle.png', 'pan', '',
              { left: o.left, top: o.top, zIndex: o.zIndex - 1, width: 63, height: 63 },
              {} ]
        ],
        options: {
            overview: true,
            contextMenu: true,
            dragging: true
        }
    };
};

LMI.Mapping.Controls.DS_SMALL_CONTROLS = function( imageBase ) {
    if (typeof imageBase == 'undefined') {
        imageBase = LMI.Mapping.Map.Defaults.imageBase;
    }
    var M = LMI.Mapping.InteractiveMap.prototype,o = {left:10,top:10,zIndex:100};
    return{zoom:{zoomIn:[imageBase + 'small_controls/map_zoom_in.gif',{left:o.left + 19,top:o.top + 63,zIndex:o.zIndex,width:15,height:14},{click:M.zoomIn}],zoomOut:[imageBase + 'small_controls/map_zoom_out.gif',{left:o.left + 19,top:o.top + 197,zIndex:o.zIndex,width:15,height:14},{click:M.zoomOut}],slider:[imageBase + 'small_controls/map_zoom_slider.gif',{left:o.left + 19,top:o.top + 82,zIndex:o.zIndex,width:15,height:110,horizontal:false,invert:false}],thumb:[imageBase + 'small_controls/map_zoom_thumb.png',{left:-3,top:o.top + 193,zIndex:o.zIndex + 1,width:21,height:11}]},misc:[[imageBase + 'small_controls/map_pan_n.gif','pan','Pan North',{left:o.left + 19,top:o.top,zIndex:o.zIndex,width:15,height:19},{click:M.panNorth}],[imageBase + 'small_controls/map_pan_ne.gif','pan','Pan North-East',{left:o.left + 33,top:o.top + 8,zIndex:o.zIndex,width:12,height:12},{click:M.panNorthEast}],[imageBase + 'small_controls/map_pan_nw.gif','pan','Pan North-West',{left:o.left + 8,top:o.top + 8,zIndex:o.zIndex,width:12,height:12},{click:M.panNorthWest}],[imageBase + 'small_controls/map_pan_s.gif','pan','Pan South',{left:o.left + 19,top:o.top + 34,zIndex:o.zIndex,width:15,height:19},{click:M.panSouth}],[imageBase + 'small_controls/map_pan_se.gif','pan','Pan South-East',{left:o.left + 33,top:o.top + 33,zIndex:o.zIndex,width:12,height:12},{click:M.panSouthEast}],[imageBase + 'small_controls/map_pan_sw.gif','pan','Pan South-West',{left:o.left + 8,top:o.top + 33,zIndex:o.zIndex,width:12,height:12},{click:M.panSouthWest}],[imageBase + 'small_controls/map_pan_e.gif','pan','Pan East',{left:o.left + 34,top:o.top + 19,zIndex:o.zIndex,width:19,height:15},{click:M.panEast}],[imageBase + 'small_controls/map_pan_w.gif','pan','Pan West',{left:o.left,top:o.top + 19,zIndex:o.zIndex,width:19,height:15},{click:M.panWest}],[imageBase + 'small_controls/map_pan_center.gif','pan','Best Fit',{left:o.left + 19,top:o.top + 19,zIndex:o.zIndex,width:15,height:15},{click:LMI.Mapping.Map.prototype.bestFitEventHandler}]],options:{overview:false,dragging:true}};
};

/**
 * Factory method to get the small controls.
 * @method LMI.Mapping.Controls.getOverviewControls
 * @param imageBase (optional) the directory in which control images reside.  Defaults to LMI.Mapping.Map.Defaults.imageBase
 * @static
 */
LMI.Mapping.Controls.getOverviewControls = function( imageBase ) {
    if( typeof imageBase === 'undefined' ) {
        imageBase = LMI.Mapping.Map.Defaults.imageBase;
    }
    return {
        misc: [
            [
                imageBase + 'map_collapse.png',
                'collapse',
                "laajenna_pienenna".localize(),
                {
                    left:0,
                    top:0,
                    zIndex:100,
                    width:11,
                    height:11
                },
                { click: LMI.Mapping.OverviewMap.prototype.toggleExpandState }
            ]
        ],
        options: {
            overview: false,
            dragging: true
        }
    };
};
