]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
more webby goodness
[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         /*
291         var marcd = null;
292         if(instanceOf(this, RecordResultPage)) {
293                 var span = createAppElement("span");
294                 span.style.marginLeft = "10px";
295
296                 if(record.pubdate() || record.edition())
297                         span.appendChild(createAppTextNode(" -- "));
298
299                 if(record.pubdate())
300                         span.appendChild(createAppTextNode(" " + record.pubdate()));
301
302                 if(record.edition())
303                         span.appendChild(createAppTextNode(" " + record.edition()));
304
305                 author_cell.appendChild(span);
306
307                 var marcb = elem( "a",
308                         {       href:"javascript:void(0)", 
309                                 style: "text-decoration:underline;"
310                         }, null, "View MARC" );
311
312                 debug("Setting up view marc callback with record " + record.doc_id());
313                 var func = buildViewMARCWindow(record);
314                 marcb.onclick = func;
315
316                 marcd = elem( "div", { style: "float:right;font-size:x-small;" } );
317                 marcd.appendChild(marcb);
318
319         }
320         */
321
322         var holddiv = null;
323         if(instanceOf(this, RecordResultPage)) {
324
325                 var holds = elem( "a", 
326                 { 
327                         href:"javascript:void(0)", 
328                         style: "text-decoration:underline" 
329                 }, {}, "Place Hold" );
330         
331         
332                 var type = "M";
333                 if(instanceOf(this, RecordResultPage))
334                         type = "T";
335         
336                 var win;
337                 var user = UserSession.instance();
338                 if(user.verifySession()) {
339                         win = new HoldsWindow(record.doc_id(), 
340                                 type, user.userObject, user.userObject, user.session_id);
341                 } else {
342                         win = new HoldsWindow(record.doc_id(), 
343                                 type, null, null, null);
344                 }
345         
346                 
347                 holds.onclick = function() { win.toggle(holds); }
348                 holddiv = elem("div");
349         
350                 holddiv.setAttribute("style", "float:right");
351                 holddiv.appendChild(holds);
352         }
353         
354         var tab = elem("table",{style:"float:right"});
355         var tr = tab.insertRow(0);
356         var tc = tr.insertCell(0);
357         var tc2 = tr.insertCell(1);
358         var tc3 = tr.insertCell(2);
359         tc.setAttribute("nowrap", "nowrap");
360         tc3.setAttribute("nowrap", "nowrap");
361
362         if(holddiv) tc.appendChild(holddiv);
363         tc2.appendChild(mktext(" "));
364         //if(marcd) tc3.appendChild(marcd);
365
366         c.appendChild(tab);
367
368
369
370         var classname = "result_even";
371         if((page_id % 2) != 0) 
372                 classname = "result_odd";
373
374         add_css_class(title_row, classname);
375         add_css_class(author_row, classname);
376         add_css_class(misc_row, classname);
377
378         /* now grab the record authors and subjects */
379         if( author ) {
380                 this.authorBox.addItem( this.mkAuthorLink(author) , author);
381         }
382
383         /* gather the subjects.  subjects are either a string or an array of
384                 [subject, broader topic].  currently, they're all just treated like
385                 subjects */
386         var arr = record.subject();
387         var x = 0;
388         for( var sub in arr ) {
389                 if(x++ > 5) break; /* too many subjects makes things real sluggish */
390
391                 var ss = arr[sub];
392
393                 /* only taking first part of subject (non-topic, etc.) */
394                 if( ss.constructor == Array)
395                         ss = ss[0];
396
397                 if( ss.constructor != Array )
398                         ss = [ss];
399
400                 for( var i in ss ) {
401                         var s = normalize(ss[i]);
402                         this.subjectBox.addItem( this.mkSubjectLink(s), s );
403                 }
404         }
405
406         var series = record.series();
407         for( var s in  series ) {
408                 debug("Found series entry: " + series[s] );
409                 var ss = normalize(series[s]);
410                 this.seriesBox.addItem( this.mkSeriesLink(ss), ss );
411         }
412
413         /* requestBatch will only have one request in it when the current
414                 record is the last record requested */
415         if( this.requestBatch.pending() < 2  )
416                 this.finalizePage();
417
418         debug("Finished displaying record " + record.doc_id());
419 }
420
421 AbstractRecordResultPage.prototype.mkAuthorLink = function(auth) {
422         var href = createAppElement("a");
423         add_css_class(href,"record_result_sidebar_link");
424
425         href.setAttribute("href",
426                 "?target=mr_result&mr_search_type=author&page=0&mr_search_query=" +
427                 encodeURIComponent(auth) +
428                 "&mr_search_depth=" + this.searchDepth +
429                 "&mr_search_location=" + this.searchLocation +
430                 "&location=" +  this.searchLocation +
431                 "&format=" + this.format +
432                 "&depth=" +  this.searchDepth);
433
434         href.appendChild(createAppTextNode(auth));
435         href.title = "Author search for " + auth;
436         return href;
437 }
438
439 AbstractRecordResultPage.prototype.mkSeriesLink = function(series) {
440         var href = createAppElement("a");
441         add_css_class(href,"record_result_sidebar_link");
442
443         debug("Series: " + series + " : " + encodeURIComponent(series));
444
445         href.setAttribute("href",
446                 "?target=mr_result&mr_search_type=series&page=0&mr_search_query=" +
447                 encodeURIComponent(series) +
448                 "&mr_search_depth=" + this.searchDepth +
449                 "&mr_search_location=" + this.searchLocation +
450                 "&location=" +  this.searchLocation +
451                 "&format=" + this.format +
452                 "&depth=" +  this.searchDepth);
453
454         href.appendChild(createAppTextNode(series));
455         href.title = "Series search for " + series;
456         return href;
457 }
458
459 AbstractRecordResultPage.prototype.mkSubjectLink = function(sub) {
460         var href = createAppElement("a");
461         add_css_class(href,"record_result_sidebar_link");
462         href.setAttribute("href",
463                 "?target=mr_result&mr_search_type=subject&page=0&mr_search_query=" +
464                 encodeURIComponent(sub) + 
465                 "&mr_search_depth=" + this.searchDepth +
466                 "&mr_search_location=" + this.searchLocation +
467                 "&location=" +  this.searchLocation +
468                 "&format=" + this.format +
469                 "&depth=" +  this.searchDepth);
470
471         href.appendChild(createAppTextNode(sub));
472         href.title = "Subject search for " + sub;
473         return href;
474 }
475
476 AbstractRecordResultPage.prototype.finalizePage = function() {
477
478         if( this.finalized )
479                 return;
480         this.finalized = true;
481
482
483         this.subjectBox.finalize();
484         this.authorBox.finalize();
485         this.seriesBox.finalize();
486
487         this.sidebarBox.appendChild(this.subjectBox.getNode());
488         this.sidebarBox.appendChild(createAppElement("br"));
489
490         this.sidebarBox.appendChild(this.authorBox.getNode());
491         this.sidebarBox.appendChild(createAppElement("br"));
492
493         this.sidebarBox.appendChild(this.seriesBox.getNode());
494         this.sidebarBox.appendChild(createAppElement("br"));
495
496 //      showMe(this.buttonsBox);
497
498         var ses = UserSession.instance().getSessionId();
499         var box = this.sidebarBox;
500
501         if(ses) {
502                 Survey.retrieveOpacRandom(ses, 
503                         function(sur) { 
504                                 sur.setSubmitCallback(
505                                         function() { alert("Thanks!"); return true; });
506                                 box.appendChild( sur.getNode() ); 
507                                 sur.setHidden(false);
508                         }
509                 );
510         } else {
511                 Survey.retrieveOpacRandomGlobal( 
512                         function(sur) { 
513                                 sur.setSubmitCallback(
514                                         function() { alert("Thanks!"); return true; });
515                                 box.appendChild( sur.getNode() ); 
516                                 sur.setHidden(false);
517                         }
518                 );
519         }
520
521
522         if(this.hitCount < 1) {
523                 if(this.progressBar) this.progressBar.stop();
524         }
525
526         /* in case we're hidden */
527         showMe(this.bigOlBox);
528         showMe(getById("hit_count_cell_2"));
529
530 }
531
532
533 AbstractRecordResultPage.prototype.displayCopyCounts = 
534         function(copy_counts, search_id, page_id) {
535                 
536         this.progressBar.manualNext();
537         var titlerow  = getById("record_result_title_row_" + page_id );
538         var authorrow  = getById("record_result_author_row_" + page_id );
539
540         var tcell = getById("record_result_title_box_" + page_id );
541
542         if(!this.theadDrawn) {
543                 var trow = getById("record_result_thead_row");
544                 for( var i in copy_counts) {
545                         var cell = trow.insertCell(trow.cells.length);
546                         add_css_class(cell,"record_result_thead_header");
547                         cell.innerHTML = 
548                                 findOrgType(findOrgUnit(
549                                         copy_counts[i].org_unit).ou_type()).opac_label();
550                 }
551                 this.theadDrawn = true;
552         }
553
554         for( var i in copy_counts) {
555                 var cell = createAppElement("td");
556                 add_css_class(cell, "copy_count_cell");
557                 cell.innerHTML = copy_counts[i].available + " / " + copy_counts[i].count;
558                 cell.setAttribute("rowspan","3");
559                 cell.rowSpan = 3;
560                 cell.title = " Availabie Copies / Total Copies";
561                 titlerow.appendChild(cell);
562         }
563
564         if(page_id  == (parseInt(this.hitsPerPage) - 1) ) {
565                 if(this.progressBar) this.progressBar.stop();
566                 if(this.hitCount < 1)
567                         this.noHits();
568         }
569
570         if( (page_id  == ((parseInt(this.hitCount) - 1 ) - parseInt(this.searchOffset))) ||
571                         (page_id == (parseInt(this.hitsPerPage) - 1) )) 
572                 if(this.progressBar) this.progressBar.stop();
573 }
574
575
576
577 AbstractRecordResultPage.prototype.noHits = function() {
578         var hcell = getById("hit_count_cell");
579         //hcell.appendChild(createAppElement("br"));
580         hcell.appendChild(createAppTextNode("0 hits were returned for you search"));
581 }
582
583
584 AbstractRecordResultPage.prototype.buildNextLinks = function() {
585
586         if(this.builtLinks)
587                 return;
588         this.builtLinks = true;
589
590         var obj = this;
591         var next;
592         var prev;
593
594         debug("Building links");
595         if( this.searchOffset < (parseInt(this.hitCount) - this.hitsPerPage)) {
596                 next = createAppElement("a");
597                 add_css_class(next,"record_next_button");
598                 add_css_class(next,"record_next_button_active");
599                 next.href = "javascript:globalPage.next();";
600         } else {
601                 next = createAppElement("span");
602                 add_css_class(next,"record_next_button_inactive");
603         }
604
605         if(this.searchOffset > 0) {
606                 prev = createAppElement("a");
607                 add_css_class(prev,"record_next_button");
608                 add_css_class(prev,"record_next_button_active");
609                 prev.href = "javascript:globalPage.prev();";
610         } else {
611                 prev = createAppElement("span");
612                 add_css_class(prev,"record_next_button_inactive");
613         }
614
615         next.appendChild(createAppTextNode("Next"));
616         prev.appendChild(createAppTextNode("Previous"));
617
618
619         var i = this.searchOffset;
620         var max = parseInt(i) + this.hitsPerPage;
621         if( max > this.hitCount )
622                 max = this.hitCount;
623
624         var hcell = getById("hit_count_cell");
625         var hcell2 = getById("hit_count_cell_2");
626         hideMe(hcell2);
627
628         if(hcell) {
629
630                 var ident = "Titles";
631                 if(instanceOf(this, MRResultPage))
632                         ident = "Title Groups";
633         
634                 hcell.appendChild(
635                         createAppTextNode( "Displaying " + ident + " " +
636                         ( parseInt(i) + 1 ) + " to " + max + " of " + this.hitCount));
637         
638                 hcell.appendChild(createAppTextNode(" "));
639                 hcell.appendChild(createAppTextNode(" "));
640                 hcell.appendChild(createAppTextNode(" "));
641         
642                 hcell.appendChild(prev);
643                 var span = createAppElement("span");
644                 span.appendChild(createAppTextNode(" ... "));
645                 hcell.appendChild(span);
646                 hcell.appendChild(next);
647         
648                 hcell2.innerHTML = hcell.innerHTML;
649         
650         }
651         
652 }
653
654
655 AbstractRecordResultPage.prototype.buildResourcePic = function(c, resource, parent) {
656         return buildResourcePic(c, resource, parent);
657 }
658
659 function buildResourcePic(c, resource, parent) {
660
661         var pic = createAppElement("img");
662
663         if(resource.indexOf("sound recording") != -1) 
664                 resource = "sound recording";
665         pic.setAttribute("src", "/images/" + resource + ".jpg");
666         pic.setAttribute("border", "0");
667         pic.className = "record_resource_pic";
668         pic.setAttribute("width", "20");
669         pic.setAttribute("height", "20");
670         pic.setAttribute("title", resource);
671
672
673         var index;
674
675         switch(resource) {
676
677                 case "text":
678                         index = 0;
679                         break;
680
681                 case "moving image":
682                         index = 1;
683                         break;
684
685                 case "sound recording":
686                         index = 2;
687                         break;
688
689                 case "software, multimedia":
690                         index = 3;
691                         break;
692
693                 case "still images":
694                         index = 4;
695                         break;
696
697                 case "cartographic":
698                         index = 5;
699                         break;
700
701                 case "mixed material":
702                         index = 6;
703                         break;
704
705                 case "notated music":
706                         index = 7;
707                         break;
708
709                 case "three dimensional object":
710                         index = 8;
711                         break;
712
713                 default:
714                         index = 0;
715         }
716
717         c.childNodes[index].innerHTML = "";
718
719         if(parent) {
720                 parent.appendChild(pic);
721                 c.childNodes[index].appendChild(parent);
722         } else {
723                 c.childNodes[index].appendChild(pic);
724         }
725 }
726
727 AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id, title) {
728
729         debug("Building record image for " + page_id);
730
731         /*
732         var isbn = record.isbn();
733         if(isbn) {
734                 isbn = isbn.replace(/^\s+/,"");
735                 var idx = isbn.indexOf(" ");
736                 if(idx > -1) {
737                         isbn = isbn.substring(0, idx);
738                 }
739
740         } else isbn = "";
741         */
742
743         pic_cell.setAttribute("rowspan","3");
744         pic_cell.rowSpan = 3;
745
746         pic_cell.noWrap = 'nowrap';
747         pic_cell.setAttribute("nowrap", "nowrap");
748
749         pic_cell.width = "60";
750         pic_cell.className = "record_image_cell";
751
752
753         var rankBox;
754         if( this.ranks.length > 0 ) {
755                 var x = (parseInt(this.page) * parseInt(this.hitsPerPage)) + parseInt(page_id);
756                 var per = parseInt(this.ranks[x] / this.ranks[0] * 100.0);
757
758                 debug("Per is " + per);
759                 per = 100 - parseInt(per);
760
761                 rankBox = createAppElement("div");
762                 add_css_class(rankBox, "relevance_box");
763
764                 var d = createAppElement("div");
765                 d.setAttribute("height", per + "%");
766                 d.style.height = per + "%";
767
768                 add_css_class(d, "relevance");
769                 rankBox.appendChild(d);
770
771                 rankBox.setAttribute("title", parseInt((100 - parseInt(per))) + "% Relevant");
772         }
773
774         /* use amazon for now */
775         //var img_src = "http://images.amazon.com/images/P/" +isbn + ".01.MZZZZZZZ.jpg";
776         //var img_src = "http://www.thecontentserver.com/bin/cntsvr.dll?GetImage&SysID=Content&CustID=Cafe&Return=1&Type=S&Key=" + isbn ;
777
778         var img_src = buildISBNSrc(cleanISBN(record.isbn()));
779         var big_div = createAppElement("div");
780         add_css_class(big_div, "record_image_big hide_me");
781
782         var big_pic = createAppElement("img");
783         var pic = createAppElement("img");
784         
785         big_pic.setAttribute("src", img_src);
786         big_pic.setAttribute("border", "0");
787         pic.setAttribute("src", img_src);
788         add_css_class(big_pic, "record_image");
789         add_css_class(pic, "record_image");
790
791         pic.setAttribute("width", "45");
792         pic.setAttribute("height", "50");
793         pic.style.width = "45";
794         pic.style.height = "50";
795
796         if(IE) 
797                 big_div.style.left = 0;
798
799
800         var anch = this.mkLink(record.doc_id(), "img", title );
801         anch.appendChild(big_pic);
802         big_div.appendChild(anch);
803         pic_cell.appendChild(big_div);
804
805         pic_cell.appendChild(pic);
806
807         if(rankBox)
808                 pic_cell.appendChild(rankBox);
809
810         pic.onmouseover = function() {showMe(big_div);}
811         big_div.onmouseout = function(){hideMe(big_div);}
812
813 }
814