1 var images_ary = new Array();
2 var images_loaded = new Array();
5 var slideshow_pause = null;
6 var slideshow_timer = null;
8 for (i = 0; i < images.length; i++) {
9 /* this array will contain 0 if image not yet loaded, 1 when loading,
15 document.getElementById('dbg_text').innerHTML += t + "\n";
18 /* load image, return 1 if image is finished loading */
20 if (images_loaded[i] == 0) {
21 images_ary[i] = new Image();
22 images_ary[i].src = images[i];
25 if (images_loaded[i] == 1) {
26 if (images_ary[i].complete) {
35 function getparam(key) {
36 all_params = location.href.split("#");
37 if (all_params.length > 1) {
38 params = all_params[1].split("&");
39 for (i = 0; i < params.length; i++) {
40 keyvalue = params[i].split("=");
41 if (keyvalue[0] == key) {
49 function loadcurrent(img) {
50 for (i = 0; i < images.length; i++) {
51 if (images[i] == img) {
61 function browser_href() {
62 all = location.href.split("/");
63 return all[all.length - 1];
66 /* check URL for changes; allows the URL to reflect currently showed image */
69 if (currentURL == 'ignore1') {
71 } else if (currentURL == 'ignore2') {
72 currentURL = browser_href();
74 href = browser_href();
75 if (href != currentURL) {
77 img = getparam('current');
81 setTimeout("checkURL()", 50);
86 /* favor current image, if user clicked on `last' or something */
89 /* don't blindly preload all images at the beginning,
90 * but rather load them one by one, in order to get
91 * next ones faster, beginning with next to current
93 if (current + 1 < images.length && load(current + 1) == 0) {
94 setTimeout("preload()", 50);
97 if (current - 1 >= 0 && load(current - 1) == 0) {
98 setTimeout("preload()", 50);
102 for (i = current + 2; i < images.length && i <= current + 5; i++) {
104 setTimeout("preload()", 50);
108 for (i = current - 2; i >= current - 3; i--) {
111 setTimeout("preload()", 50);
117 setTimeout("preload()", 50);
120 function add_cookie(val) {
121 var expires = new Date(new Date().getTime() + (30 * 86400000)); // 30 days
122 document.cookie = val
123 + '; expires=' + expires.toGMTString()
127 function get_cookie(key) {
128 if (document.cookie) {
129 var index = document.cookie.indexOf(key);
131 var oleft = (document.cookie.indexOf('=', index) + 1);
132 var oright = document.cookie.indexOf(';', index);
134 oright = document.cookie.length;
136 return document.cookie.substring(oleft, oright);
144 preferred_pause = get_cookie('booh-slideshow-pause-' + dbltilda_theme);
145 if (preferred_pause != null) {
146 document.getElementById('secs').value = preferred_pause;
149 if (getparam('run_slideshow')) {
157 if (images.length == 1) {
158 document.getElementById("b_slideshow").disabled = true;
159 document.getElementById("b_slideshow").setAttribute("class", "disabled");
162 if (navigator.userAgent.indexOf('Opera') == -1) {
163 document.onkeydown = keyDownEvent;
167 function update_sensibilities() {
169 // prevent focus to stay on disabled buttons - then keyboard navigation won't work
170 document.getElementById('thumbnails').focus();
171 document.getElementById("b_first").disabled = true;
172 document.getElementById("b_previous").disabled = true;
173 document.getElementById("b_first").setAttribute("class", "disabled");
174 document.getElementById("b_previous").setAttribute("class", "disabled");
176 document.getElementById("b_first").disabled = false;
177 document.getElementById("b_previous").disabled = false;
178 document.getElementById("b_first").removeAttribute("class");
179 document.getElementById("b_previous").removeAttribute("class");
182 if (current == images.length - 1) {
183 // prevent focus to stay on disabled buttons - then keyboard navigation won't work
184 document.getElementById('thumbnails').focus();
185 document.getElementById("b_next").disabled = true;
186 document.getElementById("b_last").disabled = true;
187 document.getElementById("b_next").setAttribute("class", "disabled");
188 document.getElementById("b_last").setAttribute("class", "disabled");
190 document.getElementById("b_next").disabled = false;
191 document.getElementById("b_last").disabled = false;
192 document.getElementById("b_next").removeAttribute("class");
193 document.getElementById("b_last").removeAttribute("class");
197 function set_cursor_(value, element) {
199 if (!element || !element.style) {
203 element.style.cursor = value;
205 children = element.childNodes;
206 for (i = 0; i < children.length; i++) {
207 set_cursor_(value, children.item[i]);
211 function set_cursor(value) {
212 set_cursor_(value, document.getElementById('body'));
213 set_cursor_(value, document.getElementById('b_first'));
214 set_cursor_(value, document.getElementById('b_previous'));
215 set_cursor_(value, document.getElementById('b_next'));
216 set_cursor_(value, document.getElementById('b_last'));
219 function show_current_text() {
220 /* don't show text if image not yet loaded because navigator
221 * won't refresh it during load */
222 if (images_loaded[current] == 2) {
223 document.getElementById('image_counter').innerHTML = ( current + 1 ) + "/" + images.length;
224 document.getElementById('main_text').innerHTML = captions[current];
225 for (i = 0; i < other_sizes.length; i++) {
226 if (other_sizes[i] == "original") {
227 var original = eval("elements_" + other_sizes[i] + "[current]");
228 if (original != undefined) {
229 document.getElementById('link' + other_sizes[i]).href = original;
230 document.getElementById('link' + other_sizes[i]).style.display = '';
232 document.getElementById('link' + other_sizes[i]).style.display = 'none';
235 document.getElementById('link' + other_sizes[i]).href = 'image-' + other_sizes[i] + dbltilda_htmlsuffix + '#current=' + eval("elements_" + other_sizes[i] + "[current]");
238 document.getElementById('thumbnails').href = 'thumbnails-' + dbltilda_current_size + '-' + thumbnailspages[current] + dbltilda_htmlsuffix + '#' + images[current];
239 set_cursor("default");
241 setTimeout("show_current_text()", 50);
246 function display_current() {
247 var main_img = document.getElementById('main_img');
248 if (types[current] == 'image') {
249 main_img.innerHTML = '<div class="fullscreen_image"><img src="' + images[current] + '"/></div>';
251 main_img.innerHTML = '<a class="fullscreenvideolink" href="' + videos[current] + '" '
252 + ' style="display:block;width:' + widths[current] + 'px;height:' + (heights[current] + 24) + 'px" id="player">'
253 + ' <div class="fullscreen_video"><img src="' + images[current] + '"/></div>'
254 + ' <img src="' + dbltilda_pathtobase + 'play_video.png" style="position:relative;top:-' + (heights[current] + 48)/2 + 'px;border:0;background-color:transparent"/>'
256 if (dbltilda_flowplayer_active == 'true') {
257 flowplayer("player", dbltilda_pathtobase + "flowplayer-3.2.16.swf");
260 oldhref = browser_href();
261 newhref = 'image-' + dbltilda_current_size + dbltilda_htmlsuffix + '#current=' + images[current];
262 if (oldhref != newhref) {
263 currentURL = 'ignore1';
264 location.href = newhref;
265 currentURL = 'ignore2';
268 update_sensibilities();
272 if (slideshow == 1) {
273 toggle_slideshow(true);
281 if (slideshow == 1) {
282 toggle_slideshow(true);
285 if (current < images.length - 1) {
292 if (slideshow == 1) {
293 toggle_slideshow(true);
296 if (current < images.length - 11) {
299 current = images.length - 1;
304 function previous() {
305 if (slideshow == 1) {
306 toggle_slideshow(true);
315 function previous10() {
316 if (slideshow == 1) {
317 toggle_slideshow(true);
329 if (slideshow == 1) {
330 toggle_slideshow(true);
333 current = images.length - 1;
337 function toggle_video() {
338 if (types[current] == 'video' && dbltilda_flowplayer_active == 'true') {
339 var player = flowplayer('player');
340 if (player.isLoaded()) {
348 function keyDownEvent(key) {
351 key.which = key.keyCode;
353 if (key.altKey || key.ctrlKey || key.shiftKey) {
381 function toggle_slideshow(now) {
382 if (slideshow == 0) {
383 slideshow_pause = document.getElementById('secs').value;
384 add_cookie('booh-slideshow-pause-' + dbltilda_theme + '=' + slideshow_pause)
385 document.getElementById("b_slideshow").value = dbltilda_stop_slideshow;
387 if (current == images.length - 1) {
393 setTimeout("run_slideshow()", slideshow_pause * 1000);
396 clearTimeout(slideshow_timer);
397 document.getElementById("b_slideshow").value = dbltilda_run_slideshow;
402 function run_slideshow() {
403 if (slideshow == 0) {
407 if (images_loaded[current + 1] == 2) {
410 slideshow_timer = setTimeout("run_slideshow()", slideshow_pause * 1000);
412 slideshow_timer = setTimeout("run_slideshow()", 50);
415 if (current == images.length - 1) {
416 toggle_slideshow(true);
420 function set_preferred_size(val) {
421 var expires = new Date(new Date().getTime() + (30 * 86400000)); // 30 days
422 document.cookie = 'booh-preferred-size-' + dbltilda_theme + '='
424 + '; expires=' + expires.toGMTString()