9f58b815f75204e6ef8ef866a5ddf9ad5f0f01d8
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / cat / opac.js
1 var docid; var marc_html; var top_pane; var bottom_pane; var opac_browser; var opac_url;
2
3 var marc_view_reset = true;
4 var marc_edit_reset = true;
5 var copy_browser_reset = true;
6 var manage_parts_reset = true;
7 var manage_multi_home_reset = true;
8 var hold_browser_reset = true;
9 var serctrl_view_reset = true;
10
11 function $(id) { return document.getElementById(id); }
12
13 function my_init() {
14     try {
15         if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
16         JSAN.errorLevel = "die"; // none, warn, or die
17         JSAN.addRepository('..');
18         JSAN.use('util.error'); g.error = new util.error();
19         g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
20
21         JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
22         XML_HTTP_SERVER = g.data.server_unadorned;
23
24         // Pull in local customizations
25         var r = new XMLHttpRequest();
26         var custom_js = xulG.url_prefix('CUSTOM_JS');
27         r.open("GET", custom_js, false);
28         r.send(null);
29         if (r.status == 200) {
30             dump('Evaluating ' + custom_js + '\n');
31             eval( r.responseText );
32         }
33
34         window.help_context_set_locally = true;
35
36         JSAN.use('util.network'); g.network = new util.network();
37
38         g.cgi = new CGI();
39         try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
40         try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
41         try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
42         try { g.view_override = g.cgi.param('default_view') || xulG.default_view; } catch(E) { g.error.sdump('D_ERROR',E); }
43
44         JSAN.use('util.deck');
45         top_pane = new util.deck('top_pane');
46         bottom_pane = new util.deck('bottom_pane');
47
48         set_opac();
49
50     } catch(E) {
51         var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
52         try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
53         alert(err_msg);
54     }
55 }
56
57 function default_focus() {
58     opac_wrapper_set_help_context(); 
59 }
60
61 function opac_wrapper_set_help_context() {
62     try {
63         dump('Entering opac.js, opac_wrapper_set_help_context\n');
64         var cw = bottom_pane.get_contentWindow(); 
65         if (cw && typeof cw['location'] != 'undefined') {
66             if (typeof cw.help_context_set_locally == 'undefined') {
67                 var help_params = {
68                     'protocol' : cw.location.protocol,
69                     'hostname' : cw.location.hostname,
70                     'port' : cw.location.port,
71                     'pathname' : cw.location.pathname,
72                     'src' : ''
73                 };
74                 xulG.set_help_context(help_params);
75             } else {
76                 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
77                 if (typeof cw.default_focus == 'function') {
78                     cw.default_focus();
79                 }
80             }
81         } else {
82             dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
83             dump('\tcw.location = ' + cw.location + '\n');
84         }
85     } catch(E) {
86         // We can expect some errors here if this called before the DOM is ready.  Easiest to just trap and ignore
87         dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
88     }
89 }
90
91 function set_brief_view() {
92     var url = xulG.url_prefix( 'XUL_BIB_BRIEF?docid=' ) + window.escape(docid); 
93     dump('spawning ' + url + '\n');
94
95     var content_params = {
96         'set_tab_name' : function(n) {
97             if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
98                 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
99             } else {
100                 dump('no set_tab_name\n');
101             }
102         }
103     };
104
105     ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
106         "set_patron_tab", "volume_item_creator", "get_new_session",
107         "holdings_maintenance_tab", "open_chrome_window", "url_prefix",
108         "network_meter", "page_meter", "set_statusbar", "set_help_context",
109         "get_barcode", "reload_opac", "get_barcode_and_settings"
110     ].forEach(function(k) { content_params[k] = xulG[k]; });
111
112     top_pane.set_iframe( 
113         url,
114         {},
115         content_params
116     );
117 }
118
119 function set_marc_view() {
120     g.view = 'marc_view';
121     if (marc_view_reset) {
122         bottom_pane.reset_iframe( xulG.url_prefix( 'XUL_MARC_VIEW?docid=' ) + window.escape(docid),{},xulG);
123         marc_view_reset = false;
124     } else {
125         bottom_pane.set_iframe( xulG.url_prefix( 'XUL_MARC_VIEW?docid=' ) + window.escape(docid),{},xulG);
126     }
127     opac_wrapper_set_help_context(); 
128     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
129 }
130
131 function set_marc_edit() {
132     g.view = 'marc_edit';
133     var a =    xulG.url_prefix( 'XUL_MARC_EDIT' );
134     var b =    {};
135     var c =    {
136             'marc_control_number_identifier' : g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
137             'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
138             'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
139                 try {
140                     var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
141                     cat.util.spawn_copy_editor = function(params) {
142                         try {
143                             if (!params.copy_ids && !params.copies) return;
144                             if (params.copy_ids && params.copy_ids.length == 0) return;
145                             if (params.copies && params.copies.length == 0) return;
146                             if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
147                             if (!params.caller_handles_update) params.handle_update = 1; // legacy
148
149                             var obj = {};
150                             JSAN.use('util.network'); obj.network = new util.network();
151                             JSAN.use('util.error'); obj.error = new util.error();
152                         
153                             var title = '';
154                             if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
155                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
156                             else if(params.copies && params.copies.length > 1 && params.edit == 1)
157                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
158                             else if(params.copy_ids && params.copy_ids.length == 1)
159                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
160                             else
161                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
162
163                             JSAN.use('util.window'); var win = new util.window();
164                             var my_xulG = win.open(
165                                 (urls.XUL_COPY_EDITOR),
166                                 title,
167                                 'chrome,modal,resizable',
168                                 params
169                             );
170                             if (!my_xulG.copies && params.edit) {
171                             } else {
172                                 return my_xulG.copies;
173                             }
174                             return [];
175                         } catch(E) {
176                             JSAN.use('util.error'); var error = new util.error();
177                             error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
178                         }
179                     }
180                     cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
181                         var error;
182                         try {
183
184                             JSAN.use('util.error'); error = new util.error();
185                             JSAN.use('util.network'); var network = new util.network();
186
187                             var acn_blob = network.simple_request(
188                                 'FM_ACN_FIND_OR_CREATE',
189                                 [ ses(), cn_label, doc_id, ses('ws_ou') ]
190                             );
191
192                             if (typeof acn_blob.ilsevent != 'undefined') {
193                                 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_blob);
194                                 return;
195                             }
196
197                             // Get the default copy status; default to available if unset, per 1.6
198                             var fast_ccs = g.data.hash.aous['cat.default_copy_status_fast'] || 0;
199
200                             var copy_obj = new acp();
201                             copy_obj.id( -1 );
202                             copy_obj.isnew('1');
203                             copy_obj.barcode( cp_barcode );
204                             copy_obj.call_number( acn_blob.acn_id );
205                             copy_obj.circ_lib( ses('ws_ou') );
206                             /* FIXME -- use constants */
207                             copy_obj.deposit(0);
208                             copy_obj.price(0);
209                             copy_obj.deposit_amount(0);
210                             copy_obj.fine_level(2); // Normal
211                             copy_obj.loan_duration(2); // Normal
212                             copy_obj.location(1); // Stacks
213                             copy_obj.status(fast_ccs);
214                             copy_obj.circulate(get_db_true());
215                             copy_obj.holdable(get_db_true());
216                             copy_obj.opac_visible(get_db_true());
217                             copy_obj.ref(get_db_false());
218                             copy_obj.mint_condition(get_db_true());
219
220                             JSAN.use('util.window'); var win = new util.window();
221
222                             var unified_interface = String( data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
223                             if (unified_interface) {
224                                 var horizontal_interface = String( data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
225                                 var url = window.xulG.url_prefix( horizontal_interface ? 'XUL_VOLUME_COPY_CREATOR_HORIZONTAL' : 'XUL_VOLUME_COPY_CREATOR' );
226                                 var w = xulG.set_tab(
227                                     url,
228                                     {
229                                         'tab_name' : document.getElementById('offlineStrings').getFormattedString(
230                                             'cat.bib_record',
231                                             [ doc_id ]
232                                         )
233                                     },
234                                     {
235                                         'doc_id' : doc_id, 
236                                         'existing_copies' : [ copy_obj ],
237                                         'load_opac_when_done' : true,
238                                         'labels_in_new_tab' : true
239                                     }
240                                 );
241
242                             } else {
243                                 var x = cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
244                                 xulG.reload_opac();
245                                 return x;
246                             }
247
248                         } catch(E) {
249                             if (error) error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add #2',E); else alert('FIXME: ' + E);
250                         }
251                     }
252                     return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
253                 } catch(E) {
254                     alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
255                 }
256             },
257             'save' : {
258                 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
259                 'func' : function (new_marcxml) {
260                     try {
261                         var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
262                         marc_view_reset = true;
263                         copy_browser_reset = true;
264                         hold_browser_reset = true;
265                         xulG.reload_opac();
266                         if (typeof r.ilsevent != 'undefined') {
267                             throw(r);
268                         } else {
269                             return {
270                                 'id' : r.id(),
271                                 'oncomplete' : function() {}
272                             };
273                         }
274                     } catch(E) {
275                             g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
276                     }
277                 }
278             },
279             'lock_tab' : xulG.lock_tab,
280             'unlock_tab' : xulG.unlock_tab
281         };
282     if (marc_edit_reset) {
283         bottom_pane.reset_iframe( a,b,c );
284         marc_edit_reset = false;
285     } else {
286         bottom_pane.set_iframe( a,b,c );
287     }
288     opac_wrapper_set_help_context(); 
289     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
290 }
291
292 function set_copy_browser() {
293     g.view = 'copy_browser';
294     if (copy_browser_reset) {
295         bottom_pane.reset_iframe( xulG.url_prefix( 'XUL_COPY_VOLUME_BROWSE?docid=' ) + window.escape(docid),{},xulG);
296         copy_browser_reset =false;
297     } else {
298         bottom_pane.set_iframe( xulG.url_prefix( 'XUL_COPY_VOLUME_BROWSE?docid=' ) + window.escape(docid),{},xulG);
299     }
300     opac_wrapper_set_help_context(); 
301     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
302 }
303
304 function set_hold_browser() {
305     g.view = 'hold_browser';
306     if (hold_browser_reset) {
307         bottom_pane.reset_iframe( xulG.url_prefix( 'XUL_HOLDS_BROWSER?docid=' ) + window.escape(docid),{},xulG);
308         hold_browser_reset = false;
309     } else {
310         bottom_pane.set_iframe( xulG.url_prefix( 'XUL_HOLDS_BROWSER?docid=' ) + window.escape(docid),{},xulG);
311     }
312     opac_wrapper_set_help_context(); 
313     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
314 }
315
316
317 function open_acq_orders() {
318     try {
319         var content_params = {
320             "session": ses(),
321             "authtime": ses("authtime"),
322             "no_xulG": false,
323             "show_nav_buttons": true,
324             "show_print_button": false
325         };
326
327         ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
328             "set_patron_tab", "volume_item_creator", "get_new_session",
329             "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
330             "url_prefix", "network_meter", "page_meter", "set_statusbar",
331             "set_help_context", "get_barcode", "reload_opac", 
332             "get_barcode_and_settings"
333         ].forEach(function(k) { content_params[k] = xulG[k]; });
334
335         var loc = urls.XUL_BROWSER + "?url=" + window.escape(
336             xulG.url_prefix("ACQ_LINEITEM") +
337             docid + "?target=bib"
338         );
339         xulG.new_tab(
340             loc, {
341                 "tab_name": $("offlineStrings").getString(
342                     "staff.cat.opac.related_items"
343                 ),
344                 "browser": false
345             }, content_params
346         );
347     } catch (E) {
348         g.error.sdump("D_ERROR", E);
349     }
350 }
351
352 function open_alt_serial_mgmt() {
353     try {
354         var content_params = {
355             "session": ses(),
356             "authtime": ses("authtime"),
357             "show_nav_buttons": true,
358             "no_xulG": false,
359             "show_print_button": false,
360             "passthru_content_params": {
361                 "reload_opac": xulG.reload_opac
362             }
363         };
364
365         ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
366             "set_patron_tab", "volume_item_creator", "get_new_session",
367             "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
368             "url_prefix", "network_meter", "page_meter", "set_statusbar",
369             "set_help_context", "get_barcode", "reload_opac",
370             "get_barcode_and_settings"
371         ].forEach(function(k) { content_params[k] = xulG[k]; });
372
373         var loc = urls.XUL_BROWSER + "?url=" + window.escape(
374             xulG.url_prefix("SERIAL_LIST_SUBSCRIPTION?record_entry=") +
375             docid
376         );
377         xulG.new_tab(
378             loc, {
379                 "tab_name": $("offlineStrings").getString(
380                     "staff.cat.opac.serial_alt_mgmt"
381                 ),
382                 "browser": false
383             }, content_params
384         );
385     } catch (E) {
386         g.error.sdump("D_ERROR", E);
387     }
388 }
389
390 function set_opac() {
391     g.view = 'opac';
392     try {
393         var content_params = { 
394             'show_nav_buttons' : true,
395             'show_print_button' : true,
396             'passthru_content_params' : { 
397                 'authtoken' : ses(), 
398                 'authtime' : ses('authtime'),
399                 'window_open' : function(a,b,c) {
400                     try {
401                         return window.open(a,b,c);
402                     } catch(E) {
403                         g.error.standard_unexpected_error_alert('window_open',E);
404                     }
405                 },
406                 'get_barcode' : xulG.get_barcode,
407                 'get_barcode_and_settings' : xulG.get_barcode_and_settings,
408                 'opac_hold_placed' : function(hold) {
409                     try {
410                         var hold_id = typeof hold == 'object' ? hold.id() : hold;
411                         g.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), hold_id ],
412                             function(blob_req) {
413                                 try {
414                                     var blob = blob_req.getResultObject();
415                                     if (typeof blob.ilsevent != 'undefined') throw(blob);
416                                     g.error.work_log(
417                                         $('offlineStrings').getFormattedString(
418                                             'staff.circ.work_log_hold_placed.message',
419                                             [
420                                                 ses('staff_usrname'),
421                                                 blob.patron_last,
422                                                 blob.patron_barcode,
423                                                 hold_id,
424                                                 blob.hold.hold_type()
425                                             ]
426                                         ), {
427                                             'au_id' : blob.hold.usr(),
428                                             'au_family_name' : blob.patron_family_name,
429                                             'au_barcode' : blob.patron_barcode
430                                         }
431                                     );
432                                 } catch(E) {
433                                     g.error.standard_unexpected_error_alert('opac.js, opac_hold_placed(), work_log #2: ',E);
434                                 }
435                             }
436                         );
437                     } catch(F) {
438                         g.error.standard_unexpected_error_alert('opac.js, opac_hold_placed(), work_log #1: ',F);
439                     }
440                 }
441             },
442             'on_url_load' : function(f) {
443                 var win;
444                 try {
445                     if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
446                         win = f.contentWindow.wrappedJSObject;
447                     } else {
448                         win = f.contentWindow;
449                     }
450                 } catch(E) {
451                     win = f.contentWindow;
452                 }
453                 win.attachEvt("rdetail", "recordRetrieved",
454                     function(id){
455                         try {
456                             if (docid == id) return;
457                             docid = id;
458                             refresh_display(id);
459                         } catch(E) {
460                             g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
461                         }
462                     }
463                 );
464                 
465                 g.f_record_start = null; g.f_record_prev = null;
466                 g.f_record_next = null; g.f_record_end = null;
467                 g.f_record_back_to_results = null;
468                 $('record_start').disabled = true; $('record_next').disabled = true;
469                 $('record_prev').disabled = true; $('record_end').disabled = true;
470                 $('record_back_to_results').disabled = true;
471                 $('record_pos').setAttribute('value','');
472
473                 function safe_to_proceed() {
474                     if (typeof xulG.is_tab_locked == 'undefined') { return true; }
475                     if (! xulG.is_tab_locked()) { return true; }
476                     var r = window.confirm(
477                         document.getElementById('offlineStrings').getString(
478                            'generic.unsaved_data_warning'
479                         )
480                     );
481                     if (r) {
482                         while ( xulG.unlock_tab() > 0 ) {};
483                         return true;
484                     } else {
485                         return false;
486                     }
487                 }
488
489                 win.attachEvt("rdetail", "nextPrevDrawn",
490                     function(rIndex,rCount){
491                         $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
492                         if (win.rdetailNext) {
493                             g.f_record_next = function() {
494                                 if (safe_to_proceed()) {
495                                     g.view_override = g.view;
496                                     win.rdetailNext();
497                                 }
498                             }
499                             $('record_next').disabled = false;
500                         }
501                         if (win.rdetailPrev) {
502                             g.f_record_prev = function() {
503                                 if (safe_to_proceed()) {
504                                     g.view_override = g.view;
505                                     win.rdetailPrev();
506                                 }
507                             }
508                             $('record_prev').disabled = false;
509                         }
510                         if (win.rdetailStart) {
511                             g.f_record_start = function() { 
512                                 if (safe_to_proceed()) {
513                                     g.view_override = g.view;
514                                     win.rdetailStart();
515                                 }
516                             }
517                             $('record_start').disabled = false;
518                         }
519                         if (win.rdetailEnd) {
520                             g.f_record_end = function() { 
521                                 if (safe_to_proceed()) {
522                                     g.view_override = g.view;
523                                     win.rdetailEnd();
524                                 }
525                             }
526                             $('record_end').disabled = false;
527                         }
528                         if (win.rdetailBackToResults) {
529                             g.f_record_back_to_results = function() {
530                                 if (safe_to_proceed()) {
531                                     g.view_override = g.view;
532                                     win.rdetailBackToResults();
533                                     if (g.view != "opac") {
534                                         set_opac();
535                                         opac_wrapper_set_help_context();
536                                     }
537                                 }
538                             }
539                             $('record_back_to_results').disabled = false;
540                         }
541                     }
542                 );
543
544                 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
545                 var mfhd_edit_menu = $('mfhd_edit');
546                 var mfhd_delete_menu = $('mfhd_delete');
547
548                 // clear menus on subsequent loads
549                 if (mfhd_edit_menu.firstChild) {
550                     mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
551                     mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
552                 }
553
554                 mfhd_edit_menu.disabled = true;
555                 mfhd_delete_menu.disabled = true;
556
557                 win.attachEvt("rdetail", "MFHDDrawn",
558                     function() {
559                         if (win.mfhdDetails && win.mfhdDetails.length > 0) {
560                             g.mfhd = {};
561                             g.mfhd.details = win.mfhdDetails;
562                             mfhd_edit_menu.disabled = false;
563                             mfhd_delete_menu.disabled = false;
564                             for (var i = 0; i < win.mfhdDetails.length; i++) {
565                                 var mfhd_details = win.mfhdDetails[i];
566                                 var num = mfhd_details.entryNum;
567                                 num++;
568                                 var label = mfhd_details.label + ' (' + num + ')';
569                                 var item = mfhd_edit_menu.appendItem(label);
570                                 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
571                                 item = mfhd_delete_menu.appendItem(label);
572                                 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
573                             }
574                         } else if (g.mfhd) { // clear from previous runs if deleting last MFHD
575                             delete g.mfhd;
576                         }
577                         var change_event = document.createEvent("Event");
578                         change_event.initEvent("MFHDChange",false,false);
579                         window.dispatchEvent(change_event);
580                     }
581                 );
582             },
583             'url_prefix' : xulG.url_prefix,
584         };
585         content_params.new_tab = xulG.new_tab;
586         content_params.set_tab = xulG.set_tab;
587         content_params.close_tab = xulG.close_tab;
588         content_params.lock_tab = xulG.lock_tab;
589         content_params.unlock_tab = xulG.unlock_tab;
590         content_params.inspect_tab = xulG.inspect_tab;
591         content_params.is_tab_locked = xulG.is_tab_locked;
592         content_params.new_patron_tab = xulG.new_patron_tab;
593         content_params.set_patron_tab = xulG.set_patron_tab;
594         content_params.volume_item_creator = xulG.volume_item_creator;
595         content_params.get_new_session = xulG.get_new_session;
596         content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
597         content_params.set_tab_name = xulG.set_tab_name;
598         content_params.open_chrome_window = xulG.open_chrome_window;
599         content_params.url_prefix = xulG.url_prefix;
600         content_params.network_meter = xulG.network_meter;
601         content_params.page_meter = xulG.page_meter;
602         content_params.set_statusbar = xulG.set_statusbar;
603         content_params.set_help_context = xulG.set_help_context;
604         content_params.get_barcode = xulG.get_barcode;
605         content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
606
607         var secure_opac = true; // default to secure
608         var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
609         if (prefs.prefHasUserValue('oils.secure_opac')) {
610             secure_opac = prefs.getBoolPref('oils.secure_opac');
611         }
612         dump('secure_opac = ' + secure_opac + '\n');
613
614         if (opac_url) {
615             content_params.url = xulG.url_prefix( opac_url, secure_opac );
616         } else {
617             content_params.url = xulG.url_prefix( 'browser', secure_opac );
618         }
619         browser_frame = bottom_pane.set_iframe( xulG.url_prefix('XUL_BROWSER?name=Catalog'), {}, content_params);
620         /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
621         browser_frame = bottom_pane.set_iframe( xulG.url_prefix('XUL_REMOTE_BROWSER?name=Catalog'), {}, content_params);
622         */
623     } catch(E) {
624         g.error.sdump('D_ERROR','set_opac: ' + E);
625     }
626     opac_wrapper_set_help_context();
627     opac_browser = bottom_pane.get_contentWindow();
628     opac_browser.addEventListener('load',opac_wrapper_set_help_context,false);
629 }
630
631 xulG.reload_opac = function() {
632     try {
633         JSAN.use('util.widgets');
634         opac_browser.g.browser.reload();
635     } catch(E) {
636         g.error.sdump("D_ERROR", 'error reloading opac: ' + E + '\n');
637     }
638 }
639
640 function set_serctrl_view() {
641     g.view = 'serctrl_view';
642     if (serctrl_view_reset) {
643         bottom_pane.reset_iframe( xulG.url_prefix( 'XUL_SERIAL_SERCTRL_MAIN?docid=' ) + window.escape(docid), {}, xulG);
644         serctrl_view_reset =false;
645     } else {
646         bottom_pane.set_iframe( xulG.url_prefix( 'XUL_SERIAL_SERCTRL_MAIN?docid=' ) + window.escape(docid), {}, xulG);
647     }
648 }
649
650 function create_mfhd() {
651     // Check if the source is allowed to have copies, first.
652     try {
653         var bibObj = g.network.request(
654             api.FM_BRE_RETRIEVE_VIA_ID.app,
655             api.FM_BRE_RETRIEVE_VIA_ID.method,
656             [ ses(), [docid] ]
657         );
658
659         bibObj = bibObj[0];
660
661         var cbsObj = g.network.request(
662             api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
663             api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
664             [ ses(), bibObj.source() ]
665         );
666
667         if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
668             alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
669             return;
670         }
671     } catch(E) {
672         g.error.sdump('D_ERROR','can have copies check: ' + E);
673         alert('Error in chrome/content/cat/opac.js, create_mfhd(): ' + E);
674         return;
675     }
676
677     try {
678         JSAN.use('util.window'); var win = new util.window();
679         var select_aou_window = win.open(
680             xulG.url_prefix('XUL_SERIAL_SELECT_AOU'),
681             '_blank',
682             'chrome,resizable,modal,centerscreen',
683             {'server_unadorned' : g.data.server_unadorned}
684         );
685         if (!select_aou_window.create_mfhd_aou) {
686             return;
687         }
688         var r = g.network.simple_request(
689                 'MFHD_XML_RECORD_CREATE',
690                 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
691             );
692         if (typeof r.ilsevent != 'undefined') {
693             throw(r);
694         }
695         alert("MFHD record created."); //TODO: better success message
696         xulG.reload_opac(); // browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
697     } catch(E) {
698         g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
699     }
700 }
701
702 function delete_mfhd(sre_id) {
703     if (g.error.yns_alert(
704         document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
705         document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
706         document.getElementById('offlineStrings').getString('cat.opac.delete'),
707         document.getElementById('offlineStrings').getString('cat.opac.cancel'),
708         null,
709         document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
710         var robj = g.network.request(
711                 'open-ils.permacrud',
712                 'open-ils.permacrud.delete.sre',
713                 [ses(),sre_id]);
714         if (typeof robj.ilsevent != 'undefined') {
715             alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error',  [docid, robj.textcode, robj.desc]) + '\n');
716         } else {
717             alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
718             xulG.reload_opac(); // browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
719         }
720     }
721 }
722
723 function open_mfhd_editor(sre_id) {
724     try {
725         var r = g.network.simple_request(
726                 'FM_SRE_RETRIEVE',
727                 [ ses(), sre_id ]
728               );
729         if (typeof r.ilsevent != 'undefined') {
730             throw(r);
731         }
732         open_marc_editor(r, 'MFHD');
733     } catch(E) {
734         g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
735     }
736 }
737
738 function open_marc_editor(rec, label) {
739     win = window.open( xulG.url_prefix('XUL_MARC_EDIT') );
740
741     win.xulG = {
742         record : {marc : rec.marc()},
743         save : {
744             label: 'Save ' + label,
745             func: function(xmlString) {  // TODO: switch to pcrud, or define an sre update method in Serial.pm?
746                 var method = 'open-ils.permacrud.update.' + rec.classname;
747                 rec.marc(xmlString);
748                 g.network.request(
749                     'open-ils.permacrud', method,
750                     [ses(), rec]
751                 );
752                 xulG.reload_opac();
753             }
754         }
755     };
756 }
757
758 function bib_in_new_tab() {
759     try {
760         var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
761         var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
762         content_params.url_prefix = xulG.url_prefix;
763         content_params.new_tab = xulG.new_tab;
764         content_params.set_tab = xulG.set_tab;
765         content_params.close_tab = xulG.close_tab;
766         content_params.lock_tab = xulG.lock_tab;
767         content_params.unlock_tab = xulG.unlock_tab;
768         content_params.inspect_tab = xulG.inspect_tab;
769         content_params.is_tab_locked = xulG.is_tab_locked;
770         content_params.new_patron_tab = xulG.new_patron_tab;
771         content_params.set_patron_tab = xulG.set_patron_tab;
772         content_params.volume_item_creator = xulG.volume_item_creator;
773         content_params.get_new_session = xulG.get_new_session;
774         content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
775         content_params.set_tab_name = xulG.set_tab_name;
776         content_params.open_chrome_window = xulG.open_chrome_window;
777         content_params.url_prefix = xulG.url_prefix;
778         content_params.network_meter = xulG.network_meter;
779         content_params.page_meter = xulG.page_meter;
780         content_params.set_statusbar = xulG.set_statusbar;
781         content_params.set_help_context = xulG.set_help_context;
782         content_params.get_barcode = xulG.get_barcode;
783         content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
784
785         xulG.new_tab(xulG.url_prefix('XUL_OPAC_WRAPPER'), {}, content_params);
786     } catch(E) {
787         g.error.sdump('D_ERROR',E);
788     }
789 }
790
791 function batch_receive_in_new_tab() {
792     try {
793         var content_params = {"session": ses(), "authtime": ses("authtime")};
794
795         ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
796             "set_patron_tab", "volume_item_creator", "get_new_session",
797             "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
798             "url_prefix", "network_meter", "page_meter", "set_statusbar",
799             "set_help_context", "get_barcode", "reload_opac",
800             "get_barcode_and_settings"
801         ].forEach(function(k) { content_params[k] = xulG[k]; });
802
803         xulG.new_tab(
804             xulG.url_prefix('XUL_SERIAL_BATCH_RECEIVE?docid=') +
805                 window.escape(docid), {
806                 "tab_name": $("offlineStrings").getString(
807                     "menu.cmd_serial_batch_receive.tab"
808                 )
809             }, content_params
810         );
811     } catch (E) {
812         g.error.sdump("D_ERROR", E);
813     }
814 }
815
816 function remove_me() {
817     var url = xulG.url_prefix( 'XUL_BIB_BRIEF?docid=' ) + window.escape(docid);
818     dump('removing ' + url + '\n');
819     try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
820     $('nav').setAttribute('hidden','true');
821 }
822
823 function add_to_bucket() {
824     JSAN.use('util.window'); var win = new util.window();
825     win.open(
826         xulG.url_prefix('XUL_RECORD_BUCKETS_QUICK'),
827         '_blank',
828         'chrome,resizable,modal,centerscreen',
829         {
830             record_ids: [ docid ]
831         }
832     );
833 }
834
835 // FIXME: now duplicated in cat.util, which we can't import here, though maybe
836 // we can do something at build time
837 function mark_for_overlay() {
838     g.data.marked_record = docid;
839     g.data.stash('marked_record');
840     var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
841     if (typeof robj.ilsevent == 'undefined') {
842         g.data.marked_record_mvr = robj;
843     } else {
844         g.data.marked_record_mvr = null;
845         g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
846     }
847     g.data.stash('marked_record_mvr');
848     if (g.data.marked_record_mvr) {
849         alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
850         xulG.set_statusbar(
851             1,
852             $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
853             $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
854             gen_statusbar_click_handler('marked_record')
855         );
856     } else {
857         alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record  ]));
858         xulG.set_statusbar(
859             1,
860             $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
861             '',
862             gen_statusbar_click_handler('marked_record')
863         );
864     }
865 }
866
867 function mark_for_hold_transfer() {
868     g.data.marked_record_for_hold_transfer = docid;
869     g.data.stash('marked_record_for_hold_transfer');
870     var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
871     if (typeof robj.ilsevent == 'undefined') {
872         g.data.marked_record_for_hold_transfer_mvr = robj;
873     } else {
874         g.data.marked_record_for_hold_transfer_mvr = null;
875         g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
876     }
877     g.data.stash('marked_record_for_hold_transfer_mvr');
878     if (g.data.marked_record_mvr) {
879         var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
880         alert(m);
881         xulG.set_statusbar(
882             3,
883             m,
884             '',
885             gen_statusbar_click_handler('marked_record_for_hold_transfer')
886         );
887     } else {
888         var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
889         alert(m);
890         xulG.set_statusbar(
891             3,
892             m,
893             '',
894             gen_statusbar_click_handler('marked_record_for_hold_transfer')
895         );
896     }
897 }
898
899 function transfer_title_holds() {
900     g.data.stash_retrieve();
901     var target = g.data.marked_record_for_hold_transfer;
902     if (!target) {
903         var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
904         alert(m);
905         return;
906     }
907     var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
908     if (robj == 1) {
909         var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
910         alert(m);
911     } else {
912         var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
913         alert(m);
914     }
915     hold_browser_reset = true;
916     if (g.view == 'hold_browser') { set_hold_browser(); };
917 }
918
919 function delete_record() {
920     if (g.error.yns_alert(
921         document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
922         document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
923         document.getElementById('offlineStrings').getString('cat.opac.delete'),
924         document.getElementById('offlineStrings').getString('cat.opac.cancel'),
925         null,
926         document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
927         var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
928         if (typeof robj.ilsevent != 'undefined') {
929             alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error',  [docid, robj.textcode, robj.desc]) + '\n');
930         } else {
931             alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
932             refresh_display(docid);
933         }
934     }
935 }
936
937 function undelete_record() {
938     if (g.error.yns_alert(
939         document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
940         document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
941         document.getElementById('offlineStrings').getString('cat.opac.undelete'),
942         document.getElementById('offlineStrings').getString('cat.opac.cancel'),
943         null,
944         document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
945
946         var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
947         if (typeof robj.ilsevent != 'undefined') {
948             alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error',  [docid, robj.textcode, robj.desc]) + '\n');
949         } else {
950             alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
951             refresh_display(docid);
952         }
953     }
954 }
955
956 function refresh_display(id) {
957     try { 
958         marc_view_reset = true;
959         marc_edit_reset = true;
960         copy_browser_reset = true;
961         hold_browser_reset = true;
962         manage_parts_reset = true;
963         manage_multi_home_reset = true;
964         serctrl_view_reset = true;
965         while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
966         var children = bottom_pane.node.childNodes;
967         for (var i = 0; i < children.length; i++) {
968             if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
969         }
970
971         set_brief_view();
972         $('nav').setAttribute('hidden','false');
973         var settings = g.network.simple_request(
974             'FM_AUS_RETRIEVE',
975             [ ses(), g.data.list.au[0].id() ]
976         );
977         var view = settings['staff_client.catalog.record_view.default'];
978         if (g.view_override) {
979             view = g.view_override;
980             g.view_override = null;
981         }
982         switch(view) {
983             case 'marc_view' : set_marc_view(); break;
984             case 'marc_edit' : set_marc_edit(); break;
985             case 'copy_browser' : set_copy_browser(); break;
986             case 'hold_browser' : set_hold_browser(); break;
987             case 'serctrl_view' : set_serctrl_view(); break;
988             case 'opac' :
989             default: set_opac(); break;
990         }
991         opac_wrapper_set_help_context(); 
992     } catch(E) {
993         g.error.standard_unexpected_error_alert('in refresh_display',E);
994     }
995 }
996
997 function set_default() {
998     var robj = g.network.simple_request(
999         'FM_AUS_UPDATE',
1000         [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
1001     )
1002     if (typeof robj.ilsevent != 'undefined') {
1003         if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
1004     }
1005 }
1006
1007 function add_volumes() {
1008     try {
1009         var edit = 0;
1010         try {
1011             edit = g.network.request(
1012                 api.PERM_MULTI_ORG_CHECK.app,
1013                 api.PERM_MULTI_ORG_CHECK.method,
1014                 [ 
1015                     ses(), 
1016                     ses('staff_id'), 
1017                     [ ses('ws_ou') ],
1018                     [ 'CREATE_VOLUME', 'CREATE_COPY' ]
1019                 ]
1020             ).length == 0 ? 1 : 0;
1021         } catch(E) {
1022             g.error.sdump('D_ERROR','batch permission check: ' + E);
1023         }
1024
1025         if (edit==0) {
1026             alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
1027             return; // no read-only view for this interface
1028         }
1029
1030         // Check if the source is allowed to have copies.
1031         try {
1032             var bibObj = g.network.request(
1033                 api.FM_BRE_RETRIEVE_VIA_ID.app,
1034                 api.FM_BRE_RETRIEVE_VIA_ID.method,
1035                                 [ ses(), [docid] ]
1036             );
1037
1038                         bibObj = bibObj[0];
1039
1040             var cbsObj = g.network.request(
1041                 api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
1042                 api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
1043                 [ ses(), bibObj.source() ]
1044             );
1045
1046             if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
1047                 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
1048                 return;
1049             }
1050         } catch(E) {
1051             g.error.sdump('D_ERROR','can have copies check: ' + E);
1052             alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
1053             return;
1054         }
1055
1056         var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
1057
1058         var url;
1059         var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
1060         if (unified_interface) {
1061             var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
1062             url = window.xulG.url_prefix( horizontal_interface ? 'XUL_VOLUME_COPY_CREATOR_HORIZONTAL' : 'XUL_VOLUME_COPY_CREATOR' );
1063         } else {
1064             url = window.xulG.url_prefix( 'XUL_VOLUME_COPY_CREATOR_ORIGINAL' );
1065         }
1066
1067         var w = xulG.new_tab(
1068             url,
1069             { 'tab_name' : title },
1070             { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ], 'reload_opac' : xulG.reload_opac }
1071         );
1072     } catch(E) {
1073         alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
1074     }
1075 }
1076
1077 function manage_parts() {
1078     try {
1079         g.view = 'manage_parts';
1080         var loc = urls.XUL_BROWSER + "?url=" + window.escape(
1081             window.xulG.url_prefix('CONIFY_MANAGE_PARTS?r=') + docid
1082         );
1083         if (manage_parts_reset) {
1084             bottom_pane.reset_iframe( loc,{},xulG);
1085             manage_parts_reset =false;
1086         } else {
1087             bottom_pane.set_iframe( loc,{},xulG);
1088         }
1089         opac_wrapper_set_help_context();
1090         bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
1091     } catch(E) {
1092         alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
1093     }
1094 }
1095
1096 function manage_multi_home_items() {
1097     try {
1098         g.view = 'manage_multi_home';
1099         var loc = window.xulG.url_prefix('MANAGE_MULTI_HOME_ITEMS');
1100         if (manage_multi_home_reset) {
1101             bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1102             manage_multi_home_reset =false;
1103         } else {
1104             bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1105         }
1106         opac_wrapper_set_help_context();
1107         bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
1108     } catch(E) {
1109         alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
1110     }
1111 }
1112
1113 function mark_for_multi_home() {
1114     g.data.marked_multi_home_record = docid;
1115     g.data.stash('marked_multi_home_record');
1116     var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
1117     if (typeof robj.ilsevent == 'undefined') {
1118         g.data.marked_multi_home_record_mvr = robj;
1119     } else {
1120         g.data.marked_multi_home_record_mvr = null;
1121         g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
1122     }
1123     g.data.stash('marked_multi_home_record_mvr');
1124
1125     if (g.data.marked_multi_home_record_mvr) {
1126         alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
1127         xulG.set_statusbar(
1128             2,
1129             $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
1130             $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1131             gen_statusbar_click_handler('marked_multi_home_record')
1132         );
1133     } else {
1134         alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
1135         xulG.set_statusbar(
1136             2,
1137             $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1138             '',
1139             gen_statusbar_click_handler('marked_multi_home_record')
1140         );
1141     }
1142 }
1143
1144 function gen_statusbar_click_handler(data_key) {
1145     return function (ev) {
1146
1147         if (! g.data[data_key]) {
1148             return;
1149         }
1150
1151         if (ev.button == 0 /* left click, spawn opac */) {
1152             var opac_url = xulG.url_prefix( 'opac_rdetail' ) + g.data[data_key];
1153             var content_params = {
1154                 'session' : ses(),
1155                 'authtime' : ses('authtime'),
1156                 'opac_url' : opac_url,
1157             };
1158             xulG.new_tab(
1159                 xulG.url_prefix('XUL_OPAC_WRAPPER'),
1160                 {'tab_name':'Retrieving title...'},
1161                 content_params
1162             );
1163         }
1164
1165         if (ev.button == 2 /* right click, remove mark */) {
1166             if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
1167                 g.data[data_key] = null;
1168                 g.data.stash(data_key);
1169                 ev.target.setAttribute('label','');
1170                 if (ev.target.hasAttribute('tooltiptext')) {
1171                     ev.target.removeAttribute('tooltiptext');
1172                 }
1173             }
1174         }
1175     }
1176 }
1177
1178