]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
more web work
[Evergreen.git] / Open-ILS / src / javascript / opac / AbstractRecordResultPage.js
1
2 AbstractRecordResultPage.prototype                                      = new Page();
3 AbstractRecordResultPage.prototype.constructor  = AbstractRecordResultPage;
4 AbstractRecordResultPage.baseClass                                      = Page.constructor;
5
6
7 /* constructor for our singleton object */
8 function AbstractRecordResultPage() {}
9
10
11 /* initialize all of the UI components and set up data structures */
12 AbstractRecordResultPage.prototype.init = function() {
13
14         debug( "Initing an AbstractRecordResultPage" );
15
16         /* included page chunks */
17         this.searchBar                  = new SearchBarChunk();
18
19         /* UI objects */
20         this.recordBox                  = getById("record_result_box");
21
22         this.authorBox = new Box();
23         this.authorBox.init("Relevant Authors", true, true, 15);
24         this.authorBox.sortByKey();
25
26         this.subjectBox = new Box();
27         this.subjectBox.init("Relevant Subjects", true, true, 15);
28         this.subjectBox.sortByCount();
29
30         this.seriesBox = new Box();
31         this.seriesBox.init("Relevant Series", true, true, 15);
32         this.seriesBox.sortByKey();
33
34         this.sidebarBox         = getById("record_sidebar_box");
35
36         this.sidebarBox.appendChild(this.buildNavBox());
37         this.sidebarBox.appendChild(elem("br"));
38
39         if(!this.hitsPerPage)
40                 this.hitsPerPage                = 10;    /* how many hits are displayed per page */
41
42         this.resetPage();
43
44         this.statusBar                  = getById("top_status_bar_table");
45         this.theadDrawn         = false;
46         this.bigOlBox                   = getById("big_ol_box");
47
48 }
49
50
51
52 /** Resets data structures for a new search */
53 AbstractRecordResultPage.prototype.resetPage = function() {
54         this.searchBar.reset();
55         var spot = getById("progress_bar_location");
56         var spot2 = getById("progress_bar_percent_location");
57         if(spot) {
58                 while(spot.lastChild) 
59                         spot.removeChild(spot.lastChild);
60
61                 /* progress items for each record and it's hit count listing */
62                 this.progressBar = new ProgressBar(parseInt(this.hitsPerPage) * 2);
63                 spot.appendChild(this.progressBar.getNode());
64         }
65         if(spot2 && this.progressBar)
66                 spot2.appendChild(this.progressBar.percentDiv);
67         this.received = 0;
68
69         RemoteRequest.cancelAll();
70
71         this.requestBatch = new RequestBatch();
72         this.finalized = false;
73         this.builtLinks = false;
74
75         this.hitsPerPageSelector = getById('hits_per_page');
76
77         var obj = this;
78         this.hitsPerPageSelector.onchange = function() {
79
80                 var hits;
81                 var hits_obj = obj.hitsPerPageSelector.options[
82                         obj.hitsPerPageSelector.selectedIndex]; 
83
84                 if(hits_obj == null)
85                         return;
86
87                 hits = hits_obj.value
88
89                 debug("Hits per page set to " + hits );
90
91                 obj.hitsPerPage = parseInt(hits);       
92
93
94                 var location = globalSelectedLocation;
95                 if(location == null) location = globalLocation.id();
96
97                 url_redirect(obj.URLRefresh());
98                 obj = null;
99         }
100
101
102         for( var i in this.hitsPerPageSelector.options ) {
103
104                 var hits_obj = obj.hitsPerPageSelector.options[i];
105                 if(hits_obj == null) continue;
106                 var hits = hits_obj.value;
107
108                 if( this.hitsPerPage == parseInt(hits) ) 
109                         this.hitsPerPageSelector.options[i].selected = true;
110         }
111
112 }
113
114
115 AbstractRecordResultPage.prototype.resetSearch = function() {
116         this.recordIDs                          = new Array();
117         this.ranks                                      = new Array();
118         this.hitCount                           = 0;                                    /* hits for the current search */
119         this.searchOffset                       = 0;                                    /* the offset for the search display */
120         this.page                                       = 0;
121
122 }
123
124 AbstractRecordResultPage.prototype.gatherIDs = function(result) {
125         if(result == null) return;
126
127         this.hitCount = parseInt(result.count);
128
129         if(result.ids.length < 1) {
130                 this.finalizePage();
131                 return false;
132         }
133         
134
135         /* the 'ids' field consist of [record, rank] */
136         /* gather all of the ID's */
137         if( result.ids  && typeof result.ids == 'object' 
138                         && result.ids[0] != null
139                         && result.ids[0].constructor == Array ) {
140
141                 for( var i in result.ids ) {
142                         if(result.ids[i]==null || result.ids[i][0] == null) break;
143                         var offset = parseInt(i) + parseInt(this.searchOffset);
144                         this.recordIDs[offset] = result.ids[i][0];
145                         var rank = parseFloat(result.ids[i][1]);
146                         if(rank == 0)
147                                 rank = 0.00000001; /* protect divide by 0 */
148                         this.ranks[offset] =  rank;
149                         /*
150                         debug("adding ranks[" + offset + "] = " + result.ids[i][1] + 
151                                         "  \nrecordIDs["+offset+"], result.ids["+i+"][0]");
152                                         */
153                 }
154
155         } else {
156
157                 for( var i in result.ids ) {
158                         if(result.ids[i]==null) break;
159                         var offset = parseInt(i) + parseInt(this.searchOffset);
160                         this.recordIDs[offset] = result.ids[i];
161                         debug("adding recordIDs["+offset+"], result.ids["+i+"]");
162                 }
163         }
164
165         return true;
166 }
167
168
169
170 AbstractRecordResultPage.prototype.complete = function() {
171
172 }
173
174
175 AbstractRecordResultPage.prototype.displayRecord = 
176         function( record, search_id, page_id ) {
177
178         if(record == null) return;
179         debug("Displaying record " + record.doc_id());
180
181         if(!instanceOf(record, Fieldmapper)) {
182                 debug(" * Received bogus record " + js2JSON(record));
183                 return;
184         }
185
186         if(page_id == 0)
187                 this.buildNextLinks();
188
189         this.received += 1;
190
191         this.progressBar.manualNext();
192
193         var id = parseInt(page_id);
194         var title_row = table_row_find_or_create(this.recordBox, id * 3 + 1 );
195         var author_row = table_row_find_or_create(this.recordBox, id * 3 + 2 );
196         var misc_row = table_row_find_or_create(this.recordBox, id * 3 + 3 );
197
198         add_css_class(misc_row, "record_misc_row");
199         add_css_class(title_row, "record_title_row");
200
201
202         var c = misc_row.insertCell(0);
203
204         /* shove in a div for each of the types of resource */
205         for( var i = 0; i!= 9; i++) {
206                 var div = createAppElement("div");
207                 div.innerHTML = "&nbsp;";
208                 add_css_class(div, "record_resource_div");
209                 c.appendChild(div);
210         }
211         //var options_cell = misc_row.insertCell(1);
212
213         c.className = "record_misc_cell";
214         var resources = record.types_of_resource();
215
216         for( var i in resources ) {
217
218                 var a;
219                 if(instanceOf(this,MRResultPage)) {
220                         var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath;
221                         var res = modsFormatToMARC(resources[i]);
222                         var a = elem("a", 
223                                 {href: prefix + "?target=record_result&mrid=" +
224                                 record.doc_id() + "&format=" + res +
225                                 "&page=0&location=" + this.searchLocation +
226                                 "&depth=" + this.searchDepth} );
227                 }
228                 this.buildResourcePic( c, resources[i], a);
229         }
230
231         author_row.id = "record_result_author_row_" + id;
232         title_row.id = "record_result_title_row_" + id;
233
234         /* build the appropriate context node for this result */
235         var menu_name = "record_result_row_" + page_id;
236         var menu = globalMenuManager.buildMenu(menu_name);
237
238         this.addMenuItems( menu, record );
239
240         globalMenuManager.setContext(title_row, menu);
241         globalMenuManager.setContext(author_row, menu);
242         globalMenuManager.setContext(misc_row, menu);
243
244         getDocument().body.appendChild(menu.getNode());
245
246         //var optionsLink = this.buildExtendedLinks(record, page_id);
247         //if(optionsLink)
248         //      options_cell.appendChild(optionsLink);
249         /* ------------------------------------ */
250
251
252         var pic_cell = title_row.insertCell(0);
253         this.buildRecordImage( pic_cell, record, page_id, record.title());
254
255         var title_cell = title_row.insertCell(title_row.cells.length);
256         title_cell.id = "record_result_title_box_" + id;
257         add_css_class( title_cell, "record_result_title_box");
258
259         var author_cell = author_row.insertCell(author_row.cells.length);
260         author_cell.id = "record_result_author_box_" + id;
261         add_css_class(author_cell, "record_result_author_box");
262
263
264         /* limit the length of the title and author lines */
265         var tlength = 80;
266
267         var title = "";
268         if( record.title() ) {
269                 if(record.title().length > tlength) {
270                         record.title(record.title().substr(0,tlength));
271                         record.title(record.title() + "...");
272                 }
273                 title = normalize(record.title());
274         }
275
276
277         var author = "";
278         if( record.author() ) {
279                 if(record.author().length > tlength) {
280                         record.author( record.author().substr(0,tlength));
281                         record.author(record.author() + "...");
282                 }
283                 author = normalize(record.author());
284         }
285
286         title_cell.appendChild(this.mkLink(record.doc_id(), "title", title, record.title() ));
287         author_cell.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
288         author_cell.appendChild(this.mkLink(record.doc_id(), "author", author ));
289
290         var marcd = null;
291         if(instanceOf(this, RecordResultPage)) {
292                 var span = createAppElement("span");
293                 span.style.marginLeft = "10px";
294
295                 if(record.pubdate() || record.edition())
296                         span.appendChild(createAppTextNode(" -- "));
297
298                 if(record.pubdate())
299                         span.appendChild(createAppTextNode(" " + record.pubdate()));
300
301                 if(record.edition())
302                         span.appendChild(createAppTextNode(" " + record.edition()));
303
304                 author_cell.appendChild(span);
305
306                 var marcb = elem( "a",
307                         {       href:"javascript:void(0)", 
308                                 style: "text-decoration:underline;"
309                         }, null, "View MARC" );
310
311                 debug("Setting up view marc callback with record " + record.doc_id());
312                 var func = buildViewMARCWindow(record);
313                 marcb.onclick = func;
314
315                 marcd = elem( "div", { style: "float:right;font-size:x-small;" } );
316                 marcd.appendChild(marcb);
317
318         }
319
320         var holddiv = null;
321         if(instanceOf(this, RecordResultPage)) {
322
323                 var holds = elem( "a", 
324                 { 
325                         href:"javascript:void(0)", 
326                         style: "text-decoration:underline" 
327                 }, {}, "Place Hold" );
328         
329         
330                 var type = "M";
331                 if(instanceOf(this, RecordResultPage))
332                         type = "T";
333         
334                 var win;
335                 var user = UserSession.instance();
336                 if(user.verifySession()) {
337                         win = new HoldsWindow(record.doc_id(), 
338                                 type, user.userObject, user.userObject, user.session_id);
339                 } else {
340                         win = new HoldsWindow(record.doc_id(), 
341                                 type, null, null, null);
342                 }
343         
344                 
345                 holds.onclick = function() { win.toggle(holds); }
346                 holddiv = elem("div");
347         
348                 //if(instanceOf(this,RecordResultPage))
349                 holddiv.setAttribute("style", "float:right");
350         
351                 holddiv.appendChild(holds);
352                 //var space = elem("span", {style:"padding:5px"},null, " ");
353                 //c.appendChild(space)
354                 //c.appendChild(mktext(" "))
355                 //c.appendChild(holddiv)
356         }
357         
358         var tab = elem("table",{style:"float:right"});
359         var tr = tab.insertRow(0);
360         var tc = tr.insertCell(0);
361         var tc2 = tr.insertCell(1);
362         var tc3 = tr.insertCell(2);
363         tc.setAttribute("nowrap", "nowrap");
364         tc3.setAttribute("nowrap", "nowrap");
365
366         if(holddiv) tc.appendChild(holddiv);
367         tc2.appendChild(mktext(" "));
368         if(marcd) tc3.appendChild(marcd);
369
370         c.appendChild(tab);
371
372
373
374         var classname = "result_even";
375         if((page_id % 2) != 0) 
376                 classname = "result_odd";
377
378         add_css_class(title_row, classname);
379         add_css_class(author_row, classname);
380         add_css_class(misc_row, classname);
381
382         /* now grab the record authors and subjects */
383         if( author ) {
384                 this.authorBox.addItem( this.mkAuthorLink(author) , author);
385         }
386
387         /* gather the subjects.  subjects are either a string or an array of
388                 [subject, broader topic].  currently, they're all just treated like
389                 subjects */
390         var arr = record.subject();
391         var x = 0;
392         for( var sub in arr ) {
393                 if(x++ > 5) break; /* too many subjects makes things real sluggish */
394
395                 var ss = arr[sub];
396
397                 /* only taking first part of subject (non-topic, etc.) */
398                 if( ss.constructor == Array)
399                         ss = ss[0];
400
401                 if( ss.constructor != Array )
402                         ss = [ss];
403
404                 for( var i in ss ) {
405                         var s = normalize(ss[i]);
406                         this.subjectBox.addItem( this.mkSubjectLink(s), s );
407                 }
408         }
409
410         var series = record.series();
411         for( var s in  series ) {
412                 debug("Found series entry: " + series[s] );
413                 var ss = normalize(series[s]);
414                 this.seriesBox.addItem( this.mkSeriesLink(ss), ss );
415         }
416
417         /* requestBatch will only have one request in it when the current
418                 record is the last record requested */
419         if( this.requestBatch.pending() < 2  )
420                 this.finalizePage();
421
422         debug("Finished displaying record " + record.doc_id());
423 }
424
425 AbstractRecordResultPage.prototype.mkAuthorLink = function(auth) {
426         var href = createAppElement("a");
427         add_css_class(href,"record_result_sidebar_link");
428
429         href.setAttribute("href",
430                 "?target=mr_result&mr_search_type=author&page=0&mr_search_query=" +
431                 encodeURIComponent(auth) +
432                 "&mr_search_depth=" + this.searchDepth +
433                 "&mr_search_location=" + this.searchLocation +
434                 "&location=" +  this.searchLocation +
435                 "&format=" + this.format +
436                 "&depth=" +  this.searchDepth);
437
438         href.appendChild(createAppTextNode(auth));
439         href.title = "Author search for " + auth;
440         return href;
441 }
442
443 AbstractRecordResultPage.prototype.mkSeriesLink = function(series) {
444         var href = createAppElement("a");
445         add_css_class(href,"record_result_sidebar_link");
446
447         debug("Series: " + series + " : " + encodeURIComponent(series));
448
449         href.setAttribute("href",
450                 "?target=mr_result&mr_search_type=series&page=0&mr_search_query=" +
451                 encodeURIComponent(series) +
452                 "&mr_search_depth=" + this.searchDepth +
453                 "&mr_search_location=" + this.searchLocation +
454                 "&location=" +  this.searchLocation +
455                 "&format=" + this.format +
456                 "&depth=" +  this.searchDepth);
457
458         href.appendChild(createAppTextNode(series));
459         href.title = "Series search for " + series;
460         return href;
461 }
462
463 AbstractRecordResultPage.prototype.mkSubjectLink = function(sub) {
464         var href = createAppElement("a");
465         add_css_class(href,"record_result_sidebar_link");
466         href.setAttribute("href",
467                 "?target=mr_result&mr_search_type=subject&page=0&mr_search_query=" +
468                 encodeURIComponent(sub) + 
469                 "&mr_search_depth=" + this.searchDepth +
470                 "&mr_search_location=" + this.searchLocation +
471                 "&location=" +  this.searchLocation +
472                 "&format=" + this.format +
473                 "&depth=" +  this.searchDepth);
474
475         href.appendChild(createAppTextNode(sub));
476         href.title = "Subject search for " + sub;
477         return href;
478 }
479
480 AbstractRecordResultPage.prototype.finalizePage = function() {
481
482         if( this.finalized )
483                 return;
484         this.finalized = true;
485
486
487         this.subjectBox.finalize();
488         this.authorBox.finalize();
489         this.seriesBox.finalize();
490
491         this.sidebarBox.appendChild(this.subjectBox.getNode());
492         this.sidebarBox.appendChild(createAppElement("br"));
493
494         this.sidebarBox.appendChild(this.authorBox.getNode());
495         this.sidebarBox.appendChild(createAppElement("br"));
496
497         this.sidebarBox.appendChild(this.seriesBox.getNode());
498         this.sidebarBox.appendChild(createAppElement("br"));
499
500 //      showMe(this.buttonsBox);
501
502         var ses = UserSession.instance().getSessionId();
503         var box = this.sidebarBox;
504
505         if(ses) {
506                 Survey.retrieveOpacRandom(ses, 
507                         function(sur) { 
508                                 sur.setSubmitCallback(
509                                         function() { alert("Thanks!"); return true; });
510                                 box.appendChild( sur.getNode() ); 
511                                 sur.setHidden(false);
512                         }
513                 );
514         } else {
515                 Survey.retrieveOpacRandomGlobal( 
516                         function(sur) { 
517                                 sur.setSubmitCallback(
518                                         function() { alert("Thanks!"); return true; });
519                                 box.appendChild( sur.getNode() ); 
520                                 sur.setHidden(false);
521                         }
522                 );
523         }
524
525
526         if(this.hitCount < 1) {
527                 if(this.progressBar) this.progressBar.stop();
528         }
529
530         /* in case we're hidden */
531         showMe(this.bigOlBox);
532         showMe(getById("hit_count_cell_2"));
533
534 }
535
536
537 AbstractRecordResultPage.prototype.displayCopyCounts = 
538         function(copy_counts, search_id, page_id) {
539                 
540         this.progressBar.manualNext();
541         var titlerow  = getById("record_result_title_row_" + page_id );
542         var authorrow  = getById("record_result_author_row_" + page_id );
543
544         var tcell = getById("record_result_title_box_" + page_id );
545
546         if(!this.theadDrawn) {
547                 var trow = getById("record_result_thead_row");
548                 for( var i in copy_counts) {
549                         var cell = trow.insertCell(trow.cells.length);
550                         add_css_class(cell,"record_result_thead_header");
551                         cell.innerHTML = 
552                                 findOrgType(findOrgUnit(
553                                         copy_counts[i].org_unit).ou_type()).opac_label();
554                 }
555                 this.theadDrawn = true;
556         }
557
558         for( var i in copy_counts) {
559                 var cell = createAppElement("td");
560                 add_css_class(cell, "copy_count_cell");
561                 cell.innerHTML = copy_counts[i].available + " / " + copy_counts[i].count;
562                 cell.setAttribute("rowspan","3");
563                 cell.rowSpan = 3;
564                 cell.title = " Availabie Copies / Total Copies";
565                 titlerow.appendChild(cell);
566         }
567
568         if(page_id  == (parseInt(this.hitsPerPage) - 1) ) {
569                 if(this.progressBar) this.progressBar.stop();
570                 if(this.hitCount < 1)
571                         this.noHits();
572         }
573
574         if( (page_id  == ((parseInt(this.hitCount) - 1 ) - parseInt(this.searchOffset))) ||
575                         (page_id == (parseInt(this.hitsPerPage) - 1) )) 
576                 if(this.progressBar) this.progressBar.stop();
577 }
578
579
580
581 AbstractRecordResultPage.prototype.noHits = function() {
582         var hcell = getById("hit_count_cell");
583         //hcell.appendChild(createAppElement("br"));
584         hcell.appendChild(createAppTextNode("0 hits were returned for you search"));
585 }
586
587
588 AbstractRecordResultPage.prototype.buildNextLinks = function() {
589
590         if(this.builtLinks)
591                 return;
592         this.builtLinks = true;
593
594         var obj = this;
595         var next;
596         var prev;
597
598         debug("Building links");
599         if( this.searchOffset < (parseInt(this.hitCount) - this.hitsPerPage)) {
600                 next = createAppElement("a");
601                 add_css_class(next,"record_next_button");
602                 add_css_class(next,"record_next_button_active");
603                 next.href = "javascript:globalPage.next();";
604         } else {
605                 next = createAppElement("span");
606                 add_css_class(next,"record_next_button_inactive");
607         }
608
609         if(this.searchOffset > 0) {
610                 prev = createAppElement("a");
611                 add_css_class(prev,"record_next_button");
612                 add_css_class(prev,"record_next_button_active");
613                 prev.href = "javascript:globalPage.prev();";
614         } else {
615                 prev = createAppElement("span");
616                 add_css_class(prev,"record_next_button_inactive");
617         }
618
619         next.appendChild(createAppTextNode("Next"));
620         prev.appendChild(createAppTextNode("Previous"));
621
622
623         var i = this.searchOffset;
624         var max = parseInt(i) + this.hitsPerPage;
625         if( max > this.hitCount )
626                 max = this.hitCount;
627
628         var hcell = getById("hit_count_cell");
629         var hcell2 = getById("hit_count_cell_2");
630         hideMe(hcell2);
631
632         if(hcell) {
633
634                 var ident = "Titles";
635                 if(instanceOf(this, MRResultPage))
636                         ident = "Title Groups";
637         
638                 hcell.appendChild(
639                         createAppTextNode( "Displaying " + ident + " " +
640                         ( parseInt(i) + 1 ) + " to " + max + " of " + this.hitCount));
641         
642                 hcell.appendChild(createAppTextNode(" "));
643                 hcell.appendChild(createAppTextNode(" "));
644                 hcell.appendChild(createAppTextNode(" "));
645         
646                 hcell.appendChild(prev);
647                 var span = createAppElement("span");
648                 span.appendChild(createAppTextNode(" ... "));
649                 hcell.appendChild(span);
650                 hcell.appendChild(next);
651         
652                 hcell2.innerHTML = hcell.innerHTML;
653         
654         }
655         
656 }
657
658
659 AbstractRecordResultPage.prototype.buildResourcePic = function(c, resource, parent) {
660         return buildResourcePic(c, resource, parent);
661 }
662
663 function buildResourcePic(c, resource, parent) {
664
665         var pic = createAppElement("img");
666
667         if(resource.indexOf("sound recording") != -1) 
668                 resource = "sound recording";
669         pic.setAttribute("src", "/images/" + resource + ".jpg");
670         pic.setAttribute("border", "0");
671         pic.className = "record_resource_pic";
672         pic.setAttribute("width", "20");
673         pic.setAttribute("height", "20");
674         pic.setAttribute("title", resource);
675
676
677         var index;
678
679         switch(resource) {
680
681                 case "text":
682                         index = 0;
683                         break;
684
685                 case "moving image":
686                         index = 1;
687                         break;
688
689                 case "sound recording":
690                         index = 2;
691                         break;
692
693                 case "software, multimedia":
694                         index = 3;
695                         break;
696
697                 case "still images":
698                         index = 4;
699                         break;
700
701                 case "cartographic":
702                         index = 5;
703                         break;
704
705                 case "mixed material":
706                         index = 6;
707                         break;
708
709                 case "notated music":
710                         index = 7;
711                         break;
712
713                 case "three dimensional object":
714                         index = 8;
715                         break;
716
717                 default:
718                         index = 0;
719         }
720
721         c.childNodes[index].innerHTML = "";
722
723         if(parent) {
724                 parent.appendChild(pic);
725                 c.childNodes[index].appendChild(parent);
726         } else {
727                 c.childNodes[index].appendChild(pic);
728         }
729 }
730
731 AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id, title) {
732
733         debug("Building record image for " + page_id);
734
735         /*
736         var isbn = record.isbn();
737         if(isbn) {
738                 isbn = isbn.replace(/^\s+/,"");
739                 var idx = isbn.indexOf(" ");
740                 if(idx > -1) {
741                         isbn = isbn.substring(0, idx);
742                 }
743
744         } else isbn = "";
745         */
746
747         pic_cell.setAttribute("rowspan","3");
748         pic_cell.rowSpan = 3;
749
750         pic_cell.noWrap = 'nowrap';
751         pic_cell.setAttribute("nowrap", "nowrap");
752
753         pic_cell.width = "60";
754         pic_cell.className = "record_image_cell";
755
756
757         var rankBox;
758         if( this.ranks.length > 0 ) {
759                 var x = (parseInt(this.page) * parseInt(this.hitsPerPage)) + parseInt(page_id);
760                 var per = parseInt(this.ranks[x] / this.ranks[0] * 100.0);
761
762                 debug("Per is " + per);
763                 per = 100 - parseInt(per);
764
765                 rankBox = createAppElement("div");
766                 add_css_class(rankBox, "relevance_box");
767
768                 var d = createAppElement("div");
769                 d.setAttribute("height", per + "%");
770                 d.style.height = per + "%";
771
772                 add_css_class(d, "relevance");
773                 rankBox.appendChild(d);
774
775                 rankBox.setAttribute("title", parseInt((100 - parseInt(per))) + "% Relevant");
776         }
777
778         /* use amazon for now */
779         //var img_src = "http://images.amazon.com/images/P/" +isbn + ".01.MZZZZZZZ.jpg";
780         //var img_src = "http://www.thecontentserver.com/bin/cntsvr.dll?GetImage&SysID=Content&CustID=Cafe&Return=1&Type=S&Key=" + isbn ;
781
782         var img_src = buildISBNSrc(cleanISBN(record.isbn()));
783         var big_div = createAppElement("div");
784         add_css_class(big_div, "record_image_big hide_me");
785
786         var big_pic = createAppElement("img");
787         var pic = createAppElement("img");
788         
789         big_pic.setAttribute("src", img_src);
790         big_pic.setAttribute("border", "0");
791         pic.setAttribute("src", img_src);
792         add_css_class(big_pic, "record_image");
793         add_css_class(pic, "record_image");
794
795         pic.setAttribute("width", "45");
796         pic.setAttribute("height", "50");
797         pic.style.width = "45";
798         pic.style.height = "50";
799
800         if(IE) 
801                 big_div.style.left = 0;
802
803
804         var anch = this.mkLink(record.doc_id(), "img", title );
805         anch.appendChild(big_pic);
806         big_div.appendChild(anch);
807         pic_cell.appendChild(big_div);
808
809         pic_cell.appendChild(pic);
810
811         if(rankBox)
812                 pic_cell.appendChild(rankBox);
813
814         pic.onmouseover = function() {showMe(big_div);}
815         big_div.onmouseout = function(){hideMe(big_div);}
816
817 }
818