set everywhere the correct path to scripts, stylesheets, images, ...
[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    refreshAvailableTags();
387
388    /* ask the server what we are currently displaying */
389    whattodo = AskServerWhatToDo();
390
391    window.alert(whattodo);
392
393    if(whattodo == 'showpi' || whattodo == 'showpi_date') {
394       showPhotoIndex();
395    }
396    if(whattodo == 'showpi_tags') {
397       refreshSelectedTags();
398       showPhotoIndex();
399    }
400    if(whattodo == 'show_photo') {
401       if(photo = getPhotoToShow()) {
402          showImage(photo);
403          refreshSelectedTags();
404       }
405    }
406
407 } // init_phpfspot()
408
409 /**
410  * change background-color on mouse-over
411  */
412 function setBackGrdColor(item, color)
413 {
414    if(color == 'mouseover')
415       item.style.backgroundColor='#c6e9ff';
416    if(color == 'mouseout')
417       item.style.backgroundColor='#eeeeee';
418    if(color == 'mouseclick')
419       item.style.backgroundColor='#93A8CA';
420
421 } // setBackGrdColor()
422
423 /**
424  * ask server, which photo needs to be shown
425  *
426  * when user press the refresh-button in a single-photo
427  * view or maybe enters the link via an external URL, the
428  * client does not know, what photo will be shown (dimensions...).
429  * But the server can tell this the browser.
430  */
431 function getPhotoToShow()
432 {
433    var photo_to_show = HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=get_photo_to_show'));
434
435    // if no image needs to be shown, return false from here
436    if(photo_to_show == "")
437       return false;
438    
439    return photo_to_show;
440
441 } // getPhotoToShow()
442
443 /**
444  * a fake-zoom for photo
445  *
446  * a quick to let the browser do some zooming on
447  * photos.
448  */
449 function zoom(mod)
450 {
451    var photo;
452
453    if(mod == undefined)
454       return;
455
456    /* internet explorer */
457    if(document.images['photo'].width)
458       photo = document.images['photo'];
459
460    /* all others */
461    if(photo == undefined && document.getElementById('photo').width)
462       photo = document.getElementById('photo');
463
464    if(photo != undefined) {
465
466       if(origWidth == undefined)
467          origWidth = photo.width;
468       if(origHeight == undefined)
469          origHeight = photo.height;
470
471       if(mod != 0) {
472          new_w = photo.width * (1 + mod/100);
473          new_h = photo.height * (1 + mod/100);
474          photo.width = new_w;
475          photo.height = new_h;
476
477          if(photo_details_pos == undefined) {
478             photo_details_pos = findPos(document.getElementById('photo_details'),'left');
479          }
480
481          if((photo.offsetLeft + new_w) >= photo_details_pos-20) {
482             hidePhotoDetails('true');
483          }
484          else {
485             hidePhotoDetails('false');
486          }
487       }
488       else {
489          photo.width = origWidth;
490          photo.height = origHeight;
491          hidePhotoDetails('false');
492       }
493    }
494
495 } // zoom()
496
497 /**
498  * hides the photo details layin
499  *
500  * if the photo is getting zoomed quiet large, this will
501  * auto-hide (and also restore) the photo-details-box.
502  */
503 function hidePhotoDetails(mode)
504 {
505    var photo_details;
506
507    if(photo_details = document.getElementById('photo_details')) {
508       if(mode == 'true') {
509          photo_details.style.visibility = 'hidden';
510          photo_details.style.display = 'none';
511       }
512       else {
513          photo_details.style.visibility = 'visible';
514          photo_details.style.display = '';
515       }
516    }
517 } // hidePhotoDetails()
518
519 /**
520  * show calendar
521  */
522 function showCalendar(date_box, click_obj)
523 {
524    var calendar = document.getElementById('calendar');
525    var year = document.getElementById(date_box+'year').value;
526    var month = document.getElementById(date_box+'month').value;
527    if(date_box == 'from') {
528       var xpos = document.getElementById('frompic').offsetLeft;
529       var ypos = document.getElementById('frompic').offsetTop;
530       calendar_mode = 'from';
531    }
532    if(date_box == 'to') {
533       var xpos = document.getElementById('topic').offsetLeft;
534       var ypos = document.getElementById('topic').offsetTop;
535       calendar_mode = 'to';
536    }
537    calendar.style.left = xpos + 100 + 'px';
538    calendar.style.top = ypos + 80 + 'px';
539
540    if(calendar.style.visibility == "" || calendar.style.visibility == 'hidden') {
541       calendar.style.visibility = 'visible';
542       calendar.innerHTML = "Loading...";
543       calendar.innerHTML = HTML_AJAX.grab(encodeURI(web_path +'/rpc.php?action=get_calendar_matrix&year=' + year + '&month=' + month));
544       calendar_shown = 1;
545    }
546    else {
547       hideCalendar();
548    }
549
550 } // showCalendar()
551
552 /**
553  * hide calendar
554  */
555 function hideCalendar()
556 {
557    var calendar = document.getElementById('calendar');
558    if(calendar.style.visibility != 'hidden') {
559       calendar.style.visibility = 'hidden';
560       calendar_shown = 0;
561    }
562 } // hideCalendar()
563
564 /**
565  * switch month in calendar
566  */
567 function setMonth(year, month, day)
568 {
569    var calendar = document.getElementById('calendar');
570    calendar.innerHTML = "Loading...";
571    calendar.innerHTML = HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=get_calendar_matrix&year='+ year +'&month='+ month +'&day='+ day));
572 }
573
574 /**
575  * get the user-selected date from the calendar and
576  * put it into the date-search boxes
577  */
578 function setCalendarDate(year, month, day)
579 {
580    document.getElementById(calendar_mode+'year').value = year;
581    document.getElementById(calendar_mode+'month').value = month;
582    document.getElementById(calendar_mode+'day').value = day;
583    hideCalendar();
584
585 } // setCalendarDate()
586
587 /**
588  * reset phpfspot complelely and move to the begining
589  */
590 function resetAll()
591 {
592    HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=reset'));
593    clearSearch();
594    refreshAvailableTags();
595    refreshSelectedTags();
596    refreshPhotoIndex();
597
598 } // resetAll()
599
600 /**
601  * find objects with their class-name
602  */
603 function WSR_getElementsByClassName(oElm, strTagName, oClassNames){
604    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
605    var arrReturnElements = new Array();
606    var arrRegExpClassNames = new Array();
607    if(typeof oClassNames == "object"){
608       for(var i=0; i<oClassNames.length; i++){
609          arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));
610       }
611    }
612    else{
613       arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));
614    }
615    var oElement;
616    var bMatchesAll;
617    for(var j=0; j<arrElements.length; j++){
618       oElement = arrElements[j];
619       bMatchesAll = true;
620       for(var k=0; k<arrRegExpClassNames.length; k++){
621          if(!arrRegExpClassNames[k].test(oElement.className)){
622             bMatchesAll = false;
623             break;
624          }
625       }
626       if(bMatchesAll){
627          arrReturnElements.push(oElement);
628       }
629    }
630    return (arrReturnElements)
631
632 } // WSR_getElementsByClassName()
633
634 /**
635  * javascript based photo preloading
636  */
637 function preloadPhotos(image_url) {
638
639    var i;
640    var timeout = 1000;
641    var waiting = 100;
642    var counting;
643
644    lbImg=WSR_getElementsByClassName(document,"img","thumb");
645    for(i=0;i<lbImg.length;i++){
646       lbImg[i].src=image_url[i];
647       // to not bomb the server with requests, give the page some time
648       // to load the images one by one. if a image exceeds the timeout,
649       // the next image will be loaded.
650       if(lbImg[i].complete != undefined && lbImg[i].complete != true) {
651          counting = 0;
652          while(lbImg[i].complete != true && counting < timeout) {
653             window.setTimeout("noop()", waiting);
654             counting+=waiting;
655          }
656       }
657    }
658
659 } // preloadPhotos()
660
661 /* a function that does nothing */
662 function noop() {}
663
664 /**
665  * start slideshow
666  */
667 function startSlideShow()
668 {
669    if(!sliding) {
670       HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=reset_slideshow'));
671       nextSlide();
672       sliding = setInterval("nextSlide()", sliding_time*1000);
673       document.getElementById('stop_ico').src = web_path + "/resources/32_stop.png";
674    }
675    else {
676       clearInterval(sliding);
677       sliding = 0;
678       document.getElementById('stop_ico').src = web_path + "/resources/32_play.png";
679    }
680
681 } // startSlideShow()
682
683 /**
684  * switch to next slide
685  */
686 function nextSlide()
687 {
688    var next_img = HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=get_next_slideshow_img'));
689    document.getElementById('slide_img').src = next_img;
690
691 } // nextSlide()
692
693 /**
694  * switch to previous slide
695  */
696 function prevSlide()
697 {
698    var prev_img = HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=get_prev_slideshow_img'));
699    document.getElementById('slide_img').src = prev_img;
700
701 } // prevSlide()
702
703 /**
704  * interrupt slide show
705  */
706 function pauseSlideShow()
707 {
708    if(!sliding_paused) {
709       sliding_paused = 1;
710       clearInterval(sliding);
711       document.getElementById('pause_ico').src = web_path + "/resources/32_play.png";
712    }
713    else {
714       sliding_paused = 0;
715       sliding = setInterval("nextSlide()", sliding_time*1000);
716       document.getElementById('pause_ico').src = web_path + "/resources/32_pause.png";
717    }
718
719 } // pauseSlideShow()
720
721 /**
722  * start auto-browse
723  */
724 function startAutoBrowse()
725 {
726    if(!autobrowse) {
727       autoBrowse();
728       autobrowse = setInterval("autoBrowse()", 5000);
729    }
730    else {
731       clearInterval(autobrowse);
732       autobrowse = 0;
733       document.getElementById('autobrowse_ico').src = web_path + "/resources/32_play.png";
734    }
735
736 } // startAutoBrowser()
737
738 /**
739  * auto-browsing
740  */
741 function autoBrowse()
742 {
743    if(document.getElementById('next_link')) {
744       var next_link = document.getElementById('next_link').href;
745       window.location.href = next_link;
746       document.getElementById('autobrowse_ico').src = web_path + "/resources/32_pause.png";
747    }
748    /* we have reached the last photo */
749    else {
750       if(ab_ico = document.getElementById('autobrowse_ico'))
751          ab_ico.src = web_path + "/resources/32_play.png";
752       clearInterval(autobrowse);
753    }
754
755 } // autoBrowse()
756
757 /**
758  * initiate slider to modify slide-switching-speed
759  */
760 function initSlider()
761 {
762    var sliderEl = document.getElementById ? document.getElementById("slider-1") : null;
763    var inputEl = document.forms[0]["slider-input-1"];
764    var s = new Slider(sliderEl, inputEl);
765    s.setMinimum(1);
766    s.setMaximum(10);
767    s.setValue(sliding_time);
768    document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
769    s.onchange = function () {
770       sliding_time = s.getValue();
771       document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
772       if(!sliding_paused && sliding) {
773          clearInterval(sliding);
774          sliding = setInterval("nextSlide()", sliding_time*1000);
775       }
776    };
777    window.onresize = function () {
778       s.recalculate();
779    };
780
781 } // initSlider()
782
783 /**
784  * if the sort-order (photo-name, date, ...) has been
785  * changed, update the photo-index view.
786  */
787 function update_sort_order(obj)
788 {  
789    var objTemp = new Object();
790    objTemp['value'] = obj.options[obj.selectedIndex].value;
791
792    var retr = HTML_AJAX.post(web_path + '/rpc.php?action=update_sort_order', objTemp);
793
794    if(retr == "ok") {
795       showPhotoIndex();
796    }
797    else {
798       window.alert("Server message: "+ retr);
799    }
800
801 } // update_sort_order()
802
803 /**
804  * handle key events
805  */
806 function keyDown(e) {
807    var evt = (e) ? e:(window.event) ? window.event:null;
808
809    if(evt) {
810       var key = (evt.charCode) ? evt.charCode :
811          ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
812
813
814       if(key == 37) /* left curosr */ {
815          if(document.getElementById('prev_link')) {
816             var prev_link = document.getElementById('prev_link').href;
817             window.location.href = prev_link;
818          }
819          return;
820       }
821       if(key == 38) /* up cursor */ {
822       }
823       if(key == 39) /* right curosr */ {
824          if(document.getElementById('next_link')) {
825             var next_link = document.getElementById('next_link').href;
826             window.location.href = next_link;
827          }
828          return;
829       }
830       if(key == 73 && evt.altKey && evt.ctrlKey) /* ctrl+alt+i */ {
831          showPhotoIndex();
832          return;
833       }
834       if(key == 82 && evt.altKey && evt.ctrlKey) /* ctrl+alt+r */ {
835          resetAll();
836          return;
837       }
838    }
839 }
840
841 document.onkeydown=keyDown;
842 if(document.layers) {
843    document.captureEvents(Event.KEYDOWN);
844 }
845
846 // will be reseted by first viewing photo-index
847 var startup = 1;
848 // calendar specific
849 var calendar_shown = 0;
850 var calendar_mode = '';
851 // auto-browsing & sliding
852 var autobrowse = 0;
853 var sliding = 0;
854 var sliding_paused = 0;
855 var sliding_time = 3;
856 // zooming
857 var origHeight;
858 var origWidth;
859 // position of the last shown photo in photo-index
860 var photo_details_pos;
861 var web_path;