47ebe320d5e981b1990b0fb93269c9e0ad97ef1e
[phpfspot.git] / phpfspot.js
1 /***************************************************************************
2  *
3  * phpfspot, presents your F-Spot photo collection in Web browsers.
4  *
5  * Copyright (c) by Andreas Unterkircher
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  ***************************************************************************/
22
23 /**
24  * display image
25  *
26  * this function will be called by client and fetches
27  * the single-photo view via AJAX from the server.
28  * Furthermore it will scrollup the browser to the top
29  * position so the image become visibile immediatley.
30  */
31 function showImage(id, scrollup)
32 {
33    /* is phpfspot skeleton really displayed? */
34    if(!document.getElementById('content'))
35       return;
36
37    var content = document.getElementById('content');
38
39    /* blank the screen */
40    if(scrollup != undefined) {
41       content.innerHTML = "";
42    }
43
44    /* fetch single-photo view from server */
45    HTML_AJAX.replace(content, encodeURI('rpc.php?action=showphoto&id=' + id));
46
47    /* scroll the window up to the top */
48    if(scrollup != undefined) {
49       window.scrollTo(0,0);
50    }
51
52    /* delete some global vars */
53    delete(origHeight); origHeight = undefined;
54    delete(origWidth); origWidth = undefined;
55    delete(photo_details_pos); photo_details_pos = undefined;
56
57 } // showImage()
58
59 /**
60  * scroll browser to the last shown photo
61  *
62  * this function will be called when user returns from single-photo
63  * to the photo index. It will scroll down the window (if possible)
64  * to the position of the last shown photo.
65  */
66 function moveToThumb(thumb_id)
67 {
68    if(thumb_id == undefined)
69       return;
70
71    if(thumbimg = document.getElementById('thumbimg' + thumb_id)) {
72       window.scrollTo(0, findPos(thumbimg,'top')-100);
73    }
74
75 } // moveToThumb()
76
77 /**
78  * return position of object
79  *
80  * this function returns the position of an object.
81  * depending on the parameter 'direction' it will either
82  * return the X or Y position.
83  */
84 function findPos(obj, direction) {
85    var cur = 0;
86    if (obj.offsetParent) {
87       do {
88          if(direction == 'left')
89             cur += obj.offsetLeft;
90          if(direction == 'top')
91             cur += obj.offsetTop;
92       } while (obj = obj.offsetParent);
93    }
94    return [cur];
95
96 } // findPos()
97
98 /**
99  * opens the credits page
100  */
101 function showCredits()
102 {
103    var credits = document.getElementById("content");
104    credits.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=showcredits'));
105
106 } // showCredits()
107
108 /**
109  * tag-selection handling
110  *
111  * this function is getting called by client to either
112  * - add
113  ∗ - delete
114  * - modify tag-match condition
115  *
116  * It will then fetch the result from the server via AJAX
117  * and updates the tag-selection.
118  */
119 function Tags(mode, id)
120 {
121    var objTemp = new Object();
122
123    if(mode == "add") {
124       // add tag to users session
125       objTemp['action'] = 'addtag';
126       objTemp['id'] = id;
127    }
128    else if(mode == "del") {
129       // del tag from users session
130       objTemp['action'] = 'deltag';
131       objTemp['id'] = id;
132    }
133    else if(mode == "condition") {
134       setCheckedValue(id, id.value);
135       objTemp['action'] = 'tagcondition';
136       objTemp['mode'] = id.value;
137    }
138
139    var retr = HTML_AJAX.post('rpc.php', objTemp);
140    if(retr == "ok") {
141       refreshAvailableTags();
142       refreshSelectedTags();
143       refreshPhotoIndex();
144    }
145    else {
146       window.alert("Server message: "+ retr);
147    }
148
149 } // Tags()
150
151 /**
152  * update available-tags tag-cloud
153  *
154  * this function queries an actual version of the tag-cloud
155  * for the available (not-selected) tags from the server via
156  * AJAX.
157  */
158 function refreshAvailableTags()
159 {
160    // update available tags
161    var avail_tags = document.getElementById('available_tags');
162    avail_tags.innerHTML = "Loading...";
163    avail_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_available_tags'));
164
165 } // refreshAvailableTags()
166
167 /**
168  * update selected-tags list
169  *
170  * this function queries an actual version of the tag-list
171  * for the selected tags from the server via AJAX.
172  */
173 function refreshSelectedTags()
174 {
175    // update selected tags
176    var selected_tags = document.getElementById("selected_tags");
177    selected_tags.innerHTML = "Loading...";
178    selected_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_selected_tags'));
179
180 } // refreshSelectedTags()
181
182 /**
183  * show photo index
184  *
185  * this function will fetch the photo-index view from
186  * the server via AJAX. It's also used to browse through
187  * the photo-index pages
188  */
189 function showPhotoIndex(begin_with, last_photo)
190 {
191    var url = "rpc.php?action=show_photo_index";
192    if(begin_with != undefined)
193       url = url + '&begin_with=' + begin_with;
194    if(last_photo != undefined)
195       url = url + '&last_photo=' + last_photo;
196
197    HTML_AJAX.replace(document.getElementById("content"), encodeURI(url));
198
199 } // showPhotoIndex()
200
201 /**
202  * update photo index
203  *
204  * this function will be called, to request a refresh of the
205  * photo index. this, for example, can be caused, when changing
206  * the tag-selection.
207  */
208 function refreshPhotoIndex()
209 {
210    /* only invoke showPhotoIndex(), if photo-index is really shown */
211    if(document.getElementById("index") != undefined || startup == 1) {
212       showPhotoIndex();
213       startup = 0;
214    }
215
216 } // refreshPhotoIndex()
217
218 /**
219  * blur cursor focus
220  *
221  * this function removes the focus-rectangle which may appear
222  * when click on a link. Not always beautiful.
223  */
224 function click(object)
225 {
226    if(object.blur)
227       object.blur();
228
229 } // click()
230
231 /**
232  * change current radio-button setting
233  *
234  * This function will check the radio-button with the given value.
235  * If no radio-button is currently displayed, this function will do
236  * nothing.
237  * If the given value does not exist, the existing radio buttons will
238  * be reseted.
239  */
240 function setCheckedValue(condition, value) {
241
242    var count = condition.length;
243    if(count == undefined) {
244       condition.checked = (condition.value == value.toString());
245       return;
246    }
247    for(var i = 0; i < count; i++) {
248       condition[i].checked = false;
249       if(condition[i].value == value.toString()) {
250          condition[i].checked = true;
251       }
252    }
253
254 } // setCheckedValue()
255
256 /**
257  * Invoke a search
258  *
259  * This function will be invoked by starting
260  * any kind of search (tag-name, photo-name, date, ...).
261  */
262 function startSearch()
263 {
264    from_year = document.getElementById('fromyear').value;
265    from_month = document.getElementById('frommonth').value;
266    from_day = document.getElementById('fromday').value;
267    from = from_year +"-"+ from_month +"-"+ from_day;
268    to_year = document.getElementById('toyear').value;
269    to_month = document.getElementById('tomonth').value;
270    to_day = document.getElementById('today').value;
271    to = to_year +"-"+ to_month +"-"+ to_day;
272
273    var objTemp = new Object();
274    objTemp['action'] = 'search';
275
276    if(document.getElementsByName('searchfor_tag')[0].value != "") {
277       objTemp['for_tag'] = document.getElementsByName('searchfor_tag')[0].value;
278    }
279    if(document.getElementsByName('searchfor_name')[0].value != "") {
280       objTemp['for_name'] = document.getElementsByName('searchfor_name')[0].value;
281    }
282    if(document.getElementsByName('consider_date')[0].checked == true) {
283       objTemp['from'] = from;
284       objTemp['to'] = to;
285    }
286
287    var retr = HTML_AJAX.post('rpc.php', objTemp);
288    if(retr == "ok") {
289       refreshAvailableTags();
290       refreshSelectedTags();
291       showPhotoIndex();
292    }
293    else {
294       window.alert("Server message: "+ retr);
295    }
296
297 } // startSearch()
298
299 /**
300  * enable/disable date search
301  *
302  * this function will either enable or disable the
303  * input fields for the date-search
304  */
305 function datesearch()
306 {
307    var mode = true;
308
309    if(document.getElementsByName('consider_date')[0].checked == true) {
310       mode = false;
311    }
312       
313    document.getElementById('fromyear').disabled = mode;
314    document.getElementById('frommonth').disabled = mode;
315    document.getElementById('fromday').disabled = mode;
316    document.getElementById('toyear').disabled = mode;
317    document.getElementById('tomonth').disabled = mode;
318    document.getElementById('today').disabled = mode;
319  
320 } // datesearch()
321
322 /**
323  * set view mode
324  *
325  * called for photo-index export. will return the
326  * selected mode via AJAX from the server.
327  */
328 function setViewMode(mode)
329 {
330    var exprt = document.getElementById('output');
331    exprt.innerHTML = "Loading...";
332    exprt.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_export&mode=' + mode));
333
334 } // setViewMode()
335
336 /**
337  * reset all search-fields
338  */
339 function clearSearch()
340 {
341    document.getElementsByName('searchfor_tag')[0].value = '';
342    document.getElementsByName('searchfor_name')[0].value = '';
343
344    if(document.getElementsByName('consider_date')[0].checked == true) {
345       document.getElementsByName('consider_date')[0].checked = false;
346       datesearch();
347    }  
348
349 } // clearSearch()
350
351 /**
352  * if the client is planless, ask the server what to do
353  * next.
354  */
355 function AskServerWhatToDo()
356 {
357    return HTML_AJAX.grab(encodeURI('rpc.php?action=what_to_do'));
358 } // AskServerWhatToDo()
359
360 /**
361  * init phpfspot
362  *
363  * this function will be called when the browser opens phpfspot
364  * the first time. It will fetch the tag-lists and will then
365  * switch to the right view, which the browser got told from
366  * the server (maybe someone hit the refresh button...).
367  */
368 function init_phpfspot(mode)
369 {
370    /* always load list of available tags */
371    refreshAvailableTags();
372
373    /* ask the server what we are currently displaying */
374    whattodo = AskServerWhatToDo();
375
376    window.alert(whattodo);
377
378    if(whattodo == 'showpi' || whattodo == 'showpi_date') {
379       showPhotoIndex();
380    }
381    if(whattodo == 'showpi_tags') {
382       refreshSelectedTags();
383       showPhotoIndex();
384    }
385    if(whattodo == 'show_photo') {
386       if(photo = getPhotoToShow()) {
387          showImage(photo);
388          refreshSelectedTags();
389       }
390    }
391
392 } // init_phpfspot()
393
394 /**
395  * change background-color on mouse-over
396  */
397 function setBackGrdColor(item, color)
398 {
399    if(color == 'mouseover')
400       item.style.backgroundColor='#c6e9ff';
401    if(color == 'mouseout')
402       item.style.backgroundColor='#eeeeee';
403    if(color == 'mouseclick')
404       item.style.backgroundColor='#93A8CA';
405
406 } // setBackGrdColor()
407
408 /**
409  * ask server, which photo needs to be shown
410  *
411  * when user press the refresh-button in a single-photo
412  * view or maybe enters the link via an external URL, the
413  * client does not know, what photo will be shown (dimensions...).
414  * But the server can tell this the browser.
415  */
416 function getPhotoToShow()
417 {
418    var photo_to_show = HTML_AJAX.grab(encodeURI('rpc.php?action=get_photo_to_show'));
419
420    // if no image needs to be shown, return false from here
421    if(photo_to_show == "")
422       return false;
423    
424    return photo_to_show;
425
426 } // getPhotoToShow()
427
428 /**
429  * a fake-zoom for photo
430  *
431  * a quick to let the browser do some zooming on
432  * photos.
433  */
434 function zoom(mod)
435 {
436    var photo;
437
438    if(mod == undefined)
439       return;
440
441    /* internet explorer */
442    if(document.images['photo'].width)
443       photo = document.images['photo'];
444
445    /* all others */
446    if(photo == undefined && document.getElementById('photo').width)
447       photo = document.getElementById('photo');
448
449    if(photo != undefined) {
450
451       if(origWidth == undefined)
452          origWidth = photo.width;
453       if(origHeight == undefined)
454          origHeight = photo.height;
455
456       if(mod != 0) {
457          new_w = photo.width * (1 + mod/100);
458          new_h = photo.height * (1 + mod/100);
459          photo.width = new_w;
460          photo.height = new_h;
461
462          if(photo_details_pos == undefined) {
463             photo_details_pos = findPos(document.getElementById('photo_details'),'left');
464          }
465
466          if((photo.offsetLeft + new_w) >= photo_details_pos-20) {
467             hidePhotoDetails('true');
468          }
469          else {
470             hidePhotoDetails('false');
471          }
472       }
473       else {
474          photo.width = origWidth;
475          photo.height = origHeight;
476          hidePhotoDetails('false');
477       }
478    }
479
480 } // zoom()
481
482 /**
483  * hides the photo details layin
484  *
485  * if the photo is getting zoomed quiet large, this will
486  * auto-hide (and also restore) the photo-details-box.
487  */
488 function hidePhotoDetails(mode)
489 {
490    var photo_details;
491
492    if(photo_details = document.getElementById('photo_details')) {
493       if(mode == 'true') {
494          photo_details.style.visibility = 'hidden';
495          photo_details.style.display = 'none';
496       }
497       else {
498          photo_details.style.visibility = 'visible';
499          photo_details.style.display = '';
500       }
501    }
502 } // hidePhotoDetails()
503
504 /**
505  * show calendar
506  */
507 function showCalendar(date_box, click_obj)
508 {
509    var calendar = document.getElementById('calendar');
510    var year = document.getElementById(date_box+'year').value;
511    var month = document.getElementById(date_box+'month').value;
512    if(date_box == 'from') {
513       var xpos = document.getElementById('frompic').offsetLeft;
514       var ypos = document.getElementById('frompic').offsetTop;
515       calendar_mode = 'from';
516    }
517    if(date_box == 'to') {
518       var xpos = document.getElementById('topic').offsetLeft;
519       var ypos = document.getElementById('topic').offsetTop;
520       calendar_mode = 'to';
521    }
522    calendar.style.left = xpos + 100 + 'px';
523    calendar.style.top = ypos + 80 + 'px';
524
525    if(calendar.style.visibility == "" || calendar.style.visibility == 'hidden') {
526       calendar.style.visibility = 'visible';
527       calendar.innerHTML = "Loading...";
528       calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year=' + year + '&month=' + month));
529       calendar_shown = 1;
530    }
531    else {
532       hideCalendar();
533    }
534
535 } // showCalendar()
536
537 /**
538  * hide calendar
539  */
540 function hideCalendar()
541 {
542    var calendar = document.getElementById('calendar');
543    if(calendar.style.visibility != 'hidden') {
544       calendar.style.visibility = 'hidden';
545       calendar_shown = 0;
546    }
547 } // hideCalendar()
548
549 /**
550  * switch month in calendar
551  */
552 function setMonth(year, month, day)
553 {
554    var calendar = document.getElementById('calendar');
555    calendar.innerHTML = "Loading...";
556    calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year='+ year +'&month='+ month +'&day='+ day));
557 }
558
559 /**
560  * get the user-selected date from the calendar and
561  * put it into the date-search boxes
562  */
563 function setCalendarDate(year, month, day)
564 {
565    document.getElementById(calendar_mode+'year').value = year;
566    document.getElementById(calendar_mode+'month').value = month;
567    document.getElementById(calendar_mode+'day').value = day;
568    hideCalendar();
569
570 } // setCalendarDate()
571
572 /**
573  * reset phpfspot complelely and move to the begining
574  */
575 function resetAll()
576 {
577    HTML_AJAX.grab(encodeURI('rpc.php?action=reset'));
578    clearSearch();
579    refreshAvailableTags();
580    refreshSelectedTags();
581    refreshPhotoIndex();
582
583 } // resetAll()
584
585 /**
586  * find objects with their class-name
587  */
588 function WSR_getElementsByClassName(oElm, strTagName, oClassNames){
589    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
590    var arrReturnElements = new Array();
591    var arrRegExpClassNames = new Array();
592    if(typeof oClassNames == "object"){
593       for(var i=0; i<oClassNames.length; i++){
594          arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));
595       }
596    }
597    else{
598       arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));
599    }
600    var oElement;
601    var bMatchesAll;
602    for(var j=0; j<arrElements.length; j++){
603       oElement = arrElements[j];
604       bMatchesAll = true;
605       for(var k=0; k<arrRegExpClassNames.length; k++){
606          if(!arrRegExpClassNames[k].test(oElement.className)){
607             bMatchesAll = false;
608             break;
609          }
610       }
611       if(bMatchesAll){
612          arrReturnElements.push(oElement);
613       }
614    }
615    return (arrReturnElements)
616
617 } // WSR_getElementsByClassName()
618
619 /**
620  * javascript based photo preloading
621  */
622 function preloadPhotos(image_url) {
623
624    var i;
625    var timeout = 1000;
626    var waiting = 100;
627    var counting;
628
629    lbImg=WSR_getElementsByClassName(document,"img","thumb");
630    for(i=0;i<lbImg.length;i++){
631       lbImg[i].src=image_url[i];
632       // to not bomb the server with requests, give the page some time
633       // to load the images one by one. if a image exceeds the timeout,
634       // the next image will be loaded.
635       if(lbImg[i].complete != undefined && lbImg[i].complete != true) {
636          counting = 0;
637          while(lbImg[i].complete != true && counting < timeout) {
638             window.setTimeout("noop()", waiting);
639             counting+=waiting;
640          }
641       }
642    }
643
644 } // preloadPhotos()
645
646 /* a function that does nothing */
647 function noop() {}
648
649 /**
650  * start slideshow
651  */
652 function startSlideShow()
653 {
654    if(!sliding) {
655       HTML_AJAX.grab(encodeURI('rpc.php?action=reset_slideshow'));
656       nextSlide();
657       sliding = setInterval("nextSlide()", sliding_time*1000);
658       document.getElementById('stop_ico').src = "resources/32_stop.png";
659    }
660    else {
661       clearInterval(sliding);
662       sliding = 0;
663       document.getElementById('stop_ico').src = "resources/32_play.png";
664    }
665
666 } // startSlideShow()
667
668 /**
669  * switch to next slide
670  */
671 function nextSlide()
672 {
673    var next_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_next_slideshow_img'));
674    document.getElementById('slide_img').src = next_img;
675
676 } // nextSlide()
677
678 /**
679  * switch to previous slide
680  */
681 function prevSlide()
682 {
683    var prev_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_prev_slideshow_img'));
684    document.getElementById('slide_img').src = prev_img;
685
686 } // prevSlide()
687
688 /**
689  * interrupt slide show
690  */
691 function pauseSlideShow()
692 {
693    if(!sliding_paused) {
694       sliding_paused = 1;
695       clearInterval(sliding);
696       document.getElementById('pause_ico').src = "resources/32_play.png";
697    }
698    else {
699       sliding_paused = 0;
700       sliding = setInterval("nextSlide()", sliding_time*1000);
701       document.getElementById('pause_ico').src = "resources/32_pause.png";
702    }
703
704 } // pauseSlideShow()
705
706 /**
707  * start auto-browse
708  */
709 function startAutoBrowse()
710 {
711    if(!autobrowse) {
712       autoBrowse();
713       autobrowse = setInterval("autoBrowse()", 5000);
714    }
715    else {
716       clearInterval(autobrowse);
717       autobrowse = 0;
718       document.getElementById('autobrowse_ico').src = "resources/32_play.png";
719    }
720
721 } // startAutoBrowser()
722
723 /**
724  * auto-browsing
725  */
726 function autoBrowse()
727 {
728    if(document.getElementById('next_link')) {
729       var next_link = document.getElementById('next_link').href;
730       window.location.href = next_link;
731       document.getElementById('autobrowse_ico').src = "resources/32_pause.png";
732    }
733    /* we have reached the last photo */
734    else {
735       if(ab_ico = document.getElementById('autobrowse_ico'))
736          ab_ico.src = "resources/32_play.png";
737       clearInterval(autobrowse);
738    }
739
740 } // autoBrowse()
741
742 /**
743  * initiate slider to modify slide-switching-speed
744  */
745 function initSlider()
746 {
747    var sliderEl = document.getElementById ? document.getElementById("slider-1") : null;
748    var inputEl = document.forms[0]["slider-input-1"];
749    var s = new Slider(sliderEl, inputEl);
750    s.setMinimum(1);
751    s.setMaximum(10);
752    s.setValue(sliding_time);
753    document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
754    s.onchange = function () {
755       sliding_time = s.getValue();
756       document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
757       if(!sliding_paused && sliding) {
758          clearInterval(sliding);
759          sliding = setInterval("nextSlide()", sliding_time*1000);
760       }
761    };
762    window.onresize = function () {
763       s.recalculate();
764    };
765
766 } // initSlider()
767
768 /**
769  * if the sort-order (photo-name, date, ...) has been
770  * changed, update the photo-index view.
771  */
772 function update_sort_order(obj)
773 {  
774    var objTemp = new Object();
775    objTemp['value'] = obj.options[obj.selectedIndex].value;
776
777    var retr = HTML_AJAX.post('rpc.php?action=update_sort_order', objTemp);
778
779    if(retr == "ok") {
780       showPhotoIndex();
781    }
782    else {
783       window.alert("Server message: "+ retr);
784    }
785
786 } // update_sort_order()
787
788 /**
789  * handle key events
790  */
791 function keyDown(e) {
792    var evt = (e) ? e:(window.event) ? window.event:null;
793
794    if(evt) {
795       var key = (evt.charCode) ? evt.charCode :
796          ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
797
798
799       if(key == 37) /* left curosr */ {
800          if(document.getElementById('prev_link')) {
801             var prev_link = document.getElementById('prev_link').href;
802             window.location.href = prev_link;
803          }
804          return;
805       }
806       if(key == 38) /* up cursor */ {
807       }
808       if(key == 39) /* right curosr */ {
809          if(document.getElementById('next_link')) {
810             var next_link = document.getElementById('next_link').href;
811             window.location.href = next_link;
812          }
813          return;
814       }
815       if(key == 73 && evt.altKey && evt.ctrlKey) /* ctrl+alt+i */ {
816          showPhotoIndex();
817          return;
818       }
819       if(key == 82 && evt.altKey && evt.ctrlKey) /* ctrl+alt+r */ {
820          resetAll();
821          return;
822       }
823    }
824 }
825
826 document.onkeydown=keyDown;
827 if(document.layers) {
828    document.captureEvents(Event.KEYDOWN);
829 }
830
831 // will be reseted by first viewing photo-index
832 var startup = 1;
833 // calendar specific
834 var calendar_shown = 0;
835 var calendar_mode = '';
836 // auto-browsing & sliding
837 var autobrowse = 0;
838 var sliding = 0;
839 var sliding_paused = 0;
840 var sliding_time = 3;
841 // zooming
842 var origHeight;
843 var origWidth;
844 // position of the last shown photo in photo-index
845 var photo_details_pos;