PageSourceSearch

https://baph.org.uk/wp-content/plugins/wp-photo-album-plus/js/wppa-slideshow.js?ver=260919-44213

js baph.org.uk collected 2026-10-02 11:20:55 UTC 80,474 bytes, 2,478 lines download raw bytes

1// wppa-slideshow.js
2//
3// Contains slideshow modules
4// Dependancies: wppa.js and default wp $ library
5//
6var wppaJsSlideshowVersion = '9.3.00.001';
7var wppaHasControlbar = false;
8
9// This is an entrypoint to load the slide data
10function wppaStoreSlideInfo(
11							mocc, 		// The occurrance of a wppa invocation
12										// ( php: $wppa['master_occur'] )
13							id, 		// The index in the slide array
14							url, 		// The url to the fs image file
15							size,
16							width,
17							height,
18							fullname,
19							name,
20							desc,
21							photoid, 		// The photo id (encrypted)
22							realid, 		// The photo id (unencrypted)
23							avgrat, 		// Average rating
24							discount, 		// Dislike count
25							myrat, 			// My rating
26							rateurl, 		// The rating url
27							linkurl,
28							linktitle,
29							linktarget,
30							timeout,
31							commenthtml, 	// The html code for the comment box
32							iptchtml,
33							exifhtml,
34							lbtitle, 		// Lightbox subtext
35							shareurl,
36							smhtml,
37							ogdsc,
38							hiresurl, 		// The url to the hi res ( source ) image file
39							videohtml, 		// The html for the video, or ''
40							audiohtml,
41							waittext, 		// The time you have to wait before you can vote again on the photo
42							imagealt,
43							posterurl,
44							filename,
45							panoramahtml,
46							pancontrolheight,
47							ratio,
48							) {
49
50	var cursor;
51
52	desc = wppaRepairScriptTags( desc );
53
54	if ( ! _wppaSlides[mocc] || '0' == id ) {	// First or next page
55		_wppaSlides[mocc] = [];
56		_wppaNames[mocc] = [];
57		_wppaFilmThumbTitles[mocc] = [];
58		_wppaFullNames[mocc] = [];
59		_wppaDsc[mocc] = [];
60		_wppaOgDsc[mocc] = [];
61		_wppaCurIdx[mocc] = -1;
62		_wppaNxtIdx[mocc] = 0;
63
64		if ( wppaSavedSlideshowTimeout[mocc] ) {
65			_wppaTimeOut[mocc] = wppaSavedSlideshowTimeout[mocc];
66		}
67		else {
68			_wppaTimeOut[mocc] = timeout;
69			wppaSavedSlideshowTimeout[mocc] = _wppaTimeOut[mocc];
70		}
71		_wppaSSRuns[mocc] = false;
72		_wppaTP[mocc] = -2;	// -2 means NO, index for _wppaStartStop otherwise
73		_wppaFg[mocc] = 0;
74		_wppaIsBusy[mocc] = false;
75		_wppaFirst[mocc] = true;
76		_wppaId[mocc] = [];
77		_wppaRealId[mocc] = [];
78		_wppaAvg[mocc] = [];
79		_wppaDisc[mocc] = [];
80		_wppaMyr[mocc] = [];
81		_wppaVRU[mocc] = [];
82		_wppaLinkUrl[mocc] = []; // linkurl;
83		_wppaLinkTitle[mocc] = []; // linktitle;
84		_wppaLinkTarget[mocc] = [];
85		_wppaCommentHtml[mocc] = [];
86		_wppaIptcHtml[mocc] = [];
87		_wppaExifHtml[mocc] = [];
88		_wppaUrl[mocc] = [];
89		_wppaSkipRated[mocc] = false;
90		_wppaLbTitle[mocc] = [];
91		_wppaDidGoto[mocc] = false;
92		wppaSlidePause[mocc] = false;
93		_wppaShareUrl[mocc] = [];
94		_wppaShareHtml[mocc] = [];
95		_wppaFilmNoMove[mocc] = false;
96		_wppaHiresUrl[mocc] = [];
97		_wppaIsVideo[mocc] = [];
98		_wppaIsAudio[mocc] = [];
99		_wppaVideoHtml[mocc] = [];
100		_wppaAudioHtml[mocc] = [];
101		_wppaVideoNatWidth[mocc] = [];
102		_wppaVideoNatHeight[mocc] = [];
103		wppaVideoPlaying[mocc] = false;
104		wppaAudioPlaying[mocc] = false;
105		_wppaWaitTexts[mocc] = [];
106		_wppaImageAlt[mocc] = [];
107		_wppaFilename[mocc] = [];
108		_wppaPanoramaHtml[mocc] = [];
109		_wppaPanControlHeight[mocc] = [];
110		_wppaRatio[mocc] = [];
111
112//		wppaFullSize[mocc] = wppaGetContainerWidth(mocc);
113	}
114
115	// Cursor
116	cursor = 'default';
117	if ( linkurl != '' ) {
118		cursor = 'pointer';
119	}
120	else if ( wppaLightBox[mocc] != '' ) {
121		cursor =  'url( '+wppaImageDirectory+wppaMagnifierCursor+' ),pointer';
122	}
123
124	// Is it a video?
125	_wppaIsVideo[mocc][id] = ( '' != videohtml );
126
127	// Is it an audio?
128	_wppaIsAudio[mocc][id] = ( '' != audiohtml );
129
130	// Fill _wppaSlides[mocc][id]
131	if ( _wppaIsVideo[mocc][id] ) {
132		_wppaSlides[mocc][id] = ' alt="' + imagealt + '" class="theimg theimg-'+mocc+' big" ';
133		if ( wppaSlideVideoStart ) { // && wppaLightBox[mocc] == '' ) {
134			_wppaSlides[mocc][id] += ' autoplay ';
135		}
136		if ( posterurl.length > 0 ) {
137			_wppaSlides[mocc][id] += ' poster="' + posterurl + '" ';
138		}
139	}
140	else if ( _wppaIsAudio[mocc][id] ) {
141		_wppaSlides[mocc][id] = ' alt="' + imagealt + '" class="theimg theimg-'+mocc+' big" ';
142		if ( wppaSlideAudioStart ) { // && wppaLightBox[mocc] == '' ) {
143			_wppaSlides[mocc][id] += ' autoplay ';
144		}
145		_wppaSlides[mocc][id] = ' src="' + url + '" alt="' + imagealt + '" class="theimg theimg-'+mocc+' big stereo" ';
146	}
147	else {
148		_wppaSlides[mocc][id] = ' src="' + url + '" alt="' + imagealt + '" class="theimg theimg-'+mocc+' big stereo" ';
149	}
150
151	// Add swipe
152	if ( wppaSlideSwipe ) {
153		_wppaSlides[mocc][id] += 	' ontouchstart="wppaTouchStart( event, this.id, '+mocc+' );"' +
154									' ontouchend="wppaTouchEnd( event );"' +
155									' ontouchmove="wppaTouchMove( event );"' +
156									' ontouchcancel="wppaTouchCancel( event );" ';
157	}
158
159	// Add 'old' width and height only for non-auto
160	if ( ! wppaAutoColumnWidth[mocc] ) _wppaSlides[mocc][id] += 'width="' + width + '" height="' + height + '" ';
161	if ( _wppaIsVideo[mocc][id] ) {
162		var controls;
163		controls = 'wppa' == wppaLightBox[mocc] ? '' : 'controls';
164		_wppaSlides[mocc][id] += 'style="' + size + '; cursor:'+cursor+'; display:none;
164" '+controls+' >'+videohtml+'</video>';
165	}
166	else {
167		_wppaSlides[mocc][id] += 'style="' + size + '; cursor:'+cursor+'; display:none; vertical-align:middle;">';
168	}
169
170    _wppaFullNames[mocc][id] = '<span class="sdf-'+mocc+'" >'+wppaRepairBrTags(fullname)+'</span>';
171    _wppaNames[mocc][id] = '<span class="sdn-'+mocc+'" >'+name+'</span>';
172	_wppaFilmThumbTitles[mocc][id] = name;
173    _wppaDsc[mocc][id] = desc;// '<span class="sdd-'+mocc+'" >'+desc+'</span>';
174	_wppaOgDsc[mocc][id] = ogdsc;
175	_wppaId[mocc][id] = photoid;		// reqd for rating and comment and monkey and registering views
176	_wppaRealId[mocc][id] = realid;
177	_wppaAvg[mocc][id] = avgrat;		// avg ratig value
178	_wppaDisc[mocc][id] = discount;		// Dislike count
179	_wppaMyr[mocc][id] = myrat;			// my rating
180	_wppaVRU[mocc][id] = rateurl;		// url that performs the vote and returns to the page
181	_wppaLinkUrl[mocc][id] = linkurl;
182	_wppaLinkTitle[mocc][id] = linktitle;
183
184	if ( linktarget != '' ) {
185		_wppaLinkTarget[mocc][id] = linktarget;
186	}
187	else if ( wppaSlideBlank[mocc] ) {
188		_wppaLinkTarget[mocc][id] = '_blank';
189	}
190	else {
191		_wppaLinkTarget[mocc][id] = '_self';
192	}
193
194	_wppaCommentHtml[mocc][id] = commenthtml;
195	_wppaIptcHtml[mocc][id] = iptchtml;
196	_wppaExifHtml[mocc][id] = exifhtml;
197	_wppaUrl[mocc][id] = url;		// Image url
198	_wppaLbTitle[mocc][id] = wppaRepairScriptTags( lbtitle );
199	_wppaShareUrl[mocc][id] = shareurl;
200	_wppaShareHtml[mocc][id] = wppaRepairScriptTags( smhtml );
201	_wppaHiresUrl[mocc][id] = hiresurl;
202	_wppaVideoHtml[mocc][id] = videohtml;
203	_wppaAudioHtml[mocc][id] = audiohtml;
204	_wppaVideoNatWidth[mocc][id] = width;
205	_wppaVideoNatHeight[mocc][id] = height;
206	_wppaWaitTexts[mocc][id] = waittext;
207	_wppaImageAlt[mocc][id] = imagealt;
208	_wppaFilename[mocc][id] = filename;
209	_wppaPanoramaHtml[mocc][id] = panoramahtml;
210	_wppaPanControlHeight[mocc][id] = pancontrolheight;
211	_wppaRatio[mocc][id] = ratio;
212}
213
214// These functions check the validity and store the users request to be executed later if busy and if applicable.
215function wppaSpeed( mocc, faster ) {
216	if ( _wppaSSRuns[mocc] ) {
217		_wppaSpeed( mocc, faster );
218	}
219}
220
221function wppaStopShow( mocc ) {
222	if ( _wppaSSRuns[mocc] ) {
223		_wppaStop( mocc );
224	}
225}
226
227function wppaStopMedia( mocc ) {
228	wppaStopAudio( mocc );
229	wppaStopVideo( mocc );
230	wppaStopShow( mocc );
231}
232
233// The application contains various togglers for start/stop
234// The busy flag will be reset at the end of the NextSlide procedure
235function wppaStartStop( mocc, index ) {
236
237	// If prev or next page due to running or prev/next button, overrule default, only once!!
238	if ( wppaSlideInitRunning[mocc] ) {
239		if ( wppaSlideInitRunning[mocc] == 'start' ) {
240			index = -1;
241		}
242		else if ( wppaSlideInitRunning[mocc] == 'stopprev' ) {
243			index = _wppaSlides[mocc].length -1;
244			_wppaStop( mocc );
245		}
246		else if ( wppaSlideInitRunning[mocc] == 'stopnext' ) {
247			index = 0;
248			_wppaStop( mocc );
249		}
250		wppaSlideInitRunning[mocc] = '';
251	}
252
253	if ( _wppaIsBusy[mocc] ) {
254
255		// Remember there is a toggle pending
256		_wppaTP[mocc] = index;
257	}
258
259	// Actually do it
260	if ( _wppaSSRuns[mocc] ) {
261
262		// Stop it
263		_wppaStop( mocc );
264	}
265	else {
266
267		// Start it
268		_wppaStart( mocc, index );
269	}
270
271	if ( wppaIsMobile ) {
272		jQuery( '#wppa-startstop-icon-' + mocc ).stop().fadeTo( 10, 1 ).fadeTo( 3000, 0 );
273		jQuery( '.ubb-'+mocc ).stop().fadeTo( 10, 1 ).fadeTo( 3000, 0 );
274	}
275}
276
277function wppaBbb( mocc, where, act ) {
278	if ( ! _wppaSSRuns[mocc] ) {
279
280		// Big Browsing Buttons only work when stopped
281		_wppaBbb( mocc, where, act );
282	}
283}
284
285function wppaUbb( mocc, where, act ) {
286	_wppaUbb( mocc, where, act );
287}
288
289function wppaRateIt( mocc, value ) {
290	_wppaRateIt( mocc, value );
291}
292
293function wppaOvlRateIt( id, value, mocc, reloadAfter ) {
294	_wppaOvlRateIt( id, value, mocc, reloadAfter );
295}
296
297function wppaPrev( mocc ) {
298wppaStopMedia( mocc );
299	_wppaDidGoto[mocc] = true;
300	if ( ! _wppaSSRuns[mocc] ) {
301		_wppaPrev( mocc );
302	}
303}
304
305function wppaPrevN( mocc, n ) {
306wppaStopMedia( mocc );
307	_wppaDidGoto[mocc] = true;
308	if ( ! _wppaSSRuns[mocc] ) {
309		_wppaPrevN( mocc, n );
310	}
311}
312
313function wppaFirst( mocc ) {
314wppaStopMedia( mocc );
315	_wppaDidGoto[mocc] = true;
316	if ( ! _wppaSSRuns[mocc] ) {
317		_wppaGoto( mocc, 0 );
318	}
319}
320
321function wppaNext( mocc ) {
322wppaStopMedia( mocc );
323	_wppaDidGoto[mocc] = true;
324	if ( ! _wppaSSRuns[mocc] ) {
325		_wppaNext( mocc );
326	}
327}
328
329function wppaNextN( mocc, n ) {
330wppaStopMedia( mocc );
331	_wppaDidGoto[mocc] = true;
332	if ( ! _wppaSSRuns[mocc] ) {
333		_wppaNextN( mocc, n );
334	}
335}
336
337function wppaLast( mocc ) {
338wppaStopMedia( mocc );
339	_wppaDidGoto[mocc] = true;
340	if ( ! _wppaSSRuns[mocc] ) {
341		_wppaGoto( mocc, _wppaSlides[mocc].length - 1 );
342	}
343}
344
345function wppaFollowMe( mocc, idx ) {
346wppaStopMedia( mocc );
347	if ( ! _wppaSSRuns[mocc] ) {
348		_wppaFollowMe( mocc, idx );
349	}
350}
351
352function wppaLeaveMe( mocc, idx ) {
353wppaStopMedia( mocc );
354	if ( ! _wppaSSRuns[mocc] ) {
355		_wppaLeaveMe( mocc, idx );
356	}
357}
358
359function wppaGoto( mocc, idx ) {
360wppaStopMedia( mocc );
361	_wppaDidGoto[mocc] = true;
362	if ( ! _wppaSSRuns[mocc] ) {
363		_wppaGoto( mocc, idx );
364	}
365}
366
367function wppaGotoFilmNoMove( mocc, idx ) {
368wppaStopMedia( mocc );
369	_wppaDidGoto[mocc] = true;
370	if ( ! _wppaSSRuns[mocc] ) {
371		_wppaFilmNoMove[mocc] = true;
372		_wppaGoto( mocc, idx );
373	}
374}
375
376function wppaGotoKeepState( mocc, idx ) {
377wppaStopMedia( mocc );
378	if ( _wppaNxtIdx[mocc] == idx ) return;
379	_wppaDidGoto[mocc] = true;
380	_wppaGotoKeepState( mocc, idx );
381}
382
383function _wppaGotoKeepState( mocc, idx ) {
384	if ( _wppaSSRuns[mocc] ) {
385		_wppaGotoRunning( mocc,idx );
386	}
387	else {
388		_wppaGoto( mocc,idx );
389	}
390}
391
392function wppaGotoRunning( mocc, idx ) {
393wppaStopMedia( mocc );
394	_wppaDidGoto[mocc] = true;
395	_wppaGotoRunning( mocc, idx );
396}
397
398function wppaValidateComment( mocc ) {
399	return _wppaValidateComment( mocc );
400}
401
402function _wppaNextSlide( mocc, mode ) {
403
404
405	var isFilmOnly = ! document.getElementById( 'slide_frame-'+mocc );
406
407	// If not in viewport or media running try again later
408//	/*
409	if ( wppaLazyLoad && ! isFilmOnly && ! wppaIsSlidshowVisible( mocc ) || wppaVideoPlaying[mocc] || wppaAudioPlaying[mocc] ) {
410
411		// Fake not inited to cause jump to loc the first time
412		wppaFilmInit[mocc] = false;
413		setTimeout(function(){_wppaNextSlide( mocc, mode )},400);
414		return;
415	}
416//	*/
417
418	// Remember current
419	_wppaLastIdx[mocc] = _wppaCurIdx[mocc];
420
421	// Filmonly continuously?
422	if ( ! document.getElementById( 'slide_frame-'+mocc ) && document.getElementById( 'filmwindow-'+mocc ) && wppaFilmonlyContinuous ) {
423
424		if ( ! _wppaSSRuns[mocc] ) {
425			_wppaCurIdx[mocc] = _wppaNxtIdx[mocc];
426			wppaFilmInit[mocc] = false;
427			_wppaAdjustFilmstrip( mocc, 'linear' );
428			return;
429		}
430
431		// Find index of next slide if in auto mode and not stop in progress
432		_wppaCurIdx[mocc] ++;
433		if ( _wppaCurIdx[mocc] == _wppaSlides[mocc].length ) _wppaCurIdx[mocc] = 0;
434
435		// Adjust filmstrip
436		_wppaAdjustFilmstrip( mocc, 'linear' );
437		_wppaNxtIdx[mocc] = _wppaCurIdx[mocc];
438
439		// Go for the next
440		setTimeout( '_wppaNextSlide( '+mocc+', \''+mode+'\' )', wppaAnimationSpeed );
441		return;
442	}
443
444	// Not slide and not filmonly normal (non contin) ?
445	if ( ! document.getElementById( 'slide_frame-'+mocc ) && ! document.getElementById( 'filmwindow-'+mocc ) ) {
446		return; 	// Nothing to do here
447	}
448
449	var fg = _wppaFg[mocc];
450	var bg = 1 - fg;
451
452	// If audio video is playing, delay a running slideshow
453	if ( ( wppaVideoPlaying[mocc] || wppaAudioPlaying[mocc] ) && _wppaSSRuns[mocc] ) {
454		setTimeout( '_wppaNextSlide( '+mocc+', \''+mode+'\' )', 500 ); 	// Retry after 500 ms
455		return;
456	}
457
458	// Stop any playing video
459//	wppaStopVideo( mocc );
460
461	// Stop playing audio
462//	wppaStopAudio( mocc );
463
464	// Paused??
465	if ( 'auto' == mode ) {
466		if ( wppaSlidePause[mocc] ) {
467			jQuery( '#theimg'+fg+'-'+mocc ).attr( "title", wppaSlidePause[mocc] );
468			jQuery( '#slide_frame-'+mocc ).attr( "title", wppaSlidePause[mocc] );
469			setTimeout( '_wppaNextSlide( '+mocc+', "auto" )', 250 );	// Retry after 250 ms.
470			return;
471		}
472	}
473	else {
474		jQuery( '#slide_frame-'+mocc ).removeAttr( "title" );
475	}
476
477	// Kill an old timed request, while stopped
478	if ( ! _wppaSSRuns[mocc] && 'auto' == mode ) return;
479
480	// Empty slideshow?
481	if ( ! _wppaSlides[mocc] ) return;
482
483	// Do not animate single image
484	if ( _wppaSlides[mocc].length < 2 && ! _wppaFirst[mocc] ) return;
485
486	// Reset request?
487	if ( ! _wppaSSRuns[mocc] && 'reset' == mode ) {
488		_wppaSSRuns[mocc] = true;
489		__wppaOverruleRun = false;
490	}
491
492	// No longer busy voting
493	_wppaVoteInProgress = false;
494
495	// Set the busy flag
496	_wppaIsBusy[mocc] = true;
497
498	// Hide metadata while changing image
499	if ( _wppaSSRuns[mocc] ) _wppaShowMetaData( mocc, 'hide' );
500
501	// Find index of next slide if in auto mode and not stop in progress
502	if ( _wppaSSRuns[mocc] ) {
503		_wppaNxtIdx[mocc] = _wppaCurIdx[mocc] + 1;
504		if ( _wppaNxtIdx[mocc] == _wppaSlides[mocc].length ) _wppaNxtIdx[mocc] = 0;
505	}
506
507	// Update geo if any
508	// GPX Plugin
509	jQuery( '#geodiv-'+mocc+'-'+_wppaId[mocc][_wppaCurIdx[mocc]] ).css( { display: 'none' });
510	jQuery( '#geodiv-'+mocc+'-'+_wppaId[mocc][_wppaNxtIdx[mocc]] ).css( { display: '' });
511
512	// WPPA+ Native
513	if ( typeof( _wppaLat ) != 'undefined' ) {
514		if ( _wppaLat[mocc] ) {
515			var id = _wppaRealId[mocc];
516			if ( _wppaLat[mocc][id[_wppaNxtIdx[mocc]]] ) {
517				jQuery( '#map-canvas-'+mocc ).css( 'display', '' );
518				wppaGeoInit( mocc, _wppaLat[mocc][id[_wppaNxtIdx[mocc]]], _wppaLon[mocc][id[_wppaNxtIdx[mocc]]] );
519			}
520			else jQuery( '#map-canvas-'+mocc ).css( 'display', 'none' );
521		}
522		else jQuery( '#map-canvas-'+mocc ).css( 'display', 'none' );
523	}
524	else jQuery( '#map-canvas-'+mocc ).css( 'display', 'none' );
525
526	// Set numbar backgrounds and fonts
527	jQuery( '[id^=wppa-numbar-' + mocc + '-]' ).css( {	backgroundColor: wppaBGcolorNumbar,
528													borderColor: wppaBcolorNumbar,
529													fontFamily: wppaFontFamilyNumbar,
530													fontSize: wppaFontSizeNumbar,
531													color: wppaFontColorNumbar,
532													fontWeight: wppaFontWeightNumbar
533													});
534
535	jQuery( "#wppa-numbar-" + mocc + "-" + _wppaNxtIdx[mocc] ).css( {	backgroundColor: wppaBGcolorNumbarActive,
536																	borderColor: wppaBcolorNumbarActive,
537																	fontFamily: wppaFontFamilyNumbarActive,
538																	fontSize: wppaFontSizeNumbarActive,
539																	color: wppaFontColorNumbarActive,
540																	fontWeight: wppaFontWeightNumbarActive
541																	});
542
543	// too many?
544	if ( _wppaSlides[mocc].length > wppaNumbarMax ) {
545
546		var lo, hi, mx = _wppaSlides[mocc].length - 1, is = _wppaNxtIdx[mocc], arm = ( wppaNumbarMax - 1 ) / 2;
547
548		// Near left
549		if ( is < arm ) {
550			lo = 0;
551			hi = wppaNumbarMax - 1 - 1;
552			jQuery( "#wppa-nbar-"+ mocc + "-lodots" ).css({display:'none'});
553			jQuery( "#wppa-nbar-"+ mocc + "-hidots" ).css({display:'block'});
554		}
555		// Near right
556		else if ( is > ( mx - arm ) ) {
557			hi = mx;
558			lo = mx - wppaNumbarMax + 1 + 1;
559			jQuery( "#wppa-nbar-"+ mocc + "-lodots" ).css({display:'block'});
560			jQuery( "#wppa-nbar-"+ mocc + "-hidots" ).css({display:'none'});
561		}
562		// near center
563		else {
564			lo = is - arm + 1;
565			hi = is + arm + 0.5 - 1;
566			if ( lo < 2 ) {
567				jQuery( "#wppa-nbar-"+ mocc + "-lodots" ).css({display:'none'});
568				jQuery( "#wppa-nbar-"+ mocc + "-hidots" ).css({display:'block'});
569			}
570			else if ( hi > mx - 1 ) {
571				jQuery( "#wppa-nbar-"+ mocc + "-lodots" ).css({display:'block'});
572				jQuery( "#wppa-nbar-"+ mocc + "-hidots" ).css({display:'none'});
573
574			}
575			else {
576				jQuery( "#wppa-nbar-"+ mocc + "-lodots" ).css({display:'block'});
577				jQuery( "#wppa-nbar-"+ mocc + "-hidots" ).css({display:'block'});
578			}
579		}
580		var i = 0;
581		while ( i < _wppaSlides[mocc].length ) {
582			if ( i != 0 && i != mx && ( i < lo || i > hi ) ) {
583				jQuery( "#wppa-numbar-" + mocc + "-" + i ).css({display:'none'});
584			}
585			else {
586				jQuery( "#wppa-numbar-" + mocc + "-" + i ).css({display:'block'});
587			}
588			i++;
589		}
590	}
591
592    // first:
593    if ( _wppaFirst[mocc] ) {
594	    if ( _wppaCurIdx[mocc] != -1 ) {
595			wppaMakeTheSlideHtml( mocc, '0', _wppaCurIdx[mocc] );
596		}
597		wppaMakeTheSlideHtml( mocc, '1', _wppaNxtIdx[mocc] );
598
599		// Display name, description and comments
600		jQuery( "#imagedesc-"+mocc ).html( _wppaDsc[mocc][_wppaCurIdx[mocc]] );
601		jQuery( "#imagetitle-"+mocc ).html( wppaMakeNameHtml( mocc ) );
602
603		// Comments displayable?
604		if ( _wppaCommentHtml[mocc][_wppaCurIdx[mocc]] == 'void' ) {
605			jQuery( "#wppa-comments-"+mocc ).hide();
606			jQuery( "#wppa-comments-"+mocc ).html('');
607		}
608		else {
609			jQuery( "#wppa-comments-"+mocc ).show();
610			jQuery( "#wppa-comments-"+mocc ).html( _wppaCommentHtml[mocc][_wppaCurIdx[mocc]] );
611		}
612		jQuery( "#iptc-"+mocc ).html( _wppaIptcHtml[mocc][_wppaCurIdx[mocc]] );
613		jQuery( "#exif-"+mocc ).html( _wppaExifHtml[mocc][_wppaCurIdx[mocc]] );
614
615		// Display prev/next
616		if ( wppaSlideshowNavigationType == 'icons' ) {
617			var iconsize = wppaIconSize( mocc, '1.5em', false );
618			jQuery( '#prev-arrow-'+mocc ).html( wppaSvgHtml( 'Prev-Button', iconsize, false, true ) );
619			jQuery( '#next-arrow-'+mocc ).html( wppaSvgHtml( 'Next-Button', iconsize, false, true ) );
620		}
621		else {
622			if ( wppaIsMini[mocc] || wppaGetContainerWidth( mocc ) < wppaMiniTreshold ) {
623				jQuery( '#prev-arrow-'+mocc ).html( '&laquo;&nbsp;'+__( 'Previous', 'wp-photo-album-plus' ) );
624				jQuery( '#next-arrow-'+mocc ).html( __( 'Next', 'wp-photo-album-plus' )+'&nbsp;&raquo;' );
625			}
626			else {
627				jQuery( '#prev-arrow-'+mocc ).html( '&laquo;&nbsp;'+__( 'Previous photo', 'wp-photo-album-plus' ) );
628				jQuery( '#next-arrow-'+mocc ).html( __( 'Next photo', 'wp-photo-album-plus' )+'&nbsp;&raquo;' );
629			}
630		}
631
632		// Display Rating
633		if ( wppaIsMini[mocc] || wppaGetContainerWidth( mocc ) < wppaMiniTreshold ) {
634			jQuery( '#wppa-avg-rat-'+mocc ).html( __( 'Avg', 'wp-photo-album-plus' ) );
635			jQuery( '#wppa-my-rat-'+mocc ).html( __( 'Mine', 'wp-photo-album-plus' ) );
636		}
637		else {
638			jQuery( '#wppa-avg-rat-'+mocc ).html( __( 'Average&nbsp;rating', 'wp-photo-album-plus' ) );
639			jQuery( '#wppa-my-rat-'+mocc ).html( __( 'My&nbsp;rating', 'wp-photo-album-plus' ) );
640		}
641	}
642
643    // load next img ( backg )
644    else {
645		wppaMakeTheSlideHtml( mocc, bg, _wppaNxtIdx[mocc] );
646    }
647
648//	_wppaFirst[mocc] = false;
649
650	// Give free for a while to enable rendering of what we have done so far
651	setTimeout( '_wppaNextSlide_2( ' + mocc + ' )', 10 );	// to be continued after 10 ms
652}
653
654function _wppaNextSlide_2( mocc ) {
655
656	var fg = _wppaFg[mocc];
657	var bg = 1 - fg;
658
659	// Wait for load complete
660	var elm = document.getElementById( 'theimg' + bg + "-" + mocc );
661	if ( elm ) { // Exists
662		if ( 1 == elm.nodeType ) {											// Is html
663			if ( 'IMG' == elm.nodeName ) {									// Is an image
664				if ( ! elm.complete ) {										// Is not complete yet
665					setTimeout( '_wppaNextSlide_2( ' + mocc + ' )', 200 );	// Try again after 200 ms
666					return;
667				}
668			}
669			else if ( 'VIDEO' == elm.nodeName ) {
670
671				if ( elm.readyState < 4 ) {
672					setTimeout( '_wppaNextSlide_2( ' + mocc + ' )', 200 );	// Try again after 200 ms
673					return;
674				}
675				else {
676					if ( _wppaFirst[mocc] ) {
677						jQuery( elm ).css({display:''});
678						if ( wppaSlideVideoStart ) {
679							elm.play();
680						}
681					}
682				}
683			}
684		}
685	}
686	_wppaFirst[mocc] = false;
687
688	// Update lightbox
689	wppaUpdateLightboxes();
690
691	jQuery( '#wppa-slide-spin-' + mocc ).hide();
692
693	// Hide subtitles
694	if ( _wppaSSRuns[mocc] != -1 ) {	// not stop in progress
695		if ( ! _wppaToTheSame ) {
696			_wppaShowMetaData( mocc, 'hide' );
697		}
698	}
699
700	// change foreground
701	_wppaFg[mocc] = 1 - _wppaFg[mocc];
702	fg = _wppaFg[mocc];
703	bg = 1 - fg;
704	setTimeout( '_wppaNextSlide_3( ' + mocc + ' )', 10 );
705}
706
707function _wppaNextSlide_3( mocc ) {
708
709	var nw 		= _wppaFg[mocc];
710	var ol 		= 1 - nw;
711
712	var olIdx 	= _wppaCurIdx[mocc];
713	var nwIdx 	= _wppaNxtIdx[mocc];
714
715	var olSli	= "#theslide" + ol + "-" + mocc;
716	var nwSli 	= "#theslide" + nw + "-" + mocc;
717
718	var olImg	= "#theimg" + ol + "-" + mocc;
719	var nwImg	= "#theimg" + nw + "-" + mocc;
720
721	var w 		= parseInt( jQuery( olSli ).css( 'width' ) );
722	var dir 	= 'nil';
723
724	if ( olIdx == nwIdx ) dir = 'none';
725	if ( olIdx == nwIdx - 1 ) dir = 'left';
726	if ( olIdx == nwIdx + 1 ) dir = 'right';
727	if ( olIdx == _wppaSlides[mocc].length - 1 && 0 == nwIdx && wppaSlideWrap[mocc] ) dir = 'left';
728	if ( 0 == olIdx && nwIdx == _wppaSlides[mocc].length - 1 && wppaSlideWrap[mocc] ) dir = 'right';
729
730	// Not known yet?
731	if ( 'nil' == dir ) {
732		if ( olIdx < nwIdx ) dir = 'left';
733		else dir = 'right';
734	}
735
736	// Repair standard css
737	jQuery( olSli ).css( { marginLeft:0, width:w });
738	jQuery( nwSli ).css( { marginLeft:0, width:w });
739
740	wppaFormatSlide( mocc );
741
742	switch ( wppaAnimationType ) {
743
744		case 'fadeafter':
745			wppaFadeOut( olImg, wppaAnimationSpeed );
746
747			// For panos and videos:
748			jQuery('#theslide'+ol+'-'+mocc).find('canvas').fadeOut(wppaAnimationSpeed);
749			jQuery('#theslide'+ol+'-'+mocc).find('video').fadeOut(wppaAnimationSpeed);
750
751			setTimeout( wppaFadeIn( nwImg, wppaAnimationSpeed, _wppaNextSlide_4( mocc ) ), wppaAnimationSpeed );
752//			jQuery( nwImg ).delay( wppaAnimationSpeed ).fadeIn( wppaAnimationSpeed, _wppaNextSlide_4( mocc ) );
753			break;
754
755		case 'swipe':
756			switch ( dir ) {
757				case 'left':
758					wppaAnimate( olSli, { marginLeft: - w }, wppaAnimationSpeed, wppaEasingSlide );
759					jQuery( nwSli ).css( { marginLeft: w });
760					wppaFadeIn( nwImg, 10 );
761					wppaAnimate( nwSli, { marginLeft: 0 }, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
762					break;
763				case 'right':
764					wppaAnimate( olSli, { marginLeft: w }, wppaAnimationSpeed, wppaEasingSlide );
765					jQuery( nwSli ).css( { marginLeft: - w });
766					wppaFadeIn( nwImg, 10 );
767					wppaAnimate( nwSli, { marginLeft: 0 }, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
768					break;
769				case 'none':
770					wppaFadeIn( nwImg, 10 );
771					setTimeout( '_wppaNextSlide_4( ' + mocc + ' )', 10 );
772					break;
773			}
774			break;
775/*
776		case 'stackon':
777			switch ( dir ) {
778				case 'left':
779					jQuery( olSli ).css( {zIndex:80});
780					jQuery( nwSli ).css( {marginLeft:w+"px", zIndex:81});
781					wppaFadeIn( nwImg, 10 );
782					setTimeout( wppaFadeOut( olImg, 10 ), wppaAnimationSpeed );
783//					setTimeout( wppaFadeOut( olImg, 10 ), wppaAnimationSpeed );
784					wppaAnimate( nwSli, {marginLeft:0+"px"}, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
785					break;
786				case 'right':
787					jQuery( olSli ).css( {zIndex:80});
788					jQuery( nwSli ).css( {marginLeft:-w+"px", zIndex:81});
789					wppaFadeIn( nwImg, 10 );
790					setTimeout( wppaFadeOut( olImg, 10 ), wppaAnimationSpeed );
791					wppaAnimate( nwSli, {marginLeft:0+"px"}, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
792					break;
793				case 'none':
794					wppaFadeIn( nwImg, 10 );
795					setTimeout( '_wppaNextSlide_4( '+mocc+' )', 10 );
796					break;
797			}
798			break;
799
800		case 'stackoff':
801			switch ( dir ) {
802				case 'left':
803					jQuery( olSli ).css( {marginLeft:0, zIndex:81});
804					wppaAnimate( olSli, {marginLeft:-w+"px"}, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
805					jQuery( nwSli ).css( {marginLeft:0, zIndex:80});
806					wppaFadeIn( nwImg, 10 );
807					setTimeout( wppaFadeOut( olImg, 10 ), wppaAnimationSpeed );
808					break;
809				case 'right':
810					jQuery( olSli ).css( {marginLeft:0, zIndex:81});
811					wppaAnimate( olSli, {marginLeft:w+"px"}, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
812					jQuery( nwSli ).css( {marginLeft:0, zIndex:80});
813					wppaFadeIn( nwImg, 10 );
814					setTimeout( wppaFadeOut( olImg, 10 ), wppaAnimationSpeed );
815					break;
816				case 'none':
817					wppaFadeIn( nwImg, 10 );
818					setTimeout( '_wppaNextSlide_4( '+mocc+' )', 10 );
819					break;
820			}
821			break;
822
823		case 'turnover':
824			switch ( dir ) {
825				case 'left':
826/*	there is a z-order problem here, if you can fix it, i would be glad
827					jQuery( olSli ).css( {zIndex:81});
828					jQuery( olSli ).wppaAnimate( {width:0}, wppaAnimationSpeed, wppaEasingSlide );
829					jQuery( olImg ).wppaAnimate( {marginLeft:0, width:0, paddingLeft:0, paddingRight:0}, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
830					jQuery( nwSli ).css( {width:w, zIndex:80});
831					wppaFadeIn( nwImg, 10 );
832					jQuery( olImg ).fadeOut( 10 );
833					break;
834*//*
835				case 'right':
836					var nwImgWid = parseInt( jQuery( nwSli ).css( 'width' ) );
837					var nwMarLft = parseInt( jQuery( nwImg ).css( 'marginLeft' ) );
838					jQuery( olSli ).css( {zIndex:80});
839					jQuery( nwSli ).css( {zIndex:81, width:0});
840					jQuery( nwImg ).css( {maxWidth:0, marginLeft:0});
841					wppaFadeIn( nwImg, 10 );
842					wppaAnimate( nwsli, {width:w}, wppaAnimationSpeed, wppaEasingSlide );
843					wppaAnimate( nwImg, {maxWidth:nwImgWid, marginLeft:nwMarLft}, wppaAnimationSpeed, wppaEasingSlide, _wppaNextSlide_4( mocc ) );
844					setTimeout( wppaFadeOut( olImg, 10 ), wppaAnimationSpeed );
845					break;
846
847				case 'none':
848					wppaFadeIn( nwImg, 10 );
849					setTimeout( '_wppaNextSlide_4( '+mocc+' )', 10 );
850					break;
851				}
852			break;
853*/
854		default:
855//		case 'fadeover':
856			wppaFadeOut( olImg, wppaAnimationSpeed );
857			jQuery('#theslide'+ol+'-'+mocc).find('canvas').fadeOut(wppaAnimationSpeed);
858			jQuery('#theslide'+ol+'-'+mocc).find('video').fadeOut(wppaAnimationSpeed);
859			wppaFadeIn( nwImg, wppaAnimationSpeed, _wppaNextSlide_4( mocc ) );
860			break;
861	}
862}
863
864function _wppaNextSlide_4( mocc ) {
865
866
867	var nw 		= _wppaFg[mocc];
868	var ol 		= 1 - nw;
869	var olSli	= "#theslide" + ol + "-" + mocc;
870	var nwSli 	= "#theslide" + nw + "-" + mocc;
871
872	// Make sure title and onclick of the new image ( slide ) are in sight
873	jQuery( olSli ).css({ zIndex:80 });
874	jQuery( nwSli ).css({ zIndex:81 });
875
876    // Next is now current // put here for swipe
877	_wppaCurIdx[mocc] = _wppaNxtIdx[mocc];
878
879	wppaFormatSlide( mocc );
880
881	// Display counter and arrow texts
882	if ( wppaIsMini[mocc] || wppaGetContainerWidth( mocc ) < wppaMiniTreshold ) {
883		jQuery( '#counter-'+mocc ).html( ( _wppaCurIdx[mocc]+1 )+' / '+_wppaSlides[mocc].length );
884	}
885	else {
886		jQuery( '#counter-'+mocc ).html( __( 'Photo', 'wp-photo-album-plus' )+' '+( _wppaCurIdx[mocc]+1 )+' '+__( 'of', 'wp-photo-album-plus' )+' '+_wppaSlides[mocc].length );
887	}
888
889	// Update breadcrumb
890	jQuery( '#bc-pname-modal-' + mocc ).html( _wppaNames[mocc][_wppaCurIdx[mocc]] );
891	jQuery( '#bc-pname-' + mocc ).html( _wppaNames[mocc][_wppaCurIdx[mocc]] );
892
893	// Adjust filmstrip
894	_wppaAdjustFilmstrip( mocc, wppaEasingSlide );
895
896	// Set rating mechanism
897	_wppaSetRatingDisplay( mocc );
898
899	// Wait for almost next slide
900	setTimeout( '_wppaNextSlide_5( ' + mocc + ' )', _wppaTextDelay );
901}
902
903function _wppaNextSlide_5( mocc ) {
904
905	// If we are going to the same slide, there is no need to hide and restore the subtitles and commentframe
906	if ( ! _wppaToTheSame ) {
907
908		// Restore subtitles
909		var imageDescHtml = _wppaDsc[mocc][_wppaCurIdx[mocc]];
910
911		jQuery( '#imagedesc-'+mocc ).html( imageDescHtml );
912
913		if ( wppaHideWhenEmpty ) {
914			var desc = _wppaDsc[mocc][_wppaCurIdx[mocc]];
915			if ( '' == desc || '&nbsp;' == desc ) {
916				jQuery( '#descbox-'+mocc ).css( 'display', 'none' );
917			}
918			else {
919				jQuery( '#descbox-'+mocc ).css( 'display', '' );
920			}
921		}
922		jQuery( "#imagetitle-"+mocc ).html( wppaMakeNameHtml( mocc ) );
923
924		// Restore comments html
925		if ( _wppaCommentHtml[mocc][_wppaCurIdx[mocc]] == 'void' ) {
926			jQuery( "#wppa-comments-"+mocc ).hide();
927			jQuery( "#wppa-comments-"+mocc ).html('');
928		}
929		else {
930			jQuery( "#wppa-comments-"+mocc ).show();
931			jQuery( "#wppa-comments-"+mocc ).html( _wppaCommentHtml[mocc][_wppaCurIdx[mocc]] );
932		}
933
934		// Restor IPTC
935		jQuery( "#iptc-"+mocc ).html( _wppaIptcHtml[mocc][_wppaCurIdx[mocc]] );
936		jQuery( "#exif-"+mocc ).html( _wppaExifHtml[mocc][_wppaCurIdx[mocc]] );
937
938		// Restore share html
939		jQuery( "#wppa-share-"+mocc ).html( _wppaShareHtml[mocc][_wppaCurIdx[mocc]] );
940	}
941	_wppaToTheSame = false;					// This has now been worked out
942
943	// Find page for returning to thumbnails
944	if ( wppaThumbPageSize ) {
945		wppaThumbPage[mocc] = parseInt( ( ( wppaSlideOffset[mocc] | 0 ) + _wppaCurIdx[mocc] ) / wppaThumbPageSize ) + 1;
946	}
947	else {
948		wppaThumbPage[mocc] = 1;
949	}
950
951	// End of non wrapped show?
952	if ( _wppaSSRuns[mocc] &&
953		! wppaSlideWrap[mocc] &&
954		( ( _wppaCurIdx[mocc] + 1 ) == _wppaSlides[mocc].length ) ) {
955			_wppaIsBusy[mocc] = false;
956			_wppaStop( mocc );	// stop
957			return;
958	}
959
960	// Re-display the metadata
961	_wppaShowMetaData( mocc, 'show' );
962
963	// Almost done, finalize
964	if ( _wppaTP[mocc] != -2 ) {								// A Toggle pending?
965		var index = _wppaTP[mocc];								// Remember the pending startstop request argument
966		_wppaTP[mocc] = -2;										// Reset the pending toggle
967		_wppaDidGoto[mocc] = false;								// Is worked out now
968		_wppaIsBusy[mocc] = false;								// No longer busy
969		if ( ! wppaIsMini[mocc] ) { 							// Not in a widget
970			_bumpViewCount( _wppaId[mocc][_wppaCurIdx[mocc]] );	// Register a view
971		}
972		_wppaDoAutocol(mocc, 'next_5');
973		wppaStartStop( mocc, index );							// Do as if the toggle request happens now
974		return;
975	}
976	else {														// No toggle pending
977		wppaUpdateLightboxes(); 								// Refresh lightbox
978
979		// Update url and title if ( ( this is non-mini ) AND
980		// ( this is the only running non-mini OR there are no running non-minis ) )
981		if ( ! wppaIsMini[mocc] ) {		// This is NOT a widget
982
983			// Prepare visual url ( for addressline )
984			var visurl = _wppaShareUrl[mocc][_wppaCurIdx[mocc]];
985
986			// Update possible QR Widget
987			if ( typeof( wppaQRUpdate ) != 'undefined' ) {
988				wppaQRUpdate( _wppaShareUrl[mocc][_wppaCurIdx[mocc]] );
989			}
990
991			// Push state if not slphoto
992			if ( _wppaSlides[mocc].length > 1 ) {
993				wppaPushStateSlide( mocc, _wppaCurIdx[mocc], visurl );
994			}
995		}
996
997		// If running: Wait for next slide
998		if ( _wppaSSRuns[mocc] ) {
999
1000			// Are we at the end of a page?
1001			if ( ( _wppaCurIdx[mocc] + 1 ) == _wppaSlides[mocc].length ) {
1002
1003				var npb = jQuery( '#wppa-next-pagelink-' + mocc );
1004				var fpb = jQuery( '#wppa-first-pagelink-' + mocc );
1005
1006				// If there is a non-hidden next page button, trigger next page after timeout
1007				if ( npb.length > 0 && jQuery( npb ).css('visibility') != 'hidden' ) {
1008					setTimeout( function() {
1009	//					wppaSavedSlideshowTimeout[mocc] = _wppaTimeOut[mocc];
1010						wppaSlideInitRunning[mocc] = 'start';
1011						jQuery( '#wppa-next-pagelink-' + mocc ).trigger( 'click' );
1012					}, wppaGetSlideshowTimeout( mocc, 'next page trigger' ) );
1013				}
1014
1015				// If there is a (hidden) first page button, trigger it after timeout
1016				else if ( fpb.length > 0 ) {
1017					setTimeout( function() {
1018	//					wppaSavedSlideshowTimeout[mocc] = _wppaTimeOut[mocc];
1019						jQuery( fpb ).trigger( 'click' );
1020					}, wppaGetSlideshowTimeout( mocc, 'first page trigger' ) );
1021				}
1022
1023				// Just wait for next slide in current page
1024				else {
1025					wppaSlideTimer[mocc] = setTimeout( '_wppaNextSlide( '+mocc+', "auto" )', wppaGetSlideshowTimeout( mocc, 'just wait for next in current(1)' ) );
1026				}
1027			}
1028
1029			// Just wait for next slide in current page
1030			else {
1031				wppaSlideTimer[mocc] = setTimeout( '_wppaNextSlide( '+mocc+', "auto" )', wppaGetSlideshowTimeout( mocc, 'just wait for next in current(2)' ) );
1032			}
1033		}
1034//		else {
1035//			_wppaStopping[mocc] = false;
1036//		}
1037	}
1038
1039	// If glossery tooltip on board...
1040	jQuery(document).trigger( 'glossaryTooltipReady' );
1041
1042	_wppaDidGoto[mocc] = false;								// Is worked out now
1043	_wppaIsBusy[mocc] = false;								// No longer busy
1044	if ( ! wppaIsMini[mocc] ) { 							// Not in a widget
1045		_bumpViewCount( _wppaId[mocc][_wppaCurIdx[mocc]] );	// Register a view
1046	}
1047
1048//	wppaStopAudio( mocc );
1049
1050/*
1051	if ( wppaSlideAudioStart ) {
1052		var elms = jQuery( '.wppa-audio-'+_wppaId[mocc][_wppaCurIdx[mocc]]+'-'+mocc );
1053		if ( elms.length > 0 ) {
1054			var audio = elms[elms.length-1];
1055			if ( audio ) {
1056				if ( ! wppaAudioPlaying[mocc] ) {
1057					audio.play();
1058				}
1059			}
1060		}
1061	}
1062*/
1063	// Hide rightclick optionally
1064	wppaProtect();
1065
1066	// Trigger resize for modal containers. This will diturb lightbox, so we do this only when lightbox is not open
1067	if ( jQuery('#wppa-overlay-bg').css('display') == 'none' ) {
1068		jQuery(window).trigger('resize');
1069	}
1070
1071	// Hide possible zoom cotrolbar
1072	if ( ! wppaHasControlbar ) {
1073		jQuery( '#wppa-pctl-div-'+mocc ).hide();
1074	}
1075}
1076
1077// Format a slide
1078function wppaFormatSlide( mocc ) {
1079
1080	// Slide present in this occ?
1081	var imgid    = 'theimg'+_wppaFg[mocc]+'-'+mocc;
1082	var elm      = document.getElementById( imgid );
1083
1084	if ( ! elm ) { // Its a pano or zoomable
1085		jQuery( '.bbb-'+mocc ).css( {width:'33%',height:'calc(100% - 40px)'} );
1086		return;
1087	}
1088
1089	// vars we have
1090	var slideid  = 'theslide'+_wppaFg[mocc]+'-'+mocc;
1091	var frameid  = 'slide_frame-'+mocc;
1092	var contw    = wppaGetContainerWidth(mocc); //jQuery('#wppa-container-'+mocc).width();
1093		wppaColWidth[mocc] = contw;
1094	var audios 	 = jQuery( '.wppa-audio-'+mocc );
1095	var natwidth  = elm.naturalWidth;
1096		if ( typeof( natwidth )=='undefined' ) natwidth = parseInt( elm.style.maxWidth );
1097	var natheight = elm.naturalHeight;
1098		if ( typeof( natheight )=='undefined' ) natheight = parseInt( elm.style.maxHeight );
1099	var aspect    = wppaAspectRatio[mocc];
1100	var fullsize  = wppaFullSize[mocc];
1101	var delta     = wppaFullFrameDelta[mocc];
1102
1103	// Switches we have
1104	var ponly   = wppaPortraitOnly[mocc];
1105	var valign  = wppaFullValign[mocc]; if ( typeof( valign )=='undefined' ) valign = 'none';
1106	var halign  = wppaFullHalign[mocc]; if ( typeof( halign )=='undefined' ) halign = 'none';
1107	var stretch = wppaStretch;
1108
1109	// vars to be calculated:
1110	var imgw, imgh;		// image width and height
1111	var margl, margt;	// image margins
1112	var slidew, slideh;	// slide width and height
1113	var framew, frameh;	// frame
1114
1115	// Calculate
1116	if ( ponly ) {
1117		imgw = contw - delta;
1118		imgh = parseInt( imgw * natheight / natwidth );
1119		margl = 0;
1120		margt = 0;
1121		slidew = contw;
1122		slideh = imgh + delta;
1123		framew = contw;
1124		frameh = slideh;
1125		// Size
1126		jQuery( '#'+frameid ).css( {width:framew, height:frameh});
1127		jQuery( '#'+slideid ).css( {width:slidew, height:slideh});
1128		jQuery( '#'+imgid ).css( {width:imgw, height:imgh});
1129	}
1130	else {
1131
1132		// not 'ponly' so we have a fixed display ratio. First assume the container is the hor limit
1133		framew = contw;
1134
1135		// If the fullsize ( Slideshow -> I -> Item 1 ) is smaller than the container width The frame is scaled down to fit the fullsize
1136		if ( fullsize < contw ) {
1137			framew = fullsize;				// The fullsize appears to be the hor limit
1138		}
1139
1140		// Now calc the height using the width and the ratio
1141		frameh = parseInt( framew * aspect );	// Always obey the occurences aspect ratio
1142		slidew = framew;
1143		slideh = frameh;
1144		if ( stretch || natwidth >= ( framew-delta ) || natheight >= ( frameh-delta ) ) {	// Image big enough
1145			if ( ( ( natheight+delta ) / ( natwidth+delta ) ) > aspect ) {	// vertical limit
1146				imgh = frameh - delta;
1147				imgw = parseInt( imgh * natwidth / natheight );
1148			}
1149			else {	// horizontal limit
1150				imgw = framew - delta;
1151				imgh = parseInt( imgw * natheight / natwidth );
1152			}
1153		}
1154		else {															// Image too small
1155			imgw = natwidth;
1156			imgh = natheight;
1157		}
1158
1159		// Align vertical
1160		if ( valign != 'default' && valign != 'none' ) {
1161			switch ( valign ) {
1162				case 'top':
1163					margt = 0;
1164					break;
1165				case 'center':
1166					margt = parseInt( ( frameh - ( imgh+delta ) ) / 2 );
1167					break;
1168				case 'bottom':
1169					margt = frameh - ( imgh+delta );
1170					break;
1171				case 'fit':
1172					margt = 0;
1173					frameh = imgh + delta;
1174					slideh = imgh + delta;
1175					break;
1176				default:
1177				//	alert( 'Unknown v align:'+valign+' occ='+mocc );
1178			}
1179			jQuery( '#'+imgid ).css( {marginTop:margt, marginBottom:0});
1180		}
1181
1182		// Size ( after v align because 'fit' changes the frameh and slidh )
1183		jQuery( '#'+frameid ).css( {width:framew, height:frameh});
1184		jQuery( '#'+slideid ).css( {width:slidew, height:slideh});
1185		jQuery( '#'+imgid ).css( {width:imgw, height:imgh});
1186
1187		// Align horizontal
1188		if ( valign != 'default' && valign != 'none' && halign != 'none' && halign != 'default' ) {
1189			switch ( halign ) {
1190				case 'left':
1191					jQuery( '#'+imgid ).css( {marginLeft:0, marginRight:'auto'});
1192					break;
1193				case 'center':
1194					jQuery( '#'+imgid ).css( {marginLeft:'auto', marginRight:'auto'});
1195					break;
1196				case 'right':
1197					jQuery( '#'+imgid ).css( {marginLeft:'auto', marginRight:0});
1198					break;
1199				default:
1200					jQuery( '#'+imgid ).css( {marginLeft:'auto', marginRight:'auto'});
1201			}
1202		}
1203
1204		// Size audio
1205		var h = jQuery( audios ).height();
1206		var l = ( framew - imgw ) / 2;
1207		if ( h && h > 0 ) {
1208			wppaAudioHeight = h;
1209			jQuery( audios ).css({height:wppaAudioHeight,width:imgw,left:l});
1210		}
1211	}
1212
1213	var hrUrl = _wppaHiresUrl[mocc][_wppaCurIdx[mocc]] || '';
1214	var isPdf = hrUrl.substr( hrUrl.length - 4, hrUrl.length ) == '.pdf';
1215	if ( isPdf ) {
1216		jQuery( '#'+slideid ).css( {width:'100%', height:'100%'});
1217	}
1218
1219	// Size Big Browse Buttons.
1220	var bbbwidth 	= parseInt( framew / 3 );
1221//	var leftmarg 	= bbbwidth*2;
1222//	var bbbheight;
1223
1224	// Make sure they do not cover the audio controlbar.
1225//	if ( audios.length > 0 ) {
1226//		bbbheight 	= frameh - wppaAudioHeight - wppaSlideBorderWidth - margt;
1227//	}
1228//	else {
1229//		bbbheight 	= frameh;
1230//	}
1231
1232	jQuery( '#bbb-'+mocc+'-l' ).css( {width:bbbwidth});
1233	jQuery( '#bbb-'+mocc+'-r' ).css( {width:bbbwidth});
1234}
1235
1236// Make name
1237function wppaMakeNameHtml( mocc ) {
1238
1239	if ( _wppaCurIdx[mocc] < 0 ) return '';
1240
1241	if ( _wppaFullNames[mocc][_wppaCurIdx[mocc]] == 'void' ) {
1242		jQuery('#namebox-'+mocc).hide();
1243		return '';
1244	}
1245	else {
1246		jQuery('#namebox-'+mocc).show();
1247	}
1248
1249	return wppaRepairBrTags( _wppaFullNames[mocc][_wppaCurIdx[mocc]] );
1250}
1251
1252function wppaVideoSlideOnPause(elm,mocc) {
1253
1254	// Pause event at the end ?
1255	if ( elm.ended ) {
1256
1257		// Indicate that the video no longer playes
1258		wppaVideoPlaying[mocc] = false;
1259	}
1260
1261	// If we want to stop the running show when manually paused
1262	else if ( wppaSlideVideoPauseStop && 		// we want to stop the running show on pause
1263		 elm.readyState == 4 &&				// must be loaded to a playable state
1264		 elm.played.length > 0 && 			// must have run
1265		 elm.played.end(0) > 0 ) { 			// must have run for some time
1266			_wppaStop(mocc); 				// stop the show
1267			wppaVideoPlaying[mocc] = false;	// Indicate that the video no longer playes
1268	}
1269}
1270
1271function wppaMakeTheSlideHtml( mocc, bgfg, idx ) {
1272
1273	var imgVideo = ( _wppaIsVideo[mocc][idx] ) ? 'video' : 'img';
1274	var theHtml;
1275	var url;
1276	var theTitle = 'title';
1277	if ( wppaLightBox[mocc] == 'wppa') theTitle = 'data-lbtitle';
1278	var mmEvents = ' onpause="wppaVideoSlideOnPause(this,'+mocc+');" onplay="wppaVideoPlaying['+mocc+'] = true;"';
1279	var hrUrl;
1280	var isPdf;
1281	var isPanorama = ( _wppaPanoramaHtml[mocc][idx].length > 0 );
1282	wppaHasControlbar = isPanorama;
1283
1284//	Stop possible zooom/pano image
1285	jQuery("body").trigger("quitimage",[mocc]);
1286
1287	// No links on panos, so quickly done
1288	if ( isPanorama ) {
1289		theHtml = _wppaPanoramaHtml[mocc][idx].replace( /title=""/g, '' );
1290
1291		jQuery( "#theslide"+(1-bgfg)+"-"+mocc ).html( '' );
1292		jQuery( "#theslide"+bgfg+"-"+mocc ).html( theHtml );
1293
1294		var h = wppaGetContainerWidth(mocc) * wppaAspectRatio[mocc];
1295//		if ( parseInt(_wppaPanControlHeight[mocc][idx] ) > 0 ) {
1296//			h += parseInt(_wppaPanControlHeight[mocc][idx]) + 5;
1297//		}
1298		jQuery( "#slide_frame-"+mocc ).css({height:h});
1299// console.log('sl cw='+wppaGetContainerWidth(mocc)+', ratio='+wppaAspectRatio[mocc]);
1300// console.log('sl h = '+h);
1301		return;
1302	}
1303
1304	hrUrl = _wppaHiresUrl[mocc][idx] || '';
1305	isPdf = hrUrl.substr( hrUrl.length - 4, hrUrl.length ) == '.pdf';
1306
1307	// Link url explicitly given ?
1308	if ( _wppaLinkUrl[mocc][idx] != '' ) {
1309		if ( wppaSlideToFullpopup ) {
1310			theHtml = 	'<a onclick="wppaStopAudio();wppaStopShow('+mocc+');'+_wppaLinkUrl[mocc][idx]+'" target="'+_wppaLinkTarget[mocc][idx]+'" title="'+_wppaLinkTitle[mocc][idx]+'">'+
1311							( isPdf ? '<iframe '+mmEvents+' src="'+hrUrl+'" title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" style="width:100%;height:100%;" ></iframe>' :
1312							'<'+imgVideo+mmEvents+' title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" '+_wppaSlides[mocc][idx] ) +
1313						'</a>';
1314		}
1315		else {
1316			theHtml = 	'<a onclick="_bumpClickCount(\''+_wppaId[mocc][idx]+'\');wppaStopAudio();wppaStopShow('+mocc+');window.open(\''+_wppaLinkUrl[mocc][idx]+'\', \''+_wppaLinkTarget[mocc][idx]+'\');" title="'+_wppaLinkTitle[mocc][idx]+'">'+
1317							( isPdf ? '<iframe '+mmEvents+' src="'+hrUrl+'" title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" style="width:100%;height:100%;" ></iframe>' :
1318							'<'+imgVideo+mmEvents+' title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" '+_wppaSlides[mocc][idx] ) +
1319						'</a>';
1320		}
1321	}
1322
1323	// No url, maybe lightbox?
1324	else {
1325
1326		// No Lightbox
1327		if ( wppaLightBox[mocc] == '' ) {
1328
1329			if ( isPdf ) {
1330				theHtml = '<iframe '+mmEvents+' src="'+hrUrl+'" title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" style="width:100%;height:100%;" ></iframe>';
1331			}
1332			else {
1333				theHtml = '<'+imgVideo+mmEvents+' title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" '+_wppaSlides[mocc][idx];
1334			}
1335		}
1336
1337		// Lightbox
1338		else {
1339			var html = '';
1340			var i = 0;
1341			var set = wppaLightboxSingle[mocc] ? '' : '[slide-'+mocc+'-'+bgfg+']';
1342
1343			// Before current slide	// This does NOT work on lightbox 3 !
1344			while ( i<idx ) {
1345
1346				// Hi res?
1347				if ( wppaOvlHires || ( wppaLightBox[mocc] != 'wppa' ) ) {
1348					url = _wppaHiresUrl[mocc][i];
1349				}
1350				else {
1351					url = wppaMakeFullsizeUrl( _wppaUrl[mocc][i] );
1352				}
1353
1354				hrUrl 	= _wppaHiresUrl[mocc][i] || '';
1355				isPdf 	= hrUrl.substr( hrUrl.length - 4, hrUrl.length ) == '.pdf';
1356
1357				html += '<a href="'+url+'"' +
1358						( ( _wppaIsVideo[mocc][i] ) ?
1359							' data-videonatwidth="'+_wppaVideoNatWidth[mocc][i]+'"' +
1360							' data-videonatheight="'+_wppaVideoNatHeight[mocc][i]+'"' +
1361							' data-videohtml="'+encodeURI( _wppaVideoHtml[mocc][i] )+'"' : '' ) +
1362						( isPdf ? ' data-pdfhtml="src=\''+hrUrl+'\'"' : '' ) +
1363						( ( _wppaAudioHtml[mocc][i] != '' ) ?
1364							' data-audiohtml="'+encodeURI( _wppaAudioHtml[mocc][i] )+'"' : '' ) +
1365							' data-id="'+_wppaId[mocc][i]+'"' +
1366						' '+theTitle+'="'+_wppaLbTitle[mocc][i]+'"' +
1367						' '+wppaRel+'="'+wppaLightBox[mocc]+set+'"></a>';
1368				i++;
1369			}
1370
1371			// Current slide
1372			// Hi res?
1373			if ( wppaOvlHires || ( wppaLightBox[mocc] != 'wppa' ) ) {
1374				url = _wppaHiresUrl[mocc][idx];
1375			}
1376			else {
1377				url = wppaMakeFullsizeUrl( _wppaUrl[mocc][idx] );
1378			}
1379
1380			hrUrl 	= _wppaHiresUrl[mocc][idx];
1381			isPdf 	= hrUrl.substr( hrUrl.length - 4, hrUrl.length ) == '.pdf';
1382
1383			var onClick = ' onclick="wppaStopAudio();wppaStopShow('+mocc+');"';
1384
1385			html += '<a href="'+url+'"' +
1386					onClick +
1387					' style="cursor:pointer;"' +
1388					' target="'+_wppaLinkTarget[mocc][idx]+'"' +
1389					( ( _wppaIsVideo[mocc][i] ) ?
1390						' data-videonatwidth="'+_wppaVideoNatWidth[mocc][idx]+'"' +
1391						' data-videonatheight="'+_wppaVideoNatHeight[mocc][idx]+'"' +
1392						' data-videohtml="'+encodeURI( _wppaVideoHtml[mocc][idx] )+'"' : '' ) +
1393					( isPdf ? ' data-pdfhtml="src=\''+hrUrl+'\'"' : '' ) +
1394					( ( _wppaAudioHtml[mocc][i] != '' ) ?
1395						' data-audiohtml="'+encodeURI( _wppaAudioHtml[mocc][idx] )+'"' : '' ) +
1396						' data-id="'+_wppaId[mocc][idx]+'"' +
1397					' '+theTitle+'="'+_wppaLbTitle[mocc][idx]+'"' +
1398					' '+wppaRel+'="'+wppaLightBox[mocc]+set+'"' + '>' +
1399						( isPdf ?
1400							'<iframe '+mmEvents+' src="'+hrUrl+'" title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" style="width:100%;height:100%;" ></iframe>' :
1401							'<'+imgVideo+mmEvents+' title="'+_wppaLinkTitle[mocc][idx]+'" id="theimg'+bgfg+'-'+mocc+'" '+_wppaSlides[mocc][idx]
1402						)+
1403					'</a>';
1404
1405			// After current slide // This does NOT work on lightbox 3 !
1406			i = idx + 1;
1407			while ( i<_wppaUrl[mocc].length ) {
1408
1409				// H ires?
1410				if ( wppaOvlHires || ( wppaLightBox[mocc] != 'wppa' ) ) {
1411					url = _wppaHiresUrl[mocc][i];
1412				}
1413				else {
1414					url = wppaMakeFullsizeUrl( _wppaUrl[mocc][i] );
1415				}
1416
1417				hrUrl 	= _wppaHiresUrl[mocc][i];
1418				isPdf 	= hrUrl.substr( hrUrl.length - 4, hrUrl.length ) == '.pdf';
1419
1420				html += '<a href="'+url+'"' +
1421						( ( _wppaIsVideo[mocc][i] ) ?
1422							' data-videonatwidth="'+_wppaVideoNatWidth[mocc][i]+'"' +
1423							' data-videonatheight="'+_wppaVideoNatHeight[mocc][i]+'"' +
1424							' data-videohtml="'+encodeURI( _wppaVideoHtml[mocc][i] )+'"' : '' ) +
1425							( isPdf ? ' data-pdfhtml="src=\''+hrUrl+'\'"' : '' ) +
1426						( ( _wppaAudioHtml[mocc][i] != '' ) ?
1427							' data-audiohtml="'+encodeURI( _wppaAudioHtml[mocc][i] )+'"' : '' ) +
1428							' data-id="'+_wppaId[mocc][i]+'"' +
1429						' '+theTitle+'="'+_wppaLbTitle[mocc][i]+'"' +
1430						' '+wppaRel+'="'+wppaLightBox[mocc]+set+'"' + '></a>';
1431				i++;
1432			}
1433
1434			theHtml = html;
1435		}
1436	}
1437
1438	// Audio?
1439	if ( _wppaAudioHtml[mocc][idx] != '' ) {
1440		theHtml += 	'<audio' +
1441						' controls' +
1442						' id="wppa-audio-'+_wppaId[mocc][idx]+'-'+mocc+'"' +
1443						' class="wppa-audio-'+mocc+' wppa-audio-'+_wppaId[mocc][idx]+'-'+mocc+'"' +
1444						' data-from="wppa"' +
1445						( wppaSlideAudioStart && wppaLightBox[mocc] == '' ? ' autoplay' : '' ) +
1446						' onplay="wppaAudioPlaying['+mocc+'] = true;"' +
1447						' onpause="wppaAudioPlaying['+mocc+'] = false"' +
1448						' style="' +
1449							'position:relative;' +
1450							'top:-'+( wppaAudioHeight + wppaSlideBorderWidth )+'px;' +
1451							'z-index:10;' +
1452							'width:'+_wppaVideoNatWidth[mocc][idx]+'px;' +
1453
1454							'padding:0;' +
1455							'box-sizing:border-box;' +
1456							'"' +
1457						' >' +
1458							_wppaAudioHtml[mocc][idx] +
1459					'</audio>';
1460	}
1461
1462	// Remove empty titles for browsers that display empty tooltip boxes
1463	theHtml = theHtml.replace( /title=""/g, '' );
1464
1465	jQuery( "#theslide"+bgfg+"-"+mocc ).html( theHtml );	// nieuw
1466
1467}
1468
1469// Adjust all filmstrips
1470function wppaAdjustAllFilmstrips( easing ) {
1471
1472	jQuery(".wppa-filmstrip").each(function(){
1473		var divId = jQuery(this).attr('id');
1474		var mocc = divId.substr(15);
1475		_wppaAdjustFilmstrip(mocc, easing);
1476	});
1477}
1478
1479// Adjust the filmstrip
1480var wppaLastAnimFilmLoc = [];
1481function _wppaAdjustFilmstrip( mocc, easing ) {
1482
1483	// Maybe filmonly continuous, in this case easing is always linear
1484	if ( easing != 'linear' ) easing = wppaEasingSlide;
1485
1486	if ( ! document.getElementById( 'wppa-filmstrip-'+mocc ) ) return;	// No filmstrip this mocc
1487	if ( ! _wppaSlides[mocc] ) return;
1488
1489	var isFilmOnly = ! document.getElementById( 'slide_frame-'+mocc );
1490	if ( ! wppaLastAnimFilmLoc[mocc] ) wppaLastAnimFilmLoc[mocc] = 0;
1491
1492	// If not visible filmonly, quit
1493	if ( isFilmOnly ) {
1494		var elm = jQuery('#wppa-filmstrip-'+mocc);
1495		if ( ! wppaIsElementInViewport( elm ) ) return;
1496	}
1497
1498	// Remove class from active thumb
1499	if ( ! isFilmOnly ) {
1500		jQuery( '.wppa-film-'+mocc ).find('img').removeClass( 'wppa-filmthumb-active' );
1501		jQuery( '.wppa-film-'+mocc ).find('canvas').removeClass( 'wppa-filmthumb-active' );
1502	}
1503
1504	if ( ! _wppaFilmNoMove[mocc] || ! wppaFilmInit[mocc] ) {
1505		wppaFilmWindowLen = wppaGetContainerWidth(mocc) - wppaFilmStripAreaDelta[mocc];
1506		jQuery( '#filmwindow-'+mocc ).width(wppaFilmWindowLen);
1507
1508		var loc = wppaFilmWindowLen / 2 - ( _wppaCurIdx[mocc] + 0.5 + wppaPreambule[mocc] ) * wppaThumbnailPitch[mocc] - wppaFilmStripMargin[mocc];
1509
1510		if ( wppaFilmShowGlue ) {
1511			loc -= ( wppaFilmStripMargin[mocc] * 2 + 2 );	// Glue
1512		}
1513		var loc_1 	= loc + wppaThumbnailPitch[mocc];		// loc -1
1514		var loc_n1 	= loc - wppaThumbnailPitch[mocc]; 	// loc +1
1515		var speed 	= wppaAnimationSpeed;
1516		if ( ! wppaFilmInit[mocc] ) {
1517			speed = 1;
1518		}
1519
1520		// If going from last to first, jump to -1 and animate to 0
1521		if ( _wppaCurIdx[mocc] == 0 && _wppaLastIdx[mocc] == ( _wppaSlides[mocc].length -1 ) ) {
1522			jQuery( '#wppa-filmstrip-'+mocc ).css( {marginLeft: loc_1+'px'} );
1523			if ( wppaLastAnimFilmLoc[mocc] != loc ) {
1524				wppaAnimate( '#wppa-filmstrip-'+mocc, {marginLeft:loc}, speed, easing );
1525				wppaLastAnimFilmLoc[mocc] = loc;
1526			}
1527		}
1528
1529		// If going from first to last, jump to n+1 and animate to n
1530		else if ( _wppaLastIdx[mocc] == 0 && _wppaCurIdx[mocc] == ( _wppaSlides[mocc].length -1 ) ) {
1531			jQuery( '#wppa-filmstrip-'+mocc ).css( {marginLeft:loc_n1} );
1532			if ( wppaLastAnimFilmLoc[mocc] != loc ) {
1533				wppaAnimate( '#wppa-filmstrip-'+mocc, {marginLeft:loc}, speed, easing );
1534				wppaLastAnimFilmLoc[mocc] = loc;
1535			}
1536		}
1537
1538		// The normal situation, jump to n-1 if required and animate to n
1539		else {
1540			var current = parseInt( jQuery( '#wppa-filmstrip-'+mocc ).css( 'margin-left' ) );
1541			var target = parseInt(loc);
1542			var pitch = wppaThumbnailPitch[mocc];
1543
1544			if ( _wppaSSRuns[mocc] ) {
1545				var r = 0;
1546				if ( target < ( current - pitch * 2 ) ) r = 1;
1547				if ( target > current ) r = 2;
1548				if ( r ) {
1549					jQuery( '#wppa-filmstrip-'+mocc ).css( {marginLeft: ( target + pitch ) } );
1550				}
1551			}
1552			else {
1553				if ( target < ( current - pitch * 1.5 ) || target > ( current + pitch * 1.5 ) ) {
1554					jQuery( '#wppa-filmstrip-'+mocc ).css( {marginLeft:target} );
1555				}
1556			}
1557
1558			// Animate to n
1559			wppaAnimate( '#wppa-filmstrip-'+mocc, {marginLeft:loc}, speed, easing );
1560			wppaLastAnimFilmLoc[mocc] = loc;
1561			wppaFilmInit[mocc] = true;
1562		}
1563
1564		_wppaLastIdx[mocc] = _wppaCurIdx[mocc];
1565	}
1566
1567	else {
1568		_wppaFilmNoMove[mocc] = false; // reset
1569	}
1570
1571	// Fix titles
1572	if ( ! isFilmOnly && _wppaCurIdx[mocc] != -1 ) {
1573		var from = _wppaCurIdx[mocc] - 10; if ( from < 0 ) from = 0;
1574		var to = _wppaCurIdx[mocc] + 10; if ( to > _wppaSlides[mocc].length ) to = _wppaSlides[mocc].length;
1575		var index = 0;
1576		while ( index < _wppaSlides[mocc].length ) {
1577
1578			var html = jQuery( '#film_wppatnf_'+_wppaId[mocc][index]+'_'+mocc ).html();
1579
1580			if ( html ) {
1581
1582				// Fit title in
1583				if ( jQuery( '#wppa-film-'+index+'-'+mocc ).attr( 'data-title' ) != '' ) {
1584					jQuery( '#wppa-film-'+index+'-'+mocc ).attr( 'title', jQuery( '#wppa-film-'+index+'-'+mocc ).attr( 'data-title' ) );
1585					jQuery( '#wppa-pre-'+index+'-'+mocc ).attr( 'title', jQuery( '#wppa-film-'+index+'-'+mocc ).attr( 'data-title' ) );
1586				}
1587				else if ( wppaFilmThumbTitle != '' && _wppaCurIdx[mocc] == index ) {
1588					jQuery( '#wppa-film-'+index+'-'+mocc ).attr( 'title', wppaFilmThumbTitle );
1589					jQuery( '#wppa-pre-'+index+'-'+mocc ).attr( 'title', wppaFilmThumbTitle );
1590				}
1591				else {
1592					jQuery( '#wppa-film-'+index+'-'+mocc ).attr( 'title', wppaClickToView + ' ' + _wppaFilmThumbTitles[mocc][index] );
1593					jQuery( '#wppa-pre-'+index+'-'+mocc ).attr( 'title', wppaClickToView + ' ' + _wppaFilmThumbTitles[mocc][index] );
1594				}
1595			}
1596			index++;
1597		}
1598	}
1599
1600	// Apply class to active filmthumb
1601	if ( ! isFilmOnly ) {
1602		jQuery( '#film_wppatnf_'+_wppaId[mocc][_wppaCurIdx[mocc]]+'_'+mocc ).find('img').addClass( 'wppa-filmthumb-active' );
1603		jQuery( '#film_wppatnf_'+_wppaId[mocc][_wppaCurIdx[mocc]]+'_'+mocc ).find('canvas').addClass( 'wppa-filmthumb-active' );
1604	}
1605}
1606
1607function _wppaNext( mocc ) {
1608
1609	// Check for end of non wrapped show
1610	if ( ! wppaSlideWrap[mocc] && _wppaCurIdx[mocc] == ( _wppaSlides[mocc].length -1 ) ) return;
1611
1612	// Find next index
1613	_wppaNxtIdx[mocc] = _wppaCurIdx[mocc] + 1;
1614
1615	// End of page? go to start of next page
1616	if ( _wppaNxtIdx[mocc] == _wppaSlides[mocc].length ) {
1617
1618		var npb = jQuery( '#wppa-next-pagelink-' + mocc );
1619		var fpb = jQuery( '#wppa-first-pagelink-' + mocc );
1620
1621		// If there is a non-hidden next page button, trigger next page after timeout
1622		if ( npb.length > 0 && jQuery( npb ).css('visibility') != 'hidden' ) {
1623			wppaSlideInitRunning[mocc] = ( _wppaSSRuns[mocc] ? 'start' : 'stopnext' );
1624			jQuery( '#wppa-next-pagelink-' + mocc ).trigger( 'click' );
1625			return;
1626		}
1627
1628		// If there is a (hidden) first page button, trigger it after timeout
1629		else if ( fpb.length > 0 ) {
1630			wppaSlideInitRunning[mocc] = ( _wppaSSRuns[mocc] ? 'start' : 'stopnext' );
1631			jQuery( fpb ).trigger( 'click' );
1632			return;
1633		}
1634
1635		// Same page
1636		else {
1637			_wppaNxtIdx[mocc] = 0;
1638			_wppaNextSlide( mocc, 0 );
1639		}
1640	}
1641
1642	// The normal case
1643	else {
1644		_wppaNextSlide( mocc, 0 );
1645	}
1646}
1647
1648function _wppaNextN( mocc, n ) {
1649
1650	// Check for end of non wrapped show
1651	if ( ! wppaSlideWrap[mocc] && _wppaCurIdx[mocc] >= ( _wppaSlides[mocc].length - n ) ) return;
1652	// Find next index
1653	_wppaNxtIdx[mocc] = _wppaCurIdx[mocc] + n;
1654	while ( _wppaNxtIdx[mocc] >= _wppaSlides[mocc].length ) _wppaNxtIdx[mocc] -= _wppaSlides[mocc].length;
1655	// And go!
1656	_wppaNextSlide( mocc, 0 );
1657}
1658
1659function _wppaNextOnCallback( mocc ) {
1660
1661	// Check for end of non wrapped show
1662	if ( ! wppaSlideWrap[mocc] && _wppaCurIdx[mocc] == ( _wppaSlides[mocc].length -1 ) ) return;
1663	// Check for skip rated after rating
1664	if ( _wppaSkipRated[mocc] ) {
1665		var now = _wppaCurIdx[mocc];
1666		var idx = now + 1;
1667		if ( idx == _wppaSlides[mocc].length ) idx = 0;	// wrap?
1668		var next = idx; // assume simple next
1669		if ( _wppaMyr[mocc][next] != 0 ) {		// Already rated, skip
1670			idx++;	// try next
1671			if ( idx == _wppaSlides[mocc].length ) idx = 0;	// wrap?
1672			while ( idx != next && _wppaMyr[mocc][idx] != 0 ) {	// still rated, skip
1673				idx ++;	// try next
1674				if ( idx == _wppaSlides[mocc].length ) idx = 0;	// wrap?
1675			}	// either idx == next or not rated
1676			next = idx;
1677		}
1678		_wppaNxtIdx[mocc] = next;
1679	}
1680	else {	// Normal situation
1681		_wppaNxtIdx[mocc] = _wppaCurIdx[mocc] + 1;
1682		if ( _wppaNxtIdx[mocc] == _wppaSlides[mocc].length ) _wppaNxtIdx[mocc] = 0;
1683	}
1684	_wppaNextSlide( mocc, 0 );
1685}
1686
1687function _wppaPrev( mocc ) {
1688
1689	// Check for begin of non wrapped show
1690	if ( ! wppaSlideWrap[mocc] && _wppaCurIdx[mocc] == 0 ) return;
1691
1692	// Find previous index
1693	_wppaNxtIdx[mocc] = _wppaCurIdx[mocc] - 1;
1694
1695	// If beyond begin, wrap to last item prev page
1696	if ( _wppaNxtIdx[mocc] < 0 ) {
1697
1698//		wppaSavedSlideshowTimeout[mocc] = _wppaTimeOut[mocc];
1699
1700		// if prev page link exists go to last item on prev page-last-item
1701		if ( jQuery( '#wppa-prev-page-last-item-' + mocc ).length ) {
1702			wppaSlideInitRunning[mocc] = ( _wppaSSRuns[mocc] ? 'start' : 'stopprev' );
1703			jQuery( '#wppa-prev-page-last-item-' + mocc ).trigger( 'click' );
1704			return;
1705		}
1706
1707		// Same page
1708		else {
1709			_wppaNxtIdx[mocc] += _wppaSlides[mocc].length;
1710			_wppaNextSlide( mocc, 0 );
1711		}
1712	}
1713
1714	// The normal case
1715	else {
1716		_wppaNextSlide( mocc, 0 );
1717	}
1718}
1719
1720function _wppaPrevN( mocc, n ) {
1721
1722	// Check for begin of non wrapped show
1723	if ( ! wppaSlideWrap[mocc] && _wppaCurIdx[mocc] < n ) return;
1724	// Find previous index
1725	_wppaNxtIdx[mocc] = _wppaCurIdx[mocc] - n;
1726	while ( _wppaNxtIdx[mocc] < 0 ) _wppaNxtIdx[mocc] += _wppaSlides[mocc].length;
1727	// And go!
1728	_wppaNextSlide( mocc, 0 );
1729}
1730
1731function _wppaGoto( mocc, idx ) {
1732
1733	_wppaToTheSame = ( _wppaNxtIdx[mocc] == idx );
1734	_wppaNxtIdx[mocc] = idx;
1735	_wppaNextSlide( mocc, 0 );
1736}
1737
1738function _wppaGotoRunning( mocc, idx ) {
1739
1740	//wait until not bussy
1741	if ( _wppaIsBusy[mocc] ) {
1742		setTimeout( '_wppaGotoRunning( '+mocc+',' + idx + ' )', 10 );	// Try again after 10 ms
1743		return;
1744	}
1745
1746	_wppaSSRuns[mocc] = false; // we don't want timed loop to occur during our work
1747
1748	_wppaToTheSame = ( _wppaNxtIdx[mocc] == idx );
1749	_wppaNxtIdx[mocc] = idx;
1750__wppaOverruleRun = true;
1751	_wppaNextSlide( mocc, "manual" ); // enqueue new transition
1752
1753	_wppaGotoContinue( mocc );
1754}
1755
1756function _wppaGotoContinue( mocc ) {
1757	if ( _wppaIsBusy[mocc] ) {
1758		setTimeout( '_wppaGotoContinue( '+mocc+' )', 10 );	// Try again after 10 ms
1759		return;
1760	}
1761	setTimeout( '_wppaNextSlide( '+mocc+', "reset" )', wppaGetSlideshowTimeout( mocc, '_wppaGotoContinue' ) + 10 ); //restart slideshow after new timeout
1762}
1763
1764function _wppaStart( mocc, idx ) {
1765
1766	// If already running, ignore
1767	if ( _wppaSSRuns[mocc] ) {
1768		return;
1769	}
1770// console.log('start '+mocc);
1771
1772	if ( wppaSlideshowNavigationType == 'icons' ) {
1773		_wppaStartIcons( mocc, idx );
1774	}
1775	else {
1776		_wppaStartText( mocc, idx );
1777	}
1778
1779	if ( _wppaSSRuns[mocc] ) {
1780		if ( wppaStartStopNew ) {
1781			jQuery( '#wppa-startstop-icon-' + mocc ).html( wppaSvgHtml( 'Pause-Button-New', wppaIconSize( mocc, wppaIsMini[mocc]?'24px':'48px', true ), false, true, '0', '0', '0', '0' ) );
1782		}
1783		else {
1784			jQuery( '#wppa-startstop-icon-' + mocc ).html( wppaSvgHtml( 'Pause-Button', wppaIconSize( mocc, wppaIsMini[mocc]?'24px':'48px', true ), false, true, '0', '10', '50', '50' ) );
1785		}
1786	}
1787
1788	// If failed, try again later
1789	if ( idx == -1 )
1790	setTimeout( function(){_wppaStart( mocc, idx )}, 200 );
1791}
1792
1793var wppaVeryFirst = true;
1794function _wppaStartIcons( mocc, idx ) {
1795
1796
1797	// A filmonly does not start when it is the very first occ, so we set wppaVeryFirst to false in case its a filmonly
1798	if ( jQuery('#filmwindow-'+mocc).length > 0 && jQuery('#slide_frame-'+mocc).length == 0 ) wppaVeryFirst = false;
1799
1800	if ( idx == -2 ) {	// Init at first without my rating
1801		var i = 0;
1802		idx = 0;
1803		_wppaSkipRated[mocc] = true;
1804		if ( _wppaMyr[mocc][i] != 0 ) {
1805			while ( i < _wppaSlides[mocc].length ) {
1806				if ( idx == 0 && _wppaMyr[mocc][i] == 0 ) idx = i;
1807				i++;
1808			}
1809		}
1810	}
1811
1812	var iconsize = wppaIconSize( mocc, '1.5em', false );
1813	if ( idx > -1 ) {	// Init still at index idx
1814		jQuery( '#startstop-'+mocc ).html( wppaSvgHtml( 'Play-Button', iconsize, false, true, '0', '10', '20', '50' ) );
1815		jQuery( '#speed0-'+mocc ).hide();
1816		jQuery( '#speed1-'+mocc ).hide();
1817		_wppaNxtIdx[mocc] = idx;
1818		_wppaCurIdx[mocc] = idx;
1819		_wppaNextSlide( mocc, 0 );
1820		_wppaShowMetaData( mocc, 'show' );
1821	}
1822	else {	// idx == -1, start from where you are
1823		if ( ! wppaVeryFirst) _wppaSSRuns[mocc] = true;
1824		_wppaNextSlide( mocc, 0 );
1825		if ( wppaVeryFirst ) _wppaSSRuns[mocc] = true;
1826		jQuery( '#startstop-'+mocc ).html( wppaSvgHtml( 'Pause-Button', iconsize, false, true, '0', '10', '20', '50' ) );
1827		jQuery( '#speed0-'+mocc ).show();
1828		jQuery( '#speed1-'+mocc ).show();
1829		_wppaShowMetaData( mocc, 'hide' );
1830		if ( jQuery( '#bc-pname-modal-'+mocc ) ) {
1831			jQuery( '#bc-pname-modal-'+mocc ).html( __( 'Slideshow', 'wp-photo-album-plus' ) );
1832		}
1833		else {
1834			jQuery( '#bc-pname-'+mocc ).html( __( 'Slideshow', 'wp-photo-album-plus' ) );
1835		}
1836	}
1837	wppaVeryFirst = false;
1838
1839	// Both cases:
1840	_wppaSetRatingDisplay( mocc );
1841}
1842
1843function _wppaStartText( mocc, idx ) {
1844
1845	// A filmonly does not start when it is the very first occ, so we set wppaVeryFirst to false in case its a filmonly
1846	if ( jQuery('#filmwindow-'+mocc).length > 0 && jQuery('#slide_frame-'+mocc).length == 0 ) wppaVeryFirst = false;
1847
1848	if ( idx == -2 ) {	// Init at first without my rating
1849		var i = 0;
1850		idx = 0;
1851		_wppaSkipRated[mocc] = true;
1852		if ( _wppaMyr[mocc][i] != 0 ) {
1853			while ( i < _wppaSlides[mocc].length ) {
1854				if ( idx == 0 && _wppaMyr[mocc][i] == 0 ) idx = i;
1855				i++;
1856			}
1857		}
1858	}
1859
1860	if ( idx > -1 ) {	// Init still at index idx
1861		jQuery( '#startstop-'+mocc ).html( __( 'Start', 'wp-photo-album-plus' )+' '+__( 'Slideshow', 'wp-photo-album-plus' ) );
1862		jQuery( '#speed0-'+mocc ).css( 'display', 'none' );
1863		jQuery( '#speed1-'+mocc ).css( 'display', 'none' );
1864		_wppaNxtIdx[mocc] = idx;
1865		_wppaCurIdx[mocc] = idx;
1866		_wppaNextSlide( mocc, 0 );
1867		_wppaShowMetaData( mocc, 'show' );
1868	}
1869	else {	// idx == -1, start from where you are
1870		if ( ! wppaVeryFirst) _wppaSSRuns[mocc] = true;
1871		_wppaNextSlide( mocc, 0 );
1872		if ( wppaVeryFirst ) _wppaSSRuns[mocc] = true;
1873		jQuery( '#startstop-'+mocc ).html( __( 'Stop', 'wp-photo-album-plus' ) );
1874		jQuery( '#speed0-'+mocc ).css( 'display', 'inline' );
1875		jQuery( '#speed1-'+mocc ).css( 'display', 'inline' );
1876		_wppaShowMetaData( mocc, 'hide' );
1877		if ( jQuery( '#bc-pname-modal-'+mocc ) ) {
1878			jQuery( '#bc-pname-modal-'+mocc ).html( __( 'Slideshow', 'wp-photo-album-plus' ) );
1879		}
1880		else {
1881			jQuery( '#b
1881c-pname-'+mocc ).html( __( 'Slideshow', 'wp-photo-album-plus' ) );
1882		}
1883	}
1884	wppaVeryFirst = false;
1885
1886	// Both cases:
1887	_wppaSetRatingDisplay( mocc );
1888}
1889
1890var wppaSlideTimer = [];
1891function _wppaStop( mocc ) {
1892// console.log('stop '+mocc);
1893//	_wppaStopping[mocc] = 1;//12;
1894
1895clearTimeout( wppaSlideTimer[mocc] );
1896
1897	if ( wppaSlideshowNavigationType == 'icons' ) {
1898		_wppaStopIcons( mocc );
1899	}
1900	else {
1901		_wppaStopText( mocc );
1902	}
1903	if ( wppaStartStopNew ) {
1904		jQuery( '#wppa-startstop-icon-' + mocc ).html( wppaSvgHtml( 'Play-Button-New', wppaIconSize( mocc, wppaIsMini[mocc]?'30px':'60px', true ), false, true, '0', '0', '0', '0' ) );
1905	}
1906	else {
1907		jQuery( '#wppa-startstop-icon-' + mocc ).html( wppaSvgHtml( 'Play-Button', wppaIconSize( mocc, wppaIsMini[mocc]?'24px':'48px', true ), false, true, '0', '10', '50', '50' ) );
1908	}
1909
1910}
1911
1912function _wppaStopIcons( mocc ) {
1913
1914    _wppaSSRuns[mocc] = false;
1915	jQuery( '#startstop-'+mocc ).html( wppaSvgHtml( 'Play-Button', wppaIconSize( mocc, '1.5em', false ), false, true ) );
1916	jQuery( '#speed0-'+mocc ).hide();
1917	jQuery( '#speed1-'+mocc ).hide();
1918	_wppaShowMetaData( mocc, 'show' );
1919	if ( jQuery( '#bc-pname-modal-'+mocc ) ) {
1920		jQuery( '#bc-pname-modal-'+mocc ).html( _wppaNames[mocc][_wppaCurIdx[mocc]] );
1921	}
1922	else {
1923		jQuery( '#bc-pname-'+mocc ).html( _wppaNames[mocc][_wppaCurIdx[mocc]] );
1924	}
1925}
1926function _wppaStopText( mocc ) {
1927
1928
1929    _wppaSSRuns[mocc] = false;
1930    jQuery( '#startstop-'+mocc ).html( __( 'Start', 'wp-photo-album-plus' )+' '+__( 'Slideshow', 'wp-photo-album-plus' ) );
1931	jQuery( '#speed0-'+mocc ).css( 'display', 'none' );
1932	jQuery( '#speed1-'+mocc ).css( 'display', 'none' );
1933	_wppaShowMetaData( mocc, 'show' );
1934	if ( jQuery( '#bc-pname-modal-'+mocc ) ) {
1935		jQuery( '#bc-pname-modal-'+mocc ).html( _wppaNames[mocc][_wppaCurIdx[mocc]] );
1936	}
1937	else {
1938		jQuery( '#bc-pname-'+mocc ).html( _wppaNames[mocc][_wppaCurIdx[mocc]] );
1939	}
1940}
1941
1942function _wppaSpeed( mocc, faster ) {
1943
1944	if ( _wppaTimeOut[mocc] == 'random' ) {
1945		return;
1946	}
1947    if ( faster ) {
1948        if ( _wppaTimeOut[mocc] > 500 ) _wppaTimeOut[mocc] /= 1.5;
1949    }
1950    else {
1951        if ( _wppaTimeOut[mocc] < 60000 ) _wppaTimeOut[mocc] *= 1.5;
1952    }
1953	wppaSavedSlideshowTimeout[mocc] = _wppaTimeOut[mocc];
1954}
1955
1956function _wppaUnloadSpinner( mocc ) {
1957
1958	jQuery( '#wppa-slide-spin-' + mocc ).hide();
1959	setTimeout( function() { jQuery( '#wppa-slide-spin-' + mocc ).stop().fadeOut(); }, 1000 );
1960
1961}
1962
1963function _wppaSetRatingDisplay( mocc ) {
1964
1965	// Rating bar present?
1966	if ( ! document.getElementById( 'wppa-rating-'+mocc ) ) {
1967		return;
1968	}
1969
1970	var idx, avg, tmp, cnt, dsc, myr, dsctxt;
1971
1972	avg = _wppaAvg[mocc][_wppaCurIdx[mocc]];
1973	if ( typeof( avg ) == 'undefined' ) return;
1974
1975	// Likes system
1976	if ( wppaRatingDisplayType == 'likes' ) {
1977
1978		myr = _wppaMyr[mocc][_wppaCurIdx[mocc]];
1979		if ( myr == 'void' ) {
1980			jQuery( '#wppa-dislike-imgdiv-'+mocc ).hide();
1981			jQuery( '#wppa-like-imgdiv-'+mocc ).hide();
1982		}
1983		else {
1984			jQuery( '#wppa-dislike-imgdiv-'+mocc ).show();
1985			jQuery( '#wppa-like-imgdiv-'+mocc ).show();
1986		}
1987
1988		var likeText = avg.split( "|" );
1989
1990		jQuery( '#wppa-like-'+mocc ).attr( 'title', likeText[0] );
1991		jQuery( '#wppa-liketext-'+mocc ).html( likeText[1] );
1992		if ( _wppaMyr[mocc][_wppaCurIdx[mocc]] == '1' ) {
1993			jQuery( '#wppa-like-'+mocc ).attr( 'src', wppaImageDirectory+'thumbdown.png' );
1994		}
1995		else { // == '0'
1996			jQuery( '#wppa-like-'+mocc ).attr( 'src', wppaImageDirectory+'thumbup.png' );
1997		}
1998		return;
1999	}
2000
2001	// Not likes system
2002	tmp = avg.split( '|' );
2003	avg = tmp[0];
2004	cnt = tmp[1];
2005
2006	dsc = _wppaDisc[mocc][_wppaCurIdx[mocc]];
2007	myr = _wppaMyr[mocc][_wppaCurIdx[mocc]];
2008
2009	if ( dsc == 'void' ) {
2010		jQuery('#wppa-rating-'+mocc).hide();
2011	}
2012	else {
2013		jQuery('#wppa-rating-'+mocc).show();
2014
2015		// Graphic display ?
2016		if ( wppaRatingDisplayType == 'graphic' ) {
2017
2018			// Set Avg rating
2019			_wppaSetRd( mocc, avg, '#wppa-avg-' );
2020
2021			// Set My rating
2022			_wppaSetRd( mocc, myr, '#wppa-rate-' );
2023
2024			// Display dislike
2025			if ( myr == 0 ) {
2026
2027				// If i did not vote yet, enable the thumb down
2028				jQuery( '#wppa-dislike-'+mocc ).css( 'display', 'inline' );
2029				jQuery( '#wppa-dislike-imgdiv-'+mocc ).css( 'display', 'inline' );
2030
2031				// Hide the filler only when there is a thumbdown
2032				if ( document.getElementById( 'wppa-dislike-'+mocc ) ) jQuery( '#wppa-filler-'+mocc ).css( 'display', 'none' );
2033				jQuery( '#wppa-dislike-'+mocc ).stop().fadeTo( 100, wppaStarOpacity );
2034			}
2035			else {
2036
2037				// If i voted, disable thumb down
2038				jQuery( '#wppa-dislike-'+mocc ).css( 'display', 'none' );
2039				jQuery( '#wppa-dislike-imgdiv-'+mocc ).css( 'display', 'none' );
2040				jQuery( '#wppa-filler-'+mocc ).css( 'display', 'inline' );
2041				jQuery( '#wppa-filler-'+mocc ).stop().fadeTo( 100, wppaStarOpacity );
2042
2043				// Show filler with dislike count
2044				jQuery( '#wppa-filler-'+mocc ).attr( 'title', dsc );
2045			}
2046		}
2047
2048		// Numeric display
2049		else {
2050			// Set avg rating
2051			jQuery( '#wppa-numrate-avg-'+mocc ).html( avg+' ( '+cnt+' ) ' );
2052
2053			// Set My rating
2054			jQuery( '.wppa-my-rat-'+mocc ).show();
2055			if ( myr ==  'void' ) {
2056				jQuery( '#wppa-numrate-mine-'+mocc ).html( '' );
2057				jQuery( '.wppa-my-rat-'+mocc ).hide();
2058			}
2059			else if ( wppaRatingOnce && myr > 0 ) {	// I did a rating and one allowed
2060				jQuery( '#wppa-numrate-mine-'+mocc ).html( myr );
2061			}
2062			else if ( myr < 0 ) {					// I did a dislike
2063				jQuery( '#wppa-numrate-mine-'+mocc ).html( ' dislike' );
2064			}
2065			else {								// Multiple allowed or change allowed or not rated yet
2066				var htm = '';
2067				for ( i=1;i<=wppaRatingMax;i++ ) {
2068					if ( myr == i ) {
2069						htm += '<span class="wppa-rating-numeric-mine" style="cursor:pointer; font-weight:bold;" onclick="_wppaRateIt( '+mocc+', '+i+' )">&nbsp;'+i+'&nbsp;</span>';
2070					}
2071					else {
2072						if ( myr > ( i-1 ) && myr < i ) htm += '&nbsp;
2072( '+myr+' )&nbsp;';
2073						htm += '<span class="wppa-rating-numeric" style="cursor:pointer;" onclick="_wppaRateIt( '+mocc+', '+i+' )" onmouseover="this.style.fontWeight=\'bold\'" onmouseout="this.style.fontWeight=\'normal\'" >&nbsp;'+i+'&nbsp;</span>';
2074					}
2075				}
2076				jQuery( '#wppa-numrate-mine-'+mocc ).html( htm );
2077			}
2078
2079			// Display dislike
2080			if ( myr == 0 ) {
2081
2082				// If i did not vote yet, enable the thumb down
2083				jQuery( '#wppa-dislike-'+mocc ).css( 'display', 'inline' );
2084				jQuery( '#wppa-dislike-imgdiv-'+mocc ).css( 'display', 'inline' );
2085				jQuery( '#wppa-filler-'+mocc ).css( 'display', 'none' );
2086				jQuery( '#wppa-dislike-'+mocc ).stop().fadeTo( 100, wppaStarOpacity );
2087			}
2088			else {
2089
2090				// If i voted, disable thumb down
2091				jQuery( '#wppa-dislike-'+mocc ).css( 'display', 'none' );
2092				jQuery( '#wppa-dislike-imgdiv-'+mocc ).css( 'display', 'none' );
2093				jQuery( '#wppa-filler-'+mocc ).css( 'display', 'inline' );
2094			}
2095
2096			// Disply text
2097			jQuery( '#wppa-discount-'+mocc ).html( dsc + '&bull; ' );	// Show count
2098			jQuery( '#wppa-filler-'+mocc ).css( 'display', 'none' );
2099
2100		}
2101		// One Button Vote only?
2102		if ( myr == 0 ) {
2103			jQuery( '#wppa-vote-button-'+mocc ).val( wppaVoteForMe );
2104		}
2105		else {
2106			jQuery( '#wppa-vote-button-'+mocc ).val( wppaVotedForMe );
2107		}
2108		jQuery( '#wppa-vote-count-'+mocc ).html( cnt );
2109	}
2110}
2111
2112function wppaGetDislikeText( dsc,myr,incmine ) {
2113
2114	return dsc;
2115/*
2116	if ( dsc == 0 && myr != 0 ) dsctxt = ' '+wppaNoDislikes+' ';
2117	else if ( dsc == 1 ) dsctxt = ' '+wppa1Dislike+' ';
2118	else dsctxt = ' '+dsc+' '+wppaDislikes+' ';
2119	if ( incmine && myr < 0 ) dsctxt+=wppaIncludingMine;
2120	return dsctxt;
2121*/
2122}
2123
2124function _wppaSetRd( mocc, avg, where ) {
2125
2126	var idx1 = parseInt( avg );
2127	var idx2 = idx1 + 1;
2128	var frac = avg - idx1;
2129	var opac = wppaStarOpacity + frac * ( 1.0 - wppaStarOpacity );
2130	var ilow = 1;
2131	var ihigh = wppaRatingMax;
2132
2133	if ( avg == 'void' ) {
2134		jQuery( '#wppa-my-rat-'+mocc ).hide();
2135		jQuery( '.wppa-my-rat-'+mocc ).hide();
2136		jQuery( '.wppa-rate-'+mocc ).hide();
2137		jQuery( '.wppa-ratingthumb' ).hide();
2138		jQuery( '#wppa-numrate-mine-'+mocc ).hide();
2139	}
2140	else {
2141		jQuery( '#wppa-my-rat-'+mocc ).show();
2142		jQuery( '.wppa-my-rat-'+mocc ).show();
2143		jQuery( '.wppa-rate-'+mocc ).show();
2144		jQuery( '.wppa-ratingthumb' ).show();
2145		jQuery( '#wppa-numrate-mine-'+mocc ).show();
2146
2147		for ( idx=ilow;idx<=ihigh;idx++ ) {
2148			if ( where == '#wppa-rate-' || where == '.wppa-rate-' ) {
2149
2150				// Replace V by *
2151				if ( jQuery( where+mocc+'-'+idx ).attr( 'src' ) != wppaImageDirectory+'star.ico' ) {
2152					jQuery( where+mocc+'-'+idx ).attr( 'src', wppaImageDirectory+'star.ico' );
2153				}
2154			}
2155			if ( idx <= idx1 ) {
2156				jQuery( where+mocc+'-'+idx ).stop().fadeTo( 100, 1.0 );
2157			}
2158			else if ( idx == idx2 ) {
2159				jQuery( where+mocc+'-'+idx ).stop().fadeTo( 100, opac );
2160			}
2161			else {
2162				jQuery( where+mocc+'-'+idx ).stop().fadeTo( 100, wppaStarOpacity );
2163			}
2164		}
2165	}
2166}
2167
2168function _wppaFollowMe( mocc, idx ) {
2169
2170	if ( _wppaSSRuns[mocc] ) return;				// Do not rate on a running show, what only works properly in Firefox
2171
2172	if ( _wppaMyr[mocc][_wppaCurIdx[mocc]] != 0 && wppaRatingOnce ) return;	// Already rated
2173	if ( _wppaMyr[mocc][_wppaCurIdx[mocc]] < 0 ) return; 	// Disliked aleady
2174	if ( _wppaVoteInProgress ) return;
2175	_wppaSetRd( mocc, idx, '#wppa-rate-' );
2176}
2177
2178function wppaOvlFollowMe( mocc, idx, val ) {
2179	if ( val ) return; // Already rated
2180	_wppaSetRd( mocc, idx, '.wppa-rate-' );
2181}
2182
2183function _wppaLeaveMe( mocc, idx ) {
2184
2185	if ( _wppaSSRuns[mocc] ) return;				// Do not rate on a running show, what only works properly in Firefox
2186
2187	if ( _wppaMyr[mocc][_wppaCurIdx[mocc]] != 0 && wppaRatingOnce ) return;	// Already rated
2188	if ( _wppaMyr[mocc][_wppaCurIdx[mocc]] < 0 ) return; 	// Disliked aleady
2189	if ( _wppaVoteInProgress ) return;
2190	_wppaSetRd( mocc, _wppaMyr[mocc][_wppaCurIdx[mocc]], '#wppa-rate-' );
2191}
2192
2193function wppaOvlLeaveMe( mocc, idx, val ) {
2194	_wppaSetRd( mocc, val, '.wppa-rate-' );
2195}
2196
2197function _wppaValidateComment( mocc, photoid ) {
2198
2199
2200	if ( ! photoid ) photoid = _wppaId[mocc][_wppaCurIdx[mocc]];
2201
2202	// Process name
2203	var name = jQuery( '#wppa-comname-'+mocc ).val();
2204	if ( name.length<1 ) {
2205		alert( __( 'Please enter your name', 'wp-photo-album-plus' ) );
2206		return false;
2207	}
2208
2209	// Process email address
2210	if ( wppaEmailRequired == 'required' || wppaEmailRequired == 'optional' ) {
2211		var email = jQuery( '#wppa-comemail-'+mocc ).val();
2212		if ( wppaEmailRequired == 'optional' && email.length == 0 ) {
2213			return true;
2214		}
2215		var atpos=email.indexOf( "@" );
2216		var dotpos=email.lastIndexOf( "." );
2217		if ( atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length ) {
2218			alert( __( 'Please enter a valid email address', 'wp-photo-album-plus' ) );
2219			return false;
2220		}
2221	}
2222
2223	// Process comment
2224	var text = jQuery( '#wppa-comment-'+mocc ).val( );
2225	if ( text.length<1 ) {
2226		alert( __( 'Please enter a comment', 'wp-photo-album-plus' ) );
2227		return false;
2228	}
2229
2230	return true;
2231}
2232
2233function _wppaGo( url ) {
2234
2235	document.location = url;	// Go!
2236}
2237
2238function _wppaBbb( mocc,where,act ) {
2239
2240
2241	if ( _wppaSSRuns[mocc] ) return;
2242
2243	var elm = '#bbb-'+mocc+'-'+where;
2244	switch ( act ) {
2245		case 'show':
2246			if ( where == 'l' ) jQuery( elm ).attr( 'title', __( 'Previous photo', 'wp-photo-album-plus' ) );
2247			if ( where == 'r' ) jQuery( elm ).attr( 'title', __( 'Next photo', 'wp-photo-album-plus' ) );
2248			jQuery( '.wppa-bbb-'+mocc ).css( 'cursor', 'pointer' );
2249			break;
2250		case 'hide':
2251			jQuery( '.wppa-bbb-'+mocc ).removeAttr( 'title' );
2252			jQuery( '.wppa-bbb-'+mocc ).css( 'cursor', 'default' );
2253			break;
2254		case 'click':
2255			if ( where == 'l' ) wppaPrev( mocc );
2256			if ( where == 'r' ) wppaNext( mocc );
2257			break;
2258		default:
2259			alert( 'Unimplemented instruction: '+act+' on: '+elm );
2260	}
2261}
2262
2263function _wppaUbb( mocc,where,act ) {
2264
2265
2266	var elm = '#ubb-'+mocc+'-'+where;
2267
2268	switch ( act ) {
2269		case 'show':
2270			if ( where == 'l' ) jQuery( elm ).attr( 'title', __( 'Previous photo', 'wp-photo-album-plus' ) );
2271			if ( where == 'r' ) jQuery( elm ).attr( 'title', __( 'Next photo', 'wp-photo-album-plus' ) );
2272			jQuery( '.ubb-'+mocc ).css( 'cursor', 'pointer' );
2273			jQuery( '.ubb-'+mocc ).stop().fadeTo( 200, 0.8 );
2274			jQuery( '#wppa-startstop-icon-' + mocc ).stop().fadeTo( 200, 0.8 );
2275			break;
2276		case 'hide':
2277			jQuery( '.ubb-'+mocc ).removeAttr( 'title' );
2278			jQuery( '.ubb-'+mocc ).css( 'cursor', 'default' );
2279			if ( wppaIsMobile ) {
2280				jQuery( '.ubb-'+mocc ).stop().fadeTo( 200, 0.1 );
2281			}
2282			else {
2283				jQuery( '.ubb-'+mocc ).stop().fadeTo( 200, 0 );
2284			}
2285			jQuery( '#wppa-startstop-icon-' + mocc ).stop().fadeTo( 200, 0 );
2286			break;
2287		case 'click':
2288			if ( wppaIsMobile ) {
2289				jQuery( '.ubb-'+mocc ).stop().fadeTo( 200, 1 ).fadeTo( 1000, 0 );
2290				jQuery( '#wppa-startstop-icon-' + mocc ).stop().fadeTo( 200, 1 ).fadeTo( 1000, 0 );
2291			}
2292			if ( where == 'l' ) {
2293				wppaPrev( mocc );
2294			}
2295			if ( where == 'r' ) {
2296				wppaNext( mocc );
2297			}
2298			break;
2299		default:
2300			alert( 'Unimplemented instruction: '+act+' on: '+elm );
2301	}
2302}
2303
2304function wppaOpenComments( mocc ) {
2305
2306	if ( _wppaSSRuns[mocc] ) _wppaStop( mocc );
2307
2308	// Show existing comments
2309	jQuery( '#wppa-comtable-wrap-'+mocc ).css( 'display', 'block' );
2310
2311	// Show the input form table
2312	jQuery( '#wppa-comform-wrap-'+mocc ).css( 'display', 'block' );
2313
2314	// Hide the comment footer
2315	jQuery( '#wppa-comfooter-wrap-'+mocc ).css( 'display', 'none' );
2316
2317	// Do autocol to fix a layout problem
2318	wppaColWidth[mocc] = 0;
2319	setTimeout( '_wppaDoAutocol( '+mocc+' )', 100 );
2320}
2321
2322function _wppaShowMetaData( mocc, key ) {
2323
2324	if ( ! _wppaSlides[mocc] ) return;
2325
2326	// What to do when the slideshow is NOT running
2327	if ( ! _wppaSSRuns[mocc] && ! __wppaOverruleRun ) {
2328		if ( key == 'show' ) {			// Show
2329			if ( wppaAutoOpenComments ) {
2330				// Show existing comments
2331				jQuery( '#wppa-comtable-wrap-'+mocc ).css( 'display', 'block' );
2332				// Show the input form table
2333				jQuery( '#wppa-comform-wrap-'+mocc ).css( 'display', 'block' );
2334				// Hide the comment footer
2335				jQuery( '#wppa-comfooter-wrap-'+mocc ).css( 'display', 'none' );
2336			}
2337			// Fade the browse arrows in
2338			if ( _wppaCurIdx[mocc] != 0 )
2339				jQuery( '.wppa-first-'+mocc ).show(); // css( 'visibility', 'visible' ); // fadeIn( 300 );
2340			if ( _wppaCurIdx[mocc] != ( _wppaSlides[mocc].length - 1 ) )
2341				jQuery( '.wppa-last-'+mocc ).show(); //css( 'visibility', 'visible' ); // fadeIn( 300 );
2342			// SM box
2343			if ( wppaShareHideWhenRunning ) {
2344				jQuery( '#wppa-share-'+mocc ).css( 'display', '' );
2345			}
2346
2347			// Fotomoto
2348			wppaFotomotoToolbar( mocc, _wppaHiresUrl[mocc][_wppaCurIdx[mocc]] );
2349
2350		}
2351		else {							// Hide
2352			// Hide existing comments
2353			jQuery( '#wppa-comtable-wrap-'+mocc ).css( 'display', 'none' );
2354			// Hide the input form table
2355			jQuery( '#wppa-comform-wrap-'+mocc ).css( 'display', 'none' );
2356			// Show the comment footer
2357			jQuery( '#wppa-comfooter-wrap-'+mocc ).css( 'display', 'block' );
2358			// Fade the browse arrows out
2359//			jQuery( '.wppa-first-'+mocc ).fadeOut( 300 );
2360//			jQuery( '.wppa-last-'+mocc ).fadeOut( 300 );
2361			wppaFotomotoHide( mocc );
2362		}
2363	}
2364	// What to do when the slideshow is running
2365	else {	// Slideshow is running
2366		if ( key == 'show' ) {
2367			// Fotomoto
2368			if ( ! wppaFotomotoHideWhenRunning ) wppaFotomotoToolbar( mocc, _wppaHiresUrl[mocc][_wppaCurIdx[mocc]] );
2369		}
2370		else {
2371			// SM box
2372			if ( wppaShareHideWhenRunning ) {
2373				jQuery( '#wppa-share-'+mocc ).css( 'display', 'none' );
2374			}
2375			// Fotomoto
2376		//	if ( wppaFotomotoHideWhenRunning )
2377		//	wppaFotomotoHide( mocc );
2378		}
2379	}
2380
2381	// What to do always, independant of slideshow is running
2382	if ( key == 'show' ) {
2383		// Show title and description
2384		jQuery( "#imagedesc-"+mocc ).css( 'visibility', 'visible' );
2385		jQuery( "#imagetitle-"+mocc ).css( 'visibility', 'visible' );
2386		// Display counter
2387		jQuery( "#counter-"+mocc ).css( 'visibility', 'visible' );
2388		// Display iptc
2389		jQuery( "#iptccontent-"+mocc ).css( 'visibility', 'visible' );
2390		jQuery( "#exifcontent-"+mocc ).css( 'visibility', 'visible' );
2391	}
2392	else {
2393		// Hide title and description
2394//		jQuery( "#imagedesc-"+mocc ).css( 'visibility', 'hidden' );
2395//		jQuery( "#imagetitle-"+mocc ).css( 'visibility', 'hidden' );
2396		// Hide counter
2397		jQuery( "#counter-"+mocc ).css( 'visibility', 'hidden' );
2398		// Fade the browse arrows out
2399		jQuery( '.wppa-first-'+mocc ).hide(); // css( 'visibility', 'hidden' ); // fadeOut( 300 );
2400		jQuery( '.wppa-last-'+mocc ).hide(); // css( 'visibility', 'hidden' ); // fadeOut( 300 );
2401		// Hide iptc
2402		jQuery( "#iptccontent-"+mocc ).css( 'visibility', 'hidden' );
2403		jQuery( "#exifcontent-"+mocc ).css( 'visibility', 'hidden' );
2404
2405	}
2406}
2407
2408function wppaGetSlideshowTimeout( mocc, from ) {
2409
2410	var time;
2411	if ( _wppaTimeOut[mocc] == 'random' ) {
2412		var min = 2 * wppaAnimationSpeed;
2413		var max = 7 * wppaAnimationSpeed;
2414		time = Math.floor(Math.random() * (max - min + 1)) + min;
2415	}
2416	else {
2417		time = _wppaTimeOut[mocc];
2418	}
2419	return time;
2420}
2421
2422function wppaIsSlidshowVisible( mocc ) {
2423
2424	if ( ! wppaLazyLoad ) {
2425		return true;
2426	}
2427
2428	var ids, len, i, elm, rect;
2429
2430	ids = ['slide_frame-'+mocc, 'filmwindow-'+mocc];
2431	len = ids.length;
2432	for ( i = 0; i < len; i++ ) {
2433		elm = document.getElementById( ids[i] );
2434		if ( elm ) {
2435			rect = elm.getBoundingClientRect();
2436			if ( wppaIsElementInViewport( elm ) ) {
2437				return true;
2438			}
2439		}
2440	}
2441	wppaFilmInit[mocc] = false;
2442	return false;
2443}
2444
2445function wppaFilmThumbToCanvas(imgId) {
2446
2447	var canvasId 		= imgId+'-canvas';
2448	var imgElm 			= document.getElementById(imgId);
2449	var canvasElm 		= document.getElementById(canvasId);
2450	if ( typeof( canvasElm ) == 'undefined' ) {
2451//		console.log( 'Error. No canvas elm for item '+imgId );
2452		return;
2453	}
2454	var ctx 			= canvasElm.getContext("2d");
2455	var	sourceWidth 	= imgElm.naturalWidth | imgElm.videoWidth;
2456	var sourceHeight 	= imgElm.naturalHeight | imgElm.videoHeight;
2457	var canvasWidth 	= canvasElm.width;
2458	var canvasHeight 	= canvasElm.height;
2459
2460	// Image too landscape or too portrait?
2461	if ( ( sourceWidth / sourceHeight ) > ( canvasWidth / canvasHeight ) ) {
2462
2463		// Too landscape
2464		fromWidth 	= sourceHeight * canvasWidth / canvasHeight;
2465		fromX 		= ( sourceWidth - fromWidth ) / 2;
2466		ctx.drawImage( imgElm, fromX, 0, fromWidth, sourceHeight, 0, 0, canvasWidth, canvasHeight );
2467	}
2468	else {
2469
2470		// Too portrait
2471		fromHeight 	= sourceWidth * canvasHeight / canvasWidth;
2472		fromY 		= ( sourceHeight - fromHeight ) /2;
2473		ctx.drawImage( imgElm, 0, fromY, sourceWidth, fromHeight, 0, 0, canvasWidth, canvasHeight );
2474	}
2475
2476//	if ( imgElm.pause ) imgElm.pause();
2477	return;
2478}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.