]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/main/menu.js
1bb5db98e3c74b7a8e8182502aebc17c4a1b1d2b
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / main / menu.js
1 dump('entering main/menu.js\n');
2 // vim:noet:sw=4:ts=4:
3
4 var offlineStrings;
5
6 if (typeof main == 'undefined') main = {};
7 main.menu = function () {
8
9     offlineStrings = document.getElementById('offlineStrings');
10     JSAN.use('util.error'); this.error = new util.error();
11     JSAN.use('util.window'); this.window = new util.window();
12     JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
13
14     this.w = window;
15     var x = document.getElementById('network_progress');
16     x.setAttribute('count','0');
17     x.addEventListener(
18         'click',
19         function() {
20             if ( window.confirm(offlineStrings.getString('menu.reset_network_stats')) ) {
21                 var y = document.getElementById('network_progress_rows');
22                 while(y.firstChild) { y.removeChild( y.lastChild ); }
23                 x.setAttribute('mode','determined');
24                 x.setAttribute('count','0');
25             }
26         },
27         false
28     );
29 }
30
31 main.menu.prototype = {
32
33     'id_incr' : 0,
34
35     'toolbar' : 'none',
36     'toolbar_size' : 'large',
37     'toolbar_mode' : 'both',
38     'toolbar_labelpos' : 'side',
39
40     'url_prefix' : function(url,secure) {
41         // This allows urls to start with a urls key (or be only a urls key)
42         // We stop at the first / or ? to allow extra paths and query strings.
43         var base_url = url.match(/^[^?/|]+/);
44         if(base_url) {
45             base_url = base_url[0];
46             if(urls[base_url])
47                 url = url.replace(/^[^?/|]+\|?/, urls[base_url]);
48         }
49         // if host unspecified URL with leading /, prefix the remote hostname
50         if (url.match(/^\//)) url = urls.remote + url;
51         // if it starts with http:// and we want secure, convert to https://
52         if (secure && url.match(/^http:\/\//)) {
53             url = url.replace(/^http:\/\//, 'https://');
54         }
55         // if it doesn't start with a known protocol, add http(s)://
56         if (! url.match(/^(http|https|chrome|oils):\/\//) && ! url.match(/^data:/) ) {
57             url = secure
58                 ? 'https://' + url
59                 : 'http://' + url;
60         }
61         dump('url_prefix = ' + url + '\n');
62         return url;
63     },
64
65     'init' : function( params ) {
66
67         var obj = this;
68
69         urls.remote = params['server'];
70
71         xulG.get_barcode = this.get_barcode;
72         xulG.get_barcode_and_settings = this.get_barcode_and_settings;
73
74         // Disable commands that we can't do anything with right now
75         if(typeof xulG.window.win.start_venkman != 'function') {
76             var element = document.getElementById('cmd_debug_venkman');
77             element.setAttribute('disabled','true');
78             element.removeAttribute('perm');
79         }
80         if(typeof xulG.window.win.inspectDOMDocument != 'function') {
81             var element = document.getElementById('cmd_debug_inspector');
82             element.setAttribute('disabled','true');
83             element.removeAttribute('perm');
84         }
85         if(typeof xulG.window.win.startChromeList != 'function') {
86             var element = document.getElementById('cmd_debug_chrome_list');
87             element.setAttribute('disabled','true');
88             element.removeAttribute('perm');
89         }
90
91
92         // Pull in local customizations
93         var r = new XMLHttpRequest();
94         var custom_js = obj.url_prefix('CUSTOM_JS');
95         r.open("GET", custom_js, false);
96         r.send(null);
97         if (r.status == 200) {
98             dump('Evaluating ' + custom_js + '\n');
99             eval( r.responseText );
100         }
101
102         this.button_bar_init();
103
104         var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
105         var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle');
106         for(var i = 0; i < menuitems.length; i++)
107             menuitems[i].setAttribute('checked', cl_first ? 'true' : 'false');
108
109         xulG.pref.addObserver('', this, false);
110         window.addEventListener("unload", function(e) { this.stop_observing(); }, false);
111
112         var network_meter = String( obj.data.hash.aous['ui.network.progress_meter'] ) == 'true';
113         if (! network_meter) {
114             var x = document.getElementById('network_progress');
115             if (x) x.setAttribute('hidden','true');
116             var y = document.getElementById('page_progress');
117             if (y) y.setAttribute('hidden','true');
118         }
119
120         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
121                     getService(Components.interfaces.nsIWindowMediator);
122         var mainwin = wm.getMostRecentWindow('eg_main');
123         mainwin.get_menu_perms(document);
124         var hotkeysets = mainwin.load_hotkey_sets();
125
126         var popupmenu = document.getElementById('main.menu.admin.client.hotkeys.current.popup');
127         
128         for(var i = 0; i < hotkeysets.length; i++) {
129             var keysetname = hotkeysets[i];
130             var menuitem = document.createElement('menuitem');
131             if(offlineStrings.testString('hotkey.' + keysetname))
132                 menuitem.setAttribute('label',offlineStrings.getString('hotkey.' + keysetname));
133             else
134                 menuitem.setAttribute('label',keysetname);
135             menuitem.setAttribute('value',keysetname);
136             menuitem.setAttribute('type','radio');
137             menuitem.setAttribute('name','menu_hotkey_current');
138             menuitem.setAttribute('command','cmd_hotkeys_set');
139             popupmenu.appendChild(menuitem);
140         }
141
142         JSAN.use('util.network');
143         var network = new util.network();
144         network.set_user_status();
145
146         this.set_menu_hotkeys();
147
148         function open_conify_page(path, labelKey, event) {
149
150             // tab label
151             labelKey = labelKey || 'menu.cmd_open_conify.tab';
152             label = offlineStrings.getString(labelKey);
153
154             // URL
155             var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix('CONIFY/') + path + '.html');
156
157             obj.command_tab(
158                 event,
159                 loc, 
160                 {'tab_name' : label, 'browser' : false }, 
161                 {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons:true} 
162             );
163         }
164
165         function open_admin_page(path, labelKey, addSes, event) {
166
167             // tab label
168             labelKey = labelKey || 'menu.cmd_open_conify.tab';
169             label = offlineStrings.getString(labelKey);
170
171             // URL
172             var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix('XUL_LOCAL_ADMIN_BASE/') + path);
173             if(addSes) loc += window.escape('?ses=' + ses());
174
175             obj.command_tab( 
176                 event,
177                 loc, 
178                 {'tab_name' : label, 'browser' : false }, 
179                 {'no_xulG' : false, 'show_print_button' : true, 'show_nav_buttons' : true } 
180             );
181         }
182
183
184         function open_eg_web_page(path, labelKey, event, content_params) {
185             
186             // tab label
187             labelKey = labelKey || 'menu.cmd_open_conify.tab';
188             var label = offlineStrings.getString(labelKey);
189
190             // URL
191             var loc = urls.XUL_BROWSER + '?url=' + window.escape(obj.url_prefix('EG_WEB_BASE/') + path);
192
193             content_params = content_params || {
194                 'no_xulG': false,
195                 'show_print_button': true,
196                 'show_nav_buttons': true 
197             };
198
199             obj.command_tab(
200                 event, loc, {tab_name: label, browser: false}, content_params
201             );
202         }
203
204         var cmd_map = {
205             'cmd_broken' : [
206                 ['oncommand'],
207                 function() { alert(offlineStrings.getString('common.unimplemented')); }
208             ],
209
210             /* File Menu */
211             'cmd_close_window' : [ 
212                 ['oncommand'], 
213                 function() {
214                     JSAN.use('util.widgets');
215                     util.widgets.dispatch('close',window);
216                 }
217             ],
218             'cmd_new_window' : [
219                 ['oncommand'],
220                 function() {
221                     var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
222                         getService(Components.interfaces.nsIWindowMediator);
223                     wm.getMostRecentWindow('eg_main').new_tabs(Array('new'));
224                 }
225             ],
226             'cmd_new_tab' : [
227                 ['oncommand'],
228                 function() {
229                     if (obj.new_tab(null,{'focus':true},null) == false)
230                     {
231                         if(window.confirm(offlineStrings.getString('menu.new_tab.max_tab_dialog')))
232                         {
233                             var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
234                                 getService(Components.interfaces.nsIWindowMediator);
235                             wm.getMostRecentWindow('eg_main').new_tabs(Array('tab'));
236                         }
237                     }
238                 }
239             ],
240             'cmd_portal' : [
241                 ['oncommand'],
242                 function() {
243                     obj.set_tab();
244                 }
245             ],
246             'cmd_close_tab' : [
247                 ['oncommand'],
248                 function(event) {
249                     var myEvent = event;
250                     var closeAll = false;
251                     if(event && event.sourceEvent) myEvent = event.sourceEvent;
252                     // Note: The last event is not supposed to be myEvent in this if.
253                     if(myEvent && myEvent.explicitOriginalTarget.nodeName.match(/toolbarbutton/) && myEvent.explicitOriginalTarget.command == event.originalTarget.id) {
254                         var value = xulG.pref.getIntPref('ui.key.accelKey');
255                         switch(value) {
256                             case 17:
257                                 closeAll = myEvent.ctrlKey;
258                                 break;
259                             case 18:
260                                 closeAll = myEvent.altKey;
261                                 break;
262                             case 224:
263                                 closeAll = myEvent.metaKey;
264                                 break;
265                         }
266                     }
267                     if(closeAll) {
268                         obj.close_all_tabs();
269                     } else {
270                         obj.close_tab();
271                     }
272                 }
273             ],
274             'cmd_close_all_tabs' : [
275                 ['oncommand'],
276                 function() { obj.close_all_tabs(); }
277             ],
278
279             /* Edit Menu */
280             'cmd_edit_copy_buckets' : [
281                 ['oncommand'],
282                 function(event) {
283                     obj.data.stash_retrieve();
284                     obj.command_tab(event,obj.url_prefix('XUL_COPY_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_copy_buckets.tab')},{});
285                 }
286             ],
287             'cmd_edit_volume_buckets' : [
288                 ['oncommand'],
289                 function(event) {
290                     obj.data.stash_retrieve();
291                     obj.command_tab(event,obj.url_prefix('XUL_VOLUME_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_volume_buckets.tab')},{});
292                 }
293             ],
294             'cmd_edit_record_buckets' : [
295                 ['oncommand'],
296                 function(event) {
297                     obj.data.stash_retrieve();
298                     obj.command_tab(event,obj.url_prefix('XUL_RECORD_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_record_buckets.tab')},{});
299                 }
300             ],
301             'cmd_edit_user_buckets' : [
302                 ['oncommand'],
303                 function(event) {
304                     obj.data.stash_retrieve();
305                     obj.command_tab(event,obj.url_prefix('XUL_USER_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_user_buckets.tab')},{});
306                 }
307             ],
308
309
310             'cmd_replace_barcode' : [
311                 ['oncommand'],
312                 function() {
313                     try {
314                         JSAN.use('util.network');
315                         var network = new util.network();
316
317                         var old_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.label'));
318                         if (!old_bc) return;
319     
320                         var copy;
321                         try {
322                             copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
323                             if (typeof copy.ilsevent != 'undefined') throw(copy); 
324                             if (!copy) throw(copy);
325                         } catch(E) {
326                             alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.retrieval.error', [old_bc]) + '\n');
327                             return;
328                         }
329     
330                         // Why did I want to do this twice?  Because this copy is more fleshed?
331                         try {
332                             copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
333                             if (typeof copy.ilsevent != 'undefined') throw(copy);
334                             if (!copy) throw(copy);
335                         } catch(E) {
336                             try { alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.retrieval.error', [old_bc]) + '\n' + (typeof E.ilsevent == 'undefined' ? '' : E.textcode + ' : ' + E.desc)); } catch(F) { alert(E + '\n' + F); }
337                             return;
338                         }
339     
340                         var new_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.replacement.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.replacement.label'));
341                         new_bc = String( new_bc ).replace(/\s/g,'');
342                         /* Casting a possibly null input value to a String turns it into "null" */
343                         if (!new_bc || new_bc == 'null') {
344                             alert(offlineStrings.getString('menu.cmd_replace_barcode.blank.error'));
345                             return;
346                         }
347     
348                         var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
349                         if (typeof test.ilsevent == 'undefined') {
350                             alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.duplicate.error', [new_bc]));
351                             return;
352                         } else {
353                             if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
354                                 obj.error.standard_unexpected_error_alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.testing.error', [new_bc]),test);
355                                 return;
356                             }    
357                         }
358
359                         copy.barcode(new_bc); copy.ischanged('1');
360                         var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
361                         if (typeof r.ilsevent != 'undefined') { 
362                             if (r.ilsevent != 0) {
363                                 if (r.ilsevent == 5000 /* PERM_FAILURE */) {
364                                     alert(offlineStrings.getString('menu.cmd_replace_barcode.permission.error'));
365                                 } else {
366                                     obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.cmd_replace_barcode.renaming.error'),r);
367                                 }
368                             }
369                         }
370                     } catch(E) {
371                         obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.cmd_replace_barcode.renaming.failure'),copy);
372                     }
373                 }
374             ],
375
376             /* Search Menu */
377             'cmd_patron_search' : [
378                 ['oncommand'],
379                 function(event) {
380                     obj.set_patron_tab({},{},event);
381                 }
382             ],
383             'cmd_search_usr_id' : [
384                 ['oncommand'],
385                 function(event) {
386                     var usr_id = prompt(
387                         offlineStrings.getString('menu.cmd_search_usr_id.tab'),
388                         '',
389                         offlineStrings.getString('menu.cmd_search_usr_id.prompt')
390                     );
391                     if (usr_id != '' && ! isNaN(usr_id)) {
392                         obj.set_patron_tab(
393                             {},
394                             { 'id' : usr_id },
395                             event
396                         );
397                     }
398                 }
399             ],
400             'cmd_search_opac' : [
401                 ['oncommand'],
402                 function(event) {
403                     obj.data.stash_retrieve();
404                     var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
405                     obj.command_tab(event,obj.url_prefix('XUL_OPAC_WRAPPER'), {'tab_name':offlineStrings.getString('menu.cmd_search_opac.tab')}, content_params);
406                 }
407             ],
408             'cmd_search_tcn' : [
409                 ['oncommand'],
410                 function(event) {
411                     var tcn = prompt(offlineStrings.getString('menu.cmd_search_tcn.tab'),'',offlineStrings.getString('menu.cmd_search_tcn.prompt'));
412
413                     function spawn_tcn(r,event) {
414                         for (var i = 0; i < r.count; i++) {
415                             var id = r.ids[i];
416                             var opac_url = obj.url_prefix('opac_rdetail') + id;
417                             obj.data.stash_retrieve();
418                             var content_params = { 
419                                 'session' : ses(), 
420                                 'authtime' : ses('authtime'),
421                                 'opac_url' : opac_url,
422                             };
423                             if (i == 0) {
424                                 obj.command_tab(
425                                     event,
426                                     obj.url_prefix('XUL_OPAC_WRAPPER'), 
427                                     {'tab_name':tcn}, 
428                                     content_params
429                                 );
430                             } else {
431                                 obj.new_tab(
432                                     obj.url_prefix('XUL_OPAC_WRAPPER'), 
433                                     {'tab_name':tcn}, 
434                                     content_params
435                                 );
436                             }
437                         }
438                     }
439
440                     if (tcn) {
441                         JSAN.use('util.network');
442                         var network = new util.network();
443                         var robj = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn]);
444                         if (robj.count != robj.ids.length) throw('FIXME -- FM_BRE_ID_SEARCH_VIA_TCN = ' + js2JSON(robj));
445                         if (robj.count == 0) {
446                             var robj2 = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn,1]);
447                             if (robj2.count == 0) {
448                                 alert(offlineStrings.getFormattedString('menu.cmd_search_tcn.not_found.error', [tcn]));
449                             } else {
450                                 if ( window.confirm(offlineStrings.getFormattedString('menu.cmd_search_tcn.deleted.error', [tcn])) ) {
451                                     spawn_tcn(robj2,event);
452                                 }
453                             }
454                         } else {
455                             spawn_tcn(robj,event);
456                         }
457                     }
458                 }
459             ],
460             'cmd_search_bib_id' : [
461                 ['oncommand'],
462                 function(event) {
463                     var bib_id = prompt(offlineStrings.getString('menu.cmd_search_bib_id.tab'),'',offlineStrings.getString('menu.cmd_search_bib_id.prompt'));
464                     if (!bib_id) return;
465
466                     var opac_url = obj.url_prefix('opac_rdetail') + bib_id;
467                     var content_params = { 
468                         'session' : ses(), 
469                         'authtime' : ses('authtime'),
470                         'opac_url' : opac_url,
471                     };
472                     obj.command_tab(
473                         event,
474                         obj.url_prefix('XUL_OPAC_WRAPPER'), 
475                         {'tab_name':'#' + bib_id}, 
476                         content_params
477                     );
478                 }
479             ],
480             'cmd_copy_status' : [
481                 ['oncommand'],
482                 function(event) {
483                     obj.data.stash_retrieve();
484                     obj.command_tab(event,obj.url_prefix('XUL_COPY_STATUS'),{},{});
485                 }
486             ],
487
488             /* Circulation Menu */
489             'cmd_patron_register' : [
490                 ['oncommand'],
491                 function(event) {
492
493                     function log_registration(p) {
494                         try {
495                             obj.error.work_log(
496                                 document.getElementById('offlineStrings').getFormattedString(
497                                     'staff.circ.work_log_patron_registration.message',
498                                     [
499                                         ses('staff_usrname'),
500                                         p.family_name(),
501                                         p.card().barcode()
502                                     ]
503                                 ), {
504                                     'au_id' : p.id(),
505                                     'au_family_name' : p.family_name(),
506                                     'au_barcode' : p.card().barcode()
507                                 }
508                             );
509                         } catch(E) {
510                             obj.error.sdump('D_ERROR','Error with work_logging in menu.js, cmd_patron_register:' + E);
511                         }
512                     }
513
514                     function spawn_editor(p) {
515                         var url = 'XUL_PATRON_EDIT';
516                         var param_count = 0;
517                         for (var i in p) {
518                             if (param_count++ == 0) url += '?'; else url += '&';
519                             url += i + '=' + window.escape(p[i]);
520                         }
521                         var loc = obj.url_prefix('XUL_BROWSER?url=') + window.escape( obj.url_prefix(url) );
522                         obj.new_tab(
523                             loc, 
524                             {}, 
525                             { 
526                                 'show_print_button' : true , 
527                                 'tab_name' : offline.getString('menu.cmd_patron_register.related.tab'),
528                                 'passthru_content_params' : {
529                                     'spawn_search' : function(s) { obj.spawn_search(s); },
530                                     'spawn_editor' : spawn_editor,
531                                     'on_save' : function(p) { log_registration(p); }
532                                 }
533                             }
534                         );
535                     }
536
537                     obj.data.stash_retrieve();
538                     var loc = obj.url_prefix('XUL_BROWSER?url=') 
539                         + window.escape( obj.url_prefix('XUL_PATRON_EDIT') );
540                     obj.command_tab(
541                         event,
542                         loc, 
543                         {}, 
544                         { 
545                             'show_print_button' : true , 
546                             'tab_name' : offlineStrings.getString('menu.cmd_patron_register.tab'),
547                             'passthru_content_params' : {
548                                 'ses' : ses(),
549                                 'spawn_search' : function(s) { obj.spawn_search(s); },
550                                 'spawn_editor' : spawn_editor,
551                                 'on_save' : function(p) { log_registration(p); }
552                             }
553                         }
554                     );
555                 }
556             ],
557             'cmd_staged_patrons' : [
558                 ['oncommand'],
559                 function(event) {
560                     obj.data.stash_retrieve();
561                     obj.command_tab(event,obj.url_prefix('XUL_STAGED_PATRONS'),{'tab_name':offlineStrings.getString('menu.circulation.staged_patrons.tab')},{});
562                 }
563             ],
564             'cmd_circ_checkin' : [
565                 ['oncommand'],
566                 function(event) { 
567                     obj.data.stash_retrieve();
568                     obj.command_tab(event,obj.url_prefix('XUL_CHECKIN'),{},{});
569                 }
570             ],
571             'cmd_circ_renew' : [
572                 ['oncommand'],
573                 function(event) { 
574                     obj.data.stash_retrieve();
575                     obj.command_tab(event,obj.url_prefix('XUL_RENEW'),{},{});
576                 }
577             ],
578             'cmd_circ_checkout' : [
579                 ['oncommand'],
580                 function(event) { 
581                     obj.data.stash_retrieve();
582                     obj.command_tab(event,obj.url_prefix('XUL_PATRON_BARCODE_ENTRY'),{},{});
583                 }
584             ],
585             'cmd_circ_hold_capture' : [
586                 ['oncommand'],
587                 function(event) { 
588                     obj.data.stash_retrieve();
589                     obj.command_tab(event,obj.url_prefix('XUL_CHECKIN?hold_capture=1'),{},{});
590                 }
591             ],
592             'cmd_browse_holds_shelf' : [
593                 ['oncommand'],
594                 function(event) { 
595                     obj.data.stash_retrieve();
596                     obj.command_tab(event,obj.url_prefix('XUL_HOLDS_BROWSER?shelf=1'),{ 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab') },{});
597                 }
598             ],
599             'cmd_clear_holds_shelf' : [
600                 ['oncommand'],
601                 function(event) {
602                     obj.data.stash_retrieve();
603                     obj.command_tab(
604                         event,
605                         obj.url_prefix(urls.XUL_HOLDS_BROWSER),
606                         {
607                             'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab')
608                         },
609                         {
610                             'shelf':1,
611                             'clear':true
612                         }
613                     );
614                 }
615             ],
616             'cmd_circ_hold_pull_list' : [
617                 ['oncommand'],
618                 function(event) { 
619                     obj.data.stash_retrieve();
620                     var loc = urls.XUL_BROWSER + '?url=' + window.escape(
621                         obj.url_prefix('XUL_HOLD_PULL_LIST')
622                     );
623                     obj.command_tab(event, loc, {'tab_name' : offlineStrings.getString('menu.cmd_browse_hold_pull_list.tab')} );
624                 }
625             ],
626
627             'cmd_in_house_use' : [
628                 ['oncommand'],
629                 function(event) { 
630                     obj.data.stash_retrieve();
631                     obj.command_tab(event,obj.url_prefix('XUL_IN_HOUSE_USE'),{},{});
632                 }
633             ],
634
635             'cmd_scan_item_as_missing_pieces' : [
636                 ['oncommand'],
637                 function() { 
638                     xulG.window.open(obj.url_prefix('XUL_SCAN_ITEM_AS_MISSING_PIECES'),'scan_missing_pieces','chrome'); 
639                 }
640             ],
641
642             'cmd_standalone' : [
643                 ['oncommand'],
644                 function() { 
645                     //obj.set_tab(obj.url_prefix('XUL_STANDALONE'),{},{});
646                     window.open(urls.XUL_STANDALONE,'Offline','chrome,resizable');
647                 }
648             ],
649
650             'cmd_local_admin' : [
651                 ['oncommand'],
652                 function(event) { 
653                     //obj.set_tab(obj.url_prefix('XUL_LOCAL_ADMIN')+'?ses='+window.escape(ses())+'&session='+window.escape(ses()),{},{});
654                     var loc = urls.XUL_BROWSER + '?url=' + window.escape(
655                         obj.url_prefix( 'XUL_LOCAL_ADMIN?ses='+window.escape(ses())+'&session='+window.escape(ses()) )
656                     );
657                     obj.command_tab(
658                         event,
659                         loc, 
660                         {'tab_name' : offlineStrings.getString('menu.cmd_local_admin.tab'), 'browser' : false }, 
661                         { 'no_xulG' : false, 'show_nav_buttons' : true, 'show_print_button' : true } 
662                     );
663
664                 }
665             ],
666
667             'cmd_toggle_meters' : [
668                 ['oncommand'],
669                 function() {
670                     var x = document.getElementById('network_progress');
671                     if (x) x.hidden = ! x.hidden;
672                     var y = document.getElementById('page_progress');
673                     if (y) y.hidden = ! y.hidden;
674                 }
675             ],
676
677             'cmd_local_admin_reports' : [
678                 ['oncommand'],
679                 function(event) { 
680                     var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix('XUL_REPORTS?ses=') + ses());
681                     obj.command_tab(
682                         event,
683                         loc, 
684                         {'tab_name' : offlineStrings.getString('menu.cmd_local_admin_reports.tab'), 'browser' : false }, 
685                         {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons : true } 
686                     );
687                 }
688             ],
689             'cmd_open_vandelay' : [
690                 ['oncommand'],
691                 function(event) { open_eg_web_page('vandelay/vandelay', null, event); }
692             ],
693             'cmd_local_admin_transit_list' : [
694                 ['oncommand'],
695                 function(event) { open_admin_page('transit_list.xul', 'menu.cmd_local_admin_transit_list.tab', false, event); }
696             ],
697             'cmd_local_admin_age_overdue_circulations_to_lost' : [
698                 ['oncommand'],
699                 function(event) { open_admin_page('circ_age_to_lost.xul', 'menu.cmd_local_admin_age_overdue_circulations_to_lost.tab', true, event); }
700             ],
701             'cmd_local_admin_cash_reports' : [
702                 ['oncommand'],
703                 function(event) { open_admin_page('cash_reports.xhtml', 'menu.cmd_local_admin_cash_reports.tab', true, event); }
704             ],
705             'cmd_local_admin_fonts_and_sounds' : [
706                 ['oncommand'],
707                 function(event) { open_admin_page('font_settings.xul', 'menu.cmd_local_admin_fonts_and_sounds.tab', false, event); }
708             ],
709             'cmd_local_admin_printer' : [
710                 ['oncommand'],
711                 function(event) { open_admin_page('printer_settings.xul', 'menu.cmd_local_admin_printer.tab', false, event); }
712             ],
713             'cmd_local_admin_do_not_auto_attempt_print_setting' : [
714                 ['oncommand'],
715                 function(event) { 
716                     obj.command_tab(event,obj.url_prefix('XUL_DO_NOT_AUTO_ATTEMPT_PRINT_SETTING'),{'tab_name':offlineStrings.getString('menu.cmd_local_admin_do_not_auto_attempt_print_setting.tab')},{});
717                 }
718             ],
719             'cmd_local_admin_closed_dates' : [
720                 ['oncommand'],
721                 function(event) { open_admin_page('closed_dates.xhtml', 'menu.cmd_local_admin_closed_dates.tab', true, event); }
722             ],
723             'cmd_local_admin_copy_locations' : [
724                 ['oncommand'],
725                 function(event) { open_admin_page('copy_locations.xhtml', 'menu.cmd_local_admin_copy_locations.tab', true, event); }
726             ],
727             'cmd_local_admin_lib_settings' : [
728                 ['oncommand'],
729                 function(event) { open_admin_page('org_unit_settings.xhtml', 'menu.cmd_local_admin_lib_settings.tab', true, event); }
730             ],
731             'cmd_local_admin_non_cat_types' : [
732                 ['oncommand'],
733                 function(event) { open_admin_page('non_cat_types.xhtml', 'menu.cmd_local_admin_non_cat_types.tab', true, event); }
734             ],
735             'cmd_local_admin_stat_cats' : [
736                 ['oncommand'],
737                 function(event) { open_admin_page('stat_cat_editor.xhtml', 'menu.cmd_local_admin_stat_cats.tab', true, event); }
738             ],
739             'cmd_local_admin_standing_penalty' : [
740                 ['oncommand'],
741                 function(event) { open_eg_web_page('conify/global/config/standing_penalty', null, event); }
742             ],
743             'cmd_local_admin_grp_penalty_threshold' : [
744                 ['oncommand'],
745                 function(event) { open_eg_web_page('conify/global/permission/grp_penalty_threshold', null, event); }
746             ],
747             'cmd_local_admin_circ_limit_set' : [
748                 ['oncommand'],
749                 function(event) { open_eg_web_page('conify/global/config/circ_limit_set', null, event); }
750             ],
751             'cmd_server_admin_config_rule_circ_duration' : [
752                 ['oncommand'],
753                 function(event) { open_eg_web_page('conify/global/config/rule_circ_duration', null, event); }
754             ],
755             'cmd_server_admin_config_hard_due_date' : [
756                 ['oncommand'],
757                 function(event) { open_eg_web_page('conify/global/config/hard_due_date', null, event); }
758             ],
759             'cmd_server_admin_config_rule_recurring_fine' : [
760                 ['oncommand'],
761                 function(event) { open_eg_web_page('conify/global/config/rule_recurring_fine', null, event); }
762             ],
763             'cmd_server_admin_config_rule_max_fine' : [
764                 ['oncommand'],
765                 function(event) { open_eg_web_page('conify/global/config/rule_max_fine', null, event); }
766             ],
767             'cmd_server_admin_config_rule_age_hold_protect' : [
768                 ['oncommand'],
769                 function(event) { open_eg_web_page('conify/global/config/rule_age_hold_protect', null, event); }
770             ],
771             'cmd_server_admin_config_circ_weights' : [
772                 ['oncommand'],
773                 function(event) { open_eg_web_page('conify/global/config/circ_matrix_weights', null, event); }
774             ],
775             'cmd_server_admin_config_hold_weights' : [
776                 ['oncommand'],
777                 function(event) { open_eg_web_page('conify/global/config/hold_matrix_weights', null, event); }
778             ],
779             'cmd_server_admin_config_weight_assoc' : [
780                 ['oncommand'],
781                 function(event) { open_eg_web_page('conify/global/config/weight_assoc', null, event); }
782             ],
783             'cmd_server_admin_config_actor_sip_fields' : [
784                 ['oncommand'],
785                 function(event) { open_eg_web_page('conify/global/config/actor_sip_fields', null, event); }
786             ],
787             'cmd_server_admin_config_asset_sip_fields' : [
788                 ['oncommand'],
789                 function(event) { open_eg_web_page('conify/global/config/asset_sip_fields', null, event); }
790             ],
791             'cmd_server_admin_circ_limit_group' : [
792                 ['oncommand'],
793                 function(event) { open_eg_web_page('conify/global/config/circ_limit_group', null, event); }
794             ],
795             'cmd_server_admin_config_usr_activity_type' : [
796                 ['oncommand'],
797                 function(event) { open_eg_web_page('conify/global/config/usr_activity_type', null, event); }
798             ],
799             'cmd_server_admin_actor_org_unit_custom_tree' : [
800                 ['oncommand'],
801                 function(event) { open_eg_web_page('conify/global/actor/org_unit_custom_tree', null, event); }
802             ],
803             'cmd_local_admin_external_text_editor' : [
804                 ['oncommand'],
805                 function() {
806                     var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
807                     var key = 'oils.text_editor.external.cmd';
808                     var has_key = prefs.prefHasUserValue(key);
809                     var value = has_key ? prefs.getCharPref(key) : 'C:\\Windows\\notepad.exe %letter.txt%';
810                     var cmd = window.prompt(
811                         document.getElementById('offlineStrings').getString('text_editor.prompt_for_external_cmd'),
812                         value
813                     );
814                     if (!cmd) { return; }
815                     prefs.setCharPref(key,cmd);
816                 }
817             ],
818             'cmd_local_admin_idl_field_doc' : [
819                 ['oncommand'],
820                 function(event) { open_eg_web_page('conify/global/config/idl_field_doc', null, event); }
821             ],
822             'cmd_local_admin_action_trigger' : [
823                 ['oncommand'],
824                 function(event) { open_eg_web_page('conify/global/action_trigger/event_definition', null, event); }
825             ],
826             'cmd_local_admin_survey' : [
827                 ['oncommand'],
828                 function(event) { open_eg_web_page('conify/global/action/survey', null, event); }
829             ],
830             'cmd_local_admin_barcode_completion' : [
831                 ['oncommand'],
832                 function() { open_eg_web_page('conify/global/config/barcode_completion', 
833                     'menu.local_admin.barcode_completion.tab'); }
834             ],
835             'cmd_local_admin_circ_matrix_matchpoint' : [
836                 ['oncommand'],
837                 function() { open_eg_web_page('conify/global/config/circ_matrix_matchpoint', 
838                     'menu.local_admin.circ_matrix_matchpoint.tab'); }
839             ],
840             'cmd_local_admin_hold_matrix_matchpoint' : [
841                 ['oncommand'],
842                 function() { open_eg_web_page('conify/global/config/hold_matrix_matchpoint', 
843                     'menu.local_admin.hold_matrix_matchpoint.tab'); }
844             ],
845             'cmd_local_admin_copy_location_order' : [
846                 ['oncommand'],
847                 function(event) { open_eg_web_page('conify/global/asset/copy_location_order', null, event); }
848             ],
849             'cmd_local_admin_work_log' : [
850                 ['oncommand'],
851                 function(event) { 
852                     obj.command_tab(
853                         event,
854                         urls.XUL_WORK_LOG,
855                         { 'tab_name' : offlineStrings.getString('menu.local_admin.work_log.tab') },
856                         {}
857                     );
858                 }
859             ],
860             "cmd_local_admin_copy_template": [
861                 ["oncommand"],
862                 function() {
863                     open_eg_web_page("conify/global/asset/copy_template");
864                 }
865             ],
866             "cmd_local_admin_item_attribute_editor": [
867                 ["oncommand"],
868                 function(event) {
869                     obj.command_tab(
870                         event,
871                         urls.XUL_COPY_EDITOR,
872                         { 'tab_name' : offlineStrings.getString('menu.local_admin.item_attribute_editor.tab') },
873                         { 'admin' : true, 'not_modal' : true }
874                     );
875                 }
876             ],
877             'cmd_local_admin_patrons_due_refunds' : [
878                 ['oncommand'],
879                 function(event) {
880                     obj.command_tab(
881                         event,
882                         obj.url_prefix('XUL_PATRONS_DUE_REFUNDS'),
883                         { 'tab_name' : offlineStrings.getString('menu.local_admin.patrons_due_refunds.tab') },
884                         {}
885                     );
886                 }
887             ],
888             'cmd_server_admin_org_type' : [
889                 ['oncommand'],
890                 function(event) { open_conify_page('actor/org_unit_type', null, event); }
891             ],
892             'cmd_server_admin_org_unit' : [
893                 ['oncommand'],
894                 function(event) { open_conify_page('actor/org_unit', null, event); }
895             ],
896             'cmd_server_admin_grp_tree' : [
897                 ['oncommand'],
898                 function(event) { open_conify_page('permission/grp_tree', null, event); }
899             ],
900             'cmd_server_admin_perm_list' : [
901                 ['oncommand'],
902                 function(event) { open_conify_page('permission/perm_list', null, event); }
903             ],
904             'cmd_server_admin_copy_status' : [
905                 ['oncommand'],
906                 function(event) { open_conify_page('config/copy_status', null, event); }
907             ],
908             'cmd_server_admin_marc_code' : [
909                 ['oncommand'],
910                 function(event) { open_eg_web_page('conify/global/config/record_attr_definition', null, event); }
911             ],
912             'cmd_server_admin_coded_value_map' : [
913                 ['oncommand'],
914                 function(event) { open_eg_web_page('conify/global/config/coded_value_map', null, event); }
915             ],
916             'cmd_server_admin_metabib_class' : [
917                 ['oncommand'],
918                 function(event) { open_eg_web_page('conify/global/config/metabib_class', null, event); }
919             ],
920             'cmd_server_admin_metabib_class_ts_map' : [
921                 ['oncommand'],
922                 function(event) { open_eg_web_page('conify/global/config/metabib_class_ts_map', null, event); }
923             ],
924             'cmd_server_admin_metabib_field' : [
925                 ['oncommand'],
926                 function(event) { open_eg_web_page('conify/global/config/metabib_field', null, event); }
927             ],
928             'cmd_server_admin_metabib_field_ts_map' : [
929                 ['oncommand'],
930                 function(event) { open_eg_web_page('conify/global/config/metabib_field_ts_map', null, event); }
931             ],
932             'cmd_server_admin_acn_prefix' : [
933                 ['oncommand'],
934                 function(event) { open_eg_web_page('conify/global/config/acn_prefix', null, event); }
935             ],
936             'cmd_server_admin_acn_suffix' : [
937                 ['oncommand'],
938                 function(event) { open_eg_web_page('conify/global/config/acn_suffix', null, event); }
939             ],
940             'cmd_server_admin_billing_type' : [
941                 ['oncommand'],
942                 function(event) { open_eg_web_page('conify/global/config/billing_type', null, event); }
943             ],
944             'cmd_server_admin_acq_invoice_item_type' : [
945                 ['oncommand'],
946                 function(event) { open_eg_web_page('conify/global/acq/invoice_item_type', null, event); }
947             ],
948             'cmd_server_admin_acq_invoice_payment_method' : [
949                 ['oncommand'],
950                 function(event) { open_eg_web_page('conify/global/acq/invoice_payment_method', null, event); }
951             ],
952             'cmd_server_admin_acq_lineitem_alert' : [
953                 ['oncommand'],
954                 function(event) { open_eg_web_page('conify/global/acq/lineitem_alert', null, event); }
955             ],
956             'cmd_server_admin_acq_lineitem_marc_attr_def' : [
957                 ['oncommand'],
958                 function(event) { open_eg_web_page('conify/global/acq/lineitem_marc_attr_def', null, event); }
959             ],
960             'cmd_server_admin_acq_fund_tag' : [
961                 ['oncommand'],
962                 function(event) { open_eg_web_page('conify/global/acq/fund_tag', null, event); }
963             ],
964             'cmd_server_admin_acq_cancel_reason' : [
965                 ['oncommand'],
966                 function(event) { open_eg_web_page('conify/global/acq/cancel_reason', null, event); }
967             ],
968             'cmd_server_admin_acq_claim_type' : [
969                 ['oncommand'],
970                 function(event) { open_eg_web_page('conify/global/acq/claim_type', null, event); }
971             ],
972             'cmd_server_admin_acq_claim_event_type' : [
973                 ['oncommand'],
974                 function(event) { open_eg_web_page('conify/global/acq/claim_event_type', null, event); }
975             ],
976             'cmd_server_admin_acq_claim_policy' : [
977                 ['oncommand'],
978                 function(event) { open_eg_web_page('conify/global/acq/claim_policy', null, event); }
979             ],
980             'cmd_server_admin_acq_claim_policy_action' : [
981                 ['oncommand'],
982                 function(event) { open_eg_web_page('conify/global/acq/claim_policy_action', null, event); }
983             ],
984             'cmd_server_admin_acq_fund' : [
985                 ['oncommand'],
986                 function(event) { open_eg_web_page('acq/fund/list', null, event); }
987             ],
988             'cmd_server_admin_acq_funding_source' : [
989                 ['oncommand'],
990                 function(event) { open_eg_web_page('acq/funding_source/list', null, event); }
991             ],
992             'cmd_server_admin_acq_provider' : [
993                 ['oncommand'],
994                 function(event) { open_eg_web_page('conify/global/acq/provider', null, event); }
995             ],
996             'cmd_server_admin_acq_edi_account' : [
997                 ['oncommand'],
998                 function(event) { open_eg_web_page('conify/global/acq/edi_account', null, event); }
999             ],
1000             'cmd_server_admin_acq_edi_message' : [
1001                 ['oncommand'],
1002                 function(event) { open_eg_web_page('acq/po/edi_messages', null, event); }
1003             ],
1004             'cmd_server_admin_acq_currency_type' : [
1005                 ['oncommand'],
1006                 function(event) { open_eg_web_page('acq/currency_type/list', null, event); }
1007             ],
1008             'cmd_server_admin_acq_exchange_rate' : [
1009                 ['oncommand'],
1010                 function(event) { open_eg_web_page('conify/global/acq/exchange_rate', null, event); }
1011             ],
1012             'cmd_server_admin_acq_distrib_formula' : [
1013                 ['oncommand'],
1014                 function(event) { open_eg_web_page('conify/global/acq/distribution_formula', null, event); }
1015             ],
1016             'cmd_server_admin_sms_carrier' : [
1017                 ['oncommand'],
1018                 function(event) { open_eg_web_page('conify/global/config/sms_carrier', null, event); }
1019             ],
1020             'cmd_server_admin_z39_source' : [
1021                 ['oncommand'],
1022                 function(event) { open_eg_web_page('conify/global/config/z3950_source', null, event); }
1023             ],
1024             'cmd_server_admin_org_unit_proximity_adjustment' : [
1025                 ['oncommand'],
1026                 function(event) { open_eg_web_page('conify/global/config/org_unit_proximity_adjustment', null, event); }
1027             ],
1028             'cmd_server_admin_circ_mod' : [
1029                 ['oncommand'],
1030                 function(event) { open_eg_web_page('conify/global/config/circ_modifier', null, event); }
1031             ],
1032             'cmd_server_admin_global_flag' : [
1033                 ['oncommand'],
1034                 function(event) { open_eg_web_page('conify/global/config/global_flag', null, event); }
1035             ],
1036             'cmd_server_admin_org_unit_setting_type' : [
1037                 ['oncommand'],
1038                 function(event) { open_eg_web_page('conify/global/config/org_unit_setting_type', null, event); }
1039             ],
1040             'cmd_server_admin_import_match_set' : [
1041                 ['oncommand'],
1042                 function(event) { open_eg_web_page('conify/global/vandelay/match_set', null, event); }
1043             ],
1044             'cmd_server_admin_usr_setting_type' : [
1045                 ['oncommand'],
1046                 function(event) { open_eg_web_page('conify/global/config/usr_setting_type', null, event); }
1047             ],
1048             'cmd_server_admin_authority_control_set': [
1049                 ['oncommand'],
1050                 function(event) { open_eg_web_page('conify/global/cat/authority/control_set', null, event); }
1051             ],
1052             'cmd_server_admin_authority_browse_axis': [
1053                 ['oncommand'],
1054                 function(event) { open_eg_web_page('conify/global/cat/authority/browse_axis', null, event); }
1055             ],
1056             'cmd_server_admin_authority_thesaurus': [
1057                 ['oncommand'],
1058                 function(event) { open_eg_web_page('conify/global/cat/authority/thesaurus', null, event); }
1059             ],
1060             'cmd_server_admin_booking_resource': [
1061                 ['oncommand'],
1062                 function(event) { open_eg_web_page('conify/global/booking/resource', null, event); }
1063             ],
1064             'cmd_server_admin_booking_resource_type': [
1065                 ['oncommand'],
1066                 function(event) { open_eg_web_page('conify/global/booking/resource_type', null, event); }
1067             ],
1068             'cmd_server_admin_booking_resource_attr': [
1069                 ['oncommand'],
1070                 function(event) { open_eg_web_page('conify/global/booking/resource_attr', null, event); }
1071             ],
1072             'cmd_server_admin_booking_resource_attr_value': [
1073                 ['oncommand'],
1074                 function(event) { open_eg_web_page('conify/global/booking/resource_attr_value', null, event); }
1075             ],
1076             'cmd_server_admin_booking_resource_attr_map': [
1077                 ['oncommand'],
1078                 function(event) { open_eg_web_page('conify/global/booking/resource_attr_map', null, event); }
1079             ],
1080             'cmd_local_admin_address_alert' : [
1081                 ['oncommand'],
1082                 function(event) { open_eg_web_page('conify/global/actor/address_alert', null, event); }
1083             ],
1084             'cmd_local_admin_copy_location_group' : [
1085                 ['oncommand'],
1086                 function(event) { open_eg_web_page('conify/global/asset/copy_location_group', null, event); }
1087             ],
1088             'cmd_local_admin_search_filter_group' : [
1089                 ['oncommand'],
1090                 function(event) { open_eg_web_page('conify/global/actor/search_filter_group', null, event); }
1091             ],
1092             'cmd_acq_create_invoice' : [
1093                 ['oncommand'],
1094                 function(event) { open_eg_web_page('acq/invoice/view?create=1', 'menu.cmd_acq_create_invoice.tab', event); }
1095             ],
1096             'cmd_acq_view_my_pl' : [
1097                 ['oncommand'],
1098                 function(event) { open_eg_web_page('acq/search/unified?ca=pl', 'menu.cmd_acq_unified_search.tab', event); }
1099             ],
1100             'cmd_acq_view_local_po' : [
1101                 ['oncommand'],
1102                 function(event) { open_eg_web_page('acq/search/unified?ca=po', 'menu.cmd_acq_unified_search.tab', event); }
1103             ],
1104             'cmd_acq_create_po' : [
1105                 ['oncommand'],
1106                 function(event) { open_eg_web_page('acq/po/create', 'menu.cmd_acq_po.tab', event); }
1107             ],
1108             'cmd_acq_view_local_inv' : [
1109                 ['oncommand'],
1110                 function(event) { open_eg_web_page('acq/search/unified?ca=inv', 'menu.cmd_acq_unified_search.tab', event); }
1111             ],
1112             'cmd_acq_user_requests' : [
1113                 ['oncommand'],
1114                 function(event) { open_eg_web_page('acq/picklist/user_request', 'menu.cmd_acq_user_requests.tab', event); }
1115             ],
1116             'cmd_acq_upload' : [
1117                 ['oncommand'],
1118                 function(event) { open_eg_web_page('acq/picklist/upload', 'menu.cmd_acq_upload.tab', event); }
1119             ],
1120             'cmd_acq_bib_search' : [
1121                 ['oncommand'],
1122                 function(event) { open_eg_web_page('acq/picklist/bib_search', 'menu.cmd_acq_bib_search.tab', event); }
1123             ],
1124             'cmd_acq_unified_search' : [
1125                 ['oncommand'],
1126                 function(event) { open_eg_web_page('acq/search/unified', 'menu.cmd_acq_unified_search.tab', event); }
1127             ],
1128             'cmd_acq_from_bib' : [
1129                 ['oncommand'],
1130                 function(event) { open_eg_web_page('acq/picklist/from_bib', 'menu.cmd_acq_from_bib.tab', event); }
1131             ],
1132             'cmd_acq_new_brief_record' : [
1133                 ['oncommand'],
1134                 function(event) { open_eg_web_page('acq/picklist/brief_record', 'menu.cmd_acq_new_brief_record.tab', event); }
1135             ],
1136             'cmd_acq_claim_eligible' : [
1137                 ['oncommand'],
1138                 function(event) { open_eg_web_page('acq/financial/claim_eligible', 'menu.cmd_acq_claim_eligible.tab', event); }
1139             ],
1140             'cmd_booking_reservation' : [
1141                 ['oncommand'],
1142                 function(event) {
1143                     open_eg_web_page(
1144                         "/eg/booking/reservation",
1145                         "menu.cmd_booking_reservation.tab",
1146                         event
1147                     );
1148                 }
1149             ],
1150             'cmd_booking_pull_list' : [
1151                 ['oncommand'],
1152                 function(event) {
1153                     open_eg_web_page(
1154                         "/eg/booking/pull_list",
1155                         "menu.cmd_booking_pull_list.tab",
1156                         event
1157                     );
1158                 }
1159             ],
1160             'cmd_booking_capture' : [
1161                 ['oncommand'],
1162                 function(event) {
1163                     open_eg_web_page(
1164                         "/eg/booking/capture",
1165                         "menu.cmd_booking_capture.tab",
1166                         event
1167                     );
1168                 }
1169             ],
1170             'cmd_booking_reservation_pickup' : [
1171                 ['oncommand'],
1172                 function(event) {
1173                     open_eg_web_page(
1174                         "/eg/booking/pickup",
1175                         "menu.cmd_booking_reservation_pickup.tab",
1176                         event
1177                     );
1178                 }
1179             ],
1180             'cmd_booking_reservation_return' : [
1181                 ['oncommand'],
1182                 function(event) {
1183                     open_eg_web_page(
1184                         "/eg/booking/return",
1185                         "menu.cmd_booking_reservation_return.tab",
1186                         event
1187                     );
1188                 }
1189             ],
1190             'cmd_reprint' : [
1191                 ['oncommand'],
1192                 function() {
1193                     try {
1194                         JSAN.use('util.print'); var print = new util.print();
1195                         print.reprint_last();
1196                     } catch(E) {
1197                         alert(E);
1198                     }
1199                 }
1200             ],
1201
1202             'cmd_retrieve_last_patron' : [
1203                 ['oncommand'],
1204                 function(event) {
1205                     obj.data.stash_retrieve();
1206                     if (!obj.data.last_patron) {
1207                         alert(offlineStrings.getString('menu.cmd_retrieve_last_patron.session.error'));
1208                         return;
1209                     }
1210                     var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
1211                     var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
1212                     obj.command_tab( event, url, {}, { 'id' : obj.data.last_patron } );
1213                 }
1214             ],
1215
1216             'cmd_url_verify' : [
1217                 ['oncommand'],
1218                 function(event) {
1219                     open_eg_web_page(
1220                         "/eg/url_verify/sessions",
1221                         "menu.cmd_url_verify.tab",
1222                         event, {
1223                             'no_xulG': false,
1224                             'show_print_button': false,
1225                             'show_nav_buttons': true 
1226                         }
1227                     );
1228                 }
1229             ],
1230             
1231             'cmd_retrieve_last_record' : [
1232                 ['oncommand'],
1233                 function(event) {
1234                     obj.data.stash_retrieve();
1235                     if (!obj.data.last_record) {
1236                         alert(offlineStrings.getString('menu.cmd_retrieve_last_record.session.error'));
1237                         return;
1238                     }
1239                     var opac_url = obj.url_prefix('opac_rdetail') + obj.data.last_record;
1240                     var content_params = {
1241                         'session' : ses(),
1242                         'authtime' : ses('authtime'),
1243                         'opac_url' : opac_url,
1244                     };
1245                     obj.command_tab(
1246                         event,
1247                         obj.url_prefix('XUL_OPAC_WRAPPER'),
1248                         {'tab_name' : offlineStrings.getString('menu.cmd_retrieve_last_record.status')},
1249                         content_params
1250                     );
1251                 }
1252             ],
1253
1254             'cmd_verify_credentials' : [
1255                 ['oncommand'],
1256                 function(event) {
1257                     obj.command_tab(
1258                         event,
1259                         obj.url_prefix('XUL_VERIFY_CREDENTIALS'),
1260                         { 'tab_name' : offlineStrings.getString('menu.cmd_verify_credentials.tabname') },
1261                         {}
1262                     );
1263                 }
1264             ],
1265
1266             /* Cataloging Menu */
1267             'cmd_z39_50_import' : [
1268                 ['oncommand'],
1269                 function(event) {
1270                     obj.data.stash_retrieve();
1271                     obj.command_tab(event,obj.url_prefix('XUL_Z3950_IMPORT'),{},{});
1272                 }
1273             ],
1274             'cmd_create_marc' : [
1275                 ['oncommand'],
1276                 function(event) {
1277                     obj.data.stash_retrieve();
1278                     obj.command_tab(event,obj.url_prefix('XUL_MARC_NEW'),{},{});
1279                 }
1280             ],
1281
1282             'cmd_authority_manage' : [
1283                 ['oncommand'],
1284                 function(event) {
1285                     open_eg_web_page(
1286                         urls.AUTHORITY_MANAGE,
1287                         "menu.cmd_authority_manage.tab",
1288                         event
1289                     );
1290                 }
1291             ],
1292
1293             'cmd_marc_batch_edit' : [
1294                 ['oncommand'],
1295                 function(event) {
1296                     obj.command_tab(
1297                         event,
1298                         obj.url_prefix('MARC_BATCH_EDIT'),{
1299                             'tab_name' : offlineStrings.getString('menu.cmd_marc_batch_edit.tab')
1300                         },
1301                         {}
1302                     );
1303                 }
1304             ],
1305
1306             /* Admin menu */
1307             'cmd_change_session' : [
1308                 ['oncommand'],
1309                 function() {
1310                     try {
1311                         obj.data.stash_retrieve();
1312                         JSAN.use('util.network'); var network = new util.network();
1313                         var temp_au = js2JSON( obj.data.list.au[0] );
1314                         var temp_ses = js2JSON( obj.data.session );
1315                         if (obj.data.list.au.length > 1) {
1316                             obj.data.list.au = [ obj.data.list.au[1] ];
1317                             obj.data.stash('list');
1318                             network.reset_titlebars( obj.data );
1319                             network.simple_request('AUTH_DELETE', [ obj.data.session.key ] );
1320                             obj.data.session = obj.data.previous_session;
1321                             obj.data.menu_perms = obj.data.previous_menu_perms;
1322                             obj.data.stash('session');
1323                             obj.data.stash('menu_perms');
1324                             try {
1325                                 var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
1326                                 var cookieUriSSL = ios.newURI("https://" + obj.data.server_unadorned, null, null);
1327                                 var cookieSvc = Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);
1328
1329                                 cookieSvc.setCookieString(cookieUriSSL, null, "ses="+obj.data.session.key + "; secure;", null);
1330                             } catch(E) {
1331                                 alert(offlineStrings.getFormattedString(main.session_cookie.error, [E]));
1332                             }
1333                         } else {
1334                             if (network.get_new_session(offlineStrings.getString('menu.cmd_chg_session.label'),{'url_prefix':obj.url_prefix})) {
1335                                 obj.data.stash_retrieve();
1336                                 if (obj.data.session.is_perm === false) {
1337                                     obj.data.list.au[1] = JSON2js( temp_au );
1338                                     obj.data.stash('list');
1339                                     obj.data.previous_session = JSON2js( temp_ses );
1340                                     obj.data.previous_menu_perms = obj.data.menu_perms;
1341                                     obj.data.stash('previous_session');
1342                                     obj.data.stash('previous_menu_perms');
1343                                 } else {
1344                                     var temp_session_object = JSON2js( temp_ses );
1345                                     network.simple_request('AUTH_DELETE', [ temp_session_object.key ] );
1346                                 }
1347                                 obj.data.menu_perms = false;
1348                                 obj.data.stash('menu_perms');
1349                             }
1350                         }
1351                         network.set_user_status();
1352                     } catch(E) {
1353                         obj.error.standard_unexpected_error_alert('cmd_change_session',E);
1354                     }
1355                 }
1356             ],
1357             'cmd_manage_offline_xacts' : [
1358                 ['oncommand'],
1359                 function(event) {
1360                     obj.command_tab(event,obj.url_prefix('XUL_OFFLINE_MANAGE_XACTS'), {'tab_name' : offlineStrings.getString('menu.cmd_manage_offline_xacts.tab')}, {});
1361                 }
1362             ],
1363             'cmd_download_patrons' : [
1364                 ['oncommand'],
1365                 function() {
1366                     try {
1367                         var x = new XMLHttpRequest();
1368                         var url = 'http://' + XML_HTTP_SERVER + '/standalone/list.txt';
1369                         x.open("GET",url,false);
1370                         x.send(null);
1371                         if (x.status == 200) {
1372                             JSAN.use('util.file'); var file = new util.file('offline_patron_list');
1373                             file.write_content('truncate',x.responseText);
1374                             file.close();
1375                             file = new util.file('offline_patron_list.date');
1376                             file.write_content('truncate',new Date());
1377                             file.close();
1378                             alert(offlineStrings.getString('menu.cmd_download_patrons.complete.status'));
1379                         } else {
1380                             alert(offlineStrings.getFormattedString('menu.cmd_download_patrons.error', [x.status, x.statusText]));
1381                         }
1382                     } catch(E) {
1383                         obj.error.standard_unexpected_error_alert('cmd_download_patrons',E);
1384                     }
1385                 }
1386             ],
1387             'cmd_adv_user_edit' : [
1388                 ['oncommand'],
1389                 function(event) {
1390                     obj.data.stash_retrieve();
1391                     obj.command_tab(event,obj.url_prefix('XUL_PATRON_BARCODE_ENTRY'), {}, { 'perm_editor' : true });
1392                 }
1393             ],
1394             'cmd_print_list_template_edit' : [
1395                 ['oncommand'],
1396                 function(event) {
1397                     obj.data.stash_retrieve();
1398                     obj.command_tab(event,obj.url_prefix('XUL_PRINT_LIST_TEMPLATE_EDITOR'), {}, {});
1399                 }
1400             ],
1401             'cmd_stat_cat_edit' : [
1402                 ['oncommand'],
1403                 function(event) {
1404                     obj.data.stash_retrieve();
1405                     obj.command_tab(event,obj.url_prefix('XUL_STAT_CAT_EDIT?ses=') + window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_stat_cat_edit.tab')},{});
1406                 }
1407             ],
1408             'cmd_non_cat_type_edit' : [
1409                 ['oncommand'],
1410                 function(event) {
1411                     obj.data.stash_retrieve();
1412                     obj.command_tab(event,obj.url_prefix('XUL_NON_CAT_LABEL_EDIT?ses=') + window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_non_cat_type_edit.tab')},{});
1413                 }
1414             ],
1415             'cmd_copy_location_edit' : [
1416                 ['oncommand'],
1417                 function(event) {
1418                     obj.data.stash_retrieve();
1419                     obj.command_tab(event,obj.url_prefix('XUL_COPY_LOCATION_EDIT?ses=') + window.escape(ses()),{'tab_name' : offlineStrings.getString('menu.cmd_copy_location_edit.tab')},{});
1420                 }
1421             ],
1422             'cmd_test' : [
1423                 ['oncommand'],
1424                 function(event) {
1425                     obj.data.stash_retrieve();
1426                     var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
1427                     obj.command_tab(event,obj.url_prefix('XUL_OPAC_WRAPPER'), {}, content_params);
1428                 }
1429             ],
1430             'cmd_test_html' : [
1431                 ['oncommand'],
1432                 function(event) {
1433                     obj.data.stash_retrieve();
1434                     obj.command_tab(event,obj.url_prefix('TEST_HTML?ses=') + window.escape(ses()),{ 'browser' : true },{});
1435                 }
1436             ],
1437             'cmd_test_xul' : [
1438                 ['oncommand'],
1439                 function(event) {
1440                     obj.data.stash_retrieve();
1441                     obj.command_tab(event,obj.url_prefix('TEST_XUL?ses=') + window.escape(ses()),{ 'browser' : false },{});
1442                 }
1443             ],
1444             'cmd_console' : [
1445                 ['oncommand'],
1446                 function(event) {
1447                     obj.command_tab(event,obj.url_prefix('XUL_DEBUG_CONSOLE'),{'tab_name' : offlineStrings.getString('menu.cmd_console.tab')},{});
1448                 }
1449             ],
1450             'cmd_shell' : [
1451                 ['oncommand'],
1452                 function(event) {
1453                     obj.command_tab(event,obj.url_prefix('XUL_DEBUG_SHELL'),{'tab_name' : offlineStrings.getString('menu.cmd_shell.tab')},{});
1454                 }
1455             ],
1456             'cmd_xuleditor' : [
1457                 ['oncommand'],
1458                 function(event) {
1459                     obj.command_tab(event,obj.url_prefix('XUL_DEBUG_XULEDITOR'),{'tab_name' : offlineStrings.getString('menu.cmd_xuleditor.tab')},{});
1460                 }
1461             ],
1462             'cmd_fieldmapper' : [
1463                 ['oncommand'],
1464                 function(event) {
1465                     obj.command_tab(event,obj.url_prefix('XUL_DEBUG_FIELDMAPPER'),{'tab_name' : offlineStrings.getString('menu.cmd_fieldmapper.tab')},{});
1466                 }
1467             ],
1468             'cmd_survey_wizard' : [
1469                 ['oncommand'],
1470                 function() {
1471                     obj.data.stash_retrieve();
1472                     xulG.window.open(obj.url_prefix('XUL_SURVEY_WIZARD'),'survey_wizard','chrome'); 
1473                 }
1474             ],
1475             'cmd_public_opac' : [
1476                 ['oncommand'],
1477                 function(event) {
1478                     var loc = urls.XUL_BROWSER + '?url=' + window.escape(
1479                         obj.url_prefix('remote')
1480                     );
1481                     obj.command_tab(
1482                         event,
1483                         loc, 
1484                         {'tab_name' : offlineStrings.getString('menu.cmd_public_opac.tab'), 'browser' : false}, 
1485                         { 'no_xulG' : true, 'show_nav_buttons' : true, 'show_print_button' : true } 
1486                     );
1487                 }
1488             ],
1489             'cmd_clear_cache' : [
1490                 ['oncommand'],
1491                 function clear_the_cache() {
1492                     try {
1493                         var cacheClass         = Components.classes["@mozilla.org/network/cache-service;1"];
1494                         var cacheService    = cacheClass.getService(Components.interfaces.nsICacheService);
1495                         cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
1496                         cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
1497                     } catch(E) {
1498                         dump(E+'\n');alert(E);
1499                     }
1500                 }
1501             ],
1502             'cmd_restore_all_tabs' : [
1503                 ['oncommand'],
1504                 function() {
1505                     var tabs = obj.controller.view.tabs;
1506                     for (var i = 0; i < tabs.childNodes.length; i++) {
1507                         tabs.childNodes[i].hidden = false;
1508                     }
1509                 }
1510             ],
1511             'cmd_extension_manager' : [
1512                 ['oncommand'],
1513                 function(event) {
1514                     obj.command_tab(event,'chrome://mozapps/content/extensions/extensions.xul?type=extensions',{'tab_name' : offlineStrings.getString('menu.cmd_extension_manager.tab')},{});
1515                 }
1516             ],
1517             'cmd_theme_manager' : [
1518                 ['oncommand'],
1519                 function(event) {
1520                     obj.command_tab(event,'chrome://mozapps/content/extensions/extensions.xul?type=themes',{'tab_name' : offlineStrings.getString('menu.cmd_theme_manager.tab')},{});
1521                 }
1522             ],
1523             'cmd_about_config' : [
1524                 ['oncommand'],
1525                 function(event) {
1526                     obj.command_tab(event,'chrome://global/content/config.xul',{'tab_name' : 'about:config'},{});
1527                 }
1528             ],
1529             'cmd_about_about' : [
1530                 ['oncommand'],
1531                 function(event) {
1532                     obj.command_tab(event,'chrome://global/content/aboutAbout.xhtml',{'tab_name' : 'about:about'},{});
1533                 }
1534             ],
1535             'cmd_shutdown' : [
1536                 ['oncommand'],
1537                 function() {
1538                     var confirm_string = offlineStrings.getString('menu.cmd_shutdown.prompt');
1539                     obj.data.stash_retrieve();
1540                     if (typeof obj.data.unsaved_data != 'undefined') {
1541                         if (obj.data.unsaved_data > 0) {
1542                             confirm_string = offlineStrings.getString('menu.shutdown.unsaved_data_warning');
1543                         }
1544                     }
1545                     if (window.confirm(confirm_string)) {
1546                         obj.data.unsaved_data = 0; // just in case the program doesn't close somehow
1547                         obj.data.stash('unsaved_data');
1548                         dump('forcing data.unsaved_data == ' + obj.data.unsaved_data + '\n');
1549                         var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
1550                         var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
1551                         var enumerator = windowManagerInterface.getEnumerator(null);
1552                         var w; // close all other windows
1553                         while ( w = enumerator.getNext() ) {
1554                             if (w != window) {
1555                                 if (w.xulG) { w.close(); } // FIXME: kludge so we don't close Firefox windows as an extension.  We should define a @windowtype for all the staff client windows and have the enumerator just pull those
1556                             }
1557                         }
1558                         window.close();
1559                     }
1560                 }
1561             ],
1562             'cmd_hotkeys_toggle' : [
1563                 ['oncommand'],
1564                 function() {
1565                     // Easy enough, toggle disabled on the keyset
1566                     var keyset = document.getElementById("menu_frame_keys");
1567                     var disabled = (keyset.getAttribute("disabled") == "true") ? "false" : "true";
1568                     if(disabled == "true")
1569                         keyset.setAttribute("disabled", "true");
1570                     else
1571                         keyset.removeAttribute("disabled");
1572                     // Then find every menuitem/toolbarbutton for this command for a graphical hint
1573                     var controls = document.getElementsByAttribute("command","cmd_hotkeys_toggle");
1574                     for(var i = 0; i < controls.length; i++)
1575                         controls[i].setAttribute("checked",disabled);
1576                 }
1577             ],
1578             'cmd_hotkeys_set' : [
1579                 ['oncommand'],
1580                 function(event) {
1581                     obj.set_menu_hotkeys(event.explicitOriginalTarget.getAttribute('value'));
1582                 }
1583             ],
1584             'cmd_hotkeys_setworkstation' : [
1585                 ['oncommand'],
1586                 function() {
1587                     xulG.pref.setCharPref('open-ils.menu.hotkeyset', obj.data.current_hotkeyset);
1588                 }
1589             ],
1590             'cmd_hotkeys_clearworkstation' : [
1591                 ['oncommand'],
1592                 function() {
1593                     if(xulG.pref.prefHasUserValue('open-ils.menu.hotkeyset'))
1594                         xulG.pref.clearUserPref('open-ils.menu.hotkeyset');
1595                 }
1596             ],
1597             'cmd_toolbar_set' : [
1598                 ['oncommand'],
1599                 function(event) {
1600                     var newToolbar = event.explicitOriginalTarget.getAttribute('value');
1601                     obj.render_toolbar(newToolbar);
1602                     obj.toolbar = newToolbar;
1603                 }
1604             ],
1605             'cmd_toolbar_mode_set' : [
1606                 ['oncommand'],
1607                 function(event) {
1608                     var newMode = event.explicitOriginalTarget.getAttribute('value');
1609                     var toolbox = document.getElementById('main_toolbox');
1610                     var toolbars = toolbox.getElementsByTagName('toolbar');
1611                     for(var i = 0; i < toolbars.length; i++)
1612                         toolbars[i].setAttribute("mode",newMode);
1613                     obj.toolbar_mode = newMode;
1614                 }
1615             ],
1616             'cmd_toolbar_size_set' : [
1617                 ['oncommand'],
1618                 function(event) {
1619                     var newSize = event.explicitOriginalTarget.getAttribute('value');
1620                     var toolbox = document.getElementById('main_toolbox');
1621                     var toolbars = toolbox.getElementsByTagName('toolbar');
1622                     for(var i = 0; i < toolbars.length; i++)
1623                         toolbars[i].setAttribute("iconsize",newSize);
1624                     obj.toolbar_size = newSize;
1625                 }
1626             ],
1627             'cmd_toolbar_label_position_set' : [
1628                 ['oncommand'],
1629                 function(event) {
1630                     var altPosition = (event.explicitOriginalTarget.getAttribute('value') == "under");
1631                     var toolbox = document.getElementById('main_toolbox');
1632                     var toolbars = toolbox.getElementsByTagName('toolbar');
1633                     for(var i = 0; i < toolbars.length; i++) {
1634                         if(altPosition)
1635                             addCSSClass(toolbars[i], 'labelbelow');
1636                         else
1637                             removeCSSClass(toolbars[i], 'labelbelow');
1638                     }
1639                     obj.toolbar_labelpos = (altPosition ? "under" : "side");
1640                 }
1641             ],
1642             'cmd_toolbar_configure' : [
1643                 ['oncommand'],
1644                 function(event) {
1645                     var url = obj.url_prefix( 'XUL_TOOLBAR_CONFIG' ); 
1646                     obj.command_tab(event,url,{},{});
1647                 }
1648             ],
1649             'cmd_toolbar_setworkstation' : [
1650                 ['oncommand'],
1651                 function() {
1652                 xulG.pref.setCharPref('open-ils.menu.toolbar', obj.toolbar);
1653                 xulG.pref.setCharPref('open-ils.menu.toolbar.iconsize', obj.toolbar_size);
1654                 xulG.pref.setCharPref('open-ils.menu.toolbar.mode', obj.toolbar_mode);
1655                 xulG.pref.setBoolPref('open-ils.menu.toolbar.labelbelow', (obj.toolbar_labelpos == "under"));
1656                 }
1657             ],
1658             'cmd_toolbar_clearworkstation' : [
1659                 ['oncommand'],
1660                 function() {
1661                     if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar'))
1662                         xulG.pref.clearUserPref('open-ils.menu.toolbar');
1663                     if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.iconsize'))
1664                         xulG.pref.clearUserPref('open-ils.menu.toolbar.iconsize');
1665                     if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.mode'))
1666                         xulG.pref.clearUserPref('open-ils.menu.toolbar.mode');
1667                     if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.labelbelow'))
1668                         xulG.pref.clearUserPref('open-ils.menu.toolbar.labelbelow');
1669                 }
1670             ],
1671             'cmd_debug_venkman' : [
1672                 ['oncommand'],
1673                 function() {
1674                     try{
1675                         xulG.window.win.start_debugger();
1676                     } catch(E) {
1677                         alert(E);
1678                     }
1679                 }
1680             ],
1681             'cmd_debug_inspector' : [
1682                 ['oncommand'],
1683                 function() {
1684                     try{
1685                         xulG.window.win.start_inspector();
1686                     } catch(E) {
1687                         alert(E);
1688                     }
1689                 }
1690             ],
1691             'cmd_debug_chrome_list' : [
1692                 ['oncommand'],
1693                 function() {
1694                     try{
1695                         xulG.window.win.start_chrome_list();
1696                     } catch(E) {
1697                         alert(E);
1698                     }
1699                 }
1700             ],
1701             'cmd_debug_chrome_shell' : [
1702                 ['oncommand'],
1703                 function() {
1704                     try{
1705                         xulG.window.win.start_js_shell();
1706                     } catch(E) {
1707                         alert(E)
1708                     }
1709                 }
1710             ],
1711             'cmd_copy_editor_copy_location_first_toggle' : [
1712                 ['oncommand'],
1713                 function() {
1714                     var curvalue = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
1715                     xulG.pref.setBoolPref('oils.copy_editor.copy_location_name_first', !curvalue);
1716                 }
1717             ],
1718             'cmd_search_prefs' : [
1719                 ['oncommand'],
1720                 function() {
1721                     try {
1722                         obj.set_tab(obj.url_prefix('XUL_SEARCH_PREFS'),{'tab_name' : offlineStrings.getString('menu.cmd_search_prefs.tab'), 'browser' : false});
1723                     } catch(E) {
1724                         alert(E)
1725                     }
1726                 }
1727             ],
1728         };
1729
1730         JSAN.use('util.controller');
1731         var cmd;
1732         obj.controller = new util.controller();
1733         obj.controller.init( { 'window_knows_me_by' : 'g.menu.controller', 'control_map' : cmd_map } );
1734
1735         obj.controller.view.tabbox = window.document.getElementById('main_tabbox');
1736         // Despite what the docs say:
1737         // The "tabs" element need not be the first child
1738         // The "panels" element need not be the second/last
1739         // Nor need they be the only ones there.
1740         // Thus, use the IDs for robustness.
1741         obj.controller.view.tabs = window.document.getElementById('main_tabs');
1742         obj.controller.view.panels = window.document.getElementById('main_panels');
1743         obj.controller.view.tabscroller = window.document.getElementById('main_tabs_scrollbox');
1744
1745         obj.sort_menu(document.getElementById('main.menu.admin'), true);
1746
1747         if(params['firstURL']) {
1748             obj.new_tab(params['firstURL'],{'focus':true},null);
1749         }
1750         else {
1751             obj.new_tab(null,{'focus':true},null);
1752         }
1753     },
1754
1755     'button_bar_init' : function() {
1756         try {
1757
1758             var obj = this;
1759
1760             JSAN.use('util.widgets');
1761
1762             // populate the menu of available toolbars
1763             var x = document.getElementById('main.menu.admin.client.toolbars.current.popup');
1764             if (x) {
1765                 util.widgets.remove_children(x);
1766
1767                 function create_menuitem(label,value,checked) {
1768                     var menuitem = document.createElement('menuitem');
1769                         menuitem.setAttribute('name','current_toolbar');
1770                         menuitem.setAttribute('type','radio');
1771                         menuitem.setAttribute('label',label);
1772                         menuitem.setAttribute('value',value);
1773                         menuitem.setAttribute('command','cmd_toolbar_set');
1774                         if (checked) menuitem.setAttribute('checked','true');
1775                     return menuitem;
1776                 }
1777
1778                 x.appendChild(
1779                     create_menuitem(
1780                         offlineStrings.getString('staff.main.button_bar.none'),
1781                         'none',
1782                         true
1783                     )
1784                 );
1785
1786                 x.appendChild(
1787                     create_menuitem(
1788                         offlineStrings.getString('staff.main.button_bar.default'),
1789                         'default',
1790                         true
1791                     )
1792                 );
1793
1794                 for (var i = 0; i < this.data.list.atb.length; i++) {
1795                     var def = this.data.list.atb[i];
1796                     x.appendChild(
1797                         create_menuitem(
1798                             def.label(),
1799                             def.id()
1800                         )
1801                     );
1802                 }
1803             }
1804
1805             // Try workstation pref for button bar
1806             var button_bar = xulG.pref.getCharPref('open-ils.menu.toolbar');
1807
1808             if (!button_bar) { // No workstation pref? Try org unit pref.
1809                 if (obj.data.hash.aous['ui.general.button_bar']) {
1810                     button_bar = String( obj.data.hash.aous['ui.general.button_bar'] );
1811                 }
1812             }
1813
1814             if (button_bar) {
1815                 this.render_toolbar(button_bar);
1816                 this.toolbar = button_bar;
1817             }
1818
1819             // Check for alternate Size pref
1820             var toolbar_size = xulG.pref.getCharPref('open-ils.menu.toolbar.iconsize');
1821             if(toolbar_size) this.toolbar_size = toolbar_size;
1822             // Check for alternate Mode pref
1823             var toolbar_mode = xulG.pref.getCharPref('open-ils.menu.toolbar.mode');
1824             if(toolbar_mode) this.toolbar_mode = toolbar_mode;
1825             // Check for alternate Label Position pref
1826             var toolbar_labelpos = xulG.pref.getBoolPref('open-ils.menu.toolbar.labelbelow');
1827             if(toolbar_labelpos) this.toolbar_labelpos = toolbar_labelpos;
1828
1829             if(button_bar || toolbar_size || toolbar_mode || toolbar_labelpos) {
1830                 var toolbar = document.getElementById('toolbar_main');
1831                 if(toolbar_mode) toolbar.setAttribute('mode', toolbar_mode);
1832                 if(toolbar_size) toolbar.setAttribute('iconsize', toolbar_size);
1833                 if(toolbar_labelpos) addCSSClass(toolbar, 'labelbelow');
1834             }
1835
1836             if(button_bar) {
1837                 var x = document.getElementById('main.menu.admin.client.toolbars.current.popup');
1838                 if (x) {
1839                     var selectitems = x.getElementsByAttribute('value',button_bar);
1840                     if(selectitems.length < 1) selecteditems = x.getElementsByAttribute('value','default');
1841                     if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1842                 }
1843             }
1844
1845             if(toolbar_size) {
1846                 var x = document.getElementById('main.menu.admin.client.toolbars.size.popup');
1847                 if (x) {
1848                     var selectitems = x.getElementsByAttribute('value',toolbar_size);
1849                     if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1850                 }
1851             }
1852
1853             if(toolbar_mode) {
1854                 var x = document.getElementById('main.menu.admin.client.toolbars.mode.popup');
1855                 if (x) {
1856                     var selectitems = x.getElementsByAttribute('value',toolbar_mode);
1857                     if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1858                 }
1859             }
1860
1861             if(toolbar_labelpos) {
1862                 var x = document.getElementById('main.menu.admin.client.toolbars.label_position.popup');
1863                 if (x) {
1864                     var selectitems = x.getElementsByAttribute('value',"under");
1865                     if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1866                 }
1867             }
1868
1869             // stash the available toolbar buttons for later use in the toolbar editing interface
1870             if (typeof this.data.toolbar_buttons == 'undefined') {
1871                 this.data.toolbar_buttons = {};
1872                 var nl = $('palette').childNodes;
1873                 for (var i = 0; i < nl.length; i++) {
1874                     var id = nl[i].getAttribute('templateid');
1875                     var label = nl[i].getAttribute('label');
1876                     if (id && label) {
1877                         this.data.toolbar_buttons[ id ] = label;
1878                     }
1879                 }
1880                 this.data.stash('toolbar_buttons');
1881             }
1882
1883         } catch(E) {
1884             alert('Error in menu.js, button_bar_init(): ' + E);
1885         }
1886     },
1887
1888     'spawn_search' : function(s) {
1889         var obj = this;
1890         obj.error.sdump('D_TRACE', offlineStrings.getFormattedString('menu.spawn_search.msg', [js2JSON(s)]) ); 
1891         obj.new_patron_tab( {}, { 'doit' : 1, 'query' : js2JSON(s) } );
1892     },
1893
1894     'close_all_tabs' : function() {
1895         var obj = this;
1896         try {
1897             var count = obj.controller.view.tabs.childNodes.length;
1898             for (var i = 1; i < count; i++) obj.close_tab();
1899             setTimeout( function(){ obj.controller.view.tabs.firstChild.focus(); }, 0);
1900         } catch(E) {
1901             obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.close_all_tabs.error'),E);
1902         }
1903     },
1904
1905     'close_tab' : function (specific_idx) {
1906         var idx = specific_idx || this.controller.view.tabs.selectedIndex;
1907         var panel = this.controller.view.panels.childNodes[ idx ];
1908
1909         var tab = this.controller.view.tabs.getItemAtIndex( idx );
1910         var id = tab.getAttribute('id');
1911         if (typeof this.tab_semaphores[id] != 'undefined') {
1912             if (this.tab_semaphores[id] > 0) {
1913                 var confirmation = window.confirm(offlineStrings.getString('menu.close_tab.unsaved_data_warning'));
1914                 if (!confirmation) { return; }
1915                 oils_unsaved_data_P( this.tab_semaphores[id] );
1916             }
1917             delete this.tab_semaphores[id];
1918         }
1919
1920         this.controller.view.tabs.removeItemAt(idx);
1921         this.controller.view.panels.removeChild(panel);
1922         if(this.controller.view.tabs.childNodes.length > idx) {
1923             this.controller.view.tabbox.selectedIndex = idx;
1924         }
1925         else {
1926             this.controller.view.tabbox.selectedIndex = idx - 1;
1927         }
1928         this.controller.view.tabscroller.ensureElementIsVisible(this.controller.view.tabs.selectedItem);
1929         this.update_all_tab_names();
1930         // Make sure we keep at least one tab open.
1931         if(this.controller.view.tabs.childNodes.length == 1) {
1932             this.new_tab(); 
1933         }
1934     },
1935     
1936     'update_all_tab_names' : function() {
1937         var doAccessKeys = !xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs');
1938         for(var i = 1; i < this.controller.view.tabs.childNodes.length; ++i) {
1939             var tab = this.controller.view.tabs.childNodes[i];
1940             tab.curindex = i;
1941             tab.label = i + ' ' + tab.origlabel;
1942             if(doAccessKeys && offlineStrings.testString('menu.tab' + i + '.accesskey')) {
1943                 tab.accessKey = offlineStrings.getString('menu.tab' + i + '.accesskey');
1944             }
1945         }
1946     },
1947
1948     'command_tab' : function(event,url,params,content_params) {
1949         var newTab = false;
1950         var myEvent = event;
1951         if(event && event.sourceEvent) myEvent = event.sourceEvent;
1952         // Note: The last event is not supposed to be myEvent in this if.
1953         if(myEvent && myEvent.explicitOriginalTarget.nodeName.match(/toolbarbutton/) && myEvent.explicitOriginalTarget.command == event.originalTarget.id) {
1954             var value = xulG.pref.getIntPref('ui.key.accelKey');
1955             switch(value) {
1956                 case 17:
1957                     newTab = myEvent.ctrlKey;
1958                     break;
1959                 case 18:
1960                     newTab = myEvent.altKey;
1961                     break;
1962                 case 224:
1963                     newTab = myEvent.metaKey;
1964                     break;
1965             }
1966             try {
1967                 if(xulG.pref.getBoolPref('open-ils.toolbar.defaultnewtab')) {
1968                     newTab = !newTab;
1969                 }
1970             }
1971             catch (e) {
1972             }
1973         }
1974         if(newTab) {
1975             this.new_tab(url,params,content_params);
1976         }
1977         else {
1978             this.set_tab(url,params,content_params);
1979         }
1980     },
1981
1982     'new_tab' : function(url,params,content_params) {
1983         var obj = this;
1984         var max_tabs = 0;
1985         try {
1986             var max_tabs = xulG.pref.getIntPref('open-ils.window_max_tabs') || max_tabs;
1987         }
1988         catch (e) {}
1989         if(max_tabs > 0 && this.controller.view.tabs.childNodes.length > max_tabs) return false;
1990         var tab = this.w.document.createElement('tab');
1991         var panel = this.w.document.createElement('tabpanel');
1992         var tabscroller = this.controller.view.tabscroller;
1993         this.controller.view.tabs.appendChild(tab);
1994         this.controller.view.panels.appendChild(panel);
1995         tab.curindex = this.controller.view.tabs.childNodes.length - 1;
1996         if(!xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs')) {
1997             if(offlineStrings.testString('menu.tab' + tab.curindex + '.accesskey')) {
1998                 tab.accessKey = offlineStrings.getString('menu.tab' + tab.curindex + '.accesskey');
1999             }
2000         }
2001         var tabs = this.controller.view.tabs;
2002         tab.addEventListener(
2003             'command',
2004             function() {
2005                 try {
2006                     tabscroller.ensureElementIsVisible(tab);
2007                     if (panel
2008                         && panel.firstChild 
2009                         && ( panel.firstChild.nodeName == 'iframe' || panel.firstChild.nodeName == 'browser' )
2010                         && panel.firstChild.contentWindow 
2011                     ) {
2012                         var cw = panel.firstChild.contentWindow;
2013                         var help_params = {
2014                             'protocol' : cw.location.protocol,
2015                             'hostname' : cw.location.hostname,
2016                             'port' : cw.location.port,
2017                             'pathname' : cw.location.pathname,
2018                             'src' : ''
2019                         };
2020                         obj.set_help_context(help_params);
2021                         if (typeof cw.default_focus == 'function') {
2022                             cw.default_focus();
2023                         }
2024                     }
2025                 } catch(E) {
2026                     obj.error.sdump('D_ERROR','init_tab_focus_handler: ' + js2JSON(E));
2027                 }
2028             }
2029             ,
2030             false
2031         );
2032         if (!content_params) content_params = {};
2033         if (!params) params = {};
2034         if (!params.tab_name) params.tab_name = offlineStrings.getString('menu.new_tab.tab');
2035         if (!params.nofocus) params.focus = true; /* make focus the default */
2036         try {
2037             if (params.focus) {
2038                 this.controller.view.tabs.selectedItem = tab;
2039                 tabscroller.ensureElementIsVisible(tab);
2040             }
2041             params.index = tab.curindex;
2042             this.set_tab(url,params,content_params);
2043             return true;
2044         } catch(E) {
2045             this.error.sdump('D_ERROR',E);
2046             return false;
2047         }
2048     },
2049
2050     'set_menu_access' : function(perms) {
2051         if(perms === false) return;
2052         var commands = document.getElementById('universal_cmds').getElementsByTagName('command');
2053         var commandperms;
2054 commands:
2055         for (var i = 0; i < commands.length; i++) { 
2056             if (commands[i].hasAttribute('perm')) {
2057                 commandperms = commands[i].getAttribute('perm').split(' ');
2058                 for (var j = 0; j < commandperms.length; j++) {
2059                     if (perms[commandperms[j]]) {
2060                         commands[i].setAttribute('disabled','false');
2061                         continue commands;
2062                     }
2063                 }
2064                 commands[i].setAttribute('disabled','true');
2065             }           
2066         }
2067
2068     },
2069
2070     'set_menu_hotkeys' : function(hotkeyset) {
2071         this.data.stash_retrieve();
2072
2073         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
2074                     getService(Components.interfaces.nsIWindowMediator);
2075         var mainwin = wm.getMostRecentWindow('eg_main');
2076         JSAN.use('util.network');
2077         var network = new util.network();
2078
2079         if(hotkeyset) { // Explicit request
2080             // Store
2081             this.data.current_hotkeyset = hotkeyset;
2082             this.data.stash('current_hotkeyset');
2083             // Then iterate over windows
2084             var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
2085             var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
2086             var enumerator = windowManagerInterface.getEnumerator('eg_menu');
2087
2088             var w;
2089             while ( w = enumerator.getNext() ) {
2090                 if ( w != window )
2091                     w.g.menu.set_menu_hotkeys();
2092             }
2093         }
2094         else { // Non-explicit request?
2095             if(this.data.current_hotkeyset) // Previous hotkeyset?
2096                 hotkeyset = this.data.current_hotkeyset; // Use it
2097             else { // No previous? We need to decide on one!
2098                 // Load the list so we know if what we are being asked to load is valid.
2099                 var hotkeysets = mainwin.load_hotkey_sets();
2100                 if(!hotkeysets) return; // No sets = nothing to load. Which is probably an error, but meh.
2101                 hotkeysets.has = function(test) {
2102                     for(i = 0; i < this.length; i++) {
2103                         if(this[i] == test) return true;
2104                     }
2105                     return false;
2106                 }; 
2107                 // Try workstation (pref)
2108                 hotkeyset = xulG.pref.getCharPref('open-ils.menu.hotkeyset');
2109
2110                 // Nothing or nothing valid?
2111                 if(!hotkeyset || !hotkeysets.has(hotkeyset)) {
2112                     hotkeyset = this.data.hash.aous['ui.general.hotkeyset'];
2113                 }
2114                 // STILL nothing? Try Default.
2115                 if(!hotkeyset || !hotkeysets.has(hotkeyset)) {
2116                     if(hotkeysets.has('Default'))
2117                         hotkeyset = 'Default';
2118                     else
2119                         return false;
2120                 }
2121                 // And save whatever we are using.
2122                 this.data.current_hotkeyset = hotkeyset;
2123                 this.data.stash('current_hotkeyset');
2124             }
2125         }
2126         // Clear out all the old hotkeys
2127         var keyset = document.getElementById('menu_frame_keys');
2128         var main_menu = document.getElementById('main_menubar');
2129         if(keyset.hasChildNodes()) {
2130             var menuitems = main_menu.getElementsByAttribute('key','*');
2131             while(menuitems.length > 0) {
2132                 var menuitem = menuitems[0];
2133                 menuitem.removeAttribute('key');
2134                 // Trick/force mozilla to re-evaluate the menuitem
2135                 // If you want to take this trick for use *anywhere* in *any* project, regardless of licensing, please do
2136                 // Because it was a PITA to figure out
2137                 menuitem.style.display = 'none'; // Hide the item to force menu to clear spot
2138                 menuitem.setAttribute('acceltext', ''); // Set acceltext to blank string outright
2139                 menuitem.removeAttribute('acceltext'); // Remove acceltext to clear out hotkey hint text
2140                 menuitem.parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself
2141                 menuitem.parentNode.hidePopup(); // And then make it go away right away.
2142                 menuitem.style.removeProperty('display'); // Restore normal css display
2143             }
2144             while(keyset.hasChildNodes()) keyset.removeChild(keyset.childNodes[0]);
2145         }
2146         keyset_lines = mainwin.get_hotkey_array(hotkeyset);
2147         // Next, fill the keyset
2148         for(var line = 0; line < keyset_lines.length; line++) {
2149             // Create and populate our <key>
2150             var key_node = document.createElement('key');
2151             key_node.setAttribute('id',keyset_lines[line][0] + "_key");
2152             key_node.setAttribute('command',keyset_lines[line][0]);
2153             key_node.setAttribute('modifiers',keyset_lines[line][1]);
2154             // If keycode starts with VK_ we assume it is a key code.
2155             // Key codes go in the keycode attribute
2156             // Regular keys (like "i") go in the key attribute
2157             if(keyset_lines[line][2].match(/^VK_/))
2158                 key_node.setAttribute('keycode',keyset_lines[line][2]);
2159             else
2160                 key_node.setAttribute('key',keyset_lines[line][2]);
2161             // If a fourth option was specified, set keytext to it.
2162             if(keyset_lines[line][3])
2163                 key_node.setAttribute('keytext',keyset_lines[line][3]);
2164             // Add the new node to the DOM
2165             keyset.appendChild(key_node);
2166             // And populate all the menu items that should now display it
2167             var menuitems = main_menu.getElementsByAttribute('command',keyset_lines[line][0]);
2168             for(var i = 0; i < menuitems.length; i++) {
2169                 menuitems[i].setAttribute('key', keyset_lines[line][0] + "_key");
2170                 // Trick/force mozilla to re-evaluate the menuitem
2171                 menuitems[i].style.display = 'none'; // Hide the item to force menu to clear spot
2172                 menuitems[i].parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself
2173                 menuitems[i].parentNode.hidePopup(); // And then make it go away right away
2174                 menuitems[i].style.removeProperty('display'); // Restore normal css display
2175             }
2176         }
2177         // Force reload of keyset cache?
2178         keyset.parentNode.insertBefore(keyset, keyset.nextSibling);
2179         // If no keys, disable ability to toggle hotkeys (because why bother?)
2180         var x = document.getElementById('cmd_hotkeys_toggle');
2181         if(x) {
2182             if(keyset.hasChildNodes())
2183                 x.removeAttribute('disabled');
2184             else
2185                 x.setAttribute('disabled', 'true');
2186         }
2187         // Select the hotkey set in the menu
2188         // This ensures that first window load OR remote window update shows properly
2189         var hotkeylist = document.getElementById('main.menu.admin.client.hotkeys.current.popup');
2190         var selectitems = hotkeylist.getElementsByAttribute('value',hotkeyset);
2191         if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
2192     },
2193
2194     'page_meter' : {
2195         'node' : document.getElementById('page_progress'),
2196         'on' : function() {
2197             document.getElementById('page_progress').setAttribute('mode','undetermined');
2198         },
2199         'off' : function() {
2200             document.getElementById('page_progress').setAttribute('mode','determined');
2201         },
2202         'tooltip' : function(text) {
2203             if (text || text == '') {
2204                 document.getElementById('page_progress').setAttribute('tooltiptext',text);
2205             }
2206             return document.getElementById('page_progress').getAttribute('tooltiptext');
2207         }
2208     },
2209
2210     'network_meter' : {
2211         'inc' : function(app,method) {
2212             try {
2213                 var m = document.getElementById('network_progress');
2214                 var count = 1 + Number( m.getAttribute('count') );
2215                 m.setAttribute('mode','undetermined');
2216                 m.setAttribute('count', count);
2217                 var rows = document.getElementById('network_progress_rows');
2218                 var row = document.getElementById('network_progress_tip_'+app+'_'+method);
2219                 if (!row) {
2220                     row = document.createElement('row'); row.setAttribute('id','network_progress_tip_'+app+'_'+method);
2221                     var a = document.createElement('label'); a.setAttribute('value','App:');
2222                     var b = document.createElement('label'); b.setAttribute('value',app);
2223                     var c = document.createElement('label'); c.setAttribute('value','Method:');
2224                     var d = document.createElement('label'); d.setAttribute('value',method);
2225                     var e = document.createElement('label'); e.setAttribute('value','Total:');
2226                     var f = document.createElement('label'); f.setAttribute('value','0'); 
2227                     f.setAttribute('id','network_progress_tip_total_'+app+'_'+method);
2228                     var g = document.createElement('label'); g.setAttribute('value','Outstanding:');
2229                     var h = document.createElement('label'); h.setAttribute('value','0');
2230                     h.setAttribute('id','network_progress_tip_out_'+app+'_'+method);
2231                     row.appendChild(a); row.appendChild(b); row.appendChild(c);
2232                     row.appendChild(d); row.appendChild(e); row.appendChild(f);
2233                     row.appendChild(g); row.appendChild(h); rows.appendChild(row);
2234                 }
2235                 var total = document.getElementById('network_progress_tip_total_'+app+'_'+method);
2236                 if (total) {
2237                     total.setAttribute('value', 1 + Number( total.getAttribute('value') ));
2238                 }
2239                 var out = document.getElementById('network_progress_tip_out_'+app+'_'+method);
2240                 if (out) {
2241                     out.setAttribute('value', 1 + Number( out.getAttribute('value') ));
2242                 }
2243             } catch(E) {
2244                 dump('network_meter.inc(): ' + E + '\n');
2245             }
2246         },
2247         'dec' : function(app,method) {
2248             try {
2249                 var m = document.getElementById('network_progress');
2250                 var count = -1 + Number( m.getAttribute('count') );
2251                 if (count < 0) count = 0;
2252                 if (count == 0) m.setAttribute('mode','determined');
2253                 m.setAttribute('count', count);
2254                 var out = document.getElementById('network_progress_tip_out_'+app+'_'+method);
2255                 if (out) {
2256                     out.setAttribute('value', -1 + Number( out.getAttribute('value') ));
2257                 }
2258             } catch(E) {
2259                 dump('network_meter.dec(): ' + E + '\n');
2260             }
2261         }
2262     },
2263     'set_patron_tab' : function(params,content_params,event) {
2264         var obj = this;
2265         var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
2266         var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
2267         obj.command_tab(event,url,params ? params : {},content_params ? content_params : {});
2268     },
2269     'new_patron_tab' : function(params,content_params) {
2270         var obj = this;
2271         var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
2272         var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
2273         obj.new_tab(url,params ? params : {},content_params ? content_params : {});
2274     },
2275     'volume_item_creator' : function(params) {
2276         var obj = this;
2277         var url;
2278         var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
2279         if (unified_interface) {
2280             var horizontal_interface = String( obj.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
2281             url = obj.url_prefix( horizontal_interface ? 'XUL_VOLUME_COPY_CREATOR_HORIZONTAL' : 'XUL_VOLUME_COPY_CREATOR' );
2282         } else {
2283             url = obj.url_prefix('XUL_VOLUME_COPY_CREATOR_ORIGINAL');
2284         }
2285         var w = obj.new_tab(
2286             url,
2287             { 'tab_name' : document.getElementById('offlineStrings').getString('staff.cat.create_or_rebarcode_items') },
2288             params
2289         );
2290     },
2291     'holdings_maintenance_tab' : function(docid,params,content_params) {
2292         var obj = this;
2293         if (!content_params) {
2294             content_params = {};
2295         }
2296         if (docid) {
2297             content_params['docid'] = docid;
2298         }
2299         var url = obj.url_prefix('XUL_COPY_VOLUME_BROWSE');
2300         obj.new_tab(url,params || {}, content_params);
2301     },
2302     'get_new_session' : function(params) {
2303         var obj = this;
2304         if (!params) { params = {}; }
2305         JSAN.use('util.network'); var net = new util.network();
2306         var result = net.get_new_session(null,{'url_prefix':obj.url_prefix},!params.operator_change);
2307         if (typeof params.callback == 'function') {
2308             return params.callback( result, ses(), ses('authtime') );
2309         }
2310         return result;
2311     },
2312     'set_help_context' : function(params) {
2313         var obj = this;
2314         if (!params) { params = {}; }
2315         if (params.protocol == 'chrome:') { return; } /* not supported */
2316         var help_btn = document.getElementById('help_btn');
2317         if (help_btn) {
2318             dump('set_help_context: ' + js2JSON(params) + '\n');
2319             if (params.protocol) { help_btn.setAttribute('protocol', params.protocol); }
2320             if (params.hostname) { help_btn.setAttribute('hostname', params.hostname);  }
2321             if (params.port) { help_btn.setAttribute('port', params.port);  }
2322             if (params.pathname) { help_btn.setAttribute('pathname', params.pathname); }
2323             if (params.src) { help_btn.setAttribute('src', params.src); }
2324         }
2325     },
2326
2327     'tab_semaphores' : {},
2328
2329     'set_tab' : function(url,params,content_params) {
2330         var obj = this;
2331         if (!url) url = 'oils://remote/xul/server/';
2332         if (!url.match(/:\/\//) && !url.match(/^data:/)) url = urls.remote + url;
2333         if (!params) params = {};
2334         if (!content_params) content_params = {};
2335         var idx = this.controller.view.tabs.selectedIndex;
2336         if (params && typeof params.index != 'undefined') idx = params.index;
2337         var tab = this.controller.view.tabs.childNodes[ idx ];
2338
2339         var id = tab.getAttribute('id');
2340         if (id) {
2341             if (typeof obj.tab_semaphores[id] != 'undefined') {
2342                 if (obj.tab_semaphores[id] > 0) {
2343                     var confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
2344                     if (!confirmation) { return; }
2345                     oils_unsaved_data_P( obj.tab_semaphores[id] );
2346                 }
2347                 delete obj.tab_semaphores[id];
2348             }
2349         }
2350         var unique_id = idx + ':' + new Date();
2351         tab.setAttribute('id',unique_id);
2352         if (params.focus) tab.focus();
2353         var panel = this.controller.view.panels.childNodes[ idx ];
2354         while ( panel.lastChild ) panel.removeChild( panel.lastChild );
2355
2356         content_params.is_tab_locked = function() {
2357             dump('is_tab_locked\n');
2358             var id = tab.getAttribute('id');
2359             if (typeof obj.tab_semaphores[id] == 'undefined') {
2360                 return false;
2361             }
2362             return obj.tab_semaphores[id] > 0;
2363         }
2364         content_params.lock_tab = function() { 
2365             dump('lock_tab\n');
2366             var id = tab.getAttribute('id');
2367             if (typeof obj.tab_semaphores[id] == 'undefined') {
2368                 obj.tab_semaphores[id] = 0;
2369             }
2370             obj.tab_semaphores[id]++; 
2371             oils_unsaved_data_V();
2372             return obj.tab_semaphores[id]; 
2373         };
2374         content_params.unlock_tab = function() { 
2375             dump('unlock_tab\n');
2376             var id = tab.getAttribute('id');
2377             if (typeof obj.tab_semaphores[id] == 'undefined') {
2378                 obj.tab_semaphores[id] = 0;
2379             }
2380             obj.tab_semaphores[id]--;
2381             if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; } 
2382             oils_unsaved_data_P();
2383             return obj.tab_semaphores[id]; 
2384         };
2385         content_params.inspect_tab = function() {
2386             var id = tab.getAttribute('id');
2387             return 'id = ' + id + ' semaphore = ' + obj.tab_semaphores[id];
2388         }
2389         content_params.new_tab = function(a,b,c) { return obj.new_tab(a,b,c); };
2390         content_params.set_tab = function(a,b,c) { return obj.set_tab(a,b,c); };
2391         content_params.open_external = function(a) { return obj.open_external(a); };
2392         content_params.close_tab = function() { return obj.close_tab(); };
2393         content_params.new_patron_tab = function(a,b) { return obj.new_patron_tab(a,b); };
2394         content_params.set_patron_tab = function(a,b) { return obj.set_patron_tab(a,b); };
2395         content_params.volume_item_creator = function(a) { return obj.volume_item_creator(a); };
2396         content_params.get_new_session = function(a) { return obj.get_new_session(a); };
2397         content_params.holdings_maintenance_tab = function(a,b,c) { return obj.holdings_maintenance_tab(a,b,c); };
2398         content_params.set_tab_name = function(name) { tab.label = tab.curindex + ' ' + name; tab.origlabel = name; };
2399         content_params.set_help_context = function(params) { return obj.set_help_context(params); };
2400         content_params.open_chrome_window = function(a,b,c) { return xulG.window.open(a,b,c); };
2401         content_params.url_prefix = function(url,secure) { return obj.url_prefix(url,secure); };
2402         content_params.network_meter = obj.network_meter;
2403         content_params.page_meter = obj.page_meter;
2404         content_params.get_barcode = obj.get_barcode;
2405         content_params.get_barcode_and_settings = obj.get_barcode_and_settings;
2406         content_params.render_toolbar_layout = function(layout) { return obj.render_toolbar_layout(layout); };
2407         content_params.set_statusbar = function(slot,text,tooltiptext,click_handler) {
2408             var e = document.getElementById('statusbarpanel'+slot);
2409             if (e) {
2410                 var p = e.parentNode;
2411                 var sbp = document.createElement('statusbarpanel');
2412                 sbp.setAttribute('id','statusbarpanel'+slot);
2413                 p.replaceChild(sbp,e); // destroy and replace the statusbarpanel as a poor man's way of clearing event handlers
2414
2415                 sbp.setAttribute('label',text);
2416                 if (tooltiptext) {
2417                     sbp.setAttribute('tooltiptext',tooltiptext);
2418                 }
2419                 if (click_handler) {
2420                     sbp.addEventListener(
2421                         'click',
2422                         click_handler,
2423                         false
2424                     );
2425                 }
2426             }
2427         };
2428         content_params.chrome_xulG = xulG;
2429         content_params._data = xulG._data;
2430         if (params && params.tab_name) content_params.set_tab_name( params.tab_name );
2431         
2432         var frame;
2433         try {
2434             if (typeof params.browser == 'undefined') params.browser = false;
2435             if (params.browser) {
2436                 obj.id_incr++;
2437                 frame = this.w.document.createElement('browser');
2438                 frame.setAttribute('flex','1');
2439                 frame.setAttribute('type','content');
2440                 frame.setAttribute('autoscroll','false');
2441                 frame.setAttribute('id','frame_'+obj.id_incr);
2442                 panel.appendChild(frame);
2443                 try {
2444                     dump('creating browser with src = ' + url + '\n');
2445                     JSAN.use('util.browser');
2446                     var b = new util.browser();
2447                     b.init(
2448                         {
2449                             'url' : url,
2450                             'push_xulG' : true,
2451                             'alt_print' : false,
2452                             'browser_id' : 'frame_'+obj.id_incr,
2453                             'passthru_content_params' : content_params,
2454                         }
2455                     );
2456                 } catch(E) {
2457                     alert(E);
2458                 }
2459             } else {
2460                 frame = this.w.document.createElement('iframe');
2461                 frame.setAttribute('flex','1');
2462                 panel.appendChild(frame);
2463                 dump('creating iframe with src = ' + url + '\n');
2464                 frame.setAttribute('src',url);
2465                 try {
2466                     var cw = frame.contentWindow;
2467                     if (typeof cw.wrappedJSObject != 'undefined') cw = cw.wrappedJSObject;
2468                     cw.IAMXUL = true;
2469                     cw.xulG = content_params;
2470                     cw.addEventListener(
2471                         'load',
2472                         function() {
2473                             try {
2474                                 if (typeof cw.help_context_set_locally == 'undefined') {
2475                                     var help_params = {
2476                                         'protocol' : cw.location.protocol,
2477                                         'hostname' : cw.location.hostname,
2478                                         'port' : cw.location.port,
2479                                         'pathname' : cw.location.pathname,
2480                                         'src' : ''
2481                                     };
2482                                     obj.set_help_context(help_params);
2483                                 } else if (typeof cw.default_focus == 'function') {
2484                                     cw.default_focus();
2485                                 }
2486                             } catch(E) {
2487                                 obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload: ' + E);
2488                             }
2489                             try {
2490                                 if (typeof params.on_tab_load == 'function') {
2491                                     params.on_tab_load(cw);
2492                                 }
2493                             } catch(E) {
2494                                 obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload #2: ' + E);
2495                             }
2496                         },
2497                         false
2498                     );
2499                 } catch(E) {
2500                     this.error.sdump('D_ERROR', 'main.menu: ' + E);
2501                 }
2502             }
2503         } catch(E) {
2504             this.error.sdump('D_ERROR', 'main.menu:2: ' + E);
2505             alert(offlineStrings.getString('menu.set_tab.error'));
2506         }
2507
2508         return frame;
2509     },
2510
2511     'open_external' : function(url) {
2512         // first construct an nsIURI object using the ioservice
2513         var ioservice = Components.classes["@mozilla.org/network/io-service;1"]
2514                             .getService(Components.interfaces.nsIIOService);
2515
2516         var uriToOpen = ioservice.newURI(url, null, null);
2517
2518         var extps = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
2519                             .getService(Components.interfaces.nsIExternalProtocolService);
2520
2521         // now, open it!
2522         extps.loadURI(uriToOpen, null);
2523     },
2524
2525     'get_barcode' : function(window, context, barcode) {
2526         JSAN.use('util.network');
2527         JSAN.use('util.sound');
2528
2529         // Depending on where we were called from data can be found in multiple ways
2530         var data;
2531         if(this.data) data = this.data;
2532         else if(xulG.data) data = xulG.data;        
2533         else {
2534             JSAN.use('util.data');
2535             data = new util.data();
2536         }
2537         data.stash_retrieve();
2538
2539         var network = new util.network();
2540         var sound = new util.sound();
2541
2542         // Should return an array. Or an error.
2543         var r = network.simple_request('GET_BARCODES', [ ses(), data.list.au[0].ws_ou(), context, barcode ]);
2544
2545         if(!r) // Nothing?
2546             return false;
2547
2548         // Top-level error, likely means bad session or no STAFF_LOGIN permission.
2549         if(typeof r.ilsevent != 'undefined') {
2550             // Hand it off to the caller.
2551             return r;
2552         }
2553
2554         // No results? Return false
2555         if(r.length == 0) return false;
2556
2557         // One result?
2558         if(r.length == 1) {
2559             // Return it. If it is an error the caller should deal with it.
2560             return r[0];
2561         }
2562
2563         // At this point we have more than one result.
2564         // Check to see what we got.
2565         var result_filter = {};
2566         var valid_r = [];
2567         var unique_count = 0;
2568         var found_errors = false;
2569         var errors = '';
2570         var len = r.length;
2571
2572         // Check each result.
2573         for(var i = 0; i < len; ++i) {
2574             // If it is an error
2575             if(typeof r[i].ilsevent != 'undefined') {
2576                 // Make note that we found errors
2577                 found_errors = true;
2578                 // Grab the error into a string
2579                 errors += js2JSON(r[i]);
2580             }
2581             else {
2582                 // Otherwise, record the type/id combo for later
2583                 var type = r[i].type;
2584                 var id = r[i].id;
2585                 var barcode = r[i].barcode;
2586                 if(!result_filter[type]) result_filter[type] = {};
2587                 if(!result_filter[type][id]) {
2588                     unique_count++;
2589                     result_filter[type][id] = [];
2590                 }
2591                 result_filter[type][id].push(barcode);
2592                 valid_r.push(r[i]);
2593             }
2594         }
2595
2596         // Only errors? Return the first one.
2597         if(unique_count == 0 && found_errors == true) {
2598             return r[0];
2599         }
2600
2601         // No errors, one (unique) result? Return it.
2602         if(unique_count == 1 && found_errors == false) return valid_r[0];
2603
2604         // For possible debugging, dump the errors.
2605         if(found_errors) dump(errors);
2606
2607         // Still here? Must need to have the user pick.
2608         if(!xulG.url_prefix) xulG.url_prefix = url_prefix; // Make util.window happy
2609         JSAN.use('util.window');
2610         var win = new util.window();
2611         var url = url_prefix('XUL_FANCY_PROMPT');
2612         var title = offlineStrings.getString('barcode_choice.title');
2613         var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">';
2614         xml += '<groupbox flex="1" style="overflow: auto; border: solid thin;"><caption label="' + title + '"/>';
2615         xml += '<description style="-moz-user-select: text; -moz-user-focus: normal; font-size: large">' + offlineStrings.getString('barcode_choice.prompt') + '</description>';
2616         if(found_errors) // Let the user know that one or more possible answers errored out.
2617             xml += '<description style="-moz-user=select: text; -moz-user-focus: normal; font-size: large">' + offlineStrings.getString('barcode_choice.errors_found') + '</description>';
2618         xml += '</groupbox><groupbox><caption label="' + offlineStrings.getString('barcode_choice.choice_label') + '"/><vbox>';
2619
2620         len = valid_r.length;
2621         // Look at all the non-error answers we got
2622         for(var i = 0; i < len; ++i) {
2623             // If we still have a filtered answer, display a button.
2624             if(result_filter[valid_r[i].type][valid_r[i].id]) {
2625                 var result_data = false;
2626                 var barcodes = result_filter[valid_r[i].type][valid_r[i].id];
2627                 var barcodes_assembled = barcodes.shift();
2628                 var button_label = '';
2629                 while(barcodes.length > 0) // Join any secondary barcodes found together
2630                     barcodes_assembled = offlineStrings.getFormattedString('barcode_choice.join_barcodes', [barcodes_assembled, barcodes.shift()]);
2631                 switch(r[i].type) {
2632                     case 'actor':
2633                         result_data = network.simple_request('BLOB_AU_PARTS_RETRIEVE',
2634                             [ ses() , valid_r[i].id, ['family_name', 'first_given_name', 'second_given_name', 'home_ou' ] ]);
2635                         button_label = offlineStrings.getFormattedString('barcode_choice.actor',
2636                             [barcodes_assembled, result_data[0], result_data[1] + (result_data[2] ? ' ' + result_data[2] : ''), data.hash.aou[ result_data[3] ].name(), data.hash.aou[ result_data[3] ].shortname()]);
2637                         break;
2638                     case 'booking':
2639                         result_data = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE', [ ses(), valid_r[i].barcode ]);
2640                         // Note: This falls through intentionally.
2641                     case 'asset':
2642                     case 'serial':
2643                         if(!result_data) // If we fell through this should be set already.
2644                             result_data = network.simple_request('FM_ACP_DETAILS', [ ses(), valid_r[i].id ]);
2645                         button_label = offlineStrings.getFormattedString('barcode_choice.asset',
2646                             [barcodes_assembled, result_data.mvr.title(), data.hash.aou[ result_data.copy.circ_lib() ].name(), data.hash.aou[ result_data.copy.circ_lib() ].shortname()]);
2647                         break;
2648                 }
2649                 r[i].data = result_data;
2650
2651                 // This ensures we only show each unique id once
2652                 delete result_filter[valid_r[i].type][valid_r[i].id];
2653
2654                 // If we have more than one context this should label each entry with where it came from
2655                 // Likely most useful for distinguishing assets from bookings
2656                 if(context != valid_r[i].type && offlineStrings.testString('barcode_choice.' + valid_r[i].type + '_label'))
2657                     button_label = offlineStrings.getFormattedString('barcode_choice.' + valid_r[i].type + '_label', [button_label]);
2658
2659                 xml += '<button label="' + button_label + '" name="fancy_submit" value="' + i + '"/>';
2660             }
2661         }
2662         xml += '<button label="' + offlineStrings.getString('barcode_choice.none') + '" name="fancy_cancel"/>';
2663         xml += '</vbox></groupbox></vbox>';
2664         var fancy_prompt_data = win.open( url, 'fancy_prompt', 'chrome,resizable,modal,width=500,height=500', { 'xml' : xml, 'title' : title, 'sound' : 'bad' } );
2665         if(fancy_prompt_data.fancy_status == 'complete')
2666             return valid_r[fancy_prompt_data.fancy_submit];
2667         else
2668             // user_false is used to indicate the user said "None of the above" to avoid fall-through erroring later.
2669             return "user_false";
2670     },
2671
2672     'get_barcode_and_settings' : function(window, barcode, settings_only) {
2673         JSAN.use('util.network');
2674         if(!settings_only) {
2675             // We need to double-check the barcode for completion and such.
2676             var new_barcode = xulG.get_barcode(window, 'actor', barcode);
2677             if(new_barcode == "user_false") return;
2678             // No error means we have a (hopefully valid) completed barcode to use.
2679             // Otherwise, fall through to other methods of checking
2680             if(typeof new_barcode.ilsevent == 'undefined')
2681                 barcode = new_barcode.barcode;
2682             else
2683                 return false;
2684         }
2685         var network = new util.network();
2686         // We have a barcode! Time to load settings.
2687         // First, we need the user ID
2688         var user = network.simple_request('FM_AU_RETRIEVE_VIA_BARCODE', [ ses(), barcode ]);
2689         if(user.ilsevent != undefined || user.textcode != undefined)
2690             return false;
2691         var settings = {};
2692         for(var i = 0; i < user.settings().length; i++) {
2693             settings[user.settings()[i].name()] = JSON2js(user.settings()[i].value());
2694         }
2695         if(!settings['opac.default_phone'] && user.day_phone()) settings['opac.default_phone'] = user.day_phone();
2696         if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') settings['opac.hold_notify'] = 'email:phone';
2697         // Taken from patron/util.js format_name
2698         var patron_name = ( user.prefix() ? user.prefix() + ' ' : '') +
2699             user.family_name() + ', ' +
2700             user.first_given_name() + ' ' +
2701             ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
2702             ( user.suffix() ? user.suffix() : '');
2703         return {"barcode": barcode, "settings" : settings, "user_email" : user.email(), "patron_name" : patron_name};
2704     },
2705
2706     'sort_menu' : function(menu, recurse) {
2707         var curgroup = new Array();
2708         var curstart = 1;
2709         var curordinal = 0;
2710         for (var itemid = 0; itemid < menu.firstChild.children.length; itemid++) {
2711             var item = menu.firstChild.children[itemid];
2712             curordinal++;
2713             if (item.getAttribute('forceFirst')) {
2714                 item.setAttribute('ordinal', curstart);
2715                 curstart++;
2716                 continue;
2717             }
2718             if (item.nodeName == 'menuseparator') {
2719                 this.sort_menu_items(curgroup, curstart);
2720                 item.setAttribute('ordinal', curordinal);
2721                 curstart = curordinal + 1;
2722                 curgroup = new Array();
2723                 continue;
2724             }
2725             if (item.nodeName == 'menu' && recurse) {
2726                 this.sort_menu(item, recurse);
2727             }
2728             curgroup.push(item);
2729         }
2730         this.sort_menu_items(curgroup, curstart);
2731     },
2732
2733     'sort_menu_items' : function(itemgroup, start) {
2734         var curpos = start;
2735         var sorted = itemgroup.sort(function(a,b) {
2736             var labelA = a.getAttribute('label').toUpperCase();
2737             var labelB = b.getAttribute('label').toUpperCase();
2738             return labelA.localeCompare(labelB);
2739         });
2740         for(var item = 0; item < sorted.length; item++) {
2741             sorted[item].setAttribute('ordinal', curpos++);
2742         }
2743     },
2744
2745     'observe' : function(subject, topic, data) {
2746         if (topic != "nsPref:changed") {
2747             return;
2748         }
2749
2750         switch(data) {
2751             case 'oils.copy_editor.copy_location_name_first':
2752                 var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
2753                 var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle');
2754                 for(var i = 0; i < menuitems.length; i++)
2755                     menuitems[i].setAttribute('checked', cl_first ? 'true' : 'false');
2756             break;
2757         }
2758     },
2759
2760     'stop_observing' : function() {
2761         xulG.pref.removeObserver('oils.copy_editor.*', this);
2762     },
2763
2764     'render_toolbar' : function(button_bar) {
2765         try {
2766
2767             this.last_sanctioned_toolbar = button_bar;
2768
2769             var toolbar = document.getElementById('toolbar_main');
2770
2771             if (button_bar == 'none' || typeof button_bar == 'undefined') {
2772                 toolbar.setAttribute('hidden','true');
2773                 return;
2774             }
2775
2776             // find the layout
2777             var layout;
2778             JSAN.use('util.widgets'); JSAN.use('util.functional');
2779             var def = this.data.hash.atb[ button_bar ];
2780             if (!def) def = util.functional.find_list( this.data.list.atb, function(e) { return e.label == button_bar; } );
2781             if (!def) {
2782                 dump('Could not find layout for specified toolbar. Defaulting to a stock toolbar.\n');
2783                 layout = ["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"];
2784             } else {
2785                 layout = JSON2js(def.layout());
2786             }
2787
2788             this.render_toolbar_layout(layout);
2789
2790         } catch(E) {
2791             alert('Error in menu.js, render_toolbar('+button_bar+'): ' + E);
2792         }
2793     },
2794
2795     'render_toolbar_layout' : function(layout) {
2796         try {
2797
2798             if (!layout) {
2799                 this.data.stash_retrieve();
2800                 this.render_toolbar( this.last_sanctioned_toolbar );
2801                 return;
2802             }
2803
2804             var toolbar = document.getElementById('toolbar_main');
2805
2806             // destroy existing toolbar
2807             util.widgets.remove_children(toolbar);
2808
2809             // create new one
2810             for (var i = 0; i < layout.length; i++) {
2811                 var e = layout[i];
2812                 if (e.match('toolbarseparator')) {
2813                         toolbar.appendChild( document.createElement('toolbarseparator') );
2814                 } else if (e.match('toolbarspacer')) {
2815                     var spacer = document.createElement('toolbarspacer');
2816                     spacer.setAttribute('flex','1');
2817                     toolbar.appendChild( spacer );
2818                 } else {
2819                     var templates = $('palette').getElementsByAttribute('templateid',e);
2820                     var template = templates.length > 0 ? templates[0] : null;
2821                     if (template) {
2822                         var clone = template.cloneNode(true);
2823                         toolbar.appendChild( clone );
2824                     } else {
2825                         var label = document.createElement('label');
2826                         label.setAttribute('value',e);
2827                         toolbar.appendChild( label );
2828                     }
2829                 }
2830             }
2831             toolbar.setAttribute('hidden','false');
2832
2833         } catch(E) {
2834             alert('Error in menu.js, render_toolbar_layout('+layout+'): ' + E);
2835         }
2836     }
2837 }
2838
2839 dump('exiting main/menu.js\n');