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