Disable Google Chrome Frame, Google Books
authorJeff Godin <jgodin@tadl.org>
Mon, 2 Apr 2012 20:19:18 +0000 (16:19 -0400)
committerJeff Godin <jgodin@tadl.org>
Mon, 2 Apr 2012 20:19:18 +0000 (16:19 -0400)
In both the tadlstaff and the tadlv2 skins:

* Disable Google Chrome Frame by removing the div and script
* Disable Google Books links, preview by setting existing
  boolean values to false

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Open-ILS/web/opac/skin/tadlstaff/js/rdetail.js [new file with mode: 0644]
Open-ILS/web/opac/skin/tadlstaff/js/result_common.js [new file with mode: 0644]
Open-ILS/web/opac/skin/tadlstaff/xml/body.xml
Open-ILS/web/opac/skin/tadlstaff/xml/home/index_body.xml
Open-ILS/web/opac/skin/tadlv2/js/rdetail.js [new file with mode: 0644]
Open-ILS/web/opac/skin/tadlv2/js/result_common.js [new file with mode: 0644]
Open-ILS/web/opac/skin/tadlv2/xml/body.xml
Open-ILS/web/opac/skin/tadlv2/xml/home/index_body.xml

diff --git a/Open-ILS/web/opac/skin/tadlstaff/js/rdetail.js b/Open-ILS/web/opac/skin/tadlstaff/js/rdetail.js
new file mode 100644 (file)
index 0000000..dbe0384
--- /dev/null
@@ -0,0 +1,1396 @@
+
+/* */
+
+detachAllEvt('common', 'run');
+attachEvt("common", "run", rdetailDraw);
+attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns);
+attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
+attachEvt("rdetail", "recordDrawn", rdetailGetPageIds);
+
+/* Per-skin configuration settings */
+var rdetailLocalOnly = true;
+var rdetailShowLocal = true;
+var rdetailShowCopyLocation = true;
+var rdetailGoogleBookPreview = false;
+var rdetailDisplaySerialHoldings = true;
+var rdetailEnableRefWorks = false;
+var rdetailRefWorksHost = 'http://www.refworks.com';
+
+/* vars vars vars */
+var record = null;
+var cp_statuses = null;
+var recordsCache = [];
+
+var copyRowParent = null;
+var copyRow = null;
+var statusRow = null;
+var numStatuses = null;
+var defaultCN;
+var callnumberCache = {};
+var globalCNCache = {};
+var localTOC;
+var cachedRecords;
+var _statusPositions = {};
+var opac_strings;
+
+var nextContainerIndex;
+
+var nextRecord;
+var prevRecord;
+
+var rdetailPrev = null;
+var rdetailNext = null;
+var rdetailStart = null;
+var rdetailEnd = null;
+
+var mfhdDetails = [];
+var orgHiding = false;
+
+if(location.href.match(/&place_hold=1/)) {
+    // prevent load flicker between canvases
+    hideMe(dojo.byId('canvas_main'));
+}
+
+dojo.require("dijit.Dialog");
+dojo.require("dijit.form.TextBox");
+
+/* serials are currently the only use of Dojo strings in the OPAC */
+if (rdetailDisplaySerialHoldings) {
+       dojo.require("dijit.Menu");
+       dojo.require("dijit.form.Button");
+       dojo.requireLocalization("openils.opac", "opac");
+       opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
+}
+
+function rdetailReload() {
+       var args = {};
+       args[PARAM_LOCATION] = getNewSearchLocation();
+       args[PARAM_DEPTH] = depthSelGetDepth();
+       goTo(buildOPACLink(args));
+}
+
+/* looks to see if we have a next and/or previous record in the
+   record cache, if so, set up the nav links */
+function rdetailSetPaging(ids) {
+
+       cachedRecords = {};
+       cachedRecords.ids = ids;
+
+       for( var i = 0; i < cachedRecords.ids.length; i++ ) {
+               var rec = cachedRecords.ids[i];
+               if( rec == getRid() ) {
+                       if( i > 0 ) prevRecord = cachedRecords.ids[i-1];
+                       if( i < cachedRecords.ids.length - 1 )
+                               nextRecord = cachedRecords.ids[i+1];
+                       break;
+               }
+       }
+
+       $('np_offset').appendChild(text(i + 1));
+       $('np_count').appendChild(text(getHitCount()));
+
+       if(prevRecord) {
+               unHideMe($('np_table'));
+               unHideMe($('np_prev'));
+               unHideMe($('np_start'));
+               rdetailPrev = function() { _rdetailNav(prevRecord); };
+               rdetailStart = function() { _rdetailNav(cachedRecords.ids[0]); };
+       }
+
+       if(nextRecord) {
+               unHideMe($('np_table'));
+               unHideMe($('np_next'));
+               unHideMe($('np_end'));
+               rdetailNext = function() { _rdetailNav(nextRecord); };
+               rdetailEnd = function() { _rdetailNav(cachedRecords.ids[cachedRecords.ids.length-1]); };
+       }
+
+       runEvt('rdetail', 'nextPrevDrawn', i, cachedRecords.ids.length);
+}
+
+
+function _rdetailNav(id, offset) {
+       var args = {};
+       args[PARAM_RID] = id;
+       goTo(buildOPACLink(args));
+}
+
+function rdetailHandlePlaceHold() {
+    function reload() {
+        location.href = location.href.replace(/&place_hold=1/, '');
+    }
+    attachEvt("common", "holdUpdated", reload);
+    attachEvt("common", "holdUpdateCanceled", reload);
+    attachEvt("common", "loginCanceled", reload);
+    holdsDrawEditor({record:getRid(), type: 'T'});
+}
+
+function rdetailDraw() {
+
+    if(new CGI().param('place_hold')) {
+        rdetailHandlePlaceHold();
+        return;
+    }
+
+       detachAllEvt('common','depthChanged');
+       detachAllEvt('common','locationUpdated');
+       attachEvt('common','depthChanged', rdetailReload);
+       attachEvt('common','locationUpdated', rdetailReload);
+       attachEvt('common','holdUpdated', rdetailReload);
+       attachEvt('common','holdUpdateCanceled', rdetailReload);
+
+       copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
+       copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
+       statusRow = G.ui.rdetail.cp_status.parentNode;
+       statusRow.id = '__rdsrow';
+
+       G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies;
+       G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies;
+
+       if(getLocation() == globalOrgTree.id())
+               hideMe(G.ui.rdetail.cp_info_all);
+
+    if(getRid()) {
+
+           var req = new Request(FETCH_RMODS, getRid());
+           req.callback(_rdetailDraw);
+           req.send();
+
+    } else { // No record ID was specified
+
+       // If we have an ISBN in the URL, let's try to find that record
+       // This allows direct linking by ISBN.
+       // Note, this uses the first record it finds
+       if(getRtype() == RTYPE_ISBN) { 
+            var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
+            req.callback(
+                function(r) {
+                    var blob = r.getResultObject();
+                    if(blob && blob.count > 0) 
+                        RID = blob.ids[0]; 
+                    var req2 = new Request(FETCH_RMODS, getRid());
+                    req2.callback(_rdetailDraw);
+                    req2.send();
+                }
+            );
+            req.send();
+        }
+    }
+
+
+       if (rdetailDisplaySerialHoldings && (
+        isXUL() || !fetchOrgSettingDefault(
+            getLocation(), "opac.fully_compressed_serial_holdings")
+        )
+    ) {
+               var req = new Request(FETCH_MFHD_SUMMARY, getRid());
+               req.callback(_holdingsDraw);
+               req.send();
+               if (isXUL()) {
+                       var here = findOrgUnit(getLocation());
+                       dojo.place("<div id='mfhd_ad_menu'></div>", "rdetail_details_table", "after");
+                       var mfhd_add = new dijit.Menu({style:"float: right;"});
+                       new dijit.MenuItem({onClick:function(){
+                               var req = new Request(CREATE_MFHD_RECORD, G.user.session, 1, here.id(), getRid());
+                               var res = req.send();
+                               alert(dojo.string.substitute(opac_strings.CREATED_MFHD_RECORD, [here.name()]));
+                       }, label:opac_strings.CREATE_MFHD}).placeAt(mfhd_add);
+                       mfhd_add.placeAt(mfhd_ad_menu);
+               }
+       }
+
+       detachAllEvt("result", "idsReceived");
+       G.evt.result.hitCountReceived = [];
+       G.evt.result.recordReceived = [];
+       G.evt.result.copyCountsReceived = [];
+       G.evt.result.allRecordsReceived = [];
+
+    if(isXUL()) 
+        unHideMe($('rdetail_show_orders'));
+}
+
+function rdetailGetPageIds() {
+       attachEvt("result", "idsReceived", rdetailSetPaging );
+       resultFetchAllRecords = true;
+       rresultCollectIds(true);
+}
+
+
+function buildunAPISpan (span, type, id) {
+       var cgi = new CGI();
+       var d = new Date();
+
+       addCSSClass(span,'unapi-id');
+
+       span.setAttribute(
+                       'title', 'tag:' + cgi.server_name + ',' +
+                       d.getFullYear() + ':' + type + '/' + id
+                       );
+}
+
+function rdetailViewMarc(r,id) {
+       hideMe($('rdetail_extras_loading'));
+       $('rdetail_view_marc_box').innerHTML = r.getResultObject();
+
+       var div = elem('div', { "class" : 'hide_me' });
+       var span = div.appendChild( elem('abbr') );
+
+       buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
+
+       $('rdetail_view_marc_box').insertBefore(span, $('rdetail_view_marc_box').firstChild);
+}
+
+function rdetailForeignItems(r,id) {
+       hideMe($('rdetail_extras_loading'));
+    var tbody = $('rdetail_foreign_items_tbody');
+
+    var robj = r.getResultObject(); /* mvr list with foreign_copy_maps fleshed */
+
+    for (var i = 0; i < robj.length; i++) {
+        var args = {};
+        args.page = RDETAIL;
+        args[PARAM_OFFSET] = 0;
+        args[PARAM_RID] = robj[i].doc_id();
+        var row = elem('tr'); tbody.appendChild(row);
+        var td1 = elem('td'); row.appendChild(td1);
+        var title = elem(
+            'a',
+            {
+                'href' : buildOPACLink(args),
+                'class' : 'classic_link'
+            },
+            robj[i].title()
+        );
+        td1.appendChild(title);
+        var td2 = elem('td',{},robj[i].author()); row.appendChild(td2);
+        var td3 = elem('td'); row.appendChild(td3);
+        var details = elem(
+            'a',
+            {
+                'href' : 'javascript:void(0)',
+                'class' : 'classic_link'
+            },
+            'Copy Details'
+        );
+        details.onclick = function(idx,context_row){
+            return function() {
+                cpdBuild(
+                    tbody,
+                    context_row,
+                    robj[idx],
+                    null,
+                    1,
+                    0,
+                    1,
+                    dojo.map(
+                        robj[idx].foreign_copy_maps(),
+                        function(x){ return x.target_copy(); }
+                    ),
+                    dojo.map(
+                        robj[idx].foreign_copy_maps(),
+                        function(x){ return x.peer_type().name(); }
+                    )
+                );
+            };
+        }(i,row);
+        td3.appendChild(details);
+    }
+}
+
+
+
+function rdetailShowLocalCopies() {
+       rdetailShowLocal = true;
+       rdetailBuildInfoRows();
+       hideMe(G.ui.rdetail.cp_info_local);
+       unHideMe(G.ui.rdetail.cp_info_all);
+       hideMe(G.ui.rdetail.cp_info_none); 
+}
+
+function rdetailShowAllCopies() {
+
+       rdetailShowLocal = false;
+       rdetailBuildInfoRows();
+       hideMe(G.ui.rdetail.cp_info_all);
+       unHideMe(G.ui.rdetail.cp_info_local);
+       hideMe(G.ui.rdetail.cp_info_none); 
+}
+
+function OpenMarcEditWindow(pcrud, rec) {
+       /*
+          To run in Firefox directly, must set signed.applets.codebase_principal_support
+          to true in about:config
+        */
+       netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+       win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
+       dojo.require('openils.PermaCrud');
+
+       win.xulG = {
+               "record": {"marc": rec.marc(), "rtype": "sre"},
+               "save": {
+                       "label": opac_strings.SAVE_MFHD_LABEL,
+                       "func": function(xmlString) {
+                               rec.marc(xmlString);
+                               rec.edit_date('now');
+                               rec.ischanged(true);
+                               pcrud.update(rec);
+                       }
+               },
+        'lock_tab' : typeof xulG != 'undefined' ? (typeof xulG['lock_tab'] != 'undefined' ? xulG.lock_tab : undefined) : undefined,
+        'unlock_tab' : typeof xulG != 'undefined' ? (typeof xulG['unlock_tab'] != 'undefined' ? xulG.unlock_tab : undefined) : undefined
+       };
+}
+
+function loadMarcEditor(recId) {
+       var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
+       var rec = pcrud.retrieve("sre", recId);
+       if (rec) {
+               OpenMarcEditWindow(pcrud, rec);
+       }
+}
+
+/*
+ * This function could be written much more intelligently
+ * Limited brain power means that I'm brute-forcing it for now
+ */
+function _holdingsDraw(h) {
+    holdings = h.getResultObject();
+
+    if (holdings) {
+        // Only draw holdings within our OU scope
+        var here = findOrgUnit(getLocation());
+        var entryNum = 0;
+        var depth = getDepth();
+        dojo.forEach(holdings, function (item) {
+            if (orgIsMine(here, findOrgUnit(item.owning_lib()), depth)) {
+                _holdingsDrawMFHD(item, entryNum);
+                entryNum++;
+            }
+        });
+    }
+
+    // Populate (or unpopulate) XUL menus
+    if (isXUL()) {
+        runEvt('rdetail','MFHDDrawn');
+    }
+}
+
+function _holdingsDrawMFHD(holdings, entryNum) {
+       var hb = holdings.basic_holdings();
+       var hba = holdings.basic_holdings_add();
+       var hs = holdings.supplement_holdings();
+       var hsa = holdings.supplement_holdings_add();
+       var hi = holdings.index_holdings();
+       var hia = holdings.index_holdings_add();
+       var ho = holdings.online();
+       var hm = holdings.missing();
+       var hinc = holdings.incomplete();
+       var hloc = holdings.location() || 'MFHD';
+
+       if (    hb.length == 0 && hba.length == 0 && hs.length == 0 &&
+               hsa.length == 0 && hi.length == 0 && hia.length == 0 &&
+               ho.length == 0 && hm.length == 0 && hinc.length == 0
+       ) {
+
+               if (isXUL()) {
+                       /* 
+                        * If we have a record, but nothing to show for it, then the
+                        * record is likely empty or corrupt. This gives cataloguers a
+                        * chance to add holdings or correct the record
+                        */
+                       hb = ['PLACEHOLDER'];
+               } else {
+                       return null;
+               }
+       }
+
+       // Show entryNum + 1 in staff client for better menu correlation
+       // Maybe this should be holdings.sre_id() instead? (which could get long after time)
+       var entryNumString = '';
+       if (isXUL()) {
+               var entryNumInc = entryNum + 1;
+               entryNumString = ' [Entry #'+entryNumInc+'] ';
+       }
+
+       var refNode;
+       if (entryNum > 0) {
+               refNode = 'rdetail_holdings_table_' + (entryNum - 1);
+       } else {
+               refNode = 'rdetail_details_table';
+       }
+
+       dojo.place("<table style='width: 100%;' id='rdetail_holdings_table_"+entryNum+"'><caption id='mfhdHoldingsCaption" + entryNum + "' class='rdetail_header color_1'>" +
+               dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) + entryNumString +
+               "</caption><tbody id='rdetail_holdings_tbody_" + entryNum +
+               "'></tbody></table>", refNode, "after"
+       );
+       if (hb.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS, hb); }
+       if (hba.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS_ADD, hba); }
+       if (hs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS, hs); }
+       if (hsa.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS_ADD, hsa); }
+       if (hi.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS, hi); }
+       if (hia.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS_ADD, hia); }
+       if (ho.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.ONLINE_VOLUMES, ho); }
+       if (hm.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.MISSING_VOLUMES, hm); }
+       if (hinc.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INCOMPLETE_VOLUMES, hinc); }
+
+       if (isXUL() && holdings.sre_id() != -1) { // -1 indicates in-DB only holdings, so no button or menu entries for MFHD
+               mfhdDetails.push({ 'id' : holdings.sre_id(), 'label' : hloc, 'entryNum' : entryNum, 'owning_lib' : holdings.owning_lib() });
+               dojo.require('openils.Event');
+               dojo.require('openils.PermaCrud');
+               var mfhd_edit = new dijit.Menu({});
+               new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.sre_id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first");
+               new dijit.MenuItem({onClick:function(){
+                       // Avoid accidental deletion of MFHD records
+                       if (!confirm(opac_strings.DELETE_MFHD_CONFIRM)) {
+                               return;
+                       }
+                       var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
+                       var mfhd_rec = pcrud.retrieve("sre", holdings.sre_id());
+                       if (mfhd_rec) {
+                               pcrud.eliminate(mfhd_rec);
+                               alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.sre_id()]));
+                       }
+               }, label:opac_strings.DELETE_MFHD}).placeAt(mfhd_edit, "last");
+               // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.sre_id());}, label:opac_strings.EDIT_PROPERTIES}).placeAt(mfhd_edit, "last");
+               var mfhd_mb = new dijit.form.DropDownButton({dropDown: mfhd_edit, label:opac_strings.EDIT_MFHD_MENU, style:"float:right"});
+               mfhd_mb.placeAt("mfhdHoldingsCaption" + entryNum, "last");
+               mfhd_edit.startup();
+       }
+}
+
+function _holdingsDrawMFHDEntry(entryNum, entryName, entry) {
+       var flatEntry = entry.toString().replace(/,/g, ', ');
+       dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>" + entryName + "</td><td class='rdetail_item'>" + flatEntry + "</td></tr>", "rdetail_holdings_tbody_" + entryNum, "last");
+}
+
+function _rdetailDraw(r) {
+       record = r.getResultObject();
+
+       runEvt('rdetail', 'recordRetrieved', record.doc_id());
+
+       G.ui.rdetail.title.appendChild(text(record.title()));
+       buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
+       G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
+       G.ui.rdetail.edition.appendChild(text(record.edition()));
+       G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
+       G.ui.rdetail.publisher.appendChild(text(record.publisher()));
+       $('rdetail_physical_desc').appendChild(text(record.physical_description()));
+       r = record.types_of_resource();
+       if(r) {
+               G.ui.rdetail.tor.appendChild(text(r[0]));
+               setResourcePic( G.ui.rdetail.tor_pic, r[0]);
+       }
+       G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
+
+       try{
+               if(record.isbn()) {
+                       if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) {
+                               unHideMe($('rdetail.jacket_attrib_div'));
+                               var href = $('rdetail.jacket_attrib_link').getAttribute('href') +cleanISBN(record.isbn());
+                               $('rdetail.jacket_attrib_link').setAttribute('href', href);
+                       }
+                       rdetailCheckForGBPreview();
+
+               } else {
+                       hideMe($("rdetail.jacket_attrib_div"));
+                       hideMe($("rdetail_img_link"));
+               }
+       } catch(E) {}
+
+
+       // see if the record has any external links 
+       var links = record.online_loc();
+       for( var i = 0; links && links.length > 0 && i < links.length; i = i + 3 ) {
+               var href = links[i];
+               // avoid matching "HTTP: The Complete Reference"
+               if( href.match(/https?:\/|ftps?:\/|mailto:/i) ) {
+                       unHideMe($('rdetail_online_row'));
+                       // MODS can contain a display label (used for the text of the link)
+                       // as well as a note about the URL; many legacy systems conflate the
+                       // two and generate MARC records that expect the note to be used as
+                       // the text of the link, with no display label; here's the canonical
+                       // format:
+                       //
+                       // 856 40 $uhttp://localhost$yDisplay label$zPublic note
+                       //
+                       // Note that the MARC21slim2MODS XSL concatenates $3 and $y together
+                       // (as $y was defined later in MARC21's life as the display label)
+                       var displayLabel = '' + links[i+1];
+                       var note = '' + links[i+2];
+                       if(!displayLabel || displayLabel.match(/https?:\/|ftps?:\/|mailto:/i)) {
+                               if(!note || note.match(/https?:\/|ftps?:\/|mailto:/i)) {
+                                       displayLabel = href;
+                               } else {
+                                       displayLabel = note;
+                               }
+                       }
+                       $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
+                       if (note && note != displayLabel) {
+                               $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
+                       }
+                       $('rdetail_online').appendChild(elem('br'));
+               }
+       }
+
+       // Fill in our unAPI ID, if anyone cares
+       var abbrs = document.getElementsByTagName('abbr');
+       var span;
+       for (var i = 0; i < abbrs.length; i++) {
+               if (abbrs[i].getAttribute('name') == 'unapi') {
+                       span = abbrs[i];
+                       break;
+               }
+       }
+       buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
+
+       $('rdetail_place_hold').onclick = function() {
+        var src = location.href;
+
+        if(forceLoginSSL && src.match(/^http:/)) {
+
+            src = src.replace(/^http:/, 'https:');
+
+            if(!src.match(/&place_hold=1/)) {
+                src += '&place_hold=1';
+            }
+
+            location.href = src;
+
+        } else {
+            holdsDrawEditor({record:record.doc_id(), type:'T'});
+        }
+    }
+
+
+       var RW = $('rdetail_exp_refworks');
+       if (RW && rdetailEnableRefWorks) {
+
+               var here = (findOrgUnit(getLocation())).name();
+               var org_name = here.replace(" ", "+");
+               var cgi = new CGI();
+
+               RW.setAttribute(
+                       'href',
+                       rdetailRefWorksHost + '/express/expressimport.asp?vendor='
+                       + org_name
+                       + '&filter=MARC+Format&database=All+MARC+Formats&encoding=65001&url=http%3A%2F%2F'
+                       + cgi.server_name + '/opac/extras/supercat/marctxt/record/'
+                       + record.doc_id()
+              );
+
+               RW.setAttribute('target', 'RefWorksMain');
+
+               unHideMe($('rdetail_exp_refworks_span'));
+       }
+
+       $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
+       G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
+       runEvt("rdetail", "recordDrawn");
+       recordsCache.push(record);
+
+       rdetailSetExtrasSelector();
+
+       var breq = new Request(FETCH_BRE, [getRid()]);
+       breq.callback( rdetailCheckDeleted );
+       breq.send();
+
+       //resultBuildCaches( [ record ] );
+       //resultDrawSubjects();
+       //resultDrawSeries();
+
+       // grab added content 
+
+    // Proxied through Evergreen AddedContent module
+       acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
+
+    var currentISBN = cleanISBN(record.isbn());
+
+    // Not proxied, cross-site javascript
+
+    // ChiliFresh
+    if (chilifresh && chilifresh != '(none)' && currentISBN) {
+        $('chilifreshReviewLink').setAttribute('id','isbn_'+currentISBN);
+        $('chilifreshReviewResult').setAttribute('id','chili_review_'+currentISBN);
+        unHideMe($('rdetail_reviews_link'));
+        unHideMe($('rdetail_chilifresh_reviews'));
+        try {
+            chili_init();
+        } catch(E) {
+            console.log(E + '\n');
+            hideMe($('rdetail_reviews_link'));
+            hideMe($('rdetail_chilifresh_reviews'));
+        }
+    }
+
+    // Novelist
+    if (novelist && currentISBN) {
+        unHideMe($('rdetail_novelist_link'));
+    }
+
+    // Multi-Home / Foreign Items / Peer Bibs
+    var req = new Request( TEST_PEER_BIBS, record.doc_id() );
+    req.callback(function(r){
+        var test = r.getResultObject();
+        if (test == "1") {
+            unHideMe($('rdetail_foreign_items_link'));
+        }
+    }); 
+    req.send();
+}
+
+
+
+function rdetailCheckDeleted(r) {
+       var br = r.getResultObject()[0];
+       if( isTrue(br.deleted()) ) {
+               hideMe($('rdetail_place_hold'));
+               $('rdetail_more_actions_selector').disabled = true;
+               unHideMe($('rdetail_deleted_exp'));
+       }
+}
+
+function rdetailSetExtrasSelector() {
+       if(!grabUser()) return;
+       unHideMe($('rdetail_more_actions'));
+
+       var req = new Request( 
+                       FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
+       req.callback(rdetailAddBookbags);
+       req.send();
+}
+
+function rdetailAddBookbags(r) {
+
+       var containers = r.getResultObject();
+       var selector = $('rdetail_more_actions_selector');
+       var found = false;
+       var index = 3;
+       doSelectorActions(selector);
+
+       for( var i = 0; i < containers.length; i++ ) {
+               found = true;
+               var container = containers[i];
+               insertSelectorVal( selector, index++, container.name(), 
+                               "container_" + container.id(), rdetailAddToBookbag,  1 );
+       }
+
+       nextContainerIndex = index;
+}
+
+var _actions = {};
+/**
+ * Adds a new bookbag and exits.
+ * 
+ * exitstatus should be 0 if the status is to be read.
+ */
+function finishBookbag(exitstatus) {
+       var name = bbName.attr('value');
+       
+       newBBDialog.hide();     
+       bbName.attr("value", ""); // Do this after hide so the text doesn't disappear.
+       
+       if(exitstatus != 0) return; // If the user canceled, just drop off here.
+       
+       var id;
+       
+       if( id = containerCreate( name ) ) {
+               alert( $('rdetail_bb_success').innerHTML );
+               var selector = $('rdetail_more_actions_selector');
+               insertSelectorVal( selector, nextContainerIndex++, name, 
+                               "container_" + id, rdetailAddToBookbag, 1 );
+               setSelector( selector, 'start' );
+       }
+}
+
+/**
+ * Creates a new Bookbag for the user.
+ */
+function rdetailNewBookbag() {
+    newBBDialog.show(); // Show the bookbag dialog.
+    dojo.connect(dijit.byId('newBBDialog'), 'onKeyPress', function(evt) {
+        if (evt.keyCode == dojo.keys.ENTER) {
+            finishBookbag(0);
+        }
+    });
+}
+
+function rdetailAddToBookbag() {
+       var selector = $('rdetail_more_actions_selector');
+       var id = selector.options[selector.selectedIndex].value;
+       setSelector( selector, 'start' );
+
+       if( containerCreateItem( id.substring(10), record.doc_id() )) {
+               alert($('rdetail_bb_item_success').innerHTML);
+       }
+}
+
+
+var rdetailMarcFetched = false;
+var rdetailForeignItemsFetched = false;
+function rdetailShowExtra(type, args) {
+
+       hideMe($('rdetail_copy_info_div'));
+       hideMe($('rdetail_summary_div'));
+       hideMe($('rdetail_reviews_div'));
+       hideMe($('rdetail_toc_div'));
+       hideMe($('rdetail_anotes_div'));
+       hideMe($('rdetail_excerpt_div'));
+       hideMe($('rdetail_preview_div'));
+       hideMe($('rdetail_marc_div'));
+       hideMe($('cn_browse'));
+       hideMe($('rdetail_cn_browse_div'));
+       hideMe($('rdetail_novelist_div'));
+       hideMe($('rdetail_foreign_items_div'));
+       hideMe($('rdetail_notes_div'));
+
+       removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_foreign_items_link'), 'rdetail_extras_selected');
+
+       switch(type) {
+
+               case "copyinfo": 
+                       unHideMe($('rdetail_copy_info_div')); 
+                       addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
+                       break;
+
+        case "summary":
+            addCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected');
+            unHideMe($('rdetail_summary_div'));
+            break;
+
+               case "reviews": 
+                       addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_reviews_div')); 
+                       break;
+
+               case "excerpt": 
+                       addCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_excerpt_div'));
+                       break;
+
+               case "preview": 
+                       addCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_preview_div'));
+                       rdetailDisplayGBPreview();
+                       break;
+
+               case "anotes": 
+                       addCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_anotes_div'));
+                       break;
+
+               case "toc": 
+                       addCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_toc_div'));
+                       break;
+
+               case "marc": 
+                       addCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_marc_div')); 
+                       if(rdetailMarcFetched) return;
+                       unHideMe($('rdetail_extras_loading'));
+                       rdetailMarcFetched = true;
+                       var req = new Request( FETCH_MARC_HTML, record.doc_id() );
+                       req.callback(rdetailViewMarc); 
+                       req.send();
+                       break;
+
+               case "novelist": 
+                       addCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_novelist_div')); 
+                       break;
+
+               case "foreign_items": 
+                       addCSSClass($('rdetail_foreign_items_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_foreign_items_div')); 
+            if(rdetailForeignItemsFetched) return;
+                       unHideMe($('rdetail_extras_loading'));
+            rdetailForeignItemsFetched = true;
+                       var req = new Request( FETCH_PEER_BIBS, record.doc_id() );
+                       req.callback(rdetailForeignItems); 
+                       req.send();
+                       break;
+
+               case 'cn':
+                       addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_cn_browse_div'));
+                       rdetailShowCNBrowse(defaultCN[1], getLocation(), null, true);
+                       break;
+
+       }
+}
+
+function rdetailVolumeDetails(args) {
+       var row = $(args.rowid);
+       var tbody = row.parentNode;
+       cpdBuild( tbody, row, record, [args.cn_prefix, args.cn, args.cn_suffix], args.org, args.depth, args.copy_location );
+       return;
+}
+
+function rdetailBuildCNList() {
+
+       var select = $('cn_browse_selector');
+       var index = 0;
+       var arr = [];
+       for( var cn_json in callnumberCache ) arr.push( cn_json );
+       arr.sort();
+
+       if( arr.length == 0 ) {
+               hideMe($('rdetail_cn_browse_select_div'));
+               return;
+       }
+
+       for( var i = 0; i < arr.length; i++ ) {
+               var cn_json = arr[i];
+        var cn = JSON2js(cn_json);
+        var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : '');
+               var opt = new Option(whole_cn_text,cn_json);
+               select.options[index++] = opt;
+       }
+       select.onchange = rdetailGatherCN;
+}
+
+function rdetailGatherCN() {
+       var cn = getSelectorVal($('cn_browse_selector'));
+       rdetailShowCNBrowse( JSON2js(cn), getLocation(), getDepth(), true );
+       setSelector( $('cn_browse_selector'), cn );
+}
+
+
+function rdetailShowCNBrowse( cn, loc, depth, fromOnclick ) {
+
+       if(!cn) {
+               unHideMe($('cn_browse_none'));
+               hideMe($('rdetail_cn_browse_select_div'));
+               return;
+       }
+
+       unHideMe($('rdetail_cn_browse_select_div'));
+       rdetailBuildCNList();
+       setSelector( $('cn_browse_selector'), js2JSON(cn) );
+       hideMe($('rdetail_copy_info_div'));
+       hideMe($('rdetail_reviews_div'));
+       hideMe($('rdetail_summary_div'));
+       hideMe($('rdetail_toc_div'));
+       hideMe($('rdetail_marc_div'));
+       unHideMe($('rdetail_cn_browse_div'));
+       unHideMe($('cn_browse'));
+       if( !rdetailLocalOnly && ! fromOnclick ) depth = findOrgDepth(globalOrgTree);
+       cnBrowseGo(cn, loc, depth);
+}
+
+function rdetailhandleAC(data) {
+
+       if( data.summary.html ) {
+               $('rdetail_summary_div').innerHTML = data.summary.html;
+               unHideMe($('rdetail_summary_link'));
+       }
+
+       if( data.reviews.html ) {
+               $('rdetail_review_container').innerHTML = data.reviews.html;
+               unHideMe($('rdetail_reviews_link'));
+       }
+
+       if( data.toc.html ) {
+               $('rdetail_toc_div').innerHTML = data.toc.html;
+               unHideMe($('rdetail_toc_link'));
+       }
+
+       if( data.excerpt.html ) {
+               $('rdetail_excerpt_div').innerHTML = data.excerpt.html;
+               unHideMe($('rdetail_excerpt_link'));
+       }
+
+       if( data.anotes.html ) {
+               $('rdetail_anotes_div').innerHTML = data.anotes.html;
+               unHideMe($('rdetail_anotes_link'));
+       }
+}
+
+function rdetailShowReviews(r) {
+       hideMe($('rdetail_extras_loading'));
+       var res = r.getResultObject();
+       var par = $('rdetail_reviews_div');
+       var template = par.removeChild($('rdetail_review_template'));
+       if( res && res.length > 0 ) {
+               unHideMe($('rdetail_reviews_link'));
+               for( var i = 0; i < res.length; i++ ) {
+                       var rev = res[i];       
+                       if( rev.text && rev.info ) {
+                               var node = template.cloneNode(true);
+                               $n(node, 'review_header').appendChild(text(rev.info));
+                               $n(node, 'review_text').appendChild(text(rev.text));
+                               par.appendChild(node);
+                       }
+               }
+       }
+}
+
+
+function rdetailShowTOC(r) {
+       hideMe($('rdetail_extras_loading'));
+       var resp = r.getResultObject();
+       if(resp) {
+               unHideMe($('rdetail_toc_link'));
+               $('rdetail_toc_div').innerHTML = resp;
+       }
+}
+
+function rdetailBuildInfoRows() {
+       var req;
+       var method = FETCH_COPY_COUNTS_SUMMARY;
+       if (rdetailShowCopyLocation)
+               method = FETCH_COPY_LOCATION_COUNTS_SUMMARY;
+       if( rdetailShowLocal ) 
+               req = new Request(method, record.doc_id(), getLocation(), getDepth())
+       else
+               req = new Request(method, record.doc_id());
+       req.callback(_rdetailBuildInfoRows);
+       req.send();
+}
+
+function _rdetailRows(node) {
+
+       if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) {
+               var loc = findOrgUnit(getLocation());
+               if( node ) {
+                       if( !orgIsMine(node, loc) && !orgIsMine(loc,node) ) return;
+               } else {
+            var kids = globalOrgTree.children();
+            if (kids) {
+                       for( var i = 0; i < kids.length; i++ ) {
+                               var org = findOrgUnit(kids[i]);
+                               if( orgIsMine(org, loc) ) {
+                                       node = org;
+                                       break;
+                               }
+                }
+                       }
+               } 
+       }
+
+       if(!node && findOrgType(globalOrgTree.ou_type()).can_have_vols())
+               node = globalOrgTree;
+
+
+       /* don't show hidden orgs */
+
+       if(node) {
+
+               if(!isXUL() && !isTrue(node.opac_visible())) return;
+
+               if (orgHiding) {
+                       if (isTrue( findOrgType(node.ou_type()).can_have_vols() )) {
+                               if ( ! orgIsMine( orgHiding.org, node, orgHiding.depth ) ) {
+                                       return;
+                               }
+                       }
+               }
+
+               var row = copyRow.cloneNode(true);
+               row.id = "cp_info_" + node.id();
+
+               var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
+               var cntd  = findNodeByName( row, config.names.rdetail.cn_cell );
+               var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell );
+               var actions = $n(row, 'rdetail_actions_cell');
+
+               var p = libtd.getElementsByTagName('a')[0];
+               libtd.insertBefore(text(node.name()), p);
+               libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1)  * 9) + "px;");
+
+               if(!findOrgType(node.ou_type()).can_have_vols()) {
+
+                       row.removeChild(cntd);
+                       row.removeChild(cpctd);
+                       row.removeChild(actions);
+                       row.setAttribute('novols', '1');
+
+                       libtd.setAttribute("colspan", numStatuses + 3 );
+                       libtd.colSpan = numStatuses + 3;
+                       addCSSClass(row, 'copy_info_region_row');
+               } 
+
+               copyRowParent.appendChild(row);
+
+       } else { node = globalOrgTree; }
+
+    var kids = node.children();
+    if (kids) {
+       for( var c = 0; c < kids.length; c++ ) 
+               _rdetailRows(kids[c]);
+    }
+}
+
+function rdetailCNPrint(orgid, cn) {
+       var div = cpdBuildPrintWindow( record, orgid);
+       var template = div.removeChild($n(div, 'cnrow'));
+       var rowNode = $("cp_info_" + orgid);
+       cpdStylePopupWindow(div);
+       openWindow(div.innerHTML);
+}
+
+var localCNFound = false;
+var ctr = 0;
+function _rdetailBuildInfoRows(r) {
+
+       if (rdetailShowCopyLocation)
+               unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) );
+
+       removeChildren(copyRowParent);
+
+       orgHiding = checkOrgHiding();
+
+       _rdetailRows();
+
+       var summary = r.getResultObject();
+       if(!summary) return;
+
+       var found = false;
+       for( var i = 0; i < summary.length; i++ ) {
+
+               var arr = summary[i];
+               globalCNCache[js2JSON([arr[1],arr[2],arr[3]])] = 1; // prefix, label, suffix.  FIXME - Am I used anywhere?
+               var thisOrg = findOrgUnit(arr[0]);
+               var rowNode = $("cp_info_" + thisOrg.id());
+               if(!rowNode) continue;
+
+               if(rowNode.getAttribute("used")) {
+
+                       if( rowNode.nextSibling ) {
+                               sib = rowNode.nextSibling;
+                               o ='cp_info_'+thisOrg.id()+'_';
+                               /* push the new row on as the last row for this org unit */
+                               while( sib && sib.id.match(o) ) {
+                                       sib = sib.nextSibling;
+                               }
+                               if(sib)
+                                       rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib);
+                               else
+                                       rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
+                       } else {
+                               rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
+                       }
+
+                       var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
+                       n.appendChild(text(thisOrg.name()));
+                       n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1)  * 9) + "px;");
+                       rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr); 
+
+               } else {
+                       rowNode.setAttribute("used", "1");
+               }
+
+               var cpc_temp = rowNode.removeChild(
+                               findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
+
+               var statuses = arr[4];
+               var cl = '';
+               if (rdetailShowCopyLocation) {
+                       cl = arr[4];
+                       statuses = arr[5];
+               }
+
+
+               rdetailApplyStatuses(rowNode, cpc_temp, statuses);
+
+               var isLocal = false;
+               if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) { 
+                       found = true; 
+                       isLocal = true; 
+                       if(!localCNFound) {
+                               localCNFound = true;
+                               defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix
+                       }
+               }
+
+               //if(isLocal) unHideMe(rowNode);
+               unHideMe(rowNode);
+
+               rdetailSetPath( thisOrg, isLocal );
+               rdetailBuildBrowseInfo( rowNode, [arr[1],arr[2],arr[3]], isLocal, thisOrg, cl );
+
+               if( i == summary.length - 1 && !defaultCN) defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix
+       }
+
+       if(!found) unHideMe(G.ui.rdetail.cp_info_none);
+}
+
+function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
+
+    var whole_cn_json = js2JSON(cn);
+    var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : '');
+
+       if(local) {
+               var cache = callnumberCache[whole_cn_json];
+               if( cache ) cache.count++;
+               else callnumberCache[whole_cn_json] = { count : 1 };
+       }
+
+       var depth = getDepth();
+       if( !local ) depth = findOrgDepth(globalOrgTree);
+
+       $n(row, 'rdetail_callnumber_cell').appendChild(text(whole_cn_text));
+
+       if (rdetailShowCopyLocation) {
+               var cl_cell = $n(row, 'rdetail_copylocation_cell');
+               cl_cell.appendChild(text(cl));
+               unHideMe(cl_cell);
+       }
+
+       _debug('setting action clicks for cn ' + whole_cn_text);
+
+       var dHref = 'javascript:rdetailVolumeDetails('+
+                       '{copy_location : "'+cl.replace(/\"/g, '\\"')+'", rowid : "'+row.id+'", cn_prefix :"'+cn[0].replace(/\"/g, '\\"')+'",cn :"'+cn[1].replace(/\"/g, '\\"')+'",cn_suffix :"'+cn[2].replace(/\"/g, '\\"')+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
+
+       var bHref = 'javascript:rdetailShowCNBrowse("'+cn[1].replace(/\"/g, '\\"') + '", '+orgNode.id()+', "'+depth+'");'; 
+
+       unHideMe( $n(row, 'details') )
+               $n(row, 'details').setAttribute('href', dHref);
+       unHideMe( $n(row, 'browse') )
+               $n(row, 'browse').setAttribute('href', bHref);
+
+       if(isXUL()) {
+               unHideMe($n(row, 'hold_div'));
+               $n(row, 'hold').onclick = function() {
+                       var req = new Request(FETCH_VOLUME_BY_INFO, cn, record.doc_id(), orgNode.id());
+                       req.callback(
+                                       function(r) {
+                                       var vol = r.getResultObject();
+                                       holdsDrawEditor({type: 'V', volumeObject : vol});
+                                       }
+                                   );
+                       req.send();
+               };
+       }
+}
+
+// sets the path to org as 'active' and displays the path if it's local 
+function rdetailSetPath(org, local) {
+       if( findOrgDepth(org) == 0 ) return;
+       var row = $("cp_info_" + org.id());
+       row.setAttribute("hasinfo", "1");
+       unHideMe(row);
+       rdetailSetPath(findOrgUnit(org.parent_ou()), local);
+}
+
+//Append all the statuses for a given summary to the 
+//copy summary table 
+function rdetailApplyStatuses( row, template, statuses ) {
+       for( var j in _statusPositions ) {
+               var stat = _statusPositions[j];
+               var val = statuses[stat.id()];
+               var nn = template.cloneNode(true);
+               if(val) nn.appendChild(text(val));
+               else nn.appendChild(text(0));
+               row.appendChild(nn);
+       }
+}
+
+//Add one td (creating a new column) to the copy summary
+//table for each opac_visible copy status
+function rdetailBuildStatusColumns() {
+
+       rdetailGrabCopyStatuses();
+       var parent = statusRow;
+       var template = parent.removeChild(G.ui.rdetail.cp_status);
+
+       var i = 0;
+       for( i = 0; i < cp_statuses.length; i++ ) {
+
+               var c = cp_statuses[i];
+               if( c && isTrue(c.opac_visible()) ) {
+                       var name = c.name();
+                       _statusPositions[i] = c;
+                       var node = template.cloneNode(true);
+                       var data = findNodeByName( node, config.names.rdetail.cp_status);
+
+                       data.appendChild(text(name));
+                       parent.appendChild(node);
+               }
+       }       
+
+       numStatuses = 0;
+       for(x in _statusPositions) numStatuses++; 
+}
+
+function rdetailGrabCopyStatuses() {
+       if(cp_statuses) return cp_statuses;
+       var req = new Request(FETCH_COPY_STATUSES);
+       req.send(true);
+       cp_statuses = req.result();
+       cp_statuses = cp_statuses.sort(_rdetailSortStatuses);
+}
+
+function _rdetailSortStatuses(a, b) {
+       return parseInt(a.id()) - parseInt(b.id());
+}
+
+/**
+ * Check for a Google Book preview after the main page loads
+ */
+function rdetailCheckForGBPreview() {
+       if (!rdetailGoogleBookPreview) return;
+        dojo.addOnLoad(function() {
+               searchForGBPreview( cleanISBN(record.isbn()) );
+       });
+}
+
+/**
+ *
+ * @param {DOM object} isbn The form element containing the input parameters "isbns"
+ */
+function searchForGBPreview( isbn ) {
+       dojo.require("dojo.io.script");
+       dojo.io.script.get({"url": "https://www.google.com/jsapi"});
+       dojo.io.script.get({"url": "http://books.google.com/books", "content": { "bibkeys": isbn, "jscmd": "viewapi", "callback": "GBPreviewCallback"}});
+}
+
+/**
+ * This function is the call-back function for the JSON scripts which 
+ * executes a Google book search response.
+ *
+ * XXX I18N of text needed
+ *
+ * @param {JSON} GBPBookInfo is the JSON object pulled from the Google books service.
+ */
+function GBPreviewCallback(GBPBookInfo) {
+       var GBPreviewDiv = document.getElementById("rdetail_preview_div");
+       var GBPBook;
+
+       for ( i in GBPBookInfo ) {
+               GBPBook = GBPBookInfo[i];
+       }
+
+       if ( !GBPBook ) {
+               return;
+       }
+
+       if ( GBPBook.preview != "noview" ) {
+               // Add a button below the book cover image to load the preview.
+               GBPBadge = document.createElement( 'img' );
+               GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif';
+               GBPBadge.title = $('rdetail_preview_badge').innerHTML;
+               GBPBadge.style.border = 0;
+               GBPBadgelink = document.createElement( 'a' );
+               GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");';
+               GBPBadgelink.appendChild( GBPBadge );
+               $('rdetail_image_cell').appendChild( GBPBadgelink );
+               $('rdetail_preview_div').style.height = 600;
+
+               /* Display the "Preview" tab in the Extras section */
+               unHideMe( $('rdetail_preview_link' ) );
+       }
+}
+
+/**
+ *  This is called when the user clicks on the 'Preview' link.  We assume
+ *  a preview is available from Google if this link was made visible.
+ *
+ * XXX I18N of Google Book Preview language attribute needed
+ */
+function rdetailDisplayGBPreview() {
+       unHideMe($('rdetail_extras_loading'));
+       GBPreviewPane = $('rdetail_preview_div');
+       if ( GBPreviewPane.getAttribute('loaded') == null ||
+               GBPreviewPane.getAttribute('loaded') == "false" ) {
+               google.load("books", "0", {"callback" : rdetailGBPViewerLoadCallback, "language": "en"} );
+               GBPreviewPane.setAttribute('loaded', 'true');
+       }
+}
+
+function rdetailGBPViewerLoadCallback() {
+       hideMe($('rdetail_extras_loading'));
+       var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div'));
+       GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );
+
+}
+
+function rdetailDrawExpandedHoldings(anchor, bibid, type) {
+    var offsets = {"basic": 0, "index": 0, "supplement": 0};
+    var limit = 10; /* XXX give user control over this? */
+    var target_id = "holding_type_" + type;
+    var target = dojo.byId(target_id);
+
+    anchor.innerHTML = "[-]";
+    anchor.oldonclick = anchor.onclick;
+    anchor.onclick = function() {
+        anchor.onclick = anchor.oldonclick;
+        anchor.innerHTML = "[+]";
+        dojo.empty(target);
+    };
+
+    function _load() {
+        dojo.empty(target);
+        fieldmapper.standardRequest(
+            ["open-ils.serial",
+                "open-ils.serial.received_siss.retrieve.by_bib.atomic"], {
+                "params": [bibid, {"offset": offsets[type], "limit": limit}],
+                "async": true,
+                "oncomplete": function(r) {
+                    try {
+                        if (msg = r.recv().content()) { /* sic, assignment */
+                            if (!msg.length) return;
+                            offsets[type] += msg.length;
+                            var table = dojo.create("table", null, target);
+                            dojo.forEach(
+                                msg, function(o) {
+                                    var tr = dojo.create("tr", null, table);
+                                    dojo.create(
+                                        "td", {
+                                            "innerHTML": o.issuance.label(),
+                                            "style": {"paddingLeft": "3em"}
+                                        }, tr
+                                    );
+
+                                    if (!o.has_units) return;
+                                    /* can't place holds if no units */
+                                    var td = dojo.create("td", null, tr);
+                                    dojo.create(
+                                        "a", {
+                                            "href":"javascript:void(0);",
+                                            "style": {"marginLeft": "1.5em"},
+                                            "onclick": function() {
+                                                holdsDrawEditor({
+                                                    "type": "I",
+                                                    "issuance": o.issuance.id()
+                                                });
+                                            },
+                                            "innerHTML": "[" +
+                                                opac_strings.PLACE_HOLD + "]"
+                                        }, td
+                                    );
+                                }
+                            );
+                            if (msg.length == limit) {
+                                dojo.create("br", null, target);
+                                dojo.create(
+                                    "a", {
+                                        "href": "javascript:void(0);",
+                                        "innerHTML":
+                                            "[" + opac_strings.MORE + "]",
+                                        "onclick": _load
+                                    }, target
+                                );
+                            }
+                        }
+                    } catch (E) {
+                        void(0);
+                    }
+                }
+            }
+        );
+    }
+    _load();
+}
diff --git a/Open-ILS/web/opac/skin/tadlstaff/js/result_common.js b/Open-ILS/web/opac/skin/tadlstaff/js/result_common.js
new file mode 100644 (file)
index 0000000..2044489
--- /dev/null
@@ -0,0 +1,859 @@
+dojo.require('openils.BibTemplate');
+dojo.requireLocalization("openils.opac", "opac");
+var opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
+
+var recordsHandled = 0;
+var recordsCache = [];
+var lowHitCount = 4;
+var isbnList = '';
+var googleBooksLink = false;
+
+var resultFetchAllRecords = false;
+var resultCompiledSearch = null;
+
+/* set up the event handlers */
+if( findCurrentPage() == MRESULT || findCurrentPage() == RRESULT ) {
+       G.evt.result.hitCountReceived.push(resultSetHitInfo);
+       G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
+       G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
+       G.evt.result.allRecordsReceived.push( function(){unHideMe($('result_info_2'))}, fetchGoogleBooksLink, fetchChiliFreshReviews);
+
+       attachEvt('result','lowHits',resultLowHits);
+       attachEvt('result','zeroHits',resultZeroHits);
+       attachEvt( "common", "locationUpdated", resultSBSubmit );
+       /* do this after we have ID's so the rank for mr pages will be correct */
+       attachEvt("result", "preCollectRecords", resultPaginate);
+}
+
+function resultSBSubmit(){searchBarSubmit();}
+
+/* returns the last 'index' postion ocurring in this page */
+function resultFinalPageIndex() {
+       if(getHitCount() < (getOffset() + getDisplayCount())) 
+               return getHitCount() - 1;
+       return getOffset() + getDisplayCount() - 1;
+}
+
+
+
+
+/* generic search method */
+function resultCollectSearchIds( type, method, handler ) {
+
+       var sort                = (getSort() == SORT_TYPE_REL) ? null : getSort(); 
+       var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
+
+       var item_type;
+       var item_form;
+       var args = {};
+
+       if( type ) {
+               var form = parseForm(getForm());
+               item_type = form.item_type;
+               item_form = form.item_form;
+
+       } else {
+               item_type = (getItemType()) ? getItemType().split(/,/) : null;
+               item_form = (getItemForm()) ? getItemForm().split(/,/) : null;
+       }
+
+       var limit = (resultFetchAllRecords) ? 1000 : getDisplayCount();
+
+       if( getOffset() > 0 ) {
+               if( getHitCount() > 0 && (getOffset() + getDisplayCount()) > getHitCount() ) 
+                       limit = getHitCount() - getOffset();
+       }
+
+       var lasso = getLasso();
+
+       if (lasso) args.org_unit = -lasso;
+       else args.org_unit = getLocation();
+
+       args.depth    = getDepth();
+       args.limit    = limit;
+       args.offset   = getOffset();
+       args.visibility_limit = 3000;
+    args.default_class = getStype();
+
+       if(sort) args.sort = sort;
+       if(sortdir) args.sort_dir = sortdir;
+       if(item_type) args.item_type    = item_type;
+       if(item_form) args.item_form    = item_form;
+    if(getAvail()) args.available = 1;
+
+
+       if(getFacet()) args.facets  = getFacet();
+
+       if(getAudience()) args.audience  = getAudience().split(/,/);
+       if(getLitForm()) args.lit_form  = getLitForm().split(/,/);
+       if(getLanguage()) args.language = getLanguage().split(/,/);
+       if(getBibLevel()) args.bib_level        = getBibLevel().split(/,/);
+       if(getCopyLocs()) args.locations        = getCopyLocs().split(/,/);
+    if(getPubdBefore()) args.before = getPubdBefore();
+    else if(getPubdAfter()) args.after = getPubdAfter();
+    else if(getPubdBetween()) args.between = getPubdBetween().split(/,/);
+
+       _debug('Search args: ' + js2JSON(args));
+       _debug('Raw query: ' + getTerm());
+
+       var my_ou = findOrgUnit(args.org_unit);
+       if (my_ou && my_ou.shortname()) {
+               var atomfeed = "/opac/extras/opensearch/1.1/" + my_ou.shortname() + "/atom-full/" + getStype() + '?searchTerms=' + getTerm();
+               if (args.facets) { atomfeed += ' ' + args.facets; }
+               if (sort) { atomfeed += '&searchSort=' + sort; }
+               if (sortdir) { atomfeed += '&searchSortDir=' + sortdir; }
+               dojo.create('link', {"rel":"alternate", "href":atomfeed, "type":"application/atom+xml"}, dojo.query('head')[0]);
+       }
+
+       var req = new Request(method, args, getTerm(), 1);
+       req.callback(handler);
+       req.send();
+}
+
+
+
+
+
+/* set the search result info, number of hits, which results we're 
+       displaying, links to the next/prev pages, etc. */
+function resultSetHitInfo() { 
+
+       var lasso = getLasso();
+       if (!lasso) {
+               /* tell the user where the results are coming from */
+               var baseorg = findOrgUnit(getLocation());
+               var depth = getDepth();
+               var mydepth = findOrgDepth(baseorg);
+               if( findOrgDepth(baseorg) != depth ) {
+                       var tmporg = baseorg;
+                       while( mydepth > depth ) {
+                               mydepth--;
+                               tmporg = findOrgUnit(tmporg.parent_ou());
+                       }
+                       unHideMe($('including_results_for'));
+                       $('including_results_location').appendChild(text(tmporg.name()));
+               }
+       }
+
+
+       try{searchTimer.stop()}catch(e){}
+
+       //if( findCurrentPage() == MRESULT ) {
+       if( findCurrentPage() == MRESULT || 
+
+               (findCurrentPage() == RRESULT &&
+                       (
+                               getRtype() == RTYPE_TITLE ||
+                               getRtype() == RTYPE_AUTHOR ||
+                               getRtype() == RTYPE_SUBJECT ||
+                               getRtype() == RTYPE_SERIES ||
+                               getRtype() == RTYPE_KEYWORD 
+                       )
+
+               ) ) {
+
+               if(getHitCount() <= lowHitCount && getTerm())
+                       runEvt('result', 'lowHits');
+       }
+
+       if(getHitCount() == 0) {
+               runEvt('result', 'zeroHits');
+               return;
+       }
+
+
+       var pages = getHitCount() / getDisplayCount();
+       if(pages % 1) pages = parseInt(pages) + 1;
+
+       
+
+       var cpage = (getOffset()/getDisplayCount()) + 1;
+
+       G.ui.result.current_page.appendChild(text(cpage));
+       G.ui.result.num_pages.appendChild(text(pages + ")")); /* the ) is dumb */
+
+       $('current_page2').appendChild(text(cpage));
+       $('num_pages2').appendChild(text(pages + ")")); /* the ) is dumb */
+
+       /* set the offsets */
+       var offsetEnd = getDisplayCount() + getOffset();  
+       if( getDisplayCount() > (getHitCount() - getOffset()))  
+               offsetEnd = getHitCount();
+
+       G.ui.result.offset_end.appendChild(text(offsetEnd));
+       G.ui.result.offset_start.appendChild(text(getOffset() + 1));
+
+       $('offset_end2').appendChild(text(offsetEnd));
+       $('offset_start2').appendChild(text(getOffset() + 1));
+
+       G.ui.result.result_count.appendChild(text(getHitCount()));
+       unHideMe(G.ui.result.info);
+
+       $('result_count2').appendChild(text(getHitCount()));
+       unHideMe($('result_info_div2'));
+}
+
+function resultLowHits() {
+       showCanvas();
+       unHideMe($('result_low_hits'));
+       if(getHitCount() > 0)
+               unHideMe($('result_low_hits_msg'));
+
+    var words = [];
+    for(var key in resultCompiledSearch.searches) 
+        words.push(resultCompiledSearch.searches[key].term);
+
+       var sreq = new Request(CHECK_SPELL, words.join(' '));
+       sreq.callback(resultSuggestSpelling);
+       sreq.send();
+
+    for(var key in resultCompiledSearch.searches) {
+               var areq = new Request(FETCH_CROSSREF, key, resultCompiledSearch.searches[key].term);
+               areq.callback(resultLowHitXRef);
+               areq.send();
+       }
+
+       if( !(getForm() == null || getForm() == 'all' || getForm() == "") ) {
+               var a = {};
+               a[PARAM_FORM] = "all";
+               $('low_hits_remove_format_link').setAttribute('href',buildOPACLink(a));
+               unHideMe($('low_hits_remove_format'));
+       }
+
+       resultSuggestSearchClass();
+
+       if(getTerm()) resultExpandSearch(); /* advanced search */
+}
+
+var lowHitsXRefSet = {};
+var lowHitsXRefLink;
+var lowHitsXRefLinkParent;
+function resultLowHitXRef(r) {
+       if(!lowHitsXRefLink){
+               lowHitsXRefLinkParent = $('low_hits_xref_link').parentNode;
+               lowHitsXRefLink = lowHitsXRefLinkParent.removeChild($('low_hits_xref_link'));
+       }
+       var res = r.getResultObject();
+       var arr = res.from;
+       arr.concat(res.also);
+       if(arr && arr.length > 0) {
+               unHideMe($('low_hits_cross_ref'));
+               var word;
+               var c = 0;
+               while( word = arr.shift() ) {
+
+            if (lowHitsXRefSet[word] == 1) continue;
+            lowHitsXRefSet[word] = 1;
+
+                       if(c++ > 20) break;
+                       var a = {};
+                       a[PARAM_TERM] = word;
+                       var template = lowHitsXRefLink.cloneNode(true);
+                       template.setAttribute('href',buildOPACLink(a));
+                       template.appendChild(text(word));
+                       lowHitsXRefLinkParent.appendChild(template);
+                       lowHitsXRefLinkParent.appendChild(text(' '));
+               }
+       }
+}
+
+function resultZeroHits() {
+       showCanvas();
+       unHideMe($('result_low_hits'));
+       unHideMe($('result_zero_hits_msg'));
+       //if(getTerm()) resultExpandSearch(); /* advanced search */
+}
+
+function resultExpandSearch() {
+       var top = findOrgDepth(globalOrgTree);
+       if(getDepth() == top) return;
+       unHideMe($('low_hits_expand_range'));
+       var par = $('low_hits_expand_link').parentNode;
+       var template = par.removeChild($('low_hits_expand_link'));
+
+       var bottom = getDepth();
+       while( top < bottom ) {
+               var a = {};
+               a[PARAM_DEPTH] = top;
+               var temp = template.cloneNode(true);
+               temp.appendChild(text(findOrgTypeFromDepth(top).opac_label()))
+               temp.setAttribute('href',buildOPACLink(a));
+               par.appendChild(temp);
+               top++;
+       }
+}
+
+function resultSuggestSearchClass() {
+       var stype = getStype();
+       if(stype == STYPE_KEYWORD) return;
+       var a = {}; var ref;
+       unHideMe($('low_hits_search_type'));
+       if(stype != STYPE_TITLE) {
+               ref = $('low_hits_title_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_TITLE;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_AUTHOR) {
+               ref = $('low_hits_author_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_AUTHOR;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_SUBJECT) {
+               ref = $('low_hits_subject_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_SUBJECT;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_KEYWORD) {
+               ref = $('low_hits_keyword_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_KEYWORD;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_SERIES) {
+               ref = $('low_hits_series_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_SERIES;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+}
+
+function resultSuggestSpelling(r) {
+       var res = r.getResultObject();
+       var phrase = getTerm();
+       var words = phrase.split(/ /);
+
+       var newterm = "";
+
+       for( var w = 0; w < words.length; w++ ) {
+               var word = words[w];
+               var blob = grep(res, function(i){return (i.word == word);});
+               if( blob ) blob = blob[0];
+               else continue;
+               if( blob.word == word ) {
+                       if( !blob.found && blob.suggestions && blob.suggestions[0] ) {
+                               newterm += " " + blob.suggestions[0];
+                               unHideMe($('did_you_mean'));
+                       } else {
+                               newterm += " " + word;
+                       }
+               }
+       }
+
+       var arg = {};
+       arg[PARAM_TERM] = newterm;
+       $('spell_check_link').setAttribute('href', buildOPACLink(arg));
+       $('spell_check_link').appendChild(text(newterm));
+}
+
+
+function resultPaginate() {
+       var o = getOffset();
+
+       if( !(  ((o) + getDisplayCount()) >= getHitCount()) ) {
+
+               var args = {};
+               args[PARAM_OFFSET]      = o + getDisplayCount();
+               args[PARAM_SORT]                = SORT;
+               args[PARAM_SORT_DIR] = SORT_DIR;
+               args[PARAM_RLIST]               = new CGI().param(PARAM_RLIST);
+
+               G.ui.result.next_link.setAttribute("href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
+
+               $('next_link2').setAttribute("href", buildOPACLink(args)); 
+               addCSSClass($('next_link2'), config.css.result.nav_active);
+
+               args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
+
+               /* when hit count is divisible by display count, we have to adjust */
+               if( getHitCount() % getDisplayCount() == 0 ) 
+                       args[PARAM_OFFSET] -= getDisplayCount();
+
+        /*
+               G.ui.result.end_link.setAttribute("href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.end_link, config.css.result.nav_active);
+
+               $('end_link2').setAttribute("href", buildOPACLink(args)); 
+               addCSSClass($('end_link2'), config.css.result.nav_active);
+        */
+       }
+
+       if( o > 0 ) {
+
+               var args = {};
+               args[PARAM_SORT]                = SORT;
+               args[PARAM_SORT_DIR] = SORT_DIR;
+               args[PARAM_RLIST]               = new CGI().param(PARAM_RLIST);
+
+               args[PARAM_OFFSET] = o - getDisplayCount();
+               G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
+
+               $('prev_link2').setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass($('prev_link2'), config.css.result.nav_active);
+
+               args[PARAM_OFFSET] = 0;
+               G.ui.result.home_link.setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
+
+               $('search_home_link2').setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass($('search_home_link2'), config.css.result.nav_active);
+       }
+
+       if(getDisplayCount() < getHitCount()) {
+               unHideMe($('start_end_links_span'));
+               unHideMe($('start_end_links_span2'));
+   }
+
+       showCanvas();
+       try{searchTimer.stop()}catch(e){}
+}
+
+function buildunAPISpan (span, type, id) {
+       var cgi = new CGI();
+       var d = new Date();
+
+       addCSSClass(span,'unapi-id');
+
+       span.setAttribute(
+               'title',
+               'tag:' + cgi.server_name + ',' +
+                       d.getFullYear() +
+                       ':' + type + '/' + id
+       );
+}
+
+function unhideGoogleBooksLink (data) {
+    for ( var i in data ) {
+        //if (data[i].preview == 'noview') continue;
+
+        var gbspan = $n(document.documentElement, 'googleBooksLink-' + i);
+        var gba = $n(gbspan, "googleBooks-link");
+
+        gba.setAttribute(
+            'href',
+            data[i].info_url
+        );
+        removeCSSClass( gbspan, 'hide_me' );
+    }
+}
+
+/* display the record info in the record display table 'pos' is the 
+               zero based position the record should have in the display table */
+function resultDisplayRecord(rec, pos, is_mr) {
+
+    fieldmapper.IDL.load(['mvr']);
+       if(rec == null) rec = new mvr(); /* so the page won't die if there was an error */
+       recordsHandled++;
+       recordsCache.push(rec);
+
+       var r = table.rows[pos + 1];
+    var currentISBN = cleanISBN(rec.isbn());
+
+    if (googleBooksLink) {
+           var gbspan = $n(r, "googleBooksLink");
+        if (currentISBN) {
+            gbspan.setAttribute(
+                'name',
+                gbspan.getAttribute('name') + '-' + currentISBN
+            );
+
+            if (isbnList) isbnList += ', ';
+            isbnList += currentISBN;
+        }
+    }
+
+    if (currentISBN && chilifresh && chilifresh != '(none)') {
+        var cfrow = $n(r, "chilifreshReview");
+        if (cfrow) {
+            removeCSSClass( cfrow, 'hide_me' );
+        }
+        var cflink = $n(r, "chilifreshReviewLink");
+        if (cflink) {
+            cflink.setAttribute(
+                'id',
+                'isbn_' + currentISBN
+            );
+        }
+        var cfdiv = $n(r, "chilifreshReviewResult");
+        if (cfdiv) {
+            cfdiv.setAttribute(
+                'id',
+                'chili_review_' + currentISBN
+            )
+        }
+    }
+
+/*
+       try {
+               var rank = parseFloat(ranks[pos + getOffset()]);
+               rank            = parseInt( rank * 100 );
+               var relspan = $n(r, "relevancy_span");
+               relspan.appendChild(text(rank));
+               unHideMe(relspan.parentNode);
+       } catch(e){ }
+*/
+
+    var pic = $n(r, config.names.result.item_jacket);
+    if (currentISBN) {
+        pic.setAttribute("src", buildISBNSrc(currentISBN));
+    } else {
+        pic.setAttribute("src", "/opac/images/blank.png");
+    }
+
+       var title_link = $n(r, config.names.result.item_title);
+       var author_link = $n(r, config.names.result.item_author);
+
+       var onlyrec;
+       if( is_mr )  {
+               onlyrec = onlyrecord[ getOffset() + pos ];
+               if(onlyrec) {
+                       buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', onlyrec);
+
+                       var args = {};
+                       args.page = RDETAIL;
+                       args[PARAM_OFFSET] = 0;
+                       args[PARAM_RID] = onlyrec;
+                       args[PARAM_MRID] = rec.doc_id();
+                       pic.parentNode.setAttribute("href", buildOPACLink(args));
+                       title_link.setAttribute("href", buildOPACLink(args));
+                       title_link.appendChild(text(normalize(truncate(rec.title(), 65))));
+
+               } else {
+                       buildunAPISpan($n(r,'unapi'), 'metabib-metarecord', rec.doc_id());
+
+                       buildTitleLink(rec, title_link); 
+                       var args = {};
+                       args.page = RRESULT;
+                       args[PARAM_OFFSET] = 0;
+                       args[PARAM_MRID] = rec.doc_id();
+                       pic.parentNode.setAttribute("href", buildOPACLink(args));
+               }
+
+               unHideMe($n(r,'place_hold_span'));
+               $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'M'); }
+            
+
+       } else {
+               onlyrec = rec.doc_id();
+               buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id());
+
+               buildTitleDetailLink(rec, title_link); 
+               var args = {};
+               args.page = RDETAIL;
+               args[PARAM_OFFSET] = 0;
+               args[PARAM_RID] = rec.doc_id();
+               pic.parentNode.setAttribute("href", buildOPACLink(args));
+
+               unHideMe($n(r,'place_hold_span'));
+               $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'T'); }
+       }
+
+       buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
+
+       if(! is_mr ) {
+       
+               if(!isNull(rec.edition()))      {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       $n(r, "result_table_edition_span").appendChild( text( rec.edition()) );
+               }
+               if(!isNull(rec.pubdate())) {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       unHideMe($n(r, "result_table_pub_span"));
+                       $n(r, "result_table_pub_span").appendChild( text( rec.pubdate() ));
+               }
+               if(!isNull(rec.publisher()) ) {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       unHideMe($n(r, "result_table_pub_span"));
+                       $n(r, "result_table_pub_span").appendChild( text( " " + rec.publisher() ));
+               }
+
+               if(!isNull(rec.physical_description()) ) {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       var t = " " + rec.physical_description();
+                       //$n(r, "result_table_phys_span").appendChild( text(t.replace(/:.*/g,'')));
+                       $n(r, "result_table_phys_span").appendChild( text(t));
+               }
+
+       }
+
+       resultBuildFormatIcons( r, rec, is_mr );
+
+       var bt_params = {
+               sync                    : false,
+               root                    : r,
+               subObjectLimit  : 10,
+               org_unit                : findOrgUnit(getLocation()).shortname(),
+               depth                   : getDepth()
+       };
+
+       if (!is_mr) {
+               bt_params = dojo.mixin( bt_params, { record : onlyrec } );
+       } else {
+               bt_params = dojo.mixin( bt_params, { metarecord : onlyrec } );
+       }
+
+       if (findOrgType(findOrgUnit(getLocation()).ou_type()).can_have_vols())
+               unHideMe($n(r,'local_callnumber_list'));
+
+       new openils.BibTemplate( bt_params ).render();
+
+       unHideMe(r);
+       
+       runEvt("result", "recordDrawn", rec.doc_id(), title_link);
+
+       /*
+       if(resultPageIsDone())  {
+               runEvt('result', 'allRecordsReceived', recordsCache);
+       }
+       */
+}
+
+function resultDrawHoldsWindow(hold_target, hold_type) {
+    var src = location.href;
+
+    if(forceLoginSSL && src.match(/^http:/)) {
+
+        src = src.replace(/^http:/, 'https:');
+
+        if(src.match(/&hold_target=/)) {
+            src.replace(/&hold_target=(\d+)/, hold_target);
+
+        } else {
+            src += '&hold_target=' + hold_target;
+        }
+
+        location.href = src;
+
+    } else {
+        holdsDrawEditor({record:hold_target, type:hold_type});
+    }
+}
+
+
+
+function _resultFindRec(id) {
+       for( var i = 0; i != recordsCache.length; i++ ) {
+               var rec = recordsCache[i];
+               if( rec && rec.doc_id() == id )
+                       return rec;
+       }
+       return null;
+}
+
+
+function resultBuildFormatIcons( row, rec, is_mr ) {
+
+       var ress = rec.types_of_resource();
+
+       for( var i in ress ) {
+
+               var res = ress[i];
+               if(!res) continue;
+
+               var link = $n(row, res + "_link");
+               link.title = res;
+               var img = link.getElementsByTagName("img")[0];
+               removeCSSClass( img, config.css.dim );
+
+               var f = getForm();
+               if( f != "all" ) {
+                       if( f == modsFormatToMARC(res) ) 
+                               addCSSClass( img, "dim2_border");
+               }
+
+               var args = {};
+               args[PARAM_OFFSET] = 0;
+
+               if(is_mr) {
+                       args.page = RRESULT;
+                       args[PARAM_TFORM] = modsFormatToMARC(res);
+                       args[PARAM_MRID] = rec.doc_id();
+
+               } else {
+                       args.page = RDETAIL
+                       args[PARAM_RID] = rec.doc_id();
+               }
+
+               link.setAttribute("href", buildOPACLink(args));
+
+       }
+}
+
+function fetchGoogleBooksLink () {
+    if (isbnList && googleBooksLink) {
+        var scriptElement = document.createElement("script");
+        scriptElement.setAttribute("id", "jsonScript");
+        scriptElement.setAttribute("src",
+            "http://books.google.com/books?bibkeys=" + 
+            escape(isbnList) + "&jscmd=viewapi&callback=unhideGoogleBooksLink");
+        scriptElement.setAttribute("type", "text/javascript");
+        // make the request to Google Book Search
+        document.documentElement.firstChild.appendChild(scriptElement);
+    }
+}
+
+function fetchChiliFreshReviews() {
+    if (chilifresh && chilifresh != '(none)') {
+        try { chili_init(); } catch(E) { console.log(E + '\n'); }
+    }
+}
+
+function resultPageIsDone(pos) {
+
+       return (recordsHandled == getDisplayCount() 
+               || recordsHandled + getOffset() == getHitCount());
+}
+
+var resultCCHeaderApplied = false;
+
+/* -------------------------------------------------------------------- */
+/* dynamically add the copy count rows based on the org type 'countsrow' 
+       is the row into which we will add TD's to hold the copy counts 
+       This code generates copy count cells with an id of
+       'copy_count_cell_<depth>_<pagePosition>'  */
+function resultAddCopyCounts(rec, pagePosition) {
+
+       var r = table.rows[pagePosition + 1];
+       var countsrow = $n(r, config.names.result.counts_row );
+       var ccell = $n(countsrow, config.names.result.count_cell);
+
+       var nodes = orgNodeTrail(findOrgUnit(getLocation()));
+       var start_here = 0;
+       var orgHiding = checkOrgHiding();
+       if (orgHiding) {
+               for (var i = 0; i < nodes.length; i++) {
+                       if (orgHiding.depth == findOrgDepth(nodes[i])) {
+                               start_here = i;
+                       }
+               }
+       }
+
+       var node = nodes[start_here];
+       var type = findOrgType(node.ou_type());
+       ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
+       ccell.title = type.opac_label();
+       //addCSSClass(ccell, config.css.result.cc_cell_even);
+
+       var lastcell = ccell;
+       var lastheadcell = null;
+
+       var cchead = null;
+       var ccheadcell = null;
+       if(!resultCCHeaderApplied && !getLasso()) {
+               ccrow = $('result_thead_row');
+               ccheadcell =  ccrow.removeChild($n(ccrow, "result_thead_ccell"));
+               var t = ccheadcell.cloneNode(true);
+               lastheadcell = t;
+               t.appendChild(text(type.opac_label()));
+               ccrow.appendChild(t);
+               resultCCHeaderApplied = true;
+       }
+
+       if(nodes[start_here+1]) {
+
+               var x = start_here+1;
+               var d = findOrgDepth(nodes[start_here+1]);
+               var d2 = findOrgDepth(nodes[nodes.length -1]);
+
+               for( var i = d; i <= d2 ; i++ ) {
+       
+                       ccell = ccell.cloneNode(true);
+
+                       //if((i % 2)) removeCSSClass(ccell, "copy_count_cell_even");
+                       //else addCSSClass(ccell, "copy_count_cell_even");
+
+                       var node = nodes[x++];
+                       var type = findOrgType(node.ou_type());
+       
+                       ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
+                       ccell.title = type.opac_label();
+                       countsrow.insertBefore(ccell, lastcell);
+                       lastcell = ccell;
+
+                       if(ccheadcell) {
+                               var t = ccheadcell.cloneNode(true);
+                               t.appendChild(text(type.opac_label()));
+                               ccrow.insertBefore(t, lastheadcell);
+                               lastheadcell = t;
+                       }
+               }
+       }
+
+       unHideMe($("search_info_table"));
+}
+
+/* collect copy counts for a record using method 'methodName' */
+function resultCollectCopyCounts(rec, pagePosition, methodName) {
+       if(rec == null || rec.doc_id() == null) return;
+
+       var loc = getLasso();
+       if (loc) loc = -loc;
+       else loc= getLocation();
+
+       var req = new Request(methodName, loc, rec.doc_id(), getForm() );
+       req.request.userdata = [ rec, pagePosition ];
+       req.callback(resultHandleCopyCounts);
+       req.send();
+}
+
+function resultHandleCopyCounts(r) {
+       runEvt('result', 'copyCountsReceived', r.userdata[0], r.userdata[1], r.getResultObject()); 
+}
+
+
+/* XXX Needs to understand Lasso copy counts... */
+/* display the collected copy counts */
+function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
+       if(copy_counts == null || rec == null) return;
+
+       if (getLasso()) {
+               var copy_counts_lasso = {
+                       transcendant : null,
+                       count : 0,
+                       unshadow : 0,
+                       available : 0,
+                       depth : -1,
+                       org_unit : getLasso()
+               };
+
+               for (var i in copy_counts) {
+                       copy_counts_lasso.transcendant = copy_counts[i].transcendant;
+                       copy_counts_lasso.count += parseInt(copy_counts[i].count);
+                       copy_counts_lasso.unshadow += parseInt(copy_counts[i].unshadow);
+                       copy_counts_lasso.available += parseInt(copy_counts[i].available);
+               }
+
+               copy_counts = [ copy_counts_lasso ];
+       }
+
+       var i = 0;
+       while(copy_counts[i] != null) {
+               var cell = $("copy_count_cell_" + i +"_" + pagePosition);
+               if (cell) {
+                       var cts = copy_counts[i];
+                       cell.appendChild(text(cts.available + " / " + cts.count));
+
+                       if(isXUL()) {
+                               /* here we style opac-invisible records for xul */
+
+                               if( cts.depth == 0 ) {
+                                       if(cts.transcendant == null && cts.unshadow == 0) {
+                                               _debug("found an opac-shadowed record: " + rec.doc_id());
+                                               var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode; 
+                                               if( cts.count == 0 ) 
+                                                       addCSSClass( row, 'no_copies' );
+                                               else 
+                                                       addCSSClass( row, 'shadowed' );
+                                       }
+                               }
+                       }
+               }
+               i++;
+       }
+}
+
+
index 3325a26..a8fd019 100644 (file)
                </tbody>
        </table>
                <!--#include virtual='footer.xml'-->
-    <center>
-        <div id='gcfPrompt' class='hide_me'>
-            <script>dojo.require('dojo.cookie')</script>;
-            <div><span>&common.googlechromeframe.why;</span></div>
-            <button onclick='CFInstall.check({preventPrompt: false, mode: "popup"});'>&common.googlechromeframe.install;</button>
-            <button onclick='dojo.cookie("noGCF", "true", {path:"/", expires: 365}); hideMe($("gcfPrompt"));'>&common.googlechromeframe.dontask;</button>
-        </div>
-    </center>
-    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
-    <script><![CDATA[ 
-        CFInstall.check({
-            preventPrompt: true,
-            onmissing: function() {
-                if (dojo.cookie("noGCF") != "true")
-                    unHideMe($('gcfPrompt'));
-            }
-        });]]>
-    </script>
 
     <script language="javascript" type="text/javascript">
         dojo.addOnLoad(init);
index 574af3b..b5fff24 100644 (file)
                </tbody>
        </table>
        <!--#include virtual='../footer.xml'-->
-    <center>
-        <div id='gcfPrompt' class='hide_me'>
-            <script>dojo.require('dojo.cookie');</script>
-            <div><span>&common.googlechromeframe.why;</span></div>
-            <button onclick='CFInstall.check({preventPrompt: false, mode: "popup"});'>&common.googlechromeframe.install;</button>
-            <button onclick='dojo.cookie("noGCF", "true", {path:"/", expires: 365}); hideMe($("gcfPrompt"));'>&common.googlechromeframe.dontask;</button>
-        </div>
-    </center>
-    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
-    <script><![CDATA[ 
-        CFInstall.check({
-            preventPrompt: true,
-            onmissing: function() {
-                if (dojo.cookie("noGCF") != "true")
-                    unHideMe($('gcfPrompt'));
-            }
-        });]]>
-    </script>
 
     <script language="javascript" type="text/javascript">
         isFrontPage = true;
diff --git a/Open-ILS/web/opac/skin/tadlv2/js/rdetail.js b/Open-ILS/web/opac/skin/tadlv2/js/rdetail.js
new file mode 100644 (file)
index 0000000..dbe0384
--- /dev/null
@@ -0,0 +1,1396 @@
+
+/* */
+
+detachAllEvt('common', 'run');
+attachEvt("common", "run", rdetailDraw);
+attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns);
+attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
+attachEvt("rdetail", "recordDrawn", rdetailGetPageIds);
+
+/* Per-skin configuration settings */
+var rdetailLocalOnly = true;
+var rdetailShowLocal = true;
+var rdetailShowCopyLocation = true;
+var rdetailGoogleBookPreview = false;
+var rdetailDisplaySerialHoldings = true;
+var rdetailEnableRefWorks = false;
+var rdetailRefWorksHost = 'http://www.refworks.com';
+
+/* vars vars vars */
+var record = null;
+var cp_statuses = null;
+var recordsCache = [];
+
+var copyRowParent = null;
+var copyRow = null;
+var statusRow = null;
+var numStatuses = null;
+var defaultCN;
+var callnumberCache = {};
+var globalCNCache = {};
+var localTOC;
+var cachedRecords;
+var _statusPositions = {};
+var opac_strings;
+
+var nextContainerIndex;
+
+var nextRecord;
+var prevRecord;
+
+var rdetailPrev = null;
+var rdetailNext = null;
+var rdetailStart = null;
+var rdetailEnd = null;
+
+var mfhdDetails = [];
+var orgHiding = false;
+
+if(location.href.match(/&place_hold=1/)) {
+    // prevent load flicker between canvases
+    hideMe(dojo.byId('canvas_main'));
+}
+
+dojo.require("dijit.Dialog");
+dojo.require("dijit.form.TextBox");
+
+/* serials are currently the only use of Dojo strings in the OPAC */
+if (rdetailDisplaySerialHoldings) {
+       dojo.require("dijit.Menu");
+       dojo.require("dijit.form.Button");
+       dojo.requireLocalization("openils.opac", "opac");
+       opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
+}
+
+function rdetailReload() {
+       var args = {};
+       args[PARAM_LOCATION] = getNewSearchLocation();
+       args[PARAM_DEPTH] = depthSelGetDepth();
+       goTo(buildOPACLink(args));
+}
+
+/* looks to see if we have a next and/or previous record in the
+   record cache, if so, set up the nav links */
+function rdetailSetPaging(ids) {
+
+       cachedRecords = {};
+       cachedRecords.ids = ids;
+
+       for( var i = 0; i < cachedRecords.ids.length; i++ ) {
+               var rec = cachedRecords.ids[i];
+               if( rec == getRid() ) {
+                       if( i > 0 ) prevRecord = cachedRecords.ids[i-1];
+                       if( i < cachedRecords.ids.length - 1 )
+                               nextRecord = cachedRecords.ids[i+1];
+                       break;
+               }
+       }
+
+       $('np_offset').appendChild(text(i + 1));
+       $('np_count').appendChild(text(getHitCount()));
+
+       if(prevRecord) {
+               unHideMe($('np_table'));
+               unHideMe($('np_prev'));
+               unHideMe($('np_start'));
+               rdetailPrev = function() { _rdetailNav(prevRecord); };
+               rdetailStart = function() { _rdetailNav(cachedRecords.ids[0]); };
+       }
+
+       if(nextRecord) {
+               unHideMe($('np_table'));
+               unHideMe($('np_next'));
+               unHideMe($('np_end'));
+               rdetailNext = function() { _rdetailNav(nextRecord); };
+               rdetailEnd = function() { _rdetailNav(cachedRecords.ids[cachedRecords.ids.length-1]); };
+       }
+
+       runEvt('rdetail', 'nextPrevDrawn', i, cachedRecords.ids.length);
+}
+
+
+function _rdetailNav(id, offset) {
+       var args = {};
+       args[PARAM_RID] = id;
+       goTo(buildOPACLink(args));
+}
+
+function rdetailHandlePlaceHold() {
+    function reload() {
+        location.href = location.href.replace(/&place_hold=1/, '');
+    }
+    attachEvt("common", "holdUpdated", reload);
+    attachEvt("common", "holdUpdateCanceled", reload);
+    attachEvt("common", "loginCanceled", reload);
+    holdsDrawEditor({record:getRid(), type: 'T'});
+}
+
+function rdetailDraw() {
+
+    if(new CGI().param('place_hold')) {
+        rdetailHandlePlaceHold();
+        return;
+    }
+
+       detachAllEvt('common','depthChanged');
+       detachAllEvt('common','locationUpdated');
+       attachEvt('common','depthChanged', rdetailReload);
+       attachEvt('common','locationUpdated', rdetailReload);
+       attachEvt('common','holdUpdated', rdetailReload);
+       attachEvt('common','holdUpdateCanceled', rdetailReload);
+
+       copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
+       copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
+       statusRow = G.ui.rdetail.cp_status.parentNode;
+       statusRow.id = '__rdsrow';
+
+       G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies;
+       G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies;
+
+       if(getLocation() == globalOrgTree.id())
+               hideMe(G.ui.rdetail.cp_info_all);
+
+    if(getRid()) {
+
+           var req = new Request(FETCH_RMODS, getRid());
+           req.callback(_rdetailDraw);
+           req.send();
+
+    } else { // No record ID was specified
+
+       // If we have an ISBN in the URL, let's try to find that record
+       // This allows direct linking by ISBN.
+       // Note, this uses the first record it finds
+       if(getRtype() == RTYPE_ISBN) { 
+            var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
+            req.callback(
+                function(r) {
+                    var blob = r.getResultObject();
+                    if(blob && blob.count > 0) 
+                        RID = blob.ids[0]; 
+                    var req2 = new Request(FETCH_RMODS, getRid());
+                    req2.callback(_rdetailDraw);
+                    req2.send();
+                }
+            );
+            req.send();
+        }
+    }
+
+
+       if (rdetailDisplaySerialHoldings && (
+        isXUL() || !fetchOrgSettingDefault(
+            getLocation(), "opac.fully_compressed_serial_holdings")
+        )
+    ) {
+               var req = new Request(FETCH_MFHD_SUMMARY, getRid());
+               req.callback(_holdingsDraw);
+               req.send();
+               if (isXUL()) {
+                       var here = findOrgUnit(getLocation());
+                       dojo.place("<div id='mfhd_ad_menu'></div>", "rdetail_details_table", "after");
+                       var mfhd_add = new dijit.Menu({style:"float: right;"});
+                       new dijit.MenuItem({onClick:function(){
+                               var req = new Request(CREATE_MFHD_RECORD, G.user.session, 1, here.id(), getRid());
+                               var res = req.send();
+                               alert(dojo.string.substitute(opac_strings.CREATED_MFHD_RECORD, [here.name()]));
+                       }, label:opac_strings.CREATE_MFHD}).placeAt(mfhd_add);
+                       mfhd_add.placeAt(mfhd_ad_menu);
+               }
+       }
+
+       detachAllEvt("result", "idsReceived");
+       G.evt.result.hitCountReceived = [];
+       G.evt.result.recordReceived = [];
+       G.evt.result.copyCountsReceived = [];
+       G.evt.result.allRecordsReceived = [];
+
+    if(isXUL()) 
+        unHideMe($('rdetail_show_orders'));
+}
+
+function rdetailGetPageIds() {
+       attachEvt("result", "idsReceived", rdetailSetPaging );
+       resultFetchAllRecords = true;
+       rresultCollectIds(true);
+}
+
+
+function buildunAPISpan (span, type, id) {
+       var cgi = new CGI();
+       var d = new Date();
+
+       addCSSClass(span,'unapi-id');
+
+       span.setAttribute(
+                       'title', 'tag:' + cgi.server_name + ',' +
+                       d.getFullYear() + ':' + type + '/' + id
+                       );
+}
+
+function rdetailViewMarc(r,id) {
+       hideMe($('rdetail_extras_loading'));
+       $('rdetail_view_marc_box').innerHTML = r.getResultObject();
+
+       var div = elem('div', { "class" : 'hide_me' });
+       var span = div.appendChild( elem('abbr') );
+
+       buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
+
+       $('rdetail_view_marc_box').insertBefore(span, $('rdetail_view_marc_box').firstChild);
+}
+
+function rdetailForeignItems(r,id) {
+       hideMe($('rdetail_extras_loading'));
+    var tbody = $('rdetail_foreign_items_tbody');
+
+    var robj = r.getResultObject(); /* mvr list with foreign_copy_maps fleshed */
+
+    for (var i = 0; i < robj.length; i++) {
+        var args = {};
+        args.page = RDETAIL;
+        args[PARAM_OFFSET] = 0;
+        args[PARAM_RID] = robj[i].doc_id();
+        var row = elem('tr'); tbody.appendChild(row);
+        var td1 = elem('td'); row.appendChild(td1);
+        var title = elem(
+            'a',
+            {
+                'href' : buildOPACLink(args),
+                'class' : 'classic_link'
+            },
+            robj[i].title()
+        );
+        td1.appendChild(title);
+        var td2 = elem('td',{},robj[i].author()); row.appendChild(td2);
+        var td3 = elem('td'); row.appendChild(td3);
+        var details = elem(
+            'a',
+            {
+                'href' : 'javascript:void(0)',
+                'class' : 'classic_link'
+            },
+            'Copy Details'
+        );
+        details.onclick = function(idx,context_row){
+            return function() {
+                cpdBuild(
+                    tbody,
+                    context_row,
+                    robj[idx],
+                    null,
+                    1,
+                    0,
+                    1,
+                    dojo.map(
+                        robj[idx].foreign_copy_maps(),
+                        function(x){ return x.target_copy(); }
+                    ),
+                    dojo.map(
+                        robj[idx].foreign_copy_maps(),
+                        function(x){ return x.peer_type().name(); }
+                    )
+                );
+            };
+        }(i,row);
+        td3.appendChild(details);
+    }
+}
+
+
+
+function rdetailShowLocalCopies() {
+       rdetailShowLocal = true;
+       rdetailBuildInfoRows();
+       hideMe(G.ui.rdetail.cp_info_local);
+       unHideMe(G.ui.rdetail.cp_info_all);
+       hideMe(G.ui.rdetail.cp_info_none); 
+}
+
+function rdetailShowAllCopies() {
+
+       rdetailShowLocal = false;
+       rdetailBuildInfoRows();
+       hideMe(G.ui.rdetail.cp_info_all);
+       unHideMe(G.ui.rdetail.cp_info_local);
+       hideMe(G.ui.rdetail.cp_info_none); 
+}
+
+function OpenMarcEditWindow(pcrud, rec) {
+       /*
+          To run in Firefox directly, must set signed.applets.codebase_principal_support
+          to true in about:config
+        */
+       netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+       win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
+       dojo.require('openils.PermaCrud');
+
+       win.xulG = {
+               "record": {"marc": rec.marc(), "rtype": "sre"},
+               "save": {
+                       "label": opac_strings.SAVE_MFHD_LABEL,
+                       "func": function(xmlString) {
+                               rec.marc(xmlString);
+                               rec.edit_date('now');
+                               rec.ischanged(true);
+                               pcrud.update(rec);
+                       }
+               },
+        'lock_tab' : typeof xulG != 'undefined' ? (typeof xulG['lock_tab'] != 'undefined' ? xulG.lock_tab : undefined) : undefined,
+        'unlock_tab' : typeof xulG != 'undefined' ? (typeof xulG['unlock_tab'] != 'undefined' ? xulG.unlock_tab : undefined) : undefined
+       };
+}
+
+function loadMarcEditor(recId) {
+       var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
+       var rec = pcrud.retrieve("sre", recId);
+       if (rec) {
+               OpenMarcEditWindow(pcrud, rec);
+       }
+}
+
+/*
+ * This function could be written much more intelligently
+ * Limited brain power means that I'm brute-forcing it for now
+ */
+function _holdingsDraw(h) {
+    holdings = h.getResultObject();
+
+    if (holdings) {
+        // Only draw holdings within our OU scope
+        var here = findOrgUnit(getLocation());
+        var entryNum = 0;
+        var depth = getDepth();
+        dojo.forEach(holdings, function (item) {
+            if (orgIsMine(here, findOrgUnit(item.owning_lib()), depth)) {
+                _holdingsDrawMFHD(item, entryNum);
+                entryNum++;
+            }
+        });
+    }
+
+    // Populate (or unpopulate) XUL menus
+    if (isXUL()) {
+        runEvt('rdetail','MFHDDrawn');
+    }
+}
+
+function _holdingsDrawMFHD(holdings, entryNum) {
+       var hb = holdings.basic_holdings();
+       var hba = holdings.basic_holdings_add();
+       var hs = holdings.supplement_holdings();
+       var hsa = holdings.supplement_holdings_add();
+       var hi = holdings.index_holdings();
+       var hia = holdings.index_holdings_add();
+       var ho = holdings.online();
+       var hm = holdings.missing();
+       var hinc = holdings.incomplete();
+       var hloc = holdings.location() || 'MFHD';
+
+       if (    hb.length == 0 && hba.length == 0 && hs.length == 0 &&
+               hsa.length == 0 && hi.length == 0 && hia.length == 0 &&
+               ho.length == 0 && hm.length == 0 && hinc.length == 0
+       ) {
+
+               if (isXUL()) {
+                       /* 
+                        * If we have a record, but nothing to show for it, then the
+                        * record is likely empty or corrupt. This gives cataloguers a
+                        * chance to add holdings or correct the record
+                        */
+                       hb = ['PLACEHOLDER'];
+               } else {
+                       return null;
+               }
+       }
+
+       // Show entryNum + 1 in staff client for better menu correlation
+       // Maybe this should be holdings.sre_id() instead? (which could get long after time)
+       var entryNumString = '';
+       if (isXUL()) {
+               var entryNumInc = entryNum + 1;
+               entryNumString = ' [Entry #'+entryNumInc+'] ';
+       }
+
+       var refNode;
+       if (entryNum > 0) {
+               refNode = 'rdetail_holdings_table_' + (entryNum - 1);
+       } else {
+               refNode = 'rdetail_details_table';
+       }
+
+       dojo.place("<table style='width: 100%;' id='rdetail_holdings_table_"+entryNum+"'><caption id='mfhdHoldingsCaption" + entryNum + "' class='rdetail_header color_1'>" +
+               dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) + entryNumString +
+               "</caption><tbody id='rdetail_holdings_tbody_" + entryNum +
+               "'></tbody></table>", refNode, "after"
+       );
+       if (hb.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS, hb); }
+       if (hba.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS_ADD, hba); }
+       if (hs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS, hs); }
+       if (hsa.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS_ADD, hsa); }
+       if (hi.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS, hi); }
+       if (hia.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS_ADD, hia); }
+       if (ho.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.ONLINE_VOLUMES, ho); }
+       if (hm.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.MISSING_VOLUMES, hm); }
+       if (hinc.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INCOMPLETE_VOLUMES, hinc); }
+
+       if (isXUL() && holdings.sre_id() != -1) { // -1 indicates in-DB only holdings, so no button or menu entries for MFHD
+               mfhdDetails.push({ 'id' : holdings.sre_id(), 'label' : hloc, 'entryNum' : entryNum, 'owning_lib' : holdings.owning_lib() });
+               dojo.require('openils.Event');
+               dojo.require('openils.PermaCrud');
+               var mfhd_edit = new dijit.Menu({});
+               new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.sre_id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first");
+               new dijit.MenuItem({onClick:function(){
+                       // Avoid accidental deletion of MFHD records
+                       if (!confirm(opac_strings.DELETE_MFHD_CONFIRM)) {
+                               return;
+                       }
+                       var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
+                       var mfhd_rec = pcrud.retrieve("sre", holdings.sre_id());
+                       if (mfhd_rec) {
+                               pcrud.eliminate(mfhd_rec);
+                               alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.sre_id()]));
+                       }
+               }, label:opac_strings.DELETE_MFHD}).placeAt(mfhd_edit, "last");
+               // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.sre_id());}, label:opac_strings.EDIT_PROPERTIES}).placeAt(mfhd_edit, "last");
+               var mfhd_mb = new dijit.form.DropDownButton({dropDown: mfhd_edit, label:opac_strings.EDIT_MFHD_MENU, style:"float:right"});
+               mfhd_mb.placeAt("mfhdHoldingsCaption" + entryNum, "last");
+               mfhd_edit.startup();
+       }
+}
+
+function _holdingsDrawMFHDEntry(entryNum, entryName, entry) {
+       var flatEntry = entry.toString().replace(/,/g, ', ');
+       dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>" + entryName + "</td><td class='rdetail_item'>" + flatEntry + "</td></tr>", "rdetail_holdings_tbody_" + entryNum, "last");
+}
+
+function _rdetailDraw(r) {
+       record = r.getResultObject();
+
+       runEvt('rdetail', 'recordRetrieved', record.doc_id());
+
+       G.ui.rdetail.title.appendChild(text(record.title()));
+       buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
+       G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
+       G.ui.rdetail.edition.appendChild(text(record.edition()));
+       G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
+       G.ui.rdetail.publisher.appendChild(text(record.publisher()));
+       $('rdetail_physical_desc').appendChild(text(record.physical_description()));
+       r = record.types_of_resource();
+       if(r) {
+               G.ui.rdetail.tor.appendChild(text(r[0]));
+               setResourcePic( G.ui.rdetail.tor_pic, r[0]);
+       }
+       G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
+
+       try{
+               if(record.isbn()) {
+                       if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) {
+                               unHideMe($('rdetail.jacket_attrib_div'));
+                               var href = $('rdetail.jacket_attrib_link').getAttribute('href') +cleanISBN(record.isbn());
+                               $('rdetail.jacket_attrib_link').setAttribute('href', href);
+                       }
+                       rdetailCheckForGBPreview();
+
+               } else {
+                       hideMe($("rdetail.jacket_attrib_div"));
+                       hideMe($("rdetail_img_link"));
+               }
+       } catch(E) {}
+
+
+       // see if the record has any external links 
+       var links = record.online_loc();
+       for( var i = 0; links && links.length > 0 && i < links.length; i = i + 3 ) {
+               var href = links[i];
+               // avoid matching "HTTP: The Complete Reference"
+               if( href.match(/https?:\/|ftps?:\/|mailto:/i) ) {
+                       unHideMe($('rdetail_online_row'));
+                       // MODS can contain a display label (used for the text of the link)
+                       // as well as a note about the URL; many legacy systems conflate the
+                       // two and generate MARC records that expect the note to be used as
+                       // the text of the link, with no display label; here's the canonical
+                       // format:
+                       //
+                       // 856 40 $uhttp://localhost$yDisplay label$zPublic note
+                       //
+                       // Note that the MARC21slim2MODS XSL concatenates $3 and $y together
+                       // (as $y was defined later in MARC21's life as the display label)
+                       var displayLabel = '' + links[i+1];
+                       var note = '' + links[i+2];
+                       if(!displayLabel || displayLabel.match(/https?:\/|ftps?:\/|mailto:/i)) {
+                               if(!note || note.match(/https?:\/|ftps?:\/|mailto:/i)) {
+                                       displayLabel = href;
+                               } else {
+                                       displayLabel = note;
+                               }
+                       }
+                       $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
+                       if (note && note != displayLabel) {
+                               $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
+                       }
+                       $('rdetail_online').appendChild(elem('br'));
+               }
+       }
+
+       // Fill in our unAPI ID, if anyone cares
+       var abbrs = document.getElementsByTagName('abbr');
+       var span;
+       for (var i = 0; i < abbrs.length; i++) {
+               if (abbrs[i].getAttribute('name') == 'unapi') {
+                       span = abbrs[i];
+                       break;
+               }
+       }
+       buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
+
+       $('rdetail_place_hold').onclick = function() {
+        var src = location.href;
+
+        if(forceLoginSSL && src.match(/^http:/)) {
+
+            src = src.replace(/^http:/, 'https:');
+
+            if(!src.match(/&place_hold=1/)) {
+                src += '&place_hold=1';
+            }
+
+            location.href = src;
+
+        } else {
+            holdsDrawEditor({record:record.doc_id(), type:'T'});
+        }
+    }
+
+
+       var RW = $('rdetail_exp_refworks');
+       if (RW && rdetailEnableRefWorks) {
+
+               var here = (findOrgUnit(getLocation())).name();
+               var org_name = here.replace(" ", "+");
+               var cgi = new CGI();
+
+               RW.setAttribute(
+                       'href',
+                       rdetailRefWorksHost + '/express/expressimport.asp?vendor='
+                       + org_name
+                       + '&filter=MARC+Format&database=All+MARC+Formats&encoding=65001&url=http%3A%2F%2F'
+                       + cgi.server_name + '/opac/extras/supercat/marctxt/record/'
+                       + record.doc_id()
+              );
+
+               RW.setAttribute('target', 'RefWorksMain');
+
+               unHideMe($('rdetail_exp_refworks_span'));
+       }
+
+       $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
+       G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
+       runEvt("rdetail", "recordDrawn");
+       recordsCache.push(record);
+
+       rdetailSetExtrasSelector();
+
+       var breq = new Request(FETCH_BRE, [getRid()]);
+       breq.callback( rdetailCheckDeleted );
+       breq.send();
+
+       //resultBuildCaches( [ record ] );
+       //resultDrawSubjects();
+       //resultDrawSeries();
+
+       // grab added content 
+
+    // Proxied through Evergreen AddedContent module
+       acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
+
+    var currentISBN = cleanISBN(record.isbn());
+
+    // Not proxied, cross-site javascript
+
+    // ChiliFresh
+    if (chilifresh && chilifresh != '(none)' && currentISBN) {
+        $('chilifreshReviewLink').setAttribute('id','isbn_'+currentISBN);
+        $('chilifreshReviewResult').setAttribute('id','chili_review_'+currentISBN);
+        unHideMe($('rdetail_reviews_link'));
+        unHideMe($('rdetail_chilifresh_reviews'));
+        try {
+            chili_init();
+        } catch(E) {
+            console.log(E + '\n');
+            hideMe($('rdetail_reviews_link'));
+            hideMe($('rdetail_chilifresh_reviews'));
+        }
+    }
+
+    // Novelist
+    if (novelist && currentISBN) {
+        unHideMe($('rdetail_novelist_link'));
+    }
+
+    // Multi-Home / Foreign Items / Peer Bibs
+    var req = new Request( TEST_PEER_BIBS, record.doc_id() );
+    req.callback(function(r){
+        var test = r.getResultObject();
+        if (test == "1") {
+            unHideMe($('rdetail_foreign_items_link'));
+        }
+    }); 
+    req.send();
+}
+
+
+
+function rdetailCheckDeleted(r) {
+       var br = r.getResultObject()[0];
+       if( isTrue(br.deleted()) ) {
+               hideMe($('rdetail_place_hold'));
+               $('rdetail_more_actions_selector').disabled = true;
+               unHideMe($('rdetail_deleted_exp'));
+       }
+}
+
+function rdetailSetExtrasSelector() {
+       if(!grabUser()) return;
+       unHideMe($('rdetail_more_actions'));
+
+       var req = new Request( 
+                       FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
+       req.callback(rdetailAddBookbags);
+       req.send();
+}
+
+function rdetailAddBookbags(r) {
+
+       var containers = r.getResultObject();
+       var selector = $('rdetail_more_actions_selector');
+       var found = false;
+       var index = 3;
+       doSelectorActions(selector);
+
+       for( var i = 0; i < containers.length; i++ ) {
+               found = true;
+               var container = containers[i];
+               insertSelectorVal( selector, index++, container.name(), 
+                               "container_" + container.id(), rdetailAddToBookbag,  1 );
+       }
+
+       nextContainerIndex = index;
+}
+
+var _actions = {};
+/**
+ * Adds a new bookbag and exits.
+ * 
+ * exitstatus should be 0 if the status is to be read.
+ */
+function finishBookbag(exitstatus) {
+       var name = bbName.attr('value');
+       
+       newBBDialog.hide();     
+       bbName.attr("value", ""); // Do this after hide so the text doesn't disappear.
+       
+       if(exitstatus != 0) return; // If the user canceled, just drop off here.
+       
+       var id;
+       
+       if( id = containerCreate( name ) ) {
+               alert( $('rdetail_bb_success').innerHTML );
+               var selector = $('rdetail_more_actions_selector');
+               insertSelectorVal( selector, nextContainerIndex++, name, 
+                               "container_" + id, rdetailAddToBookbag, 1 );
+               setSelector( selector, 'start' );
+       }
+}
+
+/**
+ * Creates a new Bookbag for the user.
+ */
+function rdetailNewBookbag() {
+    newBBDialog.show(); // Show the bookbag dialog.
+    dojo.connect(dijit.byId('newBBDialog'), 'onKeyPress', function(evt) {
+        if (evt.keyCode == dojo.keys.ENTER) {
+            finishBookbag(0);
+        }
+    });
+}
+
+function rdetailAddToBookbag() {
+       var selector = $('rdetail_more_actions_selector');
+       var id = selector.options[selector.selectedIndex].value;
+       setSelector( selector, 'start' );
+
+       if( containerCreateItem( id.substring(10), record.doc_id() )) {
+               alert($('rdetail_bb_item_success').innerHTML);
+       }
+}
+
+
+var rdetailMarcFetched = false;
+var rdetailForeignItemsFetched = false;
+function rdetailShowExtra(type, args) {
+
+       hideMe($('rdetail_copy_info_div'));
+       hideMe($('rdetail_summary_div'));
+       hideMe($('rdetail_reviews_div'));
+       hideMe($('rdetail_toc_div'));
+       hideMe($('rdetail_anotes_div'));
+       hideMe($('rdetail_excerpt_div'));
+       hideMe($('rdetail_preview_div'));
+       hideMe($('rdetail_marc_div'));
+       hideMe($('cn_browse'));
+       hideMe($('rdetail_cn_browse_div'));
+       hideMe($('rdetail_novelist_div'));
+       hideMe($('rdetail_foreign_items_div'));
+       hideMe($('rdetail_notes_div'));
+
+       removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
+       removeCSSClass($('rdetail_foreign_items_link'), 'rdetail_extras_selected');
+
+       switch(type) {
+
+               case "copyinfo": 
+                       unHideMe($('rdetail_copy_info_div')); 
+                       addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
+                       break;
+
+        case "summary":
+            addCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected');
+            unHideMe($('rdetail_summary_div'));
+            break;
+
+               case "reviews": 
+                       addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_reviews_div')); 
+                       break;
+
+               case "excerpt": 
+                       addCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_excerpt_div'));
+                       break;
+
+               case "preview": 
+                       addCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_preview_div'));
+                       rdetailDisplayGBPreview();
+                       break;
+
+               case "anotes": 
+                       addCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_anotes_div'));
+                       break;
+
+               case "toc": 
+                       addCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_toc_div'));
+                       break;
+
+               case "marc": 
+                       addCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_marc_div')); 
+                       if(rdetailMarcFetched) return;
+                       unHideMe($('rdetail_extras_loading'));
+                       rdetailMarcFetched = true;
+                       var req = new Request( FETCH_MARC_HTML, record.doc_id() );
+                       req.callback(rdetailViewMarc); 
+                       req.send();
+                       break;
+
+               case "novelist": 
+                       addCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_novelist_div')); 
+                       break;
+
+               case "foreign_items": 
+                       addCSSClass($('rdetail_foreign_items_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_foreign_items_div')); 
+            if(rdetailForeignItemsFetched) return;
+                       unHideMe($('rdetail_extras_loading'));
+            rdetailForeignItemsFetched = true;
+                       var req = new Request( FETCH_PEER_BIBS, record.doc_id() );
+                       req.callback(rdetailForeignItems); 
+                       req.send();
+                       break;
+
+               case 'cn':
+                       addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
+                       unHideMe($('rdetail_cn_browse_div'));
+                       rdetailShowCNBrowse(defaultCN[1], getLocation(), null, true);
+                       break;
+
+       }
+}
+
+function rdetailVolumeDetails(args) {
+       var row = $(args.rowid);
+       var tbody = row.parentNode;
+       cpdBuild( tbody, row, record, [args.cn_prefix, args.cn, args.cn_suffix], args.org, args.depth, args.copy_location );
+       return;
+}
+
+function rdetailBuildCNList() {
+
+       var select = $('cn_browse_selector');
+       var index = 0;
+       var arr = [];
+       for( var cn_json in callnumberCache ) arr.push( cn_json );
+       arr.sort();
+
+       if( arr.length == 0 ) {
+               hideMe($('rdetail_cn_browse_select_div'));
+               return;
+       }
+
+       for( var i = 0; i < arr.length; i++ ) {
+               var cn_json = arr[i];
+        var cn = JSON2js(cn_json);
+        var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : '');
+               var opt = new Option(whole_cn_text,cn_json);
+               select.options[index++] = opt;
+       }
+       select.onchange = rdetailGatherCN;
+}
+
+function rdetailGatherCN() {
+       var cn = getSelectorVal($('cn_browse_selector'));
+       rdetailShowCNBrowse( JSON2js(cn), getLocation(), getDepth(), true );
+       setSelector( $('cn_browse_selector'), cn );
+}
+
+
+function rdetailShowCNBrowse( cn, loc, depth, fromOnclick ) {
+
+       if(!cn) {
+               unHideMe($('cn_browse_none'));
+               hideMe($('rdetail_cn_browse_select_div'));
+               return;
+       }
+
+       unHideMe($('rdetail_cn_browse_select_div'));
+       rdetailBuildCNList();
+       setSelector( $('cn_browse_selector'), js2JSON(cn) );
+       hideMe($('rdetail_copy_info_div'));
+       hideMe($('rdetail_reviews_div'));
+       hideMe($('rdetail_summary_div'));
+       hideMe($('rdetail_toc_div'));
+       hideMe($('rdetail_marc_div'));
+       unHideMe($('rdetail_cn_browse_div'));
+       unHideMe($('cn_browse'));
+       if( !rdetailLocalOnly && ! fromOnclick ) depth = findOrgDepth(globalOrgTree);
+       cnBrowseGo(cn, loc, depth);
+}
+
+function rdetailhandleAC(data) {
+
+       if( data.summary.html ) {
+               $('rdetail_summary_div').innerHTML = data.summary.html;
+               unHideMe($('rdetail_summary_link'));
+       }
+
+       if( data.reviews.html ) {
+               $('rdetail_review_container').innerHTML = data.reviews.html;
+               unHideMe($('rdetail_reviews_link'));
+       }
+
+       if( data.toc.html ) {
+               $('rdetail_toc_div').innerHTML = data.toc.html;
+               unHideMe($('rdetail_toc_link'));
+       }
+
+       if( data.excerpt.html ) {
+               $('rdetail_excerpt_div').innerHTML = data.excerpt.html;
+               unHideMe($('rdetail_excerpt_link'));
+       }
+
+       if( data.anotes.html ) {
+               $('rdetail_anotes_div').innerHTML = data.anotes.html;
+               unHideMe($('rdetail_anotes_link'));
+       }
+}
+
+function rdetailShowReviews(r) {
+       hideMe($('rdetail_extras_loading'));
+       var res = r.getResultObject();
+       var par = $('rdetail_reviews_div');
+       var template = par.removeChild($('rdetail_review_template'));
+       if( res && res.length > 0 ) {
+               unHideMe($('rdetail_reviews_link'));
+               for( var i = 0; i < res.length; i++ ) {
+                       var rev = res[i];       
+                       if( rev.text && rev.info ) {
+                               var node = template.cloneNode(true);
+                               $n(node, 'review_header').appendChild(text(rev.info));
+                               $n(node, 'review_text').appendChild(text(rev.text));
+                               par.appendChild(node);
+                       }
+               }
+       }
+}
+
+
+function rdetailShowTOC(r) {
+       hideMe($('rdetail_extras_loading'));
+       var resp = r.getResultObject();
+       if(resp) {
+               unHideMe($('rdetail_toc_link'));
+               $('rdetail_toc_div').innerHTML = resp;
+       }
+}
+
+function rdetailBuildInfoRows() {
+       var req;
+       var method = FETCH_COPY_COUNTS_SUMMARY;
+       if (rdetailShowCopyLocation)
+               method = FETCH_COPY_LOCATION_COUNTS_SUMMARY;
+       if( rdetailShowLocal ) 
+               req = new Request(method, record.doc_id(), getLocation(), getDepth())
+       else
+               req = new Request(method, record.doc_id());
+       req.callback(_rdetailBuildInfoRows);
+       req.send();
+}
+
+function _rdetailRows(node) {
+
+       if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) {
+               var loc = findOrgUnit(getLocation());
+               if( node ) {
+                       if( !orgIsMine(node, loc) && !orgIsMine(loc,node) ) return;
+               } else {
+            var kids = globalOrgTree.children();
+            if (kids) {
+                       for( var i = 0; i < kids.length; i++ ) {
+                               var org = findOrgUnit(kids[i]);
+                               if( orgIsMine(org, loc) ) {
+                                       node = org;
+                                       break;
+                               }
+                }
+                       }
+               } 
+       }
+
+       if(!node && findOrgType(globalOrgTree.ou_type()).can_have_vols())
+               node = globalOrgTree;
+
+
+       /* don't show hidden orgs */
+
+       if(node) {
+
+               if(!isXUL() && !isTrue(node.opac_visible())) return;
+
+               if (orgHiding) {
+                       if (isTrue( findOrgType(node.ou_type()).can_have_vols() )) {
+                               if ( ! orgIsMine( orgHiding.org, node, orgHiding.depth ) ) {
+                                       return;
+                               }
+                       }
+               }
+
+               var row = copyRow.cloneNode(true);
+               row.id = "cp_info_" + node.id();
+
+               var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
+               var cntd  = findNodeByName( row, config.names.rdetail.cn_cell );
+               var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell );
+               var actions = $n(row, 'rdetail_actions_cell');
+
+               var p = libtd.getElementsByTagName('a')[0];
+               libtd.insertBefore(text(node.name()), p);
+               libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1)  * 9) + "px;");
+
+               if(!findOrgType(node.ou_type()).can_have_vols()) {
+
+                       row.removeChild(cntd);
+                       row.removeChild(cpctd);
+                       row.removeChild(actions);
+                       row.setAttribute('novols', '1');
+
+                       libtd.setAttribute("colspan", numStatuses + 3 );
+                       libtd.colSpan = numStatuses + 3;
+                       addCSSClass(row, 'copy_info_region_row');
+               } 
+
+               copyRowParent.appendChild(row);
+
+       } else { node = globalOrgTree; }
+
+    var kids = node.children();
+    if (kids) {
+       for( var c = 0; c < kids.length; c++ ) 
+               _rdetailRows(kids[c]);
+    }
+}
+
+function rdetailCNPrint(orgid, cn) {
+       var div = cpdBuildPrintWindow( record, orgid);
+       var template = div.removeChild($n(div, 'cnrow'));
+       var rowNode = $("cp_info_" + orgid);
+       cpdStylePopupWindow(div);
+       openWindow(div.innerHTML);
+}
+
+var localCNFound = false;
+var ctr = 0;
+function _rdetailBuildInfoRows(r) {
+
+       if (rdetailShowCopyLocation)
+               unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) );
+
+       removeChildren(copyRowParent);
+
+       orgHiding = checkOrgHiding();
+
+       _rdetailRows();
+
+       var summary = r.getResultObject();
+       if(!summary) return;
+
+       var found = false;
+       for( var i = 0; i < summary.length; i++ ) {
+
+               var arr = summary[i];
+               globalCNCache[js2JSON([arr[1],arr[2],arr[3]])] = 1; // prefix, label, suffix.  FIXME - Am I used anywhere?
+               var thisOrg = findOrgUnit(arr[0]);
+               var rowNode = $("cp_info_" + thisOrg.id());
+               if(!rowNode) continue;
+
+               if(rowNode.getAttribute("used")) {
+
+                       if( rowNode.nextSibling ) {
+                               sib = rowNode.nextSibling;
+                               o ='cp_info_'+thisOrg.id()+'_';
+                               /* push the new row on as the last row for this org unit */
+                               while( sib && sib.id.match(o) ) {
+                                       sib = sib.nextSibling;
+                               }
+                               if(sib)
+                                       rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib);
+                               else
+                                       rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
+                       } else {
+                               rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
+                       }
+
+                       var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
+                       n.appendChild(text(thisOrg.name()));
+                       n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1)  * 9) + "px;");
+                       rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr); 
+
+               } else {
+                       rowNode.setAttribute("used", "1");
+               }
+
+               var cpc_temp = rowNode.removeChild(
+                               findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
+
+               var statuses = arr[4];
+               var cl = '';
+               if (rdetailShowCopyLocation) {
+                       cl = arr[4];
+                       statuses = arr[5];
+               }
+
+
+               rdetailApplyStatuses(rowNode, cpc_temp, statuses);
+
+               var isLocal = false;
+               if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) { 
+                       found = true; 
+                       isLocal = true; 
+                       if(!localCNFound) {
+                               localCNFound = true;
+                               defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix
+                       }
+               }
+
+               //if(isLocal) unHideMe(rowNode);
+               unHideMe(rowNode);
+
+               rdetailSetPath( thisOrg, isLocal );
+               rdetailBuildBrowseInfo( rowNode, [arr[1],arr[2],arr[3]], isLocal, thisOrg, cl );
+
+               if( i == summary.length - 1 && !defaultCN) defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix
+       }
+
+       if(!found) unHideMe(G.ui.rdetail.cp_info_none);
+}
+
+function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
+
+    var whole_cn_json = js2JSON(cn);
+    var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : '');
+
+       if(local) {
+               var cache = callnumberCache[whole_cn_json];
+               if( cache ) cache.count++;
+               else callnumberCache[whole_cn_json] = { count : 1 };
+       }
+
+       var depth = getDepth();
+       if( !local ) depth = findOrgDepth(globalOrgTree);
+
+       $n(row, 'rdetail_callnumber_cell').appendChild(text(whole_cn_text));
+
+       if (rdetailShowCopyLocation) {
+               var cl_cell = $n(row, 'rdetail_copylocation_cell');
+               cl_cell.appendChild(text(cl));
+               unHideMe(cl_cell);
+       }
+
+       _debug('setting action clicks for cn ' + whole_cn_text);
+
+       var dHref = 'javascript:rdetailVolumeDetails('+
+                       '{copy_location : "'+cl.replace(/\"/g, '\\"')+'", rowid : "'+row.id+'", cn_prefix :"'+cn[0].replace(/\"/g, '\\"')+'",cn :"'+cn[1].replace(/\"/g, '\\"')+'",cn_suffix :"'+cn[2].replace(/\"/g, '\\"')+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
+
+       var bHref = 'javascript:rdetailShowCNBrowse("'+cn[1].replace(/\"/g, '\\"') + '", '+orgNode.id()+', "'+depth+'");'; 
+
+       unHideMe( $n(row, 'details') )
+               $n(row, 'details').setAttribute('href', dHref);
+       unHideMe( $n(row, 'browse') )
+               $n(row, 'browse').setAttribute('href', bHref);
+
+       if(isXUL()) {
+               unHideMe($n(row, 'hold_div'));
+               $n(row, 'hold').onclick = function() {
+                       var req = new Request(FETCH_VOLUME_BY_INFO, cn, record.doc_id(), orgNode.id());
+                       req.callback(
+                                       function(r) {
+                                       var vol = r.getResultObject();
+                                       holdsDrawEditor({type: 'V', volumeObject : vol});
+                                       }
+                                   );
+                       req.send();
+               };
+       }
+}
+
+// sets the path to org as 'active' and displays the path if it's local 
+function rdetailSetPath(org, local) {
+       if( findOrgDepth(org) == 0 ) return;
+       var row = $("cp_info_" + org.id());
+       row.setAttribute("hasinfo", "1");
+       unHideMe(row);
+       rdetailSetPath(findOrgUnit(org.parent_ou()), local);
+}
+
+//Append all the statuses for a given summary to the 
+//copy summary table 
+function rdetailApplyStatuses( row, template, statuses ) {
+       for( var j in _statusPositions ) {
+               var stat = _statusPositions[j];
+               var val = statuses[stat.id()];
+               var nn = template.cloneNode(true);
+               if(val) nn.appendChild(text(val));
+               else nn.appendChild(text(0));
+               row.appendChild(nn);
+       }
+}
+
+//Add one td (creating a new column) to the copy summary
+//table for each opac_visible copy status
+function rdetailBuildStatusColumns() {
+
+       rdetailGrabCopyStatuses();
+       var parent = statusRow;
+       var template = parent.removeChild(G.ui.rdetail.cp_status);
+
+       var i = 0;
+       for( i = 0; i < cp_statuses.length; i++ ) {
+
+               var c = cp_statuses[i];
+               if( c && isTrue(c.opac_visible()) ) {
+                       var name = c.name();
+                       _statusPositions[i] = c;
+                       var node = template.cloneNode(true);
+                       var data = findNodeByName( node, config.names.rdetail.cp_status);
+
+                       data.appendChild(text(name));
+                       parent.appendChild(node);
+               }
+       }       
+
+       numStatuses = 0;
+       for(x in _statusPositions) numStatuses++; 
+}
+
+function rdetailGrabCopyStatuses() {
+       if(cp_statuses) return cp_statuses;
+       var req = new Request(FETCH_COPY_STATUSES);
+       req.send(true);
+       cp_statuses = req.result();
+       cp_statuses = cp_statuses.sort(_rdetailSortStatuses);
+}
+
+function _rdetailSortStatuses(a, b) {
+       return parseInt(a.id()) - parseInt(b.id());
+}
+
+/**
+ * Check for a Google Book preview after the main page loads
+ */
+function rdetailCheckForGBPreview() {
+       if (!rdetailGoogleBookPreview) return;
+        dojo.addOnLoad(function() {
+               searchForGBPreview( cleanISBN(record.isbn()) );
+       });
+}
+
+/**
+ *
+ * @param {DOM object} isbn The form element containing the input parameters "isbns"
+ */
+function searchForGBPreview( isbn ) {
+       dojo.require("dojo.io.script");
+       dojo.io.script.get({"url": "https://www.google.com/jsapi"});
+       dojo.io.script.get({"url": "http://books.google.com/books", "content": { "bibkeys": isbn, "jscmd": "viewapi", "callback": "GBPreviewCallback"}});
+}
+
+/**
+ * This function is the call-back function for the JSON scripts which 
+ * executes a Google book search response.
+ *
+ * XXX I18N of text needed
+ *
+ * @param {JSON} GBPBookInfo is the JSON object pulled from the Google books service.
+ */
+function GBPreviewCallback(GBPBookInfo) {
+       var GBPreviewDiv = document.getElementById("rdetail_preview_div");
+       var GBPBook;
+
+       for ( i in GBPBookInfo ) {
+               GBPBook = GBPBookInfo[i];
+       }
+
+       if ( !GBPBook ) {
+               return;
+       }
+
+       if ( GBPBook.preview != "noview" ) {
+               // Add a button below the book cover image to load the preview.
+               GBPBadge = document.createElement( 'img' );
+               GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif';
+               GBPBadge.title = $('rdetail_preview_badge').innerHTML;
+               GBPBadge.style.border = 0;
+               GBPBadgelink = document.createElement( 'a' );
+               GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");';
+               GBPBadgelink.appendChild( GBPBadge );
+               $('rdetail_image_cell').appendChild( GBPBadgelink );
+               $('rdetail_preview_div').style.height = 600;
+
+               /* Display the "Preview" tab in the Extras section */
+               unHideMe( $('rdetail_preview_link' ) );
+       }
+}
+
+/**
+ *  This is called when the user clicks on the 'Preview' link.  We assume
+ *  a preview is available from Google if this link was made visible.
+ *
+ * XXX I18N of Google Book Preview language attribute needed
+ */
+function rdetailDisplayGBPreview() {
+       unHideMe($('rdetail_extras_loading'));
+       GBPreviewPane = $('rdetail_preview_div');
+       if ( GBPreviewPane.getAttribute('loaded') == null ||
+               GBPreviewPane.getAttribute('loaded') == "false" ) {
+               google.load("books", "0", {"callback" : rdetailGBPViewerLoadCallback, "language": "en"} );
+               GBPreviewPane.setAttribute('loaded', 'true');
+       }
+}
+
+function rdetailGBPViewerLoadCallback() {
+       hideMe($('rdetail_extras_loading'));
+       var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div'));
+       GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );
+
+}
+
+function rdetailDrawExpandedHoldings(anchor, bibid, type) {
+    var offsets = {"basic": 0, "index": 0, "supplement": 0};
+    var limit = 10; /* XXX give user control over this? */
+    var target_id = "holding_type_" + type;
+    var target = dojo.byId(target_id);
+
+    anchor.innerHTML = "[-]";
+    anchor.oldonclick = anchor.onclick;
+    anchor.onclick = function() {
+        anchor.onclick = anchor.oldonclick;
+        anchor.innerHTML = "[+]";
+        dojo.empty(target);
+    };
+
+    function _load() {
+        dojo.empty(target);
+        fieldmapper.standardRequest(
+            ["open-ils.serial",
+                "open-ils.serial.received_siss.retrieve.by_bib.atomic"], {
+                "params": [bibid, {"offset": offsets[type], "limit": limit}],
+                "async": true,
+                "oncomplete": function(r) {
+                    try {
+                        if (msg = r.recv().content()) { /* sic, assignment */
+                            if (!msg.length) return;
+                            offsets[type] += msg.length;
+                            var table = dojo.create("table", null, target);
+                            dojo.forEach(
+                                msg, function(o) {
+                                    var tr = dojo.create("tr", null, table);
+                                    dojo.create(
+                                        "td", {
+                                            "innerHTML": o.issuance.label(),
+                                            "style": {"paddingLeft": "3em"}
+                                        }, tr
+                                    );
+
+                                    if (!o.has_units) return;
+                                    /* can't place holds if no units */
+                                    var td = dojo.create("td", null, tr);
+                                    dojo.create(
+                                        "a", {
+                                            "href":"javascript:void(0);",
+                                            "style": {"marginLeft": "1.5em"},
+                                            "onclick": function() {
+                                                holdsDrawEditor({
+                                                    "type": "I",
+                                                    "issuance": o.issuance.id()
+                                                });
+                                            },
+                                            "innerHTML": "[" +
+                                                opac_strings.PLACE_HOLD + "]"
+                                        }, td
+                                    );
+                                }
+                            );
+                            if (msg.length == limit) {
+                                dojo.create("br", null, target);
+                                dojo.create(
+                                    "a", {
+                                        "href": "javascript:void(0);",
+                                        "innerHTML":
+                                            "[" + opac_strings.MORE + "]",
+                                        "onclick": _load
+                                    }, target
+                                );
+                            }
+                        }
+                    } catch (E) {
+                        void(0);
+                    }
+                }
+            }
+        );
+    }
+    _load();
+}
diff --git a/Open-ILS/web/opac/skin/tadlv2/js/result_common.js b/Open-ILS/web/opac/skin/tadlv2/js/result_common.js
new file mode 100644 (file)
index 0000000..2044489
--- /dev/null
@@ -0,0 +1,859 @@
+dojo.require('openils.BibTemplate');
+dojo.requireLocalization("openils.opac", "opac");
+var opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
+
+var recordsHandled = 0;
+var recordsCache = [];
+var lowHitCount = 4;
+var isbnList = '';
+var googleBooksLink = false;
+
+var resultFetchAllRecords = false;
+var resultCompiledSearch = null;
+
+/* set up the event handlers */
+if( findCurrentPage() == MRESULT || findCurrentPage() == RRESULT ) {
+       G.evt.result.hitCountReceived.push(resultSetHitInfo);
+       G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
+       G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
+       G.evt.result.allRecordsReceived.push( function(){unHideMe($('result_info_2'))}, fetchGoogleBooksLink, fetchChiliFreshReviews);
+
+       attachEvt('result','lowHits',resultLowHits);
+       attachEvt('result','zeroHits',resultZeroHits);
+       attachEvt( "common", "locationUpdated", resultSBSubmit );
+       /* do this after we have ID's so the rank for mr pages will be correct */
+       attachEvt("result", "preCollectRecords", resultPaginate);
+}
+
+function resultSBSubmit(){searchBarSubmit();}
+
+/* returns the last 'index' postion ocurring in this page */
+function resultFinalPageIndex() {
+       if(getHitCount() < (getOffset() + getDisplayCount())) 
+               return getHitCount() - 1;
+       return getOffset() + getDisplayCount() - 1;
+}
+
+
+
+
+/* generic search method */
+function resultCollectSearchIds( type, method, handler ) {
+
+       var sort                = (getSort() == SORT_TYPE_REL) ? null : getSort(); 
+       var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
+
+       var item_type;
+       var item_form;
+       var args = {};
+
+       if( type ) {
+               var form = parseForm(getForm());
+               item_type = form.item_type;
+               item_form = form.item_form;
+
+       } else {
+               item_type = (getItemType()) ? getItemType().split(/,/) : null;
+               item_form = (getItemForm()) ? getItemForm().split(/,/) : null;
+       }
+
+       var limit = (resultFetchAllRecords) ? 1000 : getDisplayCount();
+
+       if( getOffset() > 0 ) {
+               if( getHitCount() > 0 && (getOffset() + getDisplayCount()) > getHitCount() ) 
+                       limit = getHitCount() - getOffset();
+       }
+
+       var lasso = getLasso();
+
+       if (lasso) args.org_unit = -lasso;
+       else args.org_unit = getLocation();
+
+       args.depth    = getDepth();
+       args.limit    = limit;
+       args.offset   = getOffset();
+       args.visibility_limit = 3000;
+    args.default_class = getStype();
+
+       if(sort) args.sort = sort;
+       if(sortdir) args.sort_dir = sortdir;
+       if(item_type) args.item_type    = item_type;
+       if(item_form) args.item_form    = item_form;
+    if(getAvail()) args.available = 1;
+
+
+       if(getFacet()) args.facets  = getFacet();
+
+       if(getAudience()) args.audience  = getAudience().split(/,/);
+       if(getLitForm()) args.lit_form  = getLitForm().split(/,/);
+       if(getLanguage()) args.language = getLanguage().split(/,/);
+       if(getBibLevel()) args.bib_level        = getBibLevel().split(/,/);
+       if(getCopyLocs()) args.locations        = getCopyLocs().split(/,/);
+    if(getPubdBefore()) args.before = getPubdBefore();
+    else if(getPubdAfter()) args.after = getPubdAfter();
+    else if(getPubdBetween()) args.between = getPubdBetween().split(/,/);
+
+       _debug('Search args: ' + js2JSON(args));
+       _debug('Raw query: ' + getTerm());
+
+       var my_ou = findOrgUnit(args.org_unit);
+       if (my_ou && my_ou.shortname()) {
+               var atomfeed = "/opac/extras/opensearch/1.1/" + my_ou.shortname() + "/atom-full/" + getStype() + '?searchTerms=' + getTerm();
+               if (args.facets) { atomfeed += ' ' + args.facets; }
+               if (sort) { atomfeed += '&searchSort=' + sort; }
+               if (sortdir) { atomfeed += '&searchSortDir=' + sortdir; }
+               dojo.create('link', {"rel":"alternate", "href":atomfeed, "type":"application/atom+xml"}, dojo.query('head')[0]);
+       }
+
+       var req = new Request(method, args, getTerm(), 1);
+       req.callback(handler);
+       req.send();
+}
+
+
+
+
+
+/* set the search result info, number of hits, which results we're 
+       displaying, links to the next/prev pages, etc. */
+function resultSetHitInfo() { 
+
+       var lasso = getLasso();
+       if (!lasso) {
+               /* tell the user where the results are coming from */
+               var baseorg = findOrgUnit(getLocation());
+               var depth = getDepth();
+               var mydepth = findOrgDepth(baseorg);
+               if( findOrgDepth(baseorg) != depth ) {
+                       var tmporg = baseorg;
+                       while( mydepth > depth ) {
+                               mydepth--;
+                               tmporg = findOrgUnit(tmporg.parent_ou());
+                       }
+                       unHideMe($('including_results_for'));
+                       $('including_results_location').appendChild(text(tmporg.name()));
+               }
+       }
+
+
+       try{searchTimer.stop()}catch(e){}
+
+       //if( findCurrentPage() == MRESULT ) {
+       if( findCurrentPage() == MRESULT || 
+
+               (findCurrentPage() == RRESULT &&
+                       (
+                               getRtype() == RTYPE_TITLE ||
+                               getRtype() == RTYPE_AUTHOR ||
+                               getRtype() == RTYPE_SUBJECT ||
+                               getRtype() == RTYPE_SERIES ||
+                               getRtype() == RTYPE_KEYWORD 
+                       )
+
+               ) ) {
+
+               if(getHitCount() <= lowHitCount && getTerm())
+                       runEvt('result', 'lowHits');
+       }
+
+       if(getHitCount() == 0) {
+               runEvt('result', 'zeroHits');
+               return;
+       }
+
+
+       var pages = getHitCount() / getDisplayCount();
+       if(pages % 1) pages = parseInt(pages) + 1;
+
+       
+
+       var cpage = (getOffset()/getDisplayCount()) + 1;
+
+       G.ui.result.current_page.appendChild(text(cpage));
+       G.ui.result.num_pages.appendChild(text(pages + ")")); /* the ) is dumb */
+
+       $('current_page2').appendChild(text(cpage));
+       $('num_pages2').appendChild(text(pages + ")")); /* the ) is dumb */
+
+       /* set the offsets */
+       var offsetEnd = getDisplayCount() + getOffset();  
+       if( getDisplayCount() > (getHitCount() - getOffset()))  
+               offsetEnd = getHitCount();
+
+       G.ui.result.offset_end.appendChild(text(offsetEnd));
+       G.ui.result.offset_start.appendChild(text(getOffset() + 1));
+
+       $('offset_end2').appendChild(text(offsetEnd));
+       $('offset_start2').appendChild(text(getOffset() + 1));
+
+       G.ui.result.result_count.appendChild(text(getHitCount()));
+       unHideMe(G.ui.result.info);
+
+       $('result_count2').appendChild(text(getHitCount()));
+       unHideMe($('result_info_div2'));
+}
+
+function resultLowHits() {
+       showCanvas();
+       unHideMe($('result_low_hits'));
+       if(getHitCount() > 0)
+               unHideMe($('result_low_hits_msg'));
+
+    var words = [];
+    for(var key in resultCompiledSearch.searches) 
+        words.push(resultCompiledSearch.searches[key].term);
+
+       var sreq = new Request(CHECK_SPELL, words.join(' '));
+       sreq.callback(resultSuggestSpelling);
+       sreq.send();
+
+    for(var key in resultCompiledSearch.searches) {
+               var areq = new Request(FETCH_CROSSREF, key, resultCompiledSearch.searches[key].term);
+               areq.callback(resultLowHitXRef);
+               areq.send();
+       }
+
+       if( !(getForm() == null || getForm() == 'all' || getForm() == "") ) {
+               var a = {};
+               a[PARAM_FORM] = "all";
+               $('low_hits_remove_format_link').setAttribute('href',buildOPACLink(a));
+               unHideMe($('low_hits_remove_format'));
+       }
+
+       resultSuggestSearchClass();
+
+       if(getTerm()) resultExpandSearch(); /* advanced search */
+}
+
+var lowHitsXRefSet = {};
+var lowHitsXRefLink;
+var lowHitsXRefLinkParent;
+function resultLowHitXRef(r) {
+       if(!lowHitsXRefLink){
+               lowHitsXRefLinkParent = $('low_hits_xref_link').parentNode;
+               lowHitsXRefLink = lowHitsXRefLinkParent.removeChild($('low_hits_xref_link'));
+       }
+       var res = r.getResultObject();
+       var arr = res.from;
+       arr.concat(res.also);
+       if(arr && arr.length > 0) {
+               unHideMe($('low_hits_cross_ref'));
+               var word;
+               var c = 0;
+               while( word = arr.shift() ) {
+
+            if (lowHitsXRefSet[word] == 1) continue;
+            lowHitsXRefSet[word] = 1;
+
+                       if(c++ > 20) break;
+                       var a = {};
+                       a[PARAM_TERM] = word;
+                       var template = lowHitsXRefLink.cloneNode(true);
+                       template.setAttribute('href',buildOPACLink(a));
+                       template.appendChild(text(word));
+                       lowHitsXRefLinkParent.appendChild(template);
+                       lowHitsXRefLinkParent.appendChild(text(' '));
+               }
+       }
+}
+
+function resultZeroHits() {
+       showCanvas();
+       unHideMe($('result_low_hits'));
+       unHideMe($('result_zero_hits_msg'));
+       //if(getTerm()) resultExpandSearch(); /* advanced search */
+}
+
+function resultExpandSearch() {
+       var top = findOrgDepth(globalOrgTree);
+       if(getDepth() == top) return;
+       unHideMe($('low_hits_expand_range'));
+       var par = $('low_hits_expand_link').parentNode;
+       var template = par.removeChild($('low_hits_expand_link'));
+
+       var bottom = getDepth();
+       while( top < bottom ) {
+               var a = {};
+               a[PARAM_DEPTH] = top;
+               var temp = template.cloneNode(true);
+               temp.appendChild(text(findOrgTypeFromDepth(top).opac_label()))
+               temp.setAttribute('href',buildOPACLink(a));
+               par.appendChild(temp);
+               top++;
+       }
+}
+
+function resultSuggestSearchClass() {
+       var stype = getStype();
+       if(stype == STYPE_KEYWORD) return;
+       var a = {}; var ref;
+       unHideMe($('low_hits_search_type'));
+       if(stype != STYPE_TITLE) {
+               ref = $('low_hits_title_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_TITLE;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_AUTHOR) {
+               ref = $('low_hits_author_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_AUTHOR;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_SUBJECT) {
+               ref = $('low_hits_subject_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_SUBJECT;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_KEYWORD) {
+               ref = $('low_hits_keyword_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_KEYWORD;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+       if(stype != STYPE_SERIES) {
+               ref = $('low_hits_series_search');
+               unHideMe(ref);
+               a[PARAM_STYPE] = STYPE_SERIES;
+               ref.setAttribute('href',buildOPACLink(a));
+       }
+}
+
+function resultSuggestSpelling(r) {
+       var res = r.getResultObject();
+       var phrase = getTerm();
+       var words = phrase.split(/ /);
+
+       var newterm = "";
+
+       for( var w = 0; w < words.length; w++ ) {
+               var word = words[w];
+               var blob = grep(res, function(i){return (i.word == word);});
+               if( blob ) blob = blob[0];
+               else continue;
+               if( blob.word == word ) {
+                       if( !blob.found && blob.suggestions && blob.suggestions[0] ) {
+                               newterm += " " + blob.suggestions[0];
+                               unHideMe($('did_you_mean'));
+                       } else {
+                               newterm += " " + word;
+                       }
+               }
+       }
+
+       var arg = {};
+       arg[PARAM_TERM] = newterm;
+       $('spell_check_link').setAttribute('href', buildOPACLink(arg));
+       $('spell_check_link').appendChild(text(newterm));
+}
+
+
+function resultPaginate() {
+       var o = getOffset();
+
+       if( !(  ((o) + getDisplayCount()) >= getHitCount()) ) {
+
+               var args = {};
+               args[PARAM_OFFSET]      = o + getDisplayCount();
+               args[PARAM_SORT]                = SORT;
+               args[PARAM_SORT_DIR] = SORT_DIR;
+               args[PARAM_RLIST]               = new CGI().param(PARAM_RLIST);
+
+               G.ui.result.next_link.setAttribute("href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
+
+               $('next_link2').setAttribute("href", buildOPACLink(args)); 
+               addCSSClass($('next_link2'), config.css.result.nav_active);
+
+               args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
+
+               /* when hit count is divisible by display count, we have to adjust */
+               if( getHitCount() % getDisplayCount() == 0 ) 
+                       args[PARAM_OFFSET] -= getDisplayCount();
+
+        /*
+               G.ui.result.end_link.setAttribute("href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.end_link, config.css.result.nav_active);
+
+               $('end_link2').setAttribute("href", buildOPACLink(args)); 
+               addCSSClass($('end_link2'), config.css.result.nav_active);
+        */
+       }
+
+       if( o > 0 ) {
+
+               var args = {};
+               args[PARAM_SORT]                = SORT;
+               args[PARAM_SORT_DIR] = SORT_DIR;
+               args[PARAM_RLIST]               = new CGI().param(PARAM_RLIST);
+
+               args[PARAM_OFFSET] = o - getDisplayCount();
+               G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
+
+               $('prev_link2').setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass($('prev_link2'), config.css.result.nav_active);
+
+               args[PARAM_OFFSET] = 0;
+               G.ui.result.home_link.setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
+
+               $('search_home_link2').setAttribute( "href", buildOPACLink(args)); 
+               addCSSClass($('search_home_link2'), config.css.result.nav_active);
+       }
+
+       if(getDisplayCount() < getHitCount()) {
+               unHideMe($('start_end_links_span'));
+               unHideMe($('start_end_links_span2'));
+   }
+
+       showCanvas();
+       try{searchTimer.stop()}catch(e){}
+}
+
+function buildunAPISpan (span, type, id) {
+       var cgi = new CGI();
+       var d = new Date();
+
+       addCSSClass(span,'unapi-id');
+
+       span.setAttribute(
+               'title',
+               'tag:' + cgi.server_name + ',' +
+                       d.getFullYear() +
+                       ':' + type + '/' + id
+       );
+}
+
+function unhideGoogleBooksLink (data) {
+    for ( var i in data ) {
+        //if (data[i].preview == 'noview') continue;
+
+        var gbspan = $n(document.documentElement, 'googleBooksLink-' + i);
+        var gba = $n(gbspan, "googleBooks-link");
+
+        gba.setAttribute(
+            'href',
+            data[i].info_url
+        );
+        removeCSSClass( gbspan, 'hide_me' );
+    }
+}
+
+/* display the record info in the record display table 'pos' is the 
+               zero based position the record should have in the display table */
+function resultDisplayRecord(rec, pos, is_mr) {
+
+    fieldmapper.IDL.load(['mvr']);
+       if(rec == null) rec = new mvr(); /* so the page won't die if there was an error */
+       recordsHandled++;
+       recordsCache.push(rec);
+
+       var r = table.rows[pos + 1];
+    var currentISBN = cleanISBN(rec.isbn());
+
+    if (googleBooksLink) {
+           var gbspan = $n(r, "googleBooksLink");
+        if (currentISBN) {
+            gbspan.setAttribute(
+                'name',
+                gbspan.getAttribute('name') + '-' + currentISBN
+            );
+
+            if (isbnList) isbnList += ', ';
+            isbnList += currentISBN;
+        }
+    }
+
+    if (currentISBN && chilifresh && chilifresh != '(none)') {
+        var cfrow = $n(r, "chilifreshReview");
+        if (cfrow) {
+            removeCSSClass( cfrow, 'hide_me' );
+        }
+        var cflink = $n(r, "chilifreshReviewLink");
+        if (cflink) {
+            cflink.setAttribute(
+                'id',
+                'isbn_' + currentISBN
+            );
+        }
+        var cfdiv = $n(r, "chilifreshReviewResult");
+        if (cfdiv) {
+            cfdiv.setAttribute(
+                'id',
+                'chili_review_' + currentISBN
+            )
+        }
+    }
+
+/*
+       try {
+               var rank = parseFloat(ranks[pos + getOffset()]);
+               rank            = parseInt( rank * 100 );
+               var relspan = $n(r, "relevancy_span");
+               relspan.appendChild(text(rank));
+               unHideMe(relspan.parentNode);
+       } catch(e){ }
+*/
+
+    var pic = $n(r, config.names.result.item_jacket);
+    if (currentISBN) {
+        pic.setAttribute("src", buildISBNSrc(currentISBN));
+    } else {
+        pic.setAttribute("src", "/opac/images/blank.png");
+    }
+
+       var title_link = $n(r, config.names.result.item_title);
+       var author_link = $n(r, config.names.result.item_author);
+
+       var onlyrec;
+       if( is_mr )  {
+               onlyrec = onlyrecord[ getOffset() + pos ];
+               if(onlyrec) {
+                       buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', onlyrec);
+
+                       var args = {};
+                       args.page = RDETAIL;
+                       args[PARAM_OFFSET] = 0;
+                       args[PARAM_RID] = onlyrec;
+                       args[PARAM_MRID] = rec.doc_id();
+                       pic.parentNode.setAttribute("href", buildOPACLink(args));
+                       title_link.setAttribute("href", buildOPACLink(args));
+                       title_link.appendChild(text(normalize(truncate(rec.title(), 65))));
+
+               } else {
+                       buildunAPISpan($n(r,'unapi'), 'metabib-metarecord', rec.doc_id());
+
+                       buildTitleLink(rec, title_link); 
+                       var args = {};
+                       args.page = RRESULT;
+                       args[PARAM_OFFSET] = 0;
+                       args[PARAM_MRID] = rec.doc_id();
+                       pic.parentNode.setAttribute("href", buildOPACLink(args));
+               }
+
+               unHideMe($n(r,'place_hold_span'));
+               $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'M'); }
+            
+
+       } else {
+               onlyrec = rec.doc_id();
+               buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id());
+
+               buildTitleDetailLink(rec, title_link); 
+               var args = {};
+               args.page = RDETAIL;
+               args[PARAM_OFFSET] = 0;
+               args[PARAM_RID] = rec.doc_id();
+               pic.parentNode.setAttribute("href", buildOPACLink(args));
+
+               unHideMe($n(r,'place_hold_span'));
+               $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'T'); }
+       }
+
+       buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
+
+       if(! is_mr ) {
+       
+               if(!isNull(rec.edition()))      {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       $n(r, "result_table_edition_span").appendChild( text( rec.edition()) );
+               }
+               if(!isNull(rec.pubdate())) {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       unHideMe($n(r, "result_table_pub_span"));
+                       $n(r, "result_table_pub_span").appendChild( text( rec.pubdate() ));
+               }
+               if(!isNull(rec.publisher()) ) {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       unHideMe($n(r, "result_table_pub_span"));
+                       $n(r, "result_table_pub_span").appendChild( text( " " + rec.publisher() ));
+               }
+
+               if(!isNull(rec.physical_description()) ) {
+                       unHideMe( $n(r, "result_table_extra_span"));
+                       var t = " " + rec.physical_description();
+                       //$n(r, "result_table_phys_span").appendChild( text(t.replace(/:.*/g,'')));
+                       $n(r, "result_table_phys_span").appendChild( text(t));
+               }
+
+       }
+
+       resultBuildFormatIcons( r, rec, is_mr );
+
+       var bt_params = {
+               sync                    : false,
+               root                    : r,
+               subObjectLimit  : 10,
+               org_unit                : findOrgUnit(getLocation()).shortname(),
+               depth                   : getDepth()
+       };
+
+       if (!is_mr) {
+               bt_params = dojo.mixin( bt_params, { record : onlyrec } );
+       } else {
+               bt_params = dojo.mixin( bt_params, { metarecord : onlyrec } );
+       }
+
+       if (findOrgType(findOrgUnit(getLocation()).ou_type()).can_have_vols())
+               unHideMe($n(r,'local_callnumber_list'));
+
+       new openils.BibTemplate( bt_params ).render();
+
+       unHideMe(r);
+       
+       runEvt("result", "recordDrawn", rec.doc_id(), title_link);
+
+       /*
+       if(resultPageIsDone())  {
+               runEvt('result', 'allRecordsReceived', recordsCache);
+       }
+       */
+}
+
+function resultDrawHoldsWindow(hold_target, hold_type) {
+    var src = location.href;
+
+    if(forceLoginSSL && src.match(/^http:/)) {
+
+        src = src.replace(/^http:/, 'https:');
+
+        if(src.match(/&hold_target=/)) {
+            src.replace(/&hold_target=(\d+)/, hold_target);
+
+        } else {
+            src += '&hold_target=' + hold_target;
+        }
+
+        location.href = src;
+
+    } else {
+        holdsDrawEditor({record:hold_target, type:hold_type});
+    }
+}
+
+
+
+function _resultFindRec(id) {
+       for( var i = 0; i != recordsCache.length; i++ ) {
+               var rec = recordsCache[i];
+               if( rec && rec.doc_id() == id )
+                       return rec;
+       }
+       return null;
+}
+
+
+function resultBuildFormatIcons( row, rec, is_mr ) {
+
+       var ress = rec.types_of_resource();
+
+       for( var i in ress ) {
+
+               var res = ress[i];
+               if(!res) continue;
+
+               var link = $n(row, res + "_link");
+               link.title = res;
+               var img = link.getElementsByTagName("img")[0];
+               removeCSSClass( img, config.css.dim );
+
+               var f = getForm();
+               if( f != "all" ) {
+                       if( f == modsFormatToMARC(res) ) 
+                               addCSSClass( img, "dim2_border");
+               }
+
+               var args = {};
+               args[PARAM_OFFSET] = 0;
+
+               if(is_mr) {
+                       args.page = RRESULT;
+                       args[PARAM_TFORM] = modsFormatToMARC(res);
+                       args[PARAM_MRID] = rec.doc_id();
+
+               } else {
+                       args.page = RDETAIL
+                       args[PARAM_RID] = rec.doc_id();
+               }
+
+               link.setAttribute("href", buildOPACLink(args));
+
+       }
+}
+
+function fetchGoogleBooksLink () {
+    if (isbnList && googleBooksLink) {
+        var scriptElement = document.createElement("script");
+        scriptElement.setAttribute("id", "jsonScript");
+        scriptElement.setAttribute("src",
+            "http://books.google.com/books?bibkeys=" + 
+            escape(isbnList) + "&jscmd=viewapi&callback=unhideGoogleBooksLink");
+        scriptElement.setAttribute("type", "text/javascript");
+        // make the request to Google Book Search
+        document.documentElement.firstChild.appendChild(scriptElement);
+    }
+}
+
+function fetchChiliFreshReviews() {
+    if (chilifresh && chilifresh != '(none)') {
+        try { chili_init(); } catch(E) { console.log(E + '\n'); }
+    }
+}
+
+function resultPageIsDone(pos) {
+
+       return (recordsHandled == getDisplayCount() 
+               || recordsHandled + getOffset() == getHitCount());
+}
+
+var resultCCHeaderApplied = false;
+
+/* -------------------------------------------------------------------- */
+/* dynamically add the copy count rows based on the org type 'countsrow' 
+       is the row into which we will add TD's to hold the copy counts 
+       This code generates copy count cells with an id of
+       'copy_count_cell_<depth>_<pagePosition>'  */
+function resultAddCopyCounts(rec, pagePosition) {
+
+       var r = table.rows[pagePosition + 1];
+       var countsrow = $n(r, config.names.result.counts_row );
+       var ccell = $n(countsrow, config.names.result.count_cell);
+
+       var nodes = orgNodeTrail(findOrgUnit(getLocation()));
+       var start_here = 0;
+       var orgHiding = checkOrgHiding();
+       if (orgHiding) {
+               for (var i = 0; i < nodes.length; i++) {
+                       if (orgHiding.depth == findOrgDepth(nodes[i])) {
+                               start_here = i;
+                       }
+               }
+       }
+
+       var node = nodes[start_here];
+       var type = findOrgType(node.ou_type());
+       ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
+       ccell.title = type.opac_label();
+       //addCSSClass(ccell, config.css.result.cc_cell_even);
+
+       var lastcell = ccell;
+       var lastheadcell = null;
+
+       var cchead = null;
+       var ccheadcell = null;
+       if(!resultCCHeaderApplied && !getLasso()) {
+               ccrow = $('result_thead_row');
+               ccheadcell =  ccrow.removeChild($n(ccrow, "result_thead_ccell"));
+               var t = ccheadcell.cloneNode(true);
+               lastheadcell = t;
+               t.appendChild(text(type.opac_label()));
+               ccrow.appendChild(t);
+               resultCCHeaderApplied = true;
+       }
+
+       if(nodes[start_here+1]) {
+
+               var x = start_here+1;
+               var d = findOrgDepth(nodes[start_here+1]);
+               var d2 = findOrgDepth(nodes[nodes.length -1]);
+
+               for( var i = d; i <= d2 ; i++ ) {
+       
+                       ccell = ccell.cloneNode(true);
+
+                       //if((i % 2)) removeCSSClass(ccell, "copy_count_cell_even");
+                       //else addCSSClass(ccell, "copy_count_cell_even");
+
+                       var node = nodes[x++];
+                       var type = findOrgType(node.ou_type());
+       
+                       ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
+                       ccell.title = type.opac_label();
+                       countsrow.insertBefore(ccell, lastcell);
+                       lastcell = ccell;
+
+                       if(ccheadcell) {
+                               var t = ccheadcell.cloneNode(true);
+                               t.appendChild(text(type.opac_label()));
+                               ccrow.insertBefore(t, lastheadcell);
+                               lastheadcell = t;
+                       }
+               }
+       }
+
+       unHideMe($("search_info_table"));
+}
+
+/* collect copy counts for a record using method 'methodName' */
+function resultCollectCopyCounts(rec, pagePosition, methodName) {
+       if(rec == null || rec.doc_id() == null) return;
+
+       var loc = getLasso();
+       if (loc) loc = -loc;
+       else loc= getLocation();
+
+       var req = new Request(methodName, loc, rec.doc_id(), getForm() );
+       req.request.userdata = [ rec, pagePosition ];
+       req.callback(resultHandleCopyCounts);
+       req.send();
+}
+
+function resultHandleCopyCounts(r) {
+       runEvt('result', 'copyCountsReceived', r.userdata[0], r.userdata[1], r.getResultObject()); 
+}
+
+
+/* XXX Needs to understand Lasso copy counts... */
+/* display the collected copy counts */
+function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
+       if(copy_counts == null || rec == null) return;
+
+       if (getLasso()) {
+               var copy_counts_lasso = {
+                       transcendant : null,
+                       count : 0,
+                       unshadow : 0,
+                       available : 0,
+                       depth : -1,
+                       org_unit : getLasso()
+               };
+
+               for (var i in copy_counts) {
+                       copy_counts_lasso.transcendant = copy_counts[i].transcendant;
+                       copy_counts_lasso.count += parseInt(copy_counts[i].count);
+                       copy_counts_lasso.unshadow += parseInt(copy_counts[i].unshadow);
+                       copy_counts_lasso.available += parseInt(copy_counts[i].available);
+               }
+
+               copy_counts = [ copy_counts_lasso ];
+       }
+
+       var i = 0;
+       while(copy_counts[i] != null) {
+               var cell = $("copy_count_cell_" + i +"_" + pagePosition);
+               if (cell) {
+                       var cts = copy_counts[i];
+                       cell.appendChild(text(cts.available + " / " + cts.count));
+
+                       if(isXUL()) {
+                               /* here we style opac-invisible records for xul */
+
+                               if( cts.depth == 0 ) {
+                                       if(cts.transcendant == null && cts.unshadow == 0) {
+                                               _debug("found an opac-shadowed record: " + rec.doc_id());
+                                               var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode; 
+                                               if( cts.count == 0 ) 
+                                                       addCSSClass( row, 'no_copies' );
+                                               else 
+                                                       addCSSClass( row, 'shadowed' );
+                                       }
+                               }
+                       }
+               }
+               i++;
+       }
+}
+
+
index 3325a26..a8fd019 100644 (file)
                </tbody>
        </table>
                <!--#include virtual='footer.xml'-->
-    <center>
-        <div id='gcfPrompt' class='hide_me'>
-            <script>dojo.require('dojo.cookie')</script>;
-            <div><span>&common.googlechromeframe.why;</span></div>
-            <button onclick='CFInstall.check({preventPrompt: false, mode: "popup"});'>&common.googlechromeframe.install;</button>
-            <button onclick='dojo.cookie("noGCF", "true", {path:"/", expires: 365}); hideMe($("gcfPrompt"));'>&common.googlechromeframe.dontask;</button>
-        </div>
-    </center>
-    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
-    <script><![CDATA[ 
-        CFInstall.check({
-            preventPrompt: true,
-            onmissing: function() {
-                if (dojo.cookie("noGCF") != "true")
-                    unHideMe($('gcfPrompt'));
-            }
-        });]]>
-    </script>
 
     <script language="javascript" type="text/javascript">
         dojo.addOnLoad(init);
index 574af3b..b5fff24 100644 (file)
                </tbody>
        </table>
        <!--#include virtual='../footer.xml'-->
-    <center>
-        <div id='gcfPrompt' class='hide_me'>
-            <script>dojo.require('dojo.cookie');</script>
-            <div><span>&common.googlechromeframe.why;</span></div>
-            <button onclick='CFInstall.check({preventPrompt: false, mode: "popup"});'>&common.googlechromeframe.install;</button>
-            <button onclick='dojo.cookie("noGCF", "true", {path:"/", expires: 365}); hideMe($("gcfPrompt"));'>&common.googlechromeframe.dontask;</button>
-        </div>
-    </center>
-    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
-    <script><![CDATA[ 
-        CFInstall.check({
-            preventPrompt: true,
-            onmissing: function() {
-                if (dojo.cookie("noGCF") != "true")
-                    unHideMe($('gcfPrompt'));
-            }
-        });]]>
-    </script>
 
     <script language="javascript" type="text/javascript">
         isFrontPage = true;