//  This file is used to configure the items in each tool menu based on whether access to the content of the site is limited by
//  whether the user is inside or outside the city network.

var AppMenuObject = function() {
    return {        
        ViewMenu: function(limitAccess) {
            var toolsArray;
            if (limitAccess)
            {
                toolsArray = [
                        {
                            id: 'vmOverView',
                            text: getOverviewText(),
                            handler: onOverviewItemClick
                        },
                        {
                            id: 'vmPreviousExtent',
                            text: 'Previous Extent',
                            icon: 'images/prev_extent.gif',
                            handler: ncsGoPreviousExtent
                        },
                        {
                            id: 'vmRefreshMap',
                            text: 'Refresh Map',
                            icon: 'images/refreshBtn.gif',
                            handler: ncsRefreshMap
                        },
                        {
                            id: 'vmClearHighlights',
                            text: 'Clear All Highlighted Features',
                            handler: ncsClearHighlights
                        }
                    ];
            }
            else
            {
                toolsArray = [
                        {
                            id: 'vmOverView',
                            text: getOverviewText(),
                            handler: onOverviewItemClick   
                        },
                        {
                            id: 'vmPreviousExtent',
                            text: 'Previous Extent',
                            icon: 'images/prev_extent.gif',
                            handler: ncsGoPreviousExtent   
                        },
                        {
                            id: 'vmRefreshMap',
                            text: 'Refresh Map',
                            icon: 'images/refreshBtn.gif',
                            handler: ncsRefreshMap   
                        },
                        {
                            id: 'vmClearHighlights',
                            text: 'Clear All Highlighted Features',
                            handler: ncsClearHighlights   
                        },
                        {
                            id: 'vmClearBuffer',
                            text: 'Clear Buffer Image',
                            handler: ncsClearBuffer
                        }
                    ];
            }
            var viewMenu = new Ext.menu.Menu
            (
                {
                    id: 'viewMenu',
                    items: toolsArray
                }
            );
            return viewMenu;
        },
        
        ToolsMenu: function(limitAccess) {
            var toolsArray;
            if (limitAccess)
            {
                toolsArray = [
                        {
                            id: 'atZoomIn',
                            text: 'Zoom In',
                            icon: 'images/zoom-in.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapZoomIn', 'Tool')}
                        },
                        {
                            id: 'atZoomOut',
                            text: 'Zoom Out',
                            icon: 'images/zoom-out.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapZoomOut', 'Tool')}
                        },
                        {
                            id: 'atPan',
                            text: 'Pan',
                            icon: 'images/pan.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapPan', 'Tool')}
                        },
                        {
                            id: 'atZoomFull',
                            text: 'Zoom to Full Extent',
                            icon: 'images/zoom-full-extent1.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapFullExtent', 'Command')}
                        },
                        {
                            id: 'atIdentify',
                            text: 'Identify',
                            icon: 'images/identify.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapIdentify', 'Tool')}
                        },
                        {
                            id: 'atMeasure',
                            text: 'Measure',
                            icon: 'images/measure.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'Measure', 'Tool')}
                        },
                        {
                            id: 'atExportMap',
                            text: 'Print/Export Map',
                            icon: 'images/print.png',
                            handler: function(e) {ExportMap.Show()}
                        }
                    ];
            }
            else
            {
                toolsArray = [
                        {
                            id: 'atBuffer',
                            text: 'Buffer/Select',
                            icon: 'images/buffer_select.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'Buffer/Select', 'Tool')}
                        },
                        {
                            id: 'atZoomIn',
                            text: 'Zoom In',
                            icon: 'images/zoom-in.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapZoomIn', 'Tool')}
                        },
                        {
                            id: 'atZoomOut',
                            text: 'Zoom Out',
                            icon: 'images/zoom-out.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapZoomOut', 'Tool')}
                        },
                        {
                            id: 'atPan',
                            text: 'Pan',
                            icon: 'images/pan.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapPan', 'Tool')}
                        },
                        {
                            id: 'atZoomFull',
                            text: 'Zoom to Full Extent',
                            icon: 'images/zoom-full-extent1.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapFullExtent', 'Command')}
                        },
                        {
                            id: 'atIdentify',
                            text: 'Identify',
                            icon: 'images/identify.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'MapIdentify', 'Tool')}
                        },
                        {
                            id: 'atMeasure',
                            text: 'Measure',
                            icon: 'images/measure.png',
                            handler: function(e) {ncsSetActiveTool('Toolbar1', 'Measure', 'Tool')}
                        },
                        {
                            id: 'atExportMap',
                            text: 'Print/Export Map',
                            icon: 'images/print.png',
                            //handler: function(e) {MapExporter.ExportMap()}
                            handler: function(e) {ExportMap.Show()}
                        }
                    ];
            };

            var toolsMenu = new Ext.menu.Menu
            (
                {
                    id: 'toolsMenu',
                    items: toolsArray
                }
            );
            
          return toolsMenu;
        },
        
        HelpMenu: function() {
            var helpMenu = new Ext.menu.Menu
            (
                {
                    id: 'helpMenu',
                    items: [
                        {
                            id: 'hmHelp',
                            text: 'Help',
                            handler: onHelpClick
                        },
                        {
                            id: 'hmAbout',
                            text: 'About FCMaps',
                            handler: onAboutClick
                        },
                        {
                            id: 'hmContact',
                            text: 'Contact Us',
                            handler: onContactClick
                        }
                    ]
                }
            );
            return helpMenu;
        }
    };
}();