PageSourceSearch

https://pippasguardians.com/wp-content/themes/uncode/library/js/lib/ilightbox.js?ver=342305831

js pippasguardians.com collected 2026-10-04 18:01:20 UTC 125,143 bytes, 3,320 lines download raw bytes

1/**
2 * jQuery iLightBox - Revolutionary Lightbox Plugin
3 * http://www.ilightbox.net/
4 *
5 * @version: 2.2.4 - October 14, 2017
6 *
7 * @author: iProDev (Hemn Chawroka)
8 *          http://www.iprodev.com/
9 *
10 */
11(function($, window, undefined) {
12
13	var extensions = {
14			flash: ['swf'],
15			image: ['bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff', 'tif', 'jfif', 'jpe', 'webp'],
16			iframe: ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'jsp', 'php', 'pl', 'php3', 'php4', 'php5', 'phtml', 'rb', 'rhtml', 'shtml', 'txt'],
17			video: ['avi', 'mov', 'mpg', 'mpeg', 'movie', 'mp4', 'webm', 'ogv', 'ogg', '3gp', 'm4v']
18		},
19
20		// Global DOM elements
21		$win = $(window),
22		$doc = $(document),
23
24		// Support indicators
25		browser,
26		transform,
27		gpuAcceleration,
28		fullScreenApi = '',
29		userAgent = navigator.userAgent || navigator.vendor || window.opera,
30        supportTouch = "ontouchstart" in window || navigator.msMaxTouchPoints || (navigator.maxTouchPoints && navigator.userAgent.indexOf('Windows') > -1),
31        ishybrid = navigator.maxTouchPoints && navigator.userAgent.indexOf('Windows') > -1,
32        isMobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4)),
33
34		// Events
35		clickEvent = ishybrid ? "itap.iLightBox click.iLightBox" : supportTouch ? "itap.iLightBox" : "click.iLightBox",
36		touchStartEvent = ishybrid ? "touchstart.iLightBox mousedown.iLightBox" : supportTouch ? "touchstart.iLightBox" : "mousedown.iLightBox",
37		touchStopEvent = ishybrid ? "touchend.iLightBox mouseup.iLightBox" : supportTouch ? "touchend.iLightBox" : "mouseup.iLightBox",
38		touchMoveEvent = ishybrid ? "touchmove.iLightBox mousemove.iLightBox" : supportTouch ? "touchmove.iLightBox" : "mousemove.iLightBox",
39
40		// Math shorthands
41		abs = Math.abs,
42		sqrt = Math.sqrt,
43		round = Math.round,
44		max = Math.max,
45		min = Math.min,
46		floor = Math.floor,
47		random = Math.random,
48
49		pluginspages = {
50			quicktime: 'http://www.apple.com/quicktime/download',
51			flash: 'http://www.adobe.com/go/getflash'
52		},
53
54		iLightBox = function(el, options, items, instant) {
55			var iL = this;
56
57			iL.options = options,
58				iL.selector = options.selector || el,
59				iL.context = document,
60				iL.instant = instant;
61
62			if (items.length < 1) iL.attachItems();
63			else iL.items = items;
64
65			iL.vars = {
66				total: iL.items.length,
67				start: 0,
68				current: null,
69				next: null,
70				prev: null,
71				BODY: $('body'),
72				loadRequests: 0,
73				overlay: $('<div class="ilightbox-overlay"></div>'),
74				loader: $('<div class="ilightbox-loader"><div></div></div>'),
75				toolbar: $('<div class="ilightbox-toolbar"></div>'),
76				innerToolbar: $('<div class="ilightbox-inner-toolbar"></div>'),
77				title: $('<div class="ilightbox-title"></div>'),
78				closeButton: $('<a class="ilightbox-close" title="' + iL.options.text.close + '"></a>'),
79				fullScreenButton: $('<a class="ilightbox-fullscreen" title="' + iL.options.text.enterFullscreen + '"></a>'),
80				innerPlayButton: $('<a class="ilightbox-play" title="' + iL.options.text.slideShow + '"></a>'),
81				innerNextButton: $('<a class="ilightbox-next-button" title="' + iL.options.text.next + '"></a>'),
82				innerPrevButton: $('<a class="ilightbox-prev-button" title="' + iL.options.text.previous + '"></a>'),
83				holder: $('<div class="ilightbox-holder' + (supportTouch ? ' supportTouch' : '') + '" ondragstart="return false;"><div class="ilightbox-container"></div></div>'),
84				nextPhoto: $('<div class="ilightbox-holder' + (supportTouch ? ' supportTouch' : '') + ' ilightbox-next" ondragstart="return false;"><div class="ilightbox-container"></div></div>'),
85				prevPhoto: $('<div class="ilightbox-holder' + (supportTouch ? ' supportTouch' : '') + ' ilightbox-prev" ondragstart="return false;"><div class="ilightbox-container"></div></div>'),
86				nextButton: $('<a class="ilightbox-button ilightbox-next-button" ondragstart="return false;" title="' + iL.options.text.next + '"><span></span></a>'),
87				prevButton: $('<a class="ilightbox-button ilightbox-prev-button" ondragstart="return false;" title="' + iL.options.text.previous + '"><span></span></a>'),
88				thumbnails: $('<div class="ilightbox-thumbnails" ondragstart="return false;"><div class="ilightbox-thumbnails-container"><a class="ilightbox-thumbnails-dragger"></a><div class="ilightbox-thumbnails-grid"></div></div></div>'),
89				thumbs: false,
90				nextLock: false,
91				prevLock: false,
92				hashLock: false,
93				isMobile: false,
94				mobileMaxWidth: 980,
95				isInFullScreen: false,
96				isSwipe: false,
97				mouseID: 0,
98				cycleID: 0,
99				isPaused: 0,
100				captionHeight: 39,
101			};
102
103			// Hideable elements with mousemove event
104			iL.vars.hideableElements = iL.vars.nextButton.add(iL.vars.prevButton);
105
106			iL.normalizeItems();
107
108			//Check necessary plugins
109			iL.availPlugins();
110
111			//Set startFrom
112			iL.options.startFrom = (iL.options.startFrom > 0 && iL.options.startFrom >= iL.vars.total) ? iL.vars.total - 1 : iL.options.startFrom;
113
114			//If randomStart
115			iL.options.startFrom = (iL.options.randomStart) ? floor(random() * iL.vars.total) : iL.options.startFrom;
116			iL.vars.start = iL.options.startFrom;
117
118			if (instant) iL.instantCall();
119			else iL.patchItemsEvents();
120
121			if (iL.options.linkId) {
122				iL.hashChangeHandler();
123				$win.iLightBoxHashChange(function() {
124					iL.hashChangeHandler();
125				});
126			}
127
128			if (supportTouch) {
129				var RegExp = /(click|mouseenter|mouseleave|mouseover|mouseout)/ig,
130					replace = "itap";
131				iL.options.caption.show = iL.options.caption.show.replace(RegExp, replace),
132					iL.options.caption.hide = iL.options.caption.hide.replace(RegExp, replace),
133					iL.options.social.show = iL.options.social.show.replace(RegExp, replace),
134					iL.options.social.hide = iL.options.social.hide.replace(RegExp, replace);
135			}
136
137			if (iL.options.controls.arrows || $(window).width() < UNCODE.mediaQuery) {
138				$.extend(iL.options.styles, {
139					nextOffsetX: ($(window).width() > UNCODE.mediaQuery) ? 36 : 4,
140					prevOffsetX: ($(window).width() > UNCODE.mediaQuery) ? 36 : 4,
141					nextOpacity: 0,
142					prevOpacity: 0
143				});
144			}
145		};
146
147	//iLightBox helpers
148	iLightBox.prototype = {
149		showLoader: function() {
150			var iL = this;
151			iL.vars.loadRequests += 1;
152			if (iL.options.path.toLowerCase() == "horizontal") iL.vars.loader.addClass('ilightbox-show').stop().animate({
153				//top: '-30px'
154				opacity: '1'
155			}, iL.options.show.speed, 'easeOutCirc');
156			else iL.vars.loader.addClass('ilightbox-show').stop().animate({
157				//left: '-30px'
158				opacity: '1'
159			}, iL.options.show.speed, 'easeOutCirc');
160		},
161
162		hideLoader: function() {
163			var iL = this;
164			iL.vars.loadRequests -= 1;
165			iL.vars.loadRequests = (iL.vars.loadRequests < 0) ? 0 : iL.vars.loadRequests;
166			if (iL.options.path.toLowerCase() == "horizontal") {
167				if (iL.vars.loadRequests <= 0) iL.vars.loader.removeClass('ilightbox-show').stop().animate({
168					//top: '-192px'
169					opacity: '0'
170				}, iL.options.show.speed, 'easeInCirc');
171			} else {
172				if (iL.vars.loadRequests <= 0) iL.vars.loader.removeClass('ilightbox-show').stop().animate({
173					//left: '-192px'
174					opacity: '0'
175				}, iL.options.show.speed, 'easeInCirc');
176			}
177		},
178
179		createUI: function() {
180			var iL = this;
181
182			iL.ui = {
183				currentElement: iL.vars.holder,
184				nextElement: iL.vars.nextPhoto,
185				prevElement: iL.vars.prevPhoto,
186				currentItem: iL.vars.current,
187				nextItem: iL.vars.next,
188				prevItem: iL.vars.prev,
189				hide: function() {
190					iL.closeAction();
191				},
192				refresh: function() {
193					(arguments.length > 0) ? iL.repositionPhoto(true): iL.repositionPhoto();
194				},
195				fullscreen: function() {
196					iL.fullScreenAction();
197				}
198			};
199		},
200
201		attachItems: function() {
202			var iL = this,
203				itemsObject = new Array(),
204				items = new Array();
205
206			$(iL.selector, iL.context).each(function() {
207				var t = $(this),
208					URL = t.attr(iL.options.attr) || null,
209					options = t.data("options") && eval("({" + t.data("options") + "})") || {},
210					caption = t.data('caption'),
211					title = t.data('title'),
212					type = t.data('type') || getTypeByExtension(URL),
213					clone = t.data('lbox-clone') || false;
214
215				//Uncode addition ##START##
216				if (type === false) {
217					return;
218				}
219				//Uncode addition ##END##
220
221				if (t.data('lbox-clone') != undefined) return;
222
223				//Uncode addition ##START##
224				if ( typeof t.attr('data-album') != 'undefined' && t.attr('data-album') != '' ) {
225					var ALBUM_URLS = JSON.parse(t.attr('data-album')),
226						URL_i,
227						URLS_LENGHT = ALBUM_URLS.length;
228
229					for (URL_i = 0; URL_i < URLS_LENGHT; URL_i++) {
230						if ( typeof ALBUM_URLS[URL_i].url !== 'undefined' && ALBUM_URLS[URL_i].url != '' ) {
231							var item_opts = 'width:' + ALBUM_URLS[URL_i].width + ',height:' + ALBUM_URLS[URL_i].height + ',thumbnail: \'' + ALBUM_URLS[URL_i].thumbnail + '\'';
232							item_opts = item_opts && eval("({" + item_opts + "})") || {},
233							items.push({
234								URL: ALBUM_URLS[URL_i].url,
235								caption: ALBUM_URLS[URL_i].caption,
236								title: ALBUM_URLS[URL_i].title,
237								type: getTypeByExtension(ALBUM_URLS[URL_i].url),
238								options: item_opts,
239								clone: clone
240							});
241							var newT = t;
242							newT.attr('href',ALBUM_URLS[URL_i].url);
243							if (!iL.instant) itemsObject.push(newT);
244						}
245					}
246				} else {
247				//Uncode addition ##END##
248					items.push({
249						URL: URL,
250						caption: caption,
251						title: title,
252						type: type,
253						options: options,
254						clone: clone
255					});
256				}
257
258
259				if (iL.vars != undefined) iL.vars.total = items.length;
260
261				if (!iL.instant) itemsObject.push(t);
262			});
263
264			iL.items = items,
265				iL.itemsObject = itemsObject;
266
267		},
268
269		normalizeItems: function() {
270			var iL = this,
271				newItems = new Array();
272
273			$.each(iL.items, function(key, val) {
274
275				if (typeof val == "string") val = {
276					url: val
277				};
278
279				var URL = val.url || val.URL || null,
280					options = val.options || {},
281					caption = val.caption || null,
282					title = val.title || null,
283					type = (val.type) ? val.type.toLowerCase() : getTypeByExtension(URL),
284					ext = (typeof URL != 'object') ? getExtension(URL) : '';
285
286				options.thumbnail = options.thumbnail || ((type == "image") ? URL : null),
287				options.videoType = options.videoType || null,
288				options.skin = options.skin || iL.options.skin,
289				options.width = options.width || null,
290				options.height = options.height || null,
291				options.mousewheel = (typeof options.mousewheel != 'undefined') ? options.mousewheel : true,
292				options.swipe = (typeof options.swipe != 'undefined') ? options.swipe : true,
293				options.social = (typeof options.social != 'undefined') ? options.social : iL.options.social.buttons && $.extend({}, {}, iL.options.social.buttons);
294
295				if (type == "video") {
296					options.html5video = (typeof options.html5video != 'undefined') ? options.html5video : {};
297
298					options.html5video.webm = options.html5video.webm || options.html5video.WEBM || null;
299					options.html5video.controls = (typeof options.html5video.controls != 'undefined') ? options.html5video.controls : "controls";
300					options.html5video.preload = options.html5video.preload || "metadata";
301					options.html5video.autoplay = (typeof options.html5video.autoplay != 'undefined') ? options.html5video.autoplay : false;
302					//UNCODE addition
303					options.html5video.loop = (typeof options.html5video.loop != 'undefined') ? options.html5video.loop : false;
304				}
305
306				if (!options.width || !options.height) {
307					if (type == "video") options.width = 1280, options.height = 720;
308					else if (type == "iframe") options.width = '100%', options.height = '90%';
309					else if (type == "flash") options.width = 1280, options.height = 720;
310				}
311
312				delete val.url;
313				val.index = key;
314				val.URL = URL;
315				val.caption = caption;
316				val.title = title;
317				val.type = type;
318				val.options = options;
319				val.ext = ext;
320
321				newItems.push(val);
322			});
323
324			iL.items = newItems;
325		},
326
327		instantCall: function() {
328			var iL = this,
329				key = iL.vars.start;
330
331			iL.vars.current = key;
332			iL.vars.next = (iL.items[key + 1]) ? key + 1 : null;
333			iL.vars.prev = (iL.items[key - 1]) ? key - 1 : null;
334
335			iL.addContents();
336			iL.patchEvents();
337		},
338
339		addContents: function() {
340			var iL = this,
341				vars = iL.vars,
342				opts = iL.options,
343				viewport = getViewport(),
344				path = opts.path.toLowerCase(),
345				recognizingItems = vars.total > 0 && iL.items.filter(function(e, i, arr) {
346					return ['image', 'flash', 'video'].indexOf(e.type) === -1 && typeof e.recognized === 'undefined' && (opts.smartRecognition || e.options.smartRecognition);
347				}),
348				needRecognition = recognizingItems.length > 0;
349
350			if (opts.mobileOptimizer && !opts.innerToolbar)
351				vars.isMobile = viewport.width <= vars.mobileMaxWidth;
352
353			vars.overlay.addClass(opts.skin).hide().css('opacity', opts.overlay.opacity);
354
355			if (opts.linkId)
356				vars.overlay[0].setAttribute('linkid', opts.linkId);
357
358			//Add Toolbar Buttons
359			if (opts.controls.toolbar) {
360				vars.toolbar.addClass(opts.skin).append(vars.closeButton);
361				if (opts.controls.fullscreen)
362					vars.toolbar.append(vars.fullScreenButton);
363				if (opts.controls.slideshow)
364					vars.toolbar.append(vars.innerPlayButton);
365				if (vars.total > 1)
366					vars.toolbar.append(vars.innerPrevButton).append(vars.innerNextButton);
367			}
368
369			//Append elements to body
370			vars.BODY.addClass('ilightbox-noscroll').append(vars.overlay).append(vars.loader).append(vars.holder).append(vars.nextPhoto).append(vars.prevPhoto);
371
372			if (!opts.innerToolbar)
373				vars.BODY.append(vars.toolbar);
374			if (opts.controls.arrows)
375				vars.BODY.append(vars.nextButton).append(vars.prevButton);
376
377			if (opts.controls.thumbnail && vars.total > 1) {
378				vars.BODY.append(vars.thumbnails);
379				vars.thumbnails.addClass(opts.skin).addClass('ilightbox-' + path);
380				$('div.ilightbox-thumbnails-grid', vars.thumbnails).empty();
381				vars.thumbs = true;
382			}
383
384			//Configure loader and arrows
385			var loaderCss = (opts.path.toLowerCase() == "horizontal") ? {
386				left: parseInt((viewport.width / 2) - (vars.loader.outerWidth() / 2))
387			} : {
388				top: parseInt((viewport.height / 2) - (vars.loader.outerHeight() / 2))
389			};
390			vars.loader.addClass(opts.skin).css(loaderCss);
391			vars.nextButton.add(vars.prevButton).addClass(opts.skin);
392			if (path == "horizontal")
393				vars.loader.add(vars.nextButton).add(vars.prevButton).addClass('horizontal');
394
395			// Configure arrow buttons
396			vars.BODY[vars.isMobile ? 'addClass' : 'removeClass']('isMobile');
397
398			if (!opts.infinite) {
399				vars.prevButton.add(vars.prevButton).add(vars.innerPrevButton).add(vars.innerNextButton).removeClass('disabled');
400
401				if (vars.current == 0)
402					vars.prevButton.add(vars.innerPrevButton).addClass('disabled');
403				if (vars.current >= vars.total - 1)
404					vars.nextButton.add(vars.innerNextButton).addClass('disabled');
405			}
406
407			if (opts.show.effect) {
408				vars.overlay.stop().fadeIn(opts.show.speed);
409				vars.toolbar.stop().fadeIn(opts.show.speed);
410			} else {
411				vars.overlay.show();
412				vars.toolbar.show();
413			}
414
415			var length = recognizingItems.length;
416			if (needRecognition) {
417				iL.showLoader();
418
419				$.each(recognizingItems, function(key, val) {
420					var resultFnc = function(result) {
421							var key = -1,
422								filter = iL.items.filter(function(e, i, arr) {
423									if (e.URL == result.url)
424										key = i;
425
426									return e.URL == result.url;
427								}),
428								self = iL.items[key];
429
430							if (result)
431								$.extend(true, self, {
432									URL: result.source,
433									type: result.type,
434									recognized: true,
435									options: {
436										html5video: result.html5video,
437										width: (result.type == "image") ? 0 : (result.width || self.width),
438										height: (result.type == "image") ? 0 : (result.height || self.height),
439										thumbnail: self.options.thumbnail || result.thumbnail
440									}
441								});
442
443							length--;
444
445							if (length == 0) {
446								iL.hideLoader();
447
448								vars.dontGenerateThumbs = false;
449								iL.generateThumbnails();
450
451								if (opts.show.effect)
452									setTimeout(function() {
453										iL.generateBoxes();
454									}, opts.show.speed);
455								else
456									iL.generateBoxes();
457							}
458						};
459
460					iL.ogpRecognition(this, resultFnc);
461				});
462			}
463			else {
464				if (opts.show.effect)
465					setTimeout(function() {
466						iL.generateBoxes();
467					}, opts.show.speed);
468				else
469					iL.generateBoxes();
470			}
471
472			iL.createUI();
473
474			window.iLightBox = {
475				close: function() {
476					iL.closeAction();
477				},
478				fullscreen: function() {
479					iL.fullScreenAction();
480				},
481				moveNext: function() {
482					iL.moveTo('next');
483				},
484				movePrev: function() {
485					iL.moveTo('prev');
486				},
487				goTo: function(index) {
488					iL.goTo(index);
489				},
490				refresh: function() {
491					iL.refresh();
492				},
493				reposition: function() {
494					(arguments.length > 0) ? iL.repositionPhoto(true): iL.repositionPhoto();
495				},
496				setOption: function(options) {
497					iL.setOption(options);
498				},
499				destroy: function() {
500					iL.closeAction();
501					iL.dispatchItemsEvents();
502				}
503			};
504
505			if (opts.linkId) {
506				vars.hashLock = true;
507				window.location.hash = opts.linkId + '/' + vars.current;
508				setTimeout(function() {
509					vars.hashLock = false;
510				}, 55);
511			}
512
513			if (!opts.slideshow.startPaused) {
514				iL.resume();
515				vars.innerPlayButton.removeClass('ilightbox-play').addClass('ilightbox-pause');
516			}
517
518			//Trigger the onOpen callback
519			if (typeof iL.options.callback.onOpen == 'function') iL.options.callback.onOpen.call(iL);
520		},
521
522		loadContent: function(obj, opt, speed) {
523			var iL = this,
524				holder, item;
525
526			iL.createUI();
527
528			obj.speed = speed || iL.options.effects.loadedFadeSpeed;
529
530			if (opt == 'current') {
531				if (!obj.options.mousewheel) iL.vars.lockWheel = true;
532				else iL.vars.lockWheel = false;
533
534				if (!obj.options.swipe) iL.vars.lockSwipe = true;
535				else iL.vars.lockSwipe = false;
536			}
537
538			switch (opt) {
539				case 'current':
540					holder = iL.vars.holder, item = iL.vars.current;
541					break;
542				case 'next':
543					holder = iL.vars.nextPhoto, item = iL.vars.next;
544					break;
545				case 'prev':
546					holder = iL.vars.prevPhoto, item = iL.vars.prev;
547					break;
548			}
549
550			holder.removeAttr('style class').addClass('ilightbox-holder' + (supportTouch ? ' supportTouch' : '')).addClass(obj.options.skin);
551			$('div.ilightbox-inner-toolbar', holder).remove();
552
553			if (obj.title || iL.options.innerToolbar) {
554				var innerToolbar = iL.vars.innerToolbar.clone();
555				if (obj.title && iL.options.show.title) {
556					var title = iL.vars.title.clone();
557					title.empty().html(obj.title);
558					innerToolbar.append(title);
559				}
560				if (iL.options.innerToolbar) {
561					innerToolbar.append((iL.vars.total > 1) ? iL.vars.toolbar.clone() : iL.vars.toolbar);
562				}
563				holder.prepend(innerToolbar);
564			}
565
566			//console.warn('loadContent', arguments);
567
568			iL.loadSwitcher(obj, holder, item, opt);
569		},
570
571		loadSwitcher: function(obj, holder, item, opt) {
572			var iL = this,
573				opts = iL.options,
574				api = {
575					element: holder,
576					position: item
577				};
578
579			switch (obj.type) {
580				case 'image':
581					//Trigger the onBeforeLoad callback
582					if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
583					if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
584
585					iL.loadImage(obj.URL, function(img) {
586						//Trigger the onAfterLoad callback
587						if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
588						if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
589
590						var width = (img) ? img.width : 400,
591							height = (img) ? img.height : 200;
592
593						holder.data({
594							naturalWidth: width,
595							naturalHeight: height
596						});
597
598						$('div.ilightbox-container', holder).empty().append((img) ? '<img src="' + obj.URL + '" class="ilightbox-image" />' : '<span class="ilightbox-alert">' + opts.errors.loadImage + '</span>');
599
600						//Trigger the onRender callback
601						if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
602						if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
603
604						iL.configureHolder(obj, opt, holder);
605					});
606
607					break;
608
609				case 'video':
610					holder.data({
611						naturalWidth: obj.options.width,
612						naturalHeight: obj.options.height
613					});
614
615					if (opt === 'current') {
616						iL.addContent(holder, obj);
617
618						//Trigger the onRender callback
619						if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
620						if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
621					} else {
622						$('div.ilightbox-container', holder).empty();
623					}
624
625					iL.configureHolder(obj, opt, holder);
626
627					break;
628
629				case 'iframe':
630					//iL.showLoader();
631					holder.data({
632						naturalWidth: obj.options.width,
633						naturalHeight: obj.options.height
634					});
635
636					iL.configureHolder(obj, opt, holder);
637
638					if (opt === 'current') {
639						var el = iL.addContent(holder, obj);
640
641						//Trigger the onRender callback
642						if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
643						if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
644
645						//Trigger the onBeforeLoad callback
646						if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
647						if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
648
649						el.bind('load', function() {
650							//Trigger the onAfterLoad callback
651							if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
652							if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
653
654							//iL.hideLoader();
655							el.unbind('load');
656						});
657					} else {
658						$('div.ilightbox-container', holder).empty();
659					}
660
661					break;
662
663				case 'inline':
664					var el = $(obj.URL),
665						content = iL.addContent(holder, obj),
666						images = findImageInElement(holder);
667
668					holder.data({
669						naturalWidth: (iL.items[item].options.width || el.outerWidth()),
670						naturalHeight: (iL.items[item].options.height || el.outerHeight())
671					});
672					content.children().eq(0).show();
673
674					//Trigger the onRender callback
675					if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
676					if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
677
678					//Trigger the onBeforeLoad callback
679					if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
680					if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
681
682					iL.loadImage(images, function() {
683						//Trigger the onAfterLoad callback
684						if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
685						if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
686
687						iL.configureHolder(obj, opt, holder);
688					});
689
690					break;
691
692				case 'flash':
693					var el = iL.addContent(holder, obj);
694
695					holder.data({
696						naturalWidth: (iL.items[item].options.width || el.outerWidth()),
697						naturalHeight: (iL.items[item].options.height || el.outerHeight())
698					});
699
700					//Trigger the onRender callback
701					if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
702					if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
703
704					iL.configureHolder(obj, opt, holder);
705
706					break;
707
708				case 'ajax':
709					var ajax = obj.options.ajax || {};
710					//Trigger the onBeforeLoad callback
711					if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
712					if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
713
714					iL.showLoader();
715					$.ajax({
716						url: obj.URL || opts.ajaxSetup.url,
717						data: ajax.data || null,
718						dataType: ajax.dataType || "html",
719						type: ajax.type || opts.ajaxSetup.type,
720						cache: ajax.cache || opts.ajaxSetup.cache,
721						crossDomain: ajax.crossDomain || opts.ajaxSetup.crossDomain,
722						global: ajax.global || opts.ajaxSetup.global,
723						ifModified: ajax.ifModified || opts.ajaxSetup.ifModified,
724						username: ajax.username || opts.ajaxSetup.username,
725						password: ajax.password || opts.ajaxSetup.password,
726						beforeSend: ajax.beforeSend || opts.ajaxSetup.beforeSend,
727						complete: ajax.complete || opts.ajaxSetup.complete,
728						success: function(data, textStatus, jqXHR) {
729							iL.hideLoader();
730
731							var el = $(data),
732								container = $('div.ilightbox-container', holder),
733								elWidth = iL.items[item].options.width || parseInt(el[0].getAttribute('width')),
734								elHeight = iL.items[item].options.height || parseInt(el[0].getAttribute('height')),
735								css = (el[0].getAttribute('width') && el[0].getAttribute('height')) ? {
736									'overflow': 'hidden'
737								} : {};
738
739							container.empty().append($('<div class="ilightbox-wrapper"></div>').css(css).html(el));
740							holder.show().data({
741								naturalWidth: (elWidth || container.outerWidth()),
742								naturalHeight: (elHeight || container.outerHeight())
743							}).hide();
744
745							//Trigger the onRender callback
746							if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
747							if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
748
749							var images = findImageInElement(holder);
750							iL.loadImage(images, function() {
751								//Trigger the onAfterLoad callback
752								if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
753								if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
754
755								iL.configureHolder(obj, opt, holder);
756							});
757
758							opts.ajaxSetup.success(data, textStatus, jqXHR);
759							if (typeof ajax.success == 'function') ajax.success(data, textStatus, jqXHR);
760						},
761						error: function(jqXHR, textStatus, errorThrown) {
762							//Trigger the onAfterLoad callback
763							if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
764							if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
765
766							iL.hideLoader();
767							$('div.ilightbox-container', holder).empty().append('<span class="ilightbox-alert">' + opts.errors.loadContents + '</span>');
768							iL.configureHolder(obj, opt, holder);
769
770							opts.ajaxSetup.error(jqXHR, textStatus, errorThrown);
771							if (typeof ajax.error == 'function') ajax.error(jqXHR, textStatus, errorThrown);
772						}
773					});
774
775					break;
776
777				case 'html':
778					var object = obj.URL,
779						el
780					container = $('div.ilightbox-container', holder);
781
782					if (object[0].nodeName) el = object.clone();
783					else {
784						var dom = $(object);
785						if (dom.selector) el = $('<div>' + dom + '</div>');
786						else el = dom;
787					}
788
789					var elWidth = iL.items[item].options.width || parseInt(el.attr('width')),
790						elHeight = iL.items[item].options.height || parseInt(el.attr('height'));
791
792					iL.addContent(holder, obj);
793
794					el.appendTo(document.documentElement).hide();
795
796					//Trigger the onRender callback
797					if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
798					if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
799
800					var images = findImageInElement(holder);
801
802					//Trigger the onBeforeLoad callback
803					if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
804					if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
805
806					iL.loadImage(images, function() {
807						//Trigger the onAfterLoad callback
808						if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
809						if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
810
811						holder.show().data({
812							naturalWidth: (elWidth || container.outerWidth()),
813							naturalHeight: (elHeight || container.outerHeight())
814						}).hide();
815						el.remove();
816
817						iL.configureHolder(obj, opt, holder);
818					});
819
820					break;
821			}
822		},
823
824		configureHolder: function(obj, opt, holder) {
825			var iL = this,
826				vars = iL.vars,
827				opts = iL.options;
828
829			if (opt != "current")(opt == "next") ? holder.addClass('ilightbox-next') : holder.addClass('ilightbox-prev');
830
831			if (opt == "current")
832				var item = vars.current;
833			else if (opt == "next")
834				var opacity = opts.styles.nextOpacity,
835					item = vars.next;
836			else
837				var opacity = opts.styles.prevOpacity,
838					item = vars.prev;
839
840			var api = {
841				element: holder,
842				position: item
843			};
844
845			iL.items[item].options.width = iL.items[item].options.width || 0,
846			iL.items[item].options.height = iL.items[item].options.height || 0;
847
848			if (opt == "current") {
849				if (opts.show.effect) holder.css(transform, gpuAcceleration).fadeIn(obj.speed, function() {
850					holder.css(transform, '');
851					if (obj.caption) {
852						iL.setCaption(obj, holder);
853						var caption = $('div.ilightbox-caption', holder),
854							percent = parseInt((caption.outerHeight() / holder.outerHeight()) * 100);
855						if (opts.caption.start & percent <= 50) caption.fadeIn(opts.effects.fade
855Speed);
856					}
857
858					var social = obj.options.social;
859					if (social) {
860						iL.setSocial(social, obj.URL, holder);
861						if (opts.social.start) $('div.ilightbox-social', holder).fadeIn(opts.effects.fadeSpeed);
862					}
863
864					//Generate thumbnails
865					iL.generateThumbnails();
866
867					//Trigger the onShow callback
868					if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
869					if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
870				});
871				else {
872					holder.show();
873
874					//Generate thumbnails
875					iL.generateThumbnails();
876
877					//Trigger the onShow callback
878					if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
879					if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
880				}
881			} else {
882				if (opts.show.effect) holder.fadeTo(obj.speed, opacity, function() {
883					if (opt == "next") vars.nextLock = false;
884					else vars.prevLock = false;
885
886					//Generate thumbnails
887					iL.generateThumbnails();
888
889					//Trigger the onShow callback
890					if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
891					if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
892				});
893				else {
894					holder.css({
895						opacity: opacity
896					}).show();
897					if (opt == "next") vars.nextLock = false;
898					else vars.prevLock = false;
899
900					//Generate thumbnails
901					iL.generateThumbnails();
902
903					//Trigger the onShow callback
904					if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
905					if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
906				}
907			}
908
909			setTimeout(function() {
910				iL.repositionPhoto();
911			}, 0);
912		},
913
914		generateBoxes: function() {
915			var iL = this,
916				vars = iL.vars,
917				opts = iL.options;
918
919			if (opts.infinite && vars.total >= 3) {
920				if (vars.current == vars.total - 1) vars.next = 0;
921				if (vars.current == 0) vars.prev = vars.total - 1;
922			} else opts.infinite = false;
923
924			//UNCODE addition
925			if ( typeof iL.items[vars.current] == 'undefined' )
926				vars.current = 0;
927
928			iL.loadContent(iL.items[vars.current], 'current', opts.show.speed);
929
930			if (iL.items[vars.next]) iL.loadContent(iL.items[vars.next], 'next', opts.show.speed);
931			if (iL.items[vars.prev]) iL.loadContent(iL.items[vars.prev], 'prev', opts.show.speed);
932		},
933
934		generateThumbnails: function() {
935			var iL = this,
936				vars = iL.vars,
937				opts = iL.options,
938				timeOut = null;
939
940			if (vars.thumbs && !iL.vars.dontGenerateThumbs) {
941				var thumbnails = vars.thumbnails,
942					container = $('div.ilightbox-thumbnails-container', thumbnails),
943					grid = $('div.ilightbox-thumbnails-grid', container),
944					i = 0;
945
946				grid.removeAttr('style').empty();
947
948				$.each(iL.items, function(key, val) {
949					var isActive = (vars.current == key) ? 'ilightbox-active' : '',
950						opacity = (vars.current == key) ? opts.thumbnails.activeOpacity : opts.thumbnails.normalOpacity,
951						thumb = val.options.thumbnail,
952						thumbnail = $('<div class="ilightbox-thumbnail"></div>'),
953						icon = $('<div class="ilightbox-thumbnail-icon"></div>');
954
955					thumbnail.css({
956						opacity: 0
957					}).addClass(isActive);
958
959					if ((val.type == "video" || val.type == "flash") && typeof val.options.icon == 'undefined') {
960						icon.addClass('ilightbox-thumbnail-video');
961						thumbnail.append(icon);
962					} else if (val.options.icon) {
963						icon.addClass('ilightbox-thumbnail-' + val.options.icon);
964						thumbnail.append(icon);
965					}
966
967					if (thumb) iL.loadImage(thumb, function(img) {
968						i++;
969						if (img) thumbnail.data({
970							naturalWidth: img.width,
971							naturalHeight: img.height
972						}).append('<img src="' + thumb + '" border="0" />');
973						else thumbnail.data({
974							naturalWidth: opts.thumbnails.maxWidth,
975							naturalHeight: opts.thumbnails.maxHeight
976						});
977
978						clearTimeout(timeOut);
979						timeOut = setTimeout(function() {
980							iL.positionThumbnails(thumbnails, container, grid);
981						}, 20);
982						setTimeout(function() {
983							thumbnail.fadeTo(opts.effects.loadedFadeSpeed, opacity);
984						}, i * 20);
985					});
986
987					grid.append(thumbnail);
988				});
989				iL.vars.dontGenerateThumbs = true;
990			}
991		},
992
993		positionThumbnails: function(thumbnails, container, grid) {
994			var iL = this,
995				vars = iL.vars,
996				opts = iL.options,
997				viewport = getViewport(),
998				path = opts.path.toLowerCase();
999
1000			if (!thumbnails) thumbnails = vars.thumbnails;
1001			if (!container) container = $('div.ilightbox-thumbnails-container', thumbnails);
1002			if (!grid) grid = $('div.ilightbox-thumbnails-grid', container);
1003
1004			var thumbs = $('.ilightbox-thumbnail', grid),
1005				widthAvail = (path == 'horizontal') ? viewport.width - opts.styles.pageOffsetX : thumbs.eq(0).outerWidth() - opts.styles.pageOffsetX,
1006				heightAvail = (path == 'horizontal') ? thumbs.eq(0).outerHeight() - opts.styles.pageOffsetY : viewport.height - opts.styles.pageOffsetY,
1007				gridWidth = (path == 'horizontal') ? 0 : widthAvail,
1008				gridHeight = (path == 'horizontal') ? heightAvail : 0,
1009				active = $('.ilightbox-active', grid),
1010				gridCss = {},
1011				css = {};
1012
1013			if (arguments.length < 3) {
1014				thumbs.css({
1015					opacity: opts.thumbnails.normalOpacity
1016				});
1017				active.css({
1018					opacity: opts.thumbnails.activeOpacity
1019				});
1020			}
1021
1022			thumbs.each(function(i) {
1023				var t = $(this),
1024					data = t.data(),
1025					width = (path == 'horizontal') ? 0 : opts.thumbnails.maxWidth;
1026				height = (path == 'horizontal') ? opts.thumbnails.maxHeight : 0;
1027				dims = iL.getNewDimenstions(width, height, data.naturalWidth, data.naturalHeight, true);
1028
1029				t.css({
1030					width: dims.width,
1031					height: dims.height
1032				});
1033				if (path == 'horizontal') t.css({
1034					'float': 'left'
1035				});
1036
1037				(path == 'horizontal') ? (
1038					gridWidth += t.outerWidth()
1039				) : (
1040					gridHeight += t.outerHeight()
1041				);
1042			});
1043
1044			gridCss = {
1045				width: gridWidth,
1046				height: gridHeight
1047			};
1048
1049			grid.css(gridCss);
1050
1051			gridCss = {};
1052
1053			var gridOffset = grid.offset(),
1054				activeOffset = (active.length) ? active.offset() : {
1055					top: parseInt(heightAvail / 2),
1056					left: parseInt(widthAvail / 2)
1057				};
1058
1059			gridOffset.top = (gridOffset.top - $doc.scrollTop()),
1060				gridOffset.left = (gridOffset.left - $doc.scrollLeft()),
1061				activeOffset.top = (activeOffset.top - gridOffset.top - $doc.scrollTop()),
1062				activeOffset.left = (activeOffset.left - gridOffset.left - $doc.scrollLeft());
1063
1064			(path == 'horizontal') ? (
1065				gridCss.top = 0,
1066				gridCss.left = parseInt((widthAvail / 2) - activeOffset.left - (active.outerWidth() / 2))
1067			) : (
1068				gridCss.top = parseInt(((heightAvail / 2) - activeOffset.top - (active.outerHeight() / 2))),
1069				gridCss.left = 0
1070			);
1071
1072			if (arguments.length < 3) grid.stop().animate(gridCss, opts.effects.repositionSpeed, 'easeOutCirc');
1073			else grid.css(gridCss);
1074		},
1075
1076		loadImage: function(image, callback) {
1077			if (!$.isArray(image)) image = [image];
1078
1079			var iL = this,
1080				length = image.length;
1081
1082			if (length > 0) {
1083				iL.showLoader();
1084				$.each(image, function(index, value) {
1085					var img = new Image();
1086					img.onload = function() {
1087						length -= 1;
1088						if (length == 0) {
1089							iL.hideLoader();
1090							callback(img);
1091						}
1092					};
1093					img.onerror = img.onabort = function() {
1094						length -= 1;
1095						if (length == 0) {
1096							iL.hideLoader();
1097							callback(false);
1098						}
1099					};
1100					img.src = image[index];
1101				});
1102			} else callback(false);
1103		},
1104
1105		patchItemsEvents: function() {
1106			var iL = this,
1107				vars = iL.vars,
1108				clickEvent = ishybrid ? "itap.iL click.iL" : supportTouch ? "itap.iL" : "click.iL",
1109				vEvent = ishybrid ? "click.iL itap.iL" : supportTouch ? "click.iL" : "itap.iL";
1110
1111			if (iL.context && iL.selector) {
1112				var $items = $(iL.selector, iL.context);
1113
1114				$(iL.context).on(clickEvent, iL.selector, function() {
1115					var $this = $(this),
1116						//UNCODE addition
1117						key = typeof $(this).data('lb-index') !== '' && $(this).closest('.owl-item').length ? $(this).data('lb-index') : $items.index($this);
1118					if (UNCODE.isMobile) {
1119						var isCarousel = $this.closest('.owl-carousel');
1120						if (isCarousel.length) {
1121							if (isCarousel.hasClass('owl-translating')) return false;
1122						}
1123					}
1124
1125					vars.current = key;
1126					vars.next = iL.items[key + 1] ? key + 1 : null;
1127					vars.prev = iL.items[key - 1] ? key - 1 : null;
1128
1129					//UNCODE addition
1130					if ( vars.BODY.hasClass('fp-slide-scrolling') )
1131						return false;
1132
1133					iL.addContents();
1134					iL.patchEvents();
1135
1136					return false;
1137				}).on(vEvent, iL.selector, function() {
1138					return false;
1139				});
1140			} else
1141				$.each(iL.itemsObject, function(key, val) {
1142					val.on(clickEvent, function() {
1143						vars.current = key;
1144						vars.next = iL.items[key + 1] ? key + 1 : null;
1145						vars.prev = iL.items[key - 1] ? key - 1 : null;
1146
1147						iL.addContents();
1148						iL.patchEvents();
1149
1150						return false;
1151					}).on(vEvent, function() {
1152						return false;
1153					});
1154				});
1155		},
1156
1157		dispatchItemsEvents: function() {
1158			var iL = this,
1159				vars = iL.vars,
1160				opts = iL.options;
1161
1162			if (iL.context && iL.selector)
1163				$(iL.context).off('.iL', iL.selector);
1164			else
1165				$.each(iL.itemsObject, function(key, val) {
1166					val.off('.iL');
1167				});
1168		},
1169
1170		refresh: function() {
1171			var iL = this;
1172
1173			iL.dispatchItemsEvents();
1174			iL.attachItems();
1175			iL.normalizeItems();
1176			iL.patchItemsEvents();
1177		},
1178
1179		patchEvents: function() {
1180			var iL = this,
1181				vars = iL.vars,
1182				opts = iL.options,
1183				path = opts.path.toLowerCase(),
1184				holders = $('.ilightbox-holder'),
1185				fullscreenEvent = fullScreenApi.fullScreenEventName + '.iLightBox',
1186				durationThreshold = 1000,
1187				horizontalDistanceThreshold =
1188				verticalDistanceThreshold = 100,
1189				buttonsArray = [vars.nextButton[0], vars.prevButton[0], vars.nextButton[0].firstChild, vars.prevButton[0].firstChild];
1190
1191			$win.bind('resize.iLightBox', function() {
1192				var viewport = getViewport();
1193
1194				if (opts.mobileOptimizer && !opts.innerToolbar) vars.isMobile = viewport.width <= vars.mobileMaxWidth;
1195				vars.BODY[vars.isMobile ? 'addClass' : 'removeClass']('isMobile');
1196
1197				iL.repositionPhoto(null);
1198				if (supportTouch) {
1199					clearTimeout(vars.setTime);
1200					vars.setTime = setTimeout(function() {
1201						var scrollTop = getScrollXY().y;
1202						window.scrollTo(0, scrollTop - 30);
1203						window.scrollTo(0, scrollTop + 30);
1204						window.scrollTo(0, scrollTop);
1205					}, 2000);
1206				}
1207				if (vars.thumbs) iL.positionThumbnails();
1208			}).bind('keydown.iLightBox', function(event) {
1209				if (opts.controls.keyboard) {
1210					switch (event.keyCode) {
1211						case 13:
1212							if (event.shiftKey && opts.keyboard.shift_enter) iL.fullScreenAction();
1213							break;
1214						case 27:
1215							if (opts.keyboard.esc) iL.closeAction();
1216							break;
1217						case 37:
1218							if (opts.keyboard.left && !vars.lockKey) iL.moveTo('prev');
1219							break;
1220						case 38:
1221							if (opts.keyboard.up && !vars.lockKey) iL.moveTo('prev');
1222							break;
1223						case 39:
1224							if (opts.keyboard.right && !vars.lockKey) iL.moveTo('next');
1225							break;
1226						case 40:
1227							if (opts.keyboard.down && !vars.lockKey) iL.moveTo('next');
1228							break;
1229					}
1230				}
1231			});
1232
1233			if (fullScreenApi.supportsFullScreen) $win.bind(fullscreenEvent, function() {
1234				iL.doFullscreen();
1235			});
1236
1237			var holderEventsArr = [opts.caption.show + '.iLightBox', opts.caption.hide + '.iLightBox', opts.social.show + '.iLightBox', opts.social.hide + '.iLightBox'].filter(function(e, i, arr) {
1238					return arr.lastIndexOf(e) === i;
1239				}),
1240				holderEvents = "";
1241
1242			$.each(holderEventsArr, function(key, val) {
1243				if (key != 0) holderEvents += ' ';
1244				holderEvents += val;
1245			});
1246
1247			$doc.on(clickEvent, '.ilightbox-overlay', function() {
1248				if (opts.overlay.blur) iL.closeAction();
1249			}).on(clickEvent, '.ilightbox-next, .ilightbox-next-button', function() {
1250				iL.moveTo('next');
1251			}).on(clickEvent, '.ilightbox-prev, .ilightbox-prev-button', function() {
1252				iL.moveTo('prev');
1253			}).on(clickEvent, '.ilightbox-thumbnail', function() {
1254				var t = $(this),
1255					thumbs = $('.ilightbox-thumbnail', vars.thumbnails),
1256					index = thumbs.index(t);
1257
1258				if (index != vars.current) iL.goTo(index);
1259			}).on(holderEvents, '.ilightbox-holder:not(.ilightbox-next, .ilightbox-prev)', function(e) {
1260				var caption = $('div.ilightbox-caption', vars.holder),
1261					social = $('div.ilightbox-social', vars.holder),
1262					fadeSpeed = opts.effects.fadeSpeed;
1263
1264				if (vars.nextLock || vars.prevLock) {
1265					if (e.type == opts.caption.show && !caption.is(':visible')) caption.fadeIn(fadeSpeed);
1266					else if (e.type == opts.caption.hide && caption.is(':visible')) caption.fadeOut(fadeSpeed);
1267
1268					if (e.type == opts.social.show && !social.is(':visible')) social.fadeIn(fadeSpeed);
1269					else if (e.type == opts.social.hide && social.is(':visible')) social.fadeOut(fadeSpeed);
1270				} else {
1271					if (e.type == opts.caption.show && !caption.is(':visible')) caption.stop().fadeIn(fadeSpeed);
1272					else if (e.type == opts.caption.hide && caption.is(':visible')) caption.stop().fadeOut(fadeSpeed);
1273
1274					if (e.type == opts.social.show && !social.is(':visible')) social.stop().fadeIn(fadeSpeed);
1275					else if (e.type == opts.social.hide && social.is(':visible')) social.stop().fadeOut(fadeSpeed);
1276				}
1277			}).on('mouseenter.iLightBox mouseleave.iLightBox', '.ilightbox-wrapper', function(e) {
1278				if (e.type == 'mouseenter') vars.lockWheel = true;
1279				else vars.lockWheel = false;
1280			}).on(clickEvent, '.ilightbox-toolbar a.ilightbox-close, .ilightbox-toolbar a.ilightbox-fullscreen, .ilightbox-toolbar a.ilightbox-play, .ilightbox-toolbar a.ilightbox-pause', function() {
1281				var t = $(this);
1282
1283				if (t.hasClass('ilightbox-fullscreen')) iL.fullScreenAction();
1284				else if (t.hasClass('ilightbox-play')) {
1285					iL.resume();
1286					t.addClass('ilightbox-pause').removeClass('ilightbox-play');
1287				} else if (t.hasClass('ilightbox-pause')) {
1288					iL.pause();
1289					t.addClass('ilightbox-play').removeClass('ilightbox-pause');
1290				} else iL.closeAction();
1291			}).on(touchMoveEvent, '.ilightbox-overlay, .ilightbox-thumbnails-container', function(e) {
1292				// prevent scrolling
1293				e.preventDefault();
1294			});
1295
1296			function mouseMoveHandler(e) {
1297				if (!vars.isMobile) {
1298					if (!vars.mouseID) {
1299						vars.hideableElements.show();
1300					}
1301
1302					vars.mouseID = clearTimeout(vars.mouseID);
1303
1304					if (buttonsArray.indexOf(e.target) === -1)
1305						vars.mouseID = setTimeout(function() {
1306							vars.hideableElements.hide();
1307							vars.mouseID = clearTimeout(vars.mouseID);
1308						}, 3000);
1309				}
1310			}
1311
1312			if (opts.controls.arrows && !supportTouch) $doc.on('mousemove.iLightBox', mouseMoveHandler);
1313
1314			if (opts.controls.slideshow && opts.slideshow.pauseOnHover) $doc.on('mouseenter.iLightBox mouseleave.iLightBox', '.ilightbox-holder:not(.ilightbox-next, .ilightbox-prev)', function(e) {
1315				if (e.type == 'mouseenter' && vars.cycleID) iL.pause();
1316				else if (e.type == 'mouseleave' && vars.isPaused) iL.resume();
1317			});
1318
1319			var switchers = $('.ilightbox-overlay, .ilightbox-holder, .ilightbox-thumbnails'),
1320				delay = false;
1321
1322			if (opts.controls.mousewheel) switchers.on('mousewheel.iLightBox', function(event, delta) {
1323				event.preventDefault();
1324				if (delay) return;
1325				delay = true;
1326				if (!vars.lockWheel) {
1327					event.preventDefault();
1328					if (delta < 0) {
1329						iL.moveTo('next');
1330					} else if (delta > 0) {
1331						iL.moveTo('prev');
1332					}
1333				}
1334				setTimeout(function(){
1335					delay = false;
1336				}, 2000);
1337			});
1338
1339			if (opts.controls.swipe) holders.on(touchStartEvent, function(event) {
1340				if (vars.nextLock || vars.prevLock || vars.total == 1 || vars.lockSwipe) return;
1341
1342				vars.BODY.addClass('ilightbox-closedhand');
1343
1344				var data = event.originalEvent.touches ? event.originalEvent.touches[0] : event,
1345					scrollTop = $doc.scrollTop(),
1346					scrollLeft = $doc.scrollLeft(),
1347					offsets = [
1348						holders.eq(0).offset(),
1349						holders.eq(1).offset(),
1350						holders.eq(2).offset()
1351					],
1352					offSet = [{
1353						top: offsets[0].top - scrollTop,
1354						left: offsets[0].left - scrollLeft
1355					}, {
1356						top: offsets[1].top - scrollTop,
1357						left: offsets[1].left - scrollLeft
1358					}, {
1359						top: offsets[2].top - scrollTop,
1360						left: offsets[2].left - scrollLeft
1361					}],
1362					start = {
1363						time: (new Date()).getTime(),
1364						coords: [data.pageX - scrollLeft, data.pageY - scrollTop]
1365					},
1366					stop;
1367
1368				function moveEachHandler(i) {
1369					var t = $(this),
1370						offset = offSet[i],
1371						scroll = [(start.coords[0] - stop.coords[0]), (start.coords[1] - stop.coords[1])];
1372
1373					t[0].style[path == "horizontal" ? 'left' : 'top'] = (path == "horizontal" ? offset.left - scroll[0] : offset.top - scroll[1]) + 'px';
1374				}
1375
1376				function moveHandler(event) {
1377
1378					if (!start) return;
1379
1380					var data = event.originalEvent.touches ? event.originalEvent.touches[0] : event;
1381
1382					stop = {
1383						time: (new Date()).getTime(),
1384						coords: [data.pageX - scrollLeft, data.pageY - scrollTop]
1385					};
1386
1387					holders.each(moveEachHandler);
1388
1389					// prevent scrolling
1390					event.preventDefault();
1391				}
1392
1393				function repositionHolders() {
1394					holders.each(function() {
1395						var t = $(this),
1396							offset = t.data('offset') || {
1397								top: t.offset().top - scrollTop,
1398								left: t.offset().left - scrollLeft
1399							},
1400							top = offset.top,
1401							left = offset.left;
1402
1403						t.css(transform, gpuAcceleration).stop().animate({
1404							top: top,
1405							left: left
1406						}, 500, 'easeOutCirc', function() {
1407							t.css(transform, '');
1408						});
1409					});
1410				}
1411
1412				holders.bind(touchMoveEvent, moveHandler);
1413				$doc.one(touchStopEvent, function(event) {
1414					holders.unbind(touchMoveEvent, moveHandler);
1415
1416					vars.BODY.removeClass('ilightbox-closedhand');
1417
1418					if (start && stop) {
1419						if (path == "horizontal" && stop.time - start.time < durationThreshold && abs(start.coords[0] - stop.coords[0]) > horizontalDistanceThreshold && abs(start.coords[1] - stop.coords[1]) < verticalDistanceThreshold) {
1420							if (start.coords[0] > stop.coords[0]) {
1421								if (vars.current == vars.total - 1 && !opts.infinite) repositionHolders();
1422								else {
1423									vars.isSwipe = true;
1424									iL.moveTo('next');
1425								}
1426							} else {
1427								if (vars.current == 0 && !opts.infinite) repositionHolders();
1428								else {
1429									vars.isSwipe = true;
1430									iL.moveTo('prev');
1431								}
1432							}
1433						} else if (path == "vertical" && stop.time - start.time < durationThreshold && abs(start.coords[1] - stop.coords[1]) > horizontalDistanceThreshold && abs(start.coords[0] - stop.coords[0]) < verticalDistanceThreshold) {
1434							if (start.coords[1] > stop.coords[1]) {
1435								if (vars.current == vars.total - 1 && !opts.infinite) repositionHolders();
1436								else {
1437									vars.isSwipe = true;
1438									iL.moveTo('next');
1439								}
1440							} else {
1441								if (vars.current == 0 && !opts.infinite) repositionHolders();
1442								else {
1443									vars.isSwipe = true;
1444									iL.moveTo('prev');
1445								}
1446							}
1447						} else repositionHolders();
1448					}
1449					start = stop = undefined;
1450				});
1451			});
1452
1453		},
1454
1455		goTo: function(index) {
1456			var iL = this,
1457				vars = iL.vars,
1458				opts = iL.options,
1459				diff = (index - vars.current);
1460
1461			if (opts.infinite) {
1462				if (index == vars.total - 1 && vars.current == 0) diff = -1;
1463				if (vars.current == vars.total - 1 && index == 0) diff = 1;
1464			}
1465
1466			if (diff == 1) iL.moveTo('next');
1467			else if (diff == -1) iL.moveTo('prev');
1468			else {
1469
1470				if (vars.nextLock || vars.prevLock) return false;
1471
1472				//Trigger the onBeforeChange callback
1473				if (typeof opts.callback.onBeforeChange == 'function') opts.callback.onBeforeChange.call(iL, iL.ui);
1474
1475				if (opts.linkId) {
1476					vars.hashLock = true;
1477					window.location.hash = opts.linkId + '/' + index;
1478				}
1479
1480				if (iL.items[index]) {
1481					if (!iL.items[index].options.mousewheel) vars.lockWheel = true;
1482					else iL.vars.lockWheel = false;
1483
1484					if (!iL.items[index].options.swipe) vars.lockSwipe = true;
1485					else vars.lockSwipe = false;
1486				}
1487
1488				$.each([vars.holder, vars.nextPhoto, vars.prevPhoto], function(key, val) {
1489					val.css(transform, gpuAcceleration).fadeOut(opts.effects.loadedFadeSpeed);
1490				});
1491
1492				vars.current = index;
1493				vars.next = index + 1;
1494				vars.prev = index - 1;
1495
1496				iL.createUI();
1497
1498				setTimeout(function() {
1499					iL.generateBoxes();
1500				}, opts.effects.loadedFadeSpeed + 50);
1501
1502				$('.ilightbox-thumbnail', vars.thumbnails).removeClass('ilightbox-active').eq(index).addClass('ilightbox-active');
1503				iL.positionThumbnails();
1504
1505				if (opts.linkId) setTimeout(function() {
1506					vars.hashLock = false;
1507				}, 55);
1508
1509				// Configure arrow buttons
1510				if (!opts.infinite) {
1511					vars.nextButton.add(vars.prevButton).add(vars.innerPrevButton).add(vars.innerNextButton).removeClass('disabled');
1512
1513					if (vars.current == 0) {
1514						vars.prevButton.add(vars.innerPrevButton).addClass('disabled');
1515					}
1516					if (vars.current >= vars.total - 1) {
1517						vars.nextButton.add(vars.innerNextButton).addClass('disabled');
1518					}
1519				}
1520
1521				// Reset next cycle timeout
1522				iL.resetCycle();
1523
1524				//Trigger the onAfterChange callback
1525				if (typeof opts.callback.onAfterChange == 'function') opts.callback.onAfterChange.call(iL, iL.ui);
1526			}
1527		},
1528
1529		moveTo: function(side) {
1530			var iL = this,
1531				vars = iL.vars,
1532				opts = iL.options,
1533				path = opts.path.toLowerCase(),
1534				viewport = getViewport(),
1535				switchSpeed = opts.effects.switchSpeed;
1536
1537			if (vars.nextLock || vars.prevLock) return false;
1538			else {
1539
1540				var item = (side == "next") ? vars.next : vars.prev;
1541
1542				if (opts.linkId) {
1543					vars.hashLock = true;
1544					window.location.hash = opts.linkId + '/' + item;
1545				}
1546
1547				if (side == "next") {
1548					if (!iL.items[item]) return false;
1549					var firstHolder = vars.nextPhoto,
1550						secondHolder = vars.holder,
1551						lastHolder = vars.prevPhoto,
1552						firstClass = 'ilightbox-prev',
1553						secondClass = 'ilightbox-next';
1554				} else if (side == "prev") {
1555					if (!iL.items[item]) return false;
1556					var firstHolder = vars.prevPhoto,
1557						secondHolder = vars.holder,
1558						lastHolder = vars.nextPhoto,
1559						firstClass = 'ilightbox-next',
1560						secondClass = 'ilightbox-prev';
1561				}
1562
1563				//Trigger the onBeforeChange callback
1564				if (typeof opts.callback.onBeforeChange == 'function')
1565					opts.callback.onBeforeChange.call(iL, iL.ui);
1566
1567				(side == "next") ? vars.nextLock = true: vars.prevLock = true;
1568
1569				var captionFirst = $('div.ilightbox-caption', secondHolder),
1570					socialFirst = $('div.ilightbox-social', secondHolder);
1571
1572				if (captionFirst.length)
1573					captionFirst.stop().fadeOut(switchSpeed, function() {
1574						$(this).remove();
1575					});
1576				if (socialFirst.length)
1577					socialFirst.stop().fadeOut(switchSpeed, function() {
1578						$(this).remove();
1579					});
1580
1581				if (iL.items[item].caption) {
1582					iL.setCaption(iL.items[item], firstHolder);
1583					var caption = $('div.ilightbox-caption', firstHolder),
1584						percent = parseInt((caption.outerHeight() / firstHolder.outerHeight()) * 100);
1585					if (opts.caption.start && percent <= 50) caption.fadeIn(switchSpeed);
1586				}
1587
1588				var social = iL.items[item].options.social;
1589				if (social) {
1590					iL.setSocial(social, iL.items[item].URL, firstHolder);
1591					if (opts.social.start) $('div.ilightbox-social', firstHolder).fadeIn(opts.effects.fadeSpeed);
1592				}
1593
1594				$.each([firstHolder, secondHolder, lastHolder], function(key, val) {
1595					val.removeClass('ilightbox-next ilightbox-prev');
1596				});
1597
1598				var firstOffset = firstHolder.data('offset'),
1599					winW = (viewport.width - (opts.styles.pageOffsetX)),
1600					winH = (viewport.height - (opts.styles.pageOffsetY)),
1601					width = firstOffset.newDims.width,
1602					height = firstOffset.newDims.height,
1603					thumbsOffset = firstOffset.thumbsOffset,
1604					diff = firstOffset.diff,
1605					top = parseInt((winH / 2) - (height / 2) - diff.H - (thumbsOffset.H / 2)),
1606					left = parseInt((winW / 2) - (width / 2) - diff.W - (thumbsOffset.W / 2));
1607
1608				var secondOffset = secondHolder.data('offset'),
1609					object = secondOffset.object;
1610
1611				/*if (object.item.caption && !isNaN(width) && !isNaN(height) && UNCODE.wwidth > UNCODE.mediaQuery) {
1612					var objRatio = width / height;
1613					height = height - vars.captionHeight;
1614					width = height * objRatio;
1615					top = path == 'horizontal' ? parseInt((winH / 2) - (height / 2) - diff.H - (thumbsOffset.H / 2)) : top,
1616					left = parseInt((winW / 2) - (width / 2) - diff.W - (thumbsOffset.W / 2));
1617				}*/
1618
1619				firstHolder.show().css(transform, gpuAcceleration).animate({
1620					top: top,
1621					left: left,
1622					opacity: 1
1623				}, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc', function() {
1624					firstHolder.css(transform, '');
1625				});
1626
1627				$('div.ilightbox-container', firstHolder).animate({
1628					width: width,
1629					height: height
1630				}, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc');
1631
1632				diff = secondOffset.diff;
1633
1634				width = secondOffset.newDims.width,
1635					height = secondOffset.newDims.height;
1636
1637				width = parseInt(width * opts.styles[side == 'next' ? 'prevScale' : 'nextScale']),
1638					height = parseInt(height * opts.styles[side == 'next' ? 'prevScale' : 'nextScale']),
1639					top = (path == 'horizontal') ? parseInt((winH / 2) - object.offsetY - (height / 2) - diff.H - (thumbsOffset.H / 2)) : parseInt(winH - object.offsetX - diff.H - (thumbsOffset.H / 2));
1640
1641				if (side == 'prev')
1642					left = (path == 'horizontal') ? parseInt(winW - object.offsetX - diff.W - (thumbsOffset.W / 2)) : parseInt((winW / 2) - (width / 2) - diff.W - object.offsetY - (thumbsOffset.W / 2));
1643				else {
1644					top = (path == 'horizontal') ? top : parseInt(object.offsetX - diff.H - height - (thumbsOffset.H / 2)),
1645					left = (path == 'horizontal') ? parseInt(object.offsetX - diff.W - width - (thumbsOffset.W / 2)) : parseInt((winW / 2) - object.offsetY - (width / 2) - diff.W - (thumbsOffset.W / 2));
1646				}
1647
1648				/*if (object.item.caption && !isNaN(width) && !isNaN(height) && UNCODE.wwidth > UNCODE.mediaQuery) {
1649					var objRatio = width / height;
1650					height = height - vars.captionHeight;
1651					width = height * objRatio;
1652					top = path == 'horizontal' ? parseInt((winH / 2) - (height / 2) - diff.H - (thumbsOffset.H / 2)) : top;
1653				}*/
1654
1655				$('div.ilightbox-container', secondHolder).animate({
1656					width: width,
1657					height: height
1658				}, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc');
1659
1660				secondHolder.addClass(firstClass).css(transform, gpuAcceleration).animate({
1661					top: top,
1662					left: left,
1663					opacity: opts.styles.prevOpacity,
1664				}, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc', function() {
1665					secondHolder.css(transform, '');
1666
1667					$('.ilightbox-thumbnail', vars.thumbnails).removeClass('ilightbox-active').eq(item).addClass('ilightbox-active');
1668					iL.positionThumbnails();
1669
1670					if (iL.items[item]) {
1671						if (!iL.items[item].options.mousewheel) vars.lockWheel = true;
1672						else vars.lockWheel = false;
1673
1674						if (!iL.items[item].options.swipe) vars.lockSwipe = true;
1675						else vars.lockSwipe = false;
1676					}
1677
1678					vars.isSwipe = false;
1679
1680					// Remove iframe & video from previous slide
1681					if (['iframe', 'video'].indexOf(iL.items[vars.current].type) !== -1) {
1682						$('div.ilightbox-container', secondHolder).empty();
1683					}
1684
1685					if (side == "next") {
1686						vars.nextPhoto = lastHolder,
1687							vars.prevPhoto = secondHolder,
1688							vars.holder = firstHolder;
1689
1690						vars.nextPhoto.hide();
1691
1692						vars.next = vars.next + 1,
1693							vars.prev = vars.current,
1694							vars.current = vars.current + 1;
1695
1696						if (opts.infinite) {
1697							if (vars.current > vars.total - 1) vars.current = 0;
1698							if (vars.current == vars.total - 1) vars.next = 0;
1699							if (vars.current == 0) vars.prev = vars.total - 1;
1700						}
1701
1702						iL.createUI();
1703
1704						if (!iL.items[vars.next])
1705							vars.nextLock = false;
1706						else
1707							iL.loadContent(iL.items[vars.next], 'next');
1708					} else {
1709						vars.prevPhoto = lastHolder;
1710						vars.nextPhoto = secondHolder;
1711						vars.holder = firstHolder;
1712
1713						vars.prevPhoto.hide();
1714
1715						vars.next = vars.current;
1716						vars.current = vars.prev;
1717						vars.prev = vars.current - 1;
1718
1719						if (opts.infinite) {
1720							if (vars.current == vars.total - 1) vars.next = 0;
1721							if (vars.current == 0) vars.prev = vars.total - 1;
1722						}
1723
1724						iL.createUI();
1725
1726						if (!iL.items[vars.prev])
1727							vars.prevLock = false;
1728						else
1729							iL.loadContent(iL.items[vars.prev], 'prev');
1730					}
1731
1732					// Add iframe & video content for current slide
1733					if (['iframe', 'video'].indexOf(iL.items[vars.current].type) !== -1) {
1734						iL.loadContent(iL.items[vars.current], 'current');
1735					}
1736
1737					if (opts.linkId) setTimeout(function() {
1738						vars.hashLock = false;
1739					}, 55);
1740
1741					// Configure arrow buttons
1742					if (!opts.infinite) {
1743						vars.nextButton.add(vars.prevButton).add(vars.innerPrevButton).add(vars.innerNextButton).removeClass('disabled');
1744
1745						if (vars.current == 0)
1746							vars.prevButton.add(vars.innerPrevButton).addClass('disabled');
1747						if (vars.current >= vars.total - 1)
1748							vars.nextButton.add(vars.innerNextButton).addClass('disabled');
1749					}
1750
1751					iL.repositionPhoto();
1752
1753					// Reset next cycle timeout
1754					iL.resetCycle();
1755
1756					//Trigger the onAfterChange callback
1757					if (typeof opts.callback.onAfterChange == 'function')
1758						opts.callback.onAfterChange.call(iL, iL.ui);
1759				});
1760
1761				top = (path == 'horizontal') ? getPixel(lastHolder, 'top') : ((side == "next") ? parseInt(-(winH / 2) - lastHolder.outerHeight()) : parseInt(top * 2)),
1762					left = (path == 'horizontal') ? ((side == "next") ? parseInt(-(winW / 2) - lastHolder.outerWidth()) : parseInt(left * 2)) : getPixel(lastHolder, 'left');
1763
1764				lastHolder.css(transform, gpuAcceleration).animate({
1765					top: top,
1766					left: left,
1767					opacity: opts.styles.nextOpacity
1768				}, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc', function() {
1769					lastHolder.css(transform, '');
1770				}).addClass(secondClass);
1771			}
1772		},
1773
1774		setCaption: function(obj, target) {
1775			var iL = this,
1776				caption = $('<div class="ilightbox-caption"></div>');
1777
1778			if (obj.caption) {
1779				caption.html(obj.caption);
1780				$('div.ilightbox-container', target).append(caption);
1781			}
1782		},
1783
1784		normalizeSocial: function(obj, url) {
1785			var iL = this,
1786				vars = iL.vars,
1787				opts = iL.options,
1788				baseURL = window.location.href;
1789
1790			$.each(obj, function(key, value) {
1791				if (!value)
1792					return true;
1793
1794				var item = key.toLowerCase(),
1795					source, text;
1796
1797				switch (item) {
1798					case 'facebook':
1799						source = "http://www.facebook.com/share.php?v=4&src=bm&u={URL}",
1800							text = "Share on Facebook";
1801						break;
1802					case 'twitter':
1803						source = "http://twitter.com/home?status={URL}",
1804							text = "Share on Twitter";
1805						break;
1806					case 'digg':
1807						source = "http://digg.com/submit?phase=2&url={URL}",
1808							text = "Share on Digg";
1809						break;
1810					case 'reddit':
1811						source = "http://reddit.com/submit?url={URL}",
1812							text = "Share on reddit";
1813						break;
1814				}
1815
1816				obj[key] = {
1817					URL: value.URL && absolutizeURI(baseURL, value.URL) || opts.linkId && window.location.href || typeof url !== 'string' && baseURL || url && absolutizeURI(baseURL, url) || baseURL,
1818					source: value.source || source || value.URL && absolutizeURI(baseURL, value.URL) || url && absolutizeURI(baseURL, url),
1819					text: value.text || text || "Share on " + key,
1820					width: (typeof(value.width) != 'undefined' && !isNaN(value.width)) ? parseInt(value.width) : 640,
1821					height: value.height || 360
1822				};
1823
1824			});
1825
1826			return obj;
1827		},
1828
1829		setSocial: function(obj, url, target) {
1830			var iL = this,
1831				socialBar = $('<div class="ilightbox-social"></div>'),
1832				buttons = '<ul>';
1833
1834			obj = iL.normalizeSocial(obj, url);
1835
1836			$.each(obj, function(key, value) {
1837				var item = key.toLowerCase(),
1838					source = value.source.replace(/\{URL\}/g, encodeURIComponent(value.URL).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+'));
1839				buttons += '<li class="' + key + '"><a href="' + source + '" onclick="javascript:window.open(this.href' + ((value.width <= 0 || value.height <= 0) ? '' : ', \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=' + value.height + ',width=' + value.width + ',left=40,top=40\'') + ');return false;" title="' + value.text + '" target="_blank"></a></li>';
1840			});
1841
1842			buttons += '</ul>';
1843
1844			socialBar.html(buttons);
1845			$('div.ilightbox-container', target).append(socialBar);
1846		},
1847
1848		fullScreenAction: function() {
1849			var iL = this,
1850				vars = iL.vars;
1851
1852			if (fullScreenApi.supportsFullScreen) {
1853				if (fullScreenApi.isFullScreen()) fullScreenApi.cancelFullScreen(document.documentElement);
1854				else fullScreenApi.requestFullScreen(document.documentElement);
1855			} else {
1856				iL.doFullscreen();
1857			}
1858		},
1859
1860		doFullscreen: function() {
1861			var iL = this,
1862				vars = iL.vars,
1863				viewport = getViewport(),
1864				opts = iL.options;
1865
1866			if (opts.fullAlone) {
1867				var currentHolder = vars.holder,
1868					current = iL.items[vars.current],
1869					windowWidth = viewport.width,
1870					windowHeight = viewport.height,
1871					elements = [currentHolder, vars.nextPhoto, vars.prevPhoto, vars.nextButton, vars.prevButton, vars.overlay, vars.toolbar, vars.thumbnails, vars.loader],
1872					hideElements = [vars.nextPhoto, vars.prevPhoto, vars.nextButton, vars.prevButton, vars.loader, vars.thumbnails];
1873
1874				if (!vars.isInFullScreen) {
1875					vars.isInFullScreen = vars.lockKey = vars.lockWheel = vars.lockSwipe = true;
1876					vars.overlay.css({
1877						opacity: 1
1878					});
1879
1880					$.each(hideElements, function(i, element) {
1881						element.hide();
1882					});
1883
1884					vars.fullScreenButton.attr('title', opts.text.exitFullscreen);
1885
1886					if (opts.fullStretchTypes.indexOf(current.type) != -1) currentHolder.data({
1887						naturalWidthOld: currentHolder.data('naturalWidth'),
1888						naturalHeightOld: currentHolder.data('naturalHeight'),
1889						naturalWidth: windowWidth,
1890						naturalHeight: windowHeight
1891					});
1892					else {
1893						var viewport = current.options.fullViewPort || opts.fullViewPort || '',
1894							newWidth = windowWidth,
1895							newHeight = windowHeight,
1896							width = currentHolder.data('naturalWidth'),
1897							height = currentHolder.data('naturalHeight');
1898
1899						if (viewport.toLowerCase() == 'fill') {
1900							newHeight = (newWidth / width) * height;
1901
1902							if (newHeight < windowHeight) {
1903								newWidth = (windowHeight / height) * width,
1904									newHeight = windowHeight;
1905							}
1906						} else if (viewport.toLowerCase() == 'fit') {
1907							var dims = iL.getNewDimenstions(newWidth, newHeight, width, height, true);
1908
1909							newWidth = dims.width,
1910								newHeight = dims.height;
1911						} else if (viewport.toLowerCase() == 'stretch') {
1912							newWidth = newWidth,
1913								newHeight = newHeight;
1914						} else {
1915							var scale = (width > newWidth || height > newHeight) ? true : false,
1916								dims = iL.getNewDimenstions(newWidth, newHeight, width, height, scale);
1917							newWidth = dims.width,
1918								newHeight = dims.height;
1919						}
1920
1921						currentHolder.data({
1922							naturalWidthOld: currentHolder.data('naturalWidth'),
1923							naturalHeightOld: currentHolder.data('naturalHeight'),
1924							naturalWidth: newWidth,
1925							naturalHeight: newHeight
1926						});
1927					}
1928
1929					$.each(elements, function(key, val) {
1930						val.addClass('ilightbox-fullscreen');
1931					});
1932
1933					//Trigger the onEnterFullScreen callback
1934					if (typeof opts.callback.onEnterFullScreen == 'function') opts.callback.onEnterFullScreen.call(iL, iL.ui);
1935				} else {
1936					vars.isInFullScreen = vars.lockKey = vars.lockWheel = vars.lockSwipe = false;
1937					vars.overlay.css({
1938						opacity: iL.options.overlay.opacity
1939					});
1940
1941					$.each(hideElements, function(i, element) {
1942						element.show();
1943					});
1944
1945					vars.fullScreenButton.attr('title', opts.text.enterFullscreen);
1946
1947					currentHolder.data({
1948						naturalWidth: currentHolder.data('naturalWidthOld'),
1949						naturalHeight: currentHolder.data('naturalHeightOld'),
1950						naturalWidthOld: null,
1951						naturalHeightOld: null
1952					});
1953
1954					$.each(elements, function(key, val) {
1955						val.removeClass('ilightbox-fullscreen');
1956					});
1957
1958					//Trigger the onExitFullScreen callback
1959					if (typeof opts.callback.onExitFullScreen == 'function') opts.callback.onExitFullScreen.call(iL, iL.ui);
1960				}
1961			} else {
1962				if (!vars.isInFullScreen) vars.isInFullScreen = true;
1963				else vars.isInFullScreen = false;
1964			}
1965			iL.repositionPhoto(true);
1966		},
1967
1968		closeAction: function() {
1969			var iL = this,
1970				vars = iL.vars,
1971				opts = iL.options;
1972
1973			$win.unbind('.iLightBox');
1974			$doc.off('.iLightBox');
1975
1976			if (vars.isInFullScreen) fullScreenApi.cancelFullScreen(document.documentElement);
1977
1978			$('.ilightbox-overlay, .ilightbox-holder, .ilightbox-thumbnails').off('.iLightBox');
1979
1980			if (opts.hide.effect) vars.overlay.stop().fadeOut(opts.hide.speed, function() {
1981				vars.overlay.remove();
1982				vars.BODY.removeClass('ilightbox-noscroll').off('.iLightBox');
1983			});
1984			else {
1985				vars.overlay.remove();
1986				vars.BODY.removeClass('ilightbox-noscroll').off('.iLightBox');
1987			}
1988
1989			var fadeOuts = [vars.toolbar, vars.holder, vars.nextPhoto, vars.prevPhoto, vars.nextButton, vars.prevButton, vars.loader, vars.thumbnails];
1990
1991			$.each(fadeOuts, function(i, element) {
1992				element.removeAttr('style').remove();
1993			});
1994
1995			vars.dontGenerateThumbs = vars.isInFullScreen = false;
1996
1997			window.iLightBox = null;
1998
1999			if (opts.linkId) {
2000				vars.hashLock = true;
2001				removeHash();
2002				setTimeout(function() {
2003					vars.hashLock = false;
2004				}, 55);
2005			}
2006
2007			vars.nextButton.add(vars.prevButton).add(vars.innerPrevButton).add(vars.innerNextButton).removeClass('disabled');
2008
2009			//Trigger the onHide callback
2010			if (typeof opts.callback.onHide == 'function') opts.callback.onHide.call(iL, iL.ui);
2011		},
2012
2013		repositionPhoto: function() {
2014			var iL = this,
2015				vars = iL.vars,
2016				opts = iL.options,
2017				path = opts.path.toLowerCase(),
2018				viewport = getViewport(),
2019				winWidth = viewport.width,
2020				winHeight = viewport.height;
2021
2022			if (viewport.width < UNCODE.mediaQuery) opts.styles.nextOffsetX = 0;
2023
2024			var thumbsOffsetW = (vars.isInFullScreen && opts.fullAlone || vars.isMobile) ? 0 : ((path == 'horizontal') ? 0 : vars.thumbnails.outerWidth()),
2025				thumbsOffsetH = vars.isMobile ? vars.toolbar.outerHeight() : ((vars.isInFullScreen && opts.fullAlone) ? 0 : ((path == 'horizontal') ? vars.thumbnails.outerHeight() : 0)),
2026				width = (vars.isInFullScreen && opts.fullAlone) ? winWidth : (winWidth - (opts.styles.pageOffsetX)),
2027				height = (vars.isInFullScreen && opts.fullAlone) ? winHeight : (winHeight - (opts.styles.pageOffsetY)),
2028				offsetW = (path == 'horizontal') ? parseInt((iL.items[vars.next] || iL.items[vars.prev]) ? ((opts.styles.nextOffsetX + opts.styles.prevOffsetX)) * 2 : (((width / 10) <= 30) ? 30 : (width / 10))) : parseInt(((width / 10) <= 30) ? 30 : (width / 10)) + thumbsOffsetW,
2029				offsetH = (path == 'horizontal') ? parseInt(((height / 10) <= 30) ? 30 : (height / 10)) + thumbsOffsetH : parseInt((iL.items[vars.next] || iL.items[vars.prev]) ? ((opts.styles.nextOffsetX + opts.styles.prevOffsetX)) * 2 : (((height / 10) <= 30) ? 30 : (height / 10)));
2030
2031			var elObject = {
2032				type: 'current',
2033				width: width,
2034				height: height,
2035				item: iL.items[vars.current],
2036				offsetW: offsetW,
2037				offsetH: offsetH,
2038				thumbsOffsetW: thumbsOffsetW,
2039				thumbsOffsetH: thumbsOffsetH,
2040				animate: arguments.length,
2041				holder: vars.holder
2042			};
2043
2044			iL.repositionEl(elObject);
2045
2046			if (iL.items[vars.next]) {
2047				elObject = $.extend(elObject, {
2048					type: 'next',
2049					item: iL.items[vars.next],
2050					offsetX: opts.styles.nextOffsetX,
2051					offsetY: opts.styles.nextOffsetY,
2052					holder: vars.nextPhoto
2053				});
2054
2055				iL.repositionEl(elObject);
2056			}
2057
2058			if (iL.items[vars.prev]) {
2059				elObject = $.extend(elObject, {
2060					type: 'prev',
2061					item: iL.items[vars.prev],
2062					offsetX: opts.styles.nextOffsetX,
2063					offsetY: opts.styles.prevOffsetY,
2064					holder: vars.prevPhoto
2065				});
2066
2067				iL.repositionEl(elObject);
2068			}
2069
2070			var loaderCss = (path == "horizontal") ? {
2071				left: parseInt((width / 2) - (vars.loader.outerWidth() / 2))
2072			} : {
2073				top: parseInt((height / 2) - (vars.loader.outerHeight() / 2))
2074			};
2075			vars.loader.css(loaderCss);
2076		},
2077
2078		repositionEl: function(obj) {
2079			var iL = this,
2080				vars = iL.vars,
2081				opts = iL.options,
2082				path = opts.path.toLowerCase(),
2083				widthAvail = (obj.type == 'current') ? ((vars.isInFullScreen && opts.fullAlone) ? obj.width : (obj.width - obj.offsetW)) : (obj.width - obj.offsetW),
2084				heightAvail = (obj.type == 'current') ? ((vars.isInFullScreen && opts.fullAlone) ? obj.height : (obj.height - obj.offsetH)) : (obj.height - obj.offsetH),
2085				itemParent = obj.item,
2086				item = obj.item.options,
2087				holder = obj.holder,
2088				offsetX = obj.offsetX || 0,
2089				offsetY = obj.offsetY || 0,
2090				//Uncode change ##START##
2091				toolbarHeight = $('.ilightbox-inner-toolbar', holder).length ? parseInt( $('.ilightbox-inner-toolbar', holder).outerHeight() ) : 0,
2092				//Uncode change ##END##
2093				thumbsOffsetW = obj.thumbsOffsetW,
2094				thumbsOffsetH = obj.thumbsOffsetH;
2095
2096			if (obj.type == 'current') {
2097				if (typeof item.width == 'number' && item.width) widthAvail = ((vars.isInFullScreen && opts.fullAlone) && (opts.fullStretchTypes.indexOf(itemParent.type) != -1 || item.fullViewPort || opts.fullViewPort)) ? widthAvail : ((item.width > widthAvail) ? widthAvail : item.width);
2098				if (typeof item.height == 'number' && item.height) heightAvail = ((vars.isInFullScreen && opts.fullAlone) && (opts.fullStretchTypes.indexOf(itemParent.type) != -1 || item.fullViewPort || opts.fullViewPort)) ? heightAvail : ((item.height > heightAvail) ? heightAvail : item.height);
2099			} else {
2100				if (typeof item.width == 'number' && item.width) widthAvail = (item.width > widthAvail) ? widthAvail : item.width;
2101				if (typeof item.height == 'number' && item.height) heightAvail = (item.height > heightAvail) ? heightAvail : item.height;
2102			}
2103
2104
2105			//Uncode change ##START##
2106			heightAvail = parseInt(heightAvail - toolbarHeight);
2107			// heightAvail = parseInt(heightAvail - $('.ilightbox-inner-toolbar', holder).outerHeight());
2108			//Uncode change ##END##
2109
2110			var width = (typeof item.width == 'string' && item.width.indexOf('%') != -1) ? percentToValue(parseInt(item.width.replace('%', '')), obj.width) : holder.data('naturalWidth'),
2111				height = (typeof item.height == 'string' && item.height.indexOf('%') != -1) ? percentToValue(parseInt(item.height.replace('%', '')), obj.height) : holder.data('naturalHeight');
2112
2113			var dims = ((typeof item.width == 'string' && item.width.indexOf('%') != -1 || typeof item.height == 'string' && item.height.indexOf('%') != -1) ? {
2114					width: width,
2115					height: height
2116				} : iL.getNewDimenstions(widthAvail, heightAvail, width, height)),
2117				newDims = $.extend({}, dims, {});
2118
2119			if (obj.type == 'prev' || obj.type == 'next')
2120				width = parseInt(dims.width * ((obj.type == 'next') ? opts.styles.nextScale : opts.styles.prevScale)),
2121				height = parseInt(dims.height * ((obj.type == 'next') ? opts.styles.nextScale : opts.styles.prevScale));
2122			else
2123				width = dims.width,
2124				height = dims.height;
2125
2126			var widthDiff = parseInt((getPixel(holder, 'padding-left') + getPixel(holder, 'padding-right') + getPixel(holder, 'border-left-width') + getPixel(holder, 'border-right-width')) / 2),
2127				heightDiff = parseInt((getPixel(holder, 'padding-top') + getPixel(holder, 'padding-bottom') + getPixel(holder, 'border-top-width') + getPixel(holder, 'border-bottom-width') + ($('.ilightbox-inner-toolbar', holder).outerHeight() || 0)) / 2);
2128
2129			switch (obj.type) {
2130				case 'current':
2131					var top = parseInt((obj.height / 2) - (height / 2) - heightDiff - (thumbsOffsetH / 2)),
2132						left = parseInt((obj.width / 2) - (width / 2) - widthDiff - (thumbsOffsetW / 2));
2133					break;
2134
2135				case 'next':
2136					var top = (path == 'horizontal') ? parseInt((obj.height / 2) - offsetY - (height / 2) - heightDiff - (thumbsOffsetH / 2)) : parseInt(obj.height - offsetX - heightDiff - (thumbsOffsetH / 2)),
2137						left = (path == 'horizontal') ? parseInt(obj.width - offsetX - widthDiff - (thumbsOffsetW / 2)) : parseInt((obj.width / 2) - (width / 2) - widthDiff - offsetY - (thumbsOffsetW / 2));
2138					break;
2139
2140				case 'prev':
2141					var top = (path == 'horizontal') ? parseInt((obj.height / 2) - offsetY - (height / 2) - heightDiff - (thumbsOffsetH / 2)) : parseInt(offsetX - heightDiff - height - (thumbsOffsetH / 2)),
2142						left = (path == 'horizontal') ? parseInt(offsetX - widthDiff - width - (thumbsOffsetW / 2)) : parseInt((obj.width / 2) - offsetY - (width / 2) - widthDiff - (thumbsOffsetW / 2));
2143					break;
2144			}
2145
2146			holder.data('offset', {
2147				top: top,
2148				left: left,
2149				newDims: newDims,
2150				diff: {
2151					W: widthDiff,
2152					H: heightDiff
2153				},
2154				thumbsOffset: {
2155					W: thumbsOffsetW,
2156					H: thumbsOffsetH
2157				},
2158				object: obj
2159			});
2160
2161			var opacityMobile;
2162			if ( isMobile ) {
2163				opacityMobile = {
2164					opacity: 1,
2165					top: top,
2166					left: left
2167				};
2168			} else {
2169				opacityMobile = {
2170					top: top,
2171					left: left
2172				};
2173			}
2174
2175			if (obj.animate > 0 && opts.effects.reposition) {
2176				holder.css(transform, gpuAcceleration).stop().animate(
2177					opacityMobile,
2178					opts.effects.repositionSpeed, 'easeOutCirc', function() {
2179					holder.css(transform, '');
2180				});
2181				$('div.ilightbox-container', holder).stop().animate({
2182					width: width,
2183					height: height
2184				}, opts.effects.repositionSpeed, 'easeOutCirc');
2185				$('div.ilightbox-inner-toolbar', holder).stop().animate({
2186					width: width
2187				}, opts.effects.repositionSpeed, 'easeOutCirc', function() {
2188					$(this).css('overflow', 'visible');
2189				});
2190			} else {
2191				holder.css(opacityMobile);
2192				$('div.ilightbox-container', holder).css({
2193					width: width,
2194					height: height
2195				});
2196				$('div.ilightbox-inner-toolbar', holder).css({
2197					width: width
2198				});
2199			}
2200		},
2201
2202
2203		resume: function(priority) {
2204			var iL = this,
2205				vars = iL.vars,
2206				opts = iL.options;
2207
2208			if (!opts.slideshow.pauseTime || opts.controls.slideshow && vars.total <= 1 || priority < vars.isPaused) {
2209				return;
2210			}
2211
2212			vars.isPaused = 0;
2213
2214			if (vars.cycleID) {
2215				vars.cycleID = clearTimeout(vars.cycleID);
2216			}
2217
2218			vars.cycleID = setTimeout(function() {
2219				if (vars.current == vars.total - 1) iL.goTo(0);
2220				else iL.moveTo('next');
2221			}, opts.slideshow.pauseTime);
2222		},
2223
2224		pause: function(priority) {
2225			var iL = this,
2226				vars = iL.vars,
2227				opts = iL.options;
2228
2229			if (priority < vars.isPaused) {
2230				return;
2231			}
2232
2233			vars.isPaused = priority || 100;
2234
2235			if (vars.cycleID) {
2236				vars.cycleID = clearTimeout(vars.cycleID);
2237			}
2238		},
2239
2240		resetCycle: function() {
2241			var iL = this,
2242				vars = iL.vars,
2243				opts = iL.options;
2244
2245			if (opts.controls.slideshow && vars.cycleID && !vars.isPaused) {
2246				iL.resume();
2247			}
2248		},
2249
2250		getNewDimenstions: function(width, height, width_old, height_old, thumb) {
2251			var iL = this;
2252
2253			if (!width) factor = height / height_old;
2254			else if (!height) factor = width / width_old;
2255			else factor = min(width / width_old, height / height_old);
2256
2257			if (!thumb) {
2258				if (factor > iL.options.maxScale) factor = iL.options.maxScale;
2259				else if (factor < iL.options.minScale) factor = iL.options.minScale;
2260			}
2261
2262			var final_width = (iL.options.keepAspectRatio) ? round(width_old * factor) : width,
2263				final_height = (iL.options.keepAspectRatio) ? round(height_old * factor) : height;
2264
2265			return {
2266				width: final_width,
2267				height: final_height,
2268				ratio: factor
2269			};
2270		},
2271
2272		setOption: function(options) {
2273			var iL = this;
2274
2275			iL.options = $.extend(true, iL.options, options || {});
2276			iL.refresh();
2277		},
2278
2279		availPlugins: function() {
2280			var iL = this,
2281				testEl = document.createElement("video");
2282
2283			iL.plugins = {
2284				flash: !isMobile,
2285				quicktime: (parseInt(PluginDetect.getVersion("QuickTime")) >= 0) ? true : false,
2286				html5H264: !!(testEl.canPlayType && testEl.canPlayType('video/mp4').replace(/no/, '')),
2287				html5WebM: !!(testEl.canPlayType && testEl.canPlayType('video/webm').replace(/no/, '')),
2288				html5Vorbis: !!(testEl.canPlayType && testEl.canPlayType('video/ogg').replace(/no/, '')),
2289				html5QuickTime: !!(testEl.canPlayType && testEl.canPlayType('video/quicktime').replace(/no/, ''))
2290			};
2291		},
2292
2293		addContent: function(element, obj) {
2294			var iL = this,
2295				el;
2296
2297			switch (obj.type) {
2298				case 'video':
2299					var HTML5 = false,
2300						videoType = obj.videoType,
2301						html5video = obj.options.html5video;
2302
2303					if (((videoType == 'video/mp4' || obj.ext == 'mp4' || obj.ext == 'm4v') || html5video.h264) && iL.plugins.html5H264)
2304						obj.ext = 'mp4',
2305						obj.URL = html5video.h264 || obj.URL;
2306					else if (html5video.webm && iL.plugins.html5WebM)
2307						obj.ext = 'webm',
2308						obj.URL = html5video.webm || obj.URL;
2309					else if (html5video.ogg && iL.plugins.html5Vorbis)
2310						obj.ext = 'ogv',
2311						obj.URL = html5video.ogg || obj.URL;
2312
2313					if (iL.plugins.html5H264 && (videoType == 'video/mp4' || obj.ext == 'mp4' || obj.ext == 'm4v')) HTML5 = true, videoType = "video/mp4";
2314					else if (iL.plugins.html5WebM && (videoType == 'video/webm' || obj.ext == 'webm')) HTML5 = true, videoType = "video/webm";
2315					else if (iL.plugins.html5Vorbis && (videoType == 'video/ogg' || obj.ext == 'ogv')) HTML5 = true, videoType = "video/ogg";
2316					else if (iL.plugins.html5QuickTime && (videoType == 'video/quicktime' || obj.ext == 'mov' || obj.ext == 'qt')) HTML5 = true, videoType = "video/quicktime";
2317
2318					if (HTML5) {
2319						el = $('<video />
2319', {
2320							"width": "100%",
2321							"height": "100%",
2322							"preload": html5video.preload,
2323							"autoplay": html5video.autoplay,
2324							"loop": html5video.loop,
2325							"poster": html5video.poster,
2326							"controls": html5video.controls,
2327							"controlslist": "nodownload"
2328						}).append($('<source />', {
2329							"src": obj.URL,
2330							"type": videoType
2331						}));
2332					} else {
2333						if (!iL.plugins.quicktime) el = $('<span />', {
2334							"class": "ilightbox-alert",
2335							html: iL.options.errors.missingPlugin.replace('{pluginspage}', pluginspages.quicktime).replace('{type}', 'QuickTime')
2336						});
2337						else {
2338
2339							el = $('<object />', {
2340								"type": "video/quicktime",
2341								"pluginspage": pluginspages.quicktime
2342							}).attr({
2343								"data": obj.URL,
2344								"width": "100%",
2345								"height": "100%"
2346							}).append($('<param />', {
2347								"name": "src",
2348								"value": obj.URL
2349							})).append($('<param />', {
2350								"name": "autoplay",
2351								"value": "false"
2352							})).append($('<param />', {
2353								"name": "loop",
2354								"value": "false"
2355							})).append($('<param />', {
2356								"name": "scale",
2357								"value": "tofit"
2358							}));
2359
2360							if (browser.msie) el = QT_GenerateOBJECTText(obj.URL, '100%', '100%', '', 'SCALE', 'tofit', 'AUTOPLAY', 'false', 'LOOP', 'false');
2361						}
2362					}
2363
2364					break;
2365
2366				case 'flash':
2367					if (!iL.plugins.flash) el = $('<span />', {
2368						"class": "ilightbox-alert",
2369						html: iL.options.errors.missingPlugin.replace('{pluginspage}', pluginspages.flash).replace('{type}', 'Adobe Flash player')
2370					});
2371					else {
2372						var flashvars = "",
2373							i = 0;
2374
2375						if (obj.options.flashvars) $.each(obj.options.flashvars, function(k, v) {
2376							if (i != 0) flashvars += "&";
2377							flashvars += k + "=" + encodeURIComponent(v);
2378							i++;
2379						});
2380						else flashvars = null;
2381
2382						el = $('<embed />').attr({
2383							"type": "application/x-shockwave-flash",
2384							"src": obj.URL,
2385							"width": (typeof obj.options.width == 'number' && obj.options.width && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.width : "100%",
2386							"height": (typeof obj.options.height == 'number' && obj.options.height && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.height : "100%",
2387							"quality": "high",
2388							"bgcolor": "#000000",
2389							"play": "true",
2390							"loop": "true",
2391							"menu": "true",
2392							"wmode": "transparent",
2393							"scale": "showall",
2394							"allowScriptAccess": "always",
2395							"allowFullScreen": "true",
2396							"flashvars": flashvars,
2397							"fullscreen": "yes"
2398						});
2399					}
2400
2401					break;
2402
2403				case 'iframe':
2404					el = $('<iframe />').attr({
2405						"width": (typeof obj.options.width == 'number' && obj.options.width && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.width : "100%",
2406						"height": (typeof obj.options.height == 'number' && obj.options.height && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.height : "100%",
2407						src: obj.URL,
2408						frameborder: 0,
2409						'hspace': 0,
2410						'vspace': 0,
2411						'scrolling': supportTouch ? 'auto' : 'scroll',
2412						'webkitAllowFullScreen': '',
2413						'mozallowfullscreen': '',
2414						'allowFullScreen': ''
2415					});
2416
2417					break;
2418
2419				case 'inline':
2420					el = $('<div class="ilightbox-wrapper"></div>').html($(obj.URL).clone(true));
2421
2422					break;
2423
2424				case 'html':
2425					var object = obj.URL,
2426						el;
2427
2428					if (object[0].nodeName) {
2429						el = $('<div class="ilightbox-wrapper"></div>').html(object);
2430					} else {
2431						var dom = $(obj.URL),
2432							html = (dom.selector) ? $('<div>' + dom + '</div>') : dom;
2433						el = $('<div class="ilightbox-wrapper"></div>').html(html);
2434					}
2435
2436					break;
2437			}
2438
2439			$('div.ilightbox-container', element).empty().html(el);
2440
2441			// For fixing Chrome about just playing the video for first time
2442			if (el[0].tagName.toLowerCase() === 'video' && browser.webkit) setTimeout(function() {
2443				var src = el[0].currentSrc + '?' + floor(random() * 30000);
2444				el[0].currentSrc = src;
2445				el[0].src = src;
2446			});
2447
2448			return el;
2449		},
2450
2451		ogpRecognition: function(obj, callback) {
2452			var iL = this,
2453				url = obj.URL;
2454
2455			iL.showLoader();
2456			doAjax(url, function(data) {
2457				iL.hideLoader();
2458				if (data) {
2459					var object = new Object();
2460
2461					object.length = false,
2462					object.url = data.url;
2463
2464					if (data.status == 200) {
2465						var result = data.results,
2466							type = result.type,
2467							source = result.source;
2468
2469						object.source = source.src,
2470						object.width = source.width && parseInt(source.width) || 0,
2471						object.height = source.height && parseInt(source.height) || 0,
2472						object.type = type,
2473						object.thumbnail = source.thumbnail || result.images && result.images[0],
2474						object.html5video = result.html5video || {},
2475						object.length = true;
2476
2477						if (source.type == 'application/x-shockwave-flash') object.type = "flash";
2478						else if (source.type.indexOf("video/") != -1) object.type = "video";
2479						else if (source.type.indexOf("/html") != -1) object.type = "iframe";
2480						else if (source.type.indexOf("image/") != -1) object.type = "image";
2481
2482					} else if (typeof data.response != 'undefined')
2483						throw data.response;
2484
2485					callback.call(this, object.length ? object : false);
2486				}
2487			});
2488		},
2489
2490		hashChangeHandler: function(url) {
2491			var iL = this,
2492				vars = iL.vars,
2493				opts = iL.options,
2494				URL = url || window.location.href,
2495				hash = parseURI(URL).hash,
2496				split = hash.split('/'),
2497				index = split[1];
2498
2499			if (vars.hashLock || ('#' + opts.linkId != split[0] && hash.length > 1)) return;
2500
2501			if (index) {
2502				var target = split[1] || 0;
2503				if (iL.items[target]) {
2504					var overlay = $('.ilightbox-overlay');
2505					if (overlay.length && overlay.attr('linkid') == opts.linkId) {
2506						iL.goTo(target);
2507					} else {
2508						iL.itemsObject[target].trigger(ishybrid ? "itap click" : supportTouch ? 'itap' : 'click');
2509						//iL.goTo(target);
2510					}
2511				} else {
2512					var overlay = $('.ilightbox-overlay');
2513					if (overlay.length) iL.closeAction();
2514				}
2515			} else {
2516				var overlay = $('.ilightbox-overlay');
2517				if (overlay.length) iL.closeAction();
2518			}
2519		}
2520	};
2521
2522	/**
2523	 * Parse style to pixels.
2524	 *
2525	 * @param {Object}   $element   jQuery object with element.
2526	 * @param {Property} property   CSS property to get the pixels from.
2527	 *
2528	 * @return {Int}
2529	 */
2530	function getPixel($element, property) {
2531		return parseInt($element.css(property), 10) || 0;
2532	}
2533
2534	/**
2535	 * Make sure that number is within the limits.
2536	 *
2537	 * @param {Number} number
2538	 * @param {Number} min
2539	 * @param {Number} max
2540	 *
2541	 * @return {Number}
2542	 */
2543	function within(number, min, max) {
2544		return number < min ? min : number > max ? max : number;
2545	}
2546
2547	/**
2548	 * Get viewport/window size (width and height).
2549	 *
2550	 * @return {Object}
2551	 */
2552	function getViewport() {
2553		var e = window,
2554			a = 'inner';
2555		if (!('innerWidth' in window)) {
2556			a = 'client';
2557			e = document.documentElement || document.body;
2558		}
2559		return {
2560			width: e[a + 'Width'],
2561			height: e[a + 'Height']
2562		}
2563	}
2564
2565	/**
2566	 * Remove hash tag from the URL
2567	 *
2568	 * @return {Void}
2569	 */
2570	function removeHash() {
2571		var scroll = getScrollXY();
2572
2573		//UNCODE change
2574		// window.location.hash = "";
2575		// history.pushState("", document.title, window.location.pathname + window.location.search);
2576		history.replaceState({}, document.title, window.location.pathname + window.location.search);
2577
2578		// Restore the scroll offset, should be flicker free
2579		window.scrollTo(scroll.x, scroll.y);
2580	}
2581
2582	/**
2583	 * Do the ajax requests with callback.
2584	 *
2585	 * @param {String}   url
2586	 * @param {Function} callback
2587	 *
2588	 * @return {Void}
2589	 */
2590	function doAjax(url, callback) {
2591		var url = "//ilightbox.net/getSource/jsonp.php?url=" + encodeURIComponent(url).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A');
2592		$.ajax({
2593			url: url,
2594			dataType: 'jsonp'
2595		});
2596
2597		iLCallback = function(data) {
2598			callback.call(this, data);
2599		};
2600	}
2601
2602	/**
2603	 * Find image from DOM elements
2604	 *
2605	 * @param {Element} element
2606	 *
2607	 * @return {Void}
2608	 */
2609	function findImageInElement(element) {
2610		var elements = $('*', element),
2611			imagesArr = new Array();
2612
2613		elements.each(function() {
2614			var url = "",
2615				element = this;
2616
2617			if ($(element).css("background-image") != "none") {
2618				url = $(element).css("background-image");
2619			} else if (typeof($(element).attr("src")) != "undefined" && element.nodeName.toLowerCase() == "img") {
2620				url = $(element).attr("src");
2621			}
2622
2623			if (url.indexOf("gradient") == -1) {
2624				url = url.replace(/url\(\"/g, "");
2625				url = url.replace(/url\(/g, "");
2626				url = url.replace(/\"\)/g, "");
2627				url = url.replace(/\)/g, "");
2628
2629				var urls = url.split(",");
2630
2631				for (var i = 0; i < urls.length; i++) {
2632					if (urls[i].length > 0 && $.inArray(urls[i], imagesArr) == -1) {
2633						var extra = "";
2634						if (browser.msie && browser.version < 9) {
2635							extra = "?" + floor(random() * 3000);
2636						}
2637						imagesArr.push(urls[i] + extra);
2638					}
2639				}
2640			}
2641		});
2642
2643		return imagesArr;
2644	}
2645
2646	/**
2647	 * Get file extension.
2648	 *
2649	 * @param {String} URL
2650	 *
2651	 * @return {String}
2652	 */
2653	function getExtension(URL) {
2654		if (URL !== null) {
2655			//UNCODE: fix issue to detect media type with query strings
2656			var ext = URL.indexOf('?') !== -1 ? URL.split('?')[0] : URL;
2657			ext = ext.split('.').pop().toLowerCase();
2658
2659			return ext;
2660		}
2661	}
2662
2663	/**
2664	 * Get type via extension.
2665	 *
2666	 * @param {String} URL
2667	 *
2668	 * @return {String}
2669	 */
2670	function getTypeByExtension(URL) {
2671		var type,
2672			ext = getExtension(URL);
2673
2674		//Uncode addition ##START##
2675		if (URL == undefined) {
2676			return false;
2677		}
2678		//Uncode addition ##END##
2679
2680		if (extensions.image.indexOf(ext) !== -1) type = 'image';
2681		else if (extensions.flash.indexOf(ext) !== -1) type = 'flash';
2682		else if (extensions.video.indexOf(ext) !== -1) type = 'video';
2683		else if (ext.substring(0, 1) == "#") type = 'inline'; //Uncode addition
2684		else type = 'iframe';
2685
2686		return type;
2687	}
2688
2689	/**
2690	 * Return value from percent of a number.
2691	 *
2692	 * @param {Number} percent
2693	 * @param {Number} total
2694	 *
2695	 * @return {Number}
2696	 */
2697	function percentToValue(percent, total) {
2698		return parseInt((total / 100) * percent);
2699	}
2700
2701	/**
2702	 * A JavaScript equivalent of PHP’s parse_url.
2703	 *
2704	 * @param {String} url           The URL to parse.
2705	 *
2706	 * @return {Mixed}
2707	 */
2708	function parseURI(url) {
2709		var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
2710		// authority = '//' + user + ':' + pass '@' + hostname + ':' port
2711		return (m ? {
2712			href: m[0] || '',
2713			protocol: m[1] || '',
2714			authority: m[2] || '',
2715			host: m[3] || '',
2716			hostname: m[4] || '',
2717			port: m[5] || '',
2718			pathname: m[6] || '',
2719			search: m[7] || '',
2720			hash: m[8] || ''
2721		} : null);
2722	}
2723
2724	/**
2725	 * Gets the absolute URI.
2726	 *
2727	 * @param {String} href     The relative URL.
2728	 * @param {String} base     The base URL.
2729	 *
2730	 * @return {String}         The absolute URL.
2731	 */
2732	function absolutizeURI(base, href) { // RFC 3986
2733		var iL = this;
2734
2735		function removeDotSegments(input) {
2736			var output = [];
2737			input.replace(/^(\.\.?(\/|$))+/, '')
2738				.replace(/\/(\.(\/|$))+/g, '/')
2739				.replace(/\/\.\.$/, '/../')
2740				.replace(/\/?[^\/]*/g, function(p) {
2741					if (p === '/..') {
2742						output.pop();
2743					} else {
2744						output.push(p);
2745					}
2746				});
2747			return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
2748		}
2749
2750		href = parseURI(href || '');
2751		base = parseURI(base || '');
2752
2753		return !href || !base ? null : (href.protocol || base.protocol) +
2754			(href.protocol || href.authority ? href.authority : base.authority) +
2755			removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : (href.pathname ? ((base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname) : base.pathname)) +
2756			(href.protocol || href.authority || href.pathname ? href.search : (href.search || base.search)) +
2757			href.hash;
2758	}
2759
2760	/**
2761	 * A JavaScript equivalent of PHP’s version_compare.
2762	 *
2763	 * @param {String} v1
2764	 * @param {String} v2
2765	 * @param {String} operator
2766	 *
2767	 * @return {Boolean}
2768	 */
2769	function version_compare(v1, v2, operator) {
2770		this.php_js = this.php_js || {};
2771		this.php_js.ENV = this.php_js.ENV || {};
2772		var i = 0,
2773			x = 0,
2774			compare = 0,
2775			vm = {
2776				'dev': -6,
2777				'alpha': -5,
2778				'a': -5,
2779				'beta': -4,
2780				'b': -4,
2781				'RC': -3,
2782				'rc': -3,
2783				'#': -2,
2784				'p': 1,
2785				'pl': 1
2786			},
2787			prepVersion = function(v) {
2788				v = ('' + v).replace(/[_\-+]/g, '.');
2789				v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.');
2790				return (!v.length ? [-8] : v.split('.'));
2791			},
2792			numVersion = function(v) {
2793				return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10));
2794			};
2795		v1 = prepVersion(v1);
2796		v2 = prepVersion(v2);
2797		x = max(v1.length, v2.length);
2798		for (i = 0; i < x; i++) {
2799			if (v1[i] == v2[i]) {
2800				continue;
2801			}
2802			v1[i] = numVersion(v1[i]);
2803			v2[i] = numVersion(v2[i]);
2804			if (v1[i] < v2[i]) {
2805				compare = -1;
2806				break;
2807			} else if (v1[i] > v2[i]) {
2808				compare = 1;
2809				break;
2810			}
2811		}
2812		if (!operator) {
2813			return compare;
2814		}
2815
2816		switch (operator) {
2817			case '>':
2818			case 'gt':
2819				return (compare > 0);
2820			case '>=':
2821			case 'ge':
2822				return (compare >= 0);
2823			case '<=':
2824			case 'le':
2825				return (compare <= 0);
2826			case '==':
2827			case '=':
2828			case 'eq':
2829				return (compare === 0);
2830			case '<>':
2831			case '!=':
2832			case 'ne':
2833				return (compare !== 0);
2834			case '':
2835			case '<':
2836			case 'lt':
2837				return (compare < 0);
2838			default:
2839				return null;
2840		}
2841	}
2842
2843
2844	// Begin the iLightBox plugin
2845	$.fn.iLightBox = function() {
2846
2847		var args = arguments,
2848			opt = ($.isPlainObject(args[0])) ? args[0] : args[1],
2849			items = ($.isArray(args[0]) || typeof args[0] == 'string') ? args[0] : args[1];
2850
2851		if (!opt) opt = {};
2852
2853		// Default options. Play carefully.
2854		var options = $.extend(true, {
2855			attr: 'href',
2856			path: 'vertical',
2857			skin: 'dark',
2858			linkId: false,
2859			infinite: false,
2860			startFrom: 0,
2861			randomStart: false,
2862			keepAspectRatio: true,
2863			maxScale: 1,
2864			minScale: .2,
2865			innerToolbar: false,
2866			smartRecognition: false,
2867			mobileOptimizer: true,
2868			fullAlone: true,
2869			fullViewPort: null,
2870			fullStretchTypes: 'flash, video',
2871			overlay: {
2872				blur: true,
2873				opacity: .85
2874			},
2875			controls: {
2876				arrows: false,
2877				slideshow: false,
2878				toolbar: true,
2879				fullscreen: true,
2880				thumbnail: true,
2881				keyboard: true,
2882				mousewheel: true,
2883				swipe: true
2884			},
2885			keyboard: {
2886				left: true, // previous
2887				right: true, // next
2888				up: true, // previous
2889				down: true, // next
2890				esc: true, // close
2891				shift_enter: true // fullscreen
2892			},
2893			show: {
2894				effect: true,
2895				speed: 300,
2896				title: true
2897			},
2898			hide: {
2899				effect: true,
2900				speed: 300
2901			},
2902			caption: {
2903				start: true,
2904				show: 'mouseenter',
2905				hide: 'mouseleave'
2906			},
2907			social: {
2908				start: true,
2909				show: 'mouseenter',
2910				hide: 'mouseleave',
2911				buttons: false
2912			},
2913			styles: {
2914				pageOffsetX: 0,
2915				pageOffsetY: 0,
2916				nextOffsetX: 45,
2917				nextOffsetY: 0,
2918				nextOpacity: 1,
2919				nextScale: 1,
2920				prevOffsetX: 45,
2921				prevOffsetY: 0,
2922				prevOpacity: 1,
2923				prevScale: 1
2924			},
2925			thumbnails: {
2926				maxWidth: 120,
2927				maxHeight: 80,
2928				normalOpacity: 1,
2929				activeOpacity: .6
2930			},
2931			effects: {
2932				reposition: true,
2933				repositionSpeed: 200,
2934				switchSpeed: 500,
2935				loadedFadeSpeed: 180,
2936				fadeSpeed: 200
2937			},
2938			slideshow: {
2939				pauseTime: 5000,
2940				pauseOnHover: false,
2941				startPaused: true
2942			},
2943			text: {
2944				close: "Press Esc to close",
2945				enterFullscreen: "Enter Fullscreen (Shift+Enter)",
2946				exitFullscreen: "Exit Fullscreen (Shift+Enter)",
2947				slideShow: "Slideshow",
2948				next: "Next",
2949				previous: "Previous"
2950			},
2951			errors: {
2952				loadImage: "An error occurred when trying to load photo.",
2953				loadContents: "An error occurred when trying to load contents.",
2954				missingPlugin: "The content your are attempting to view requires the <a href='{pluginspage}' target='_blank'>{type} plugin<\/a>."
2955			},
2956			ajaxSetup: {
2957				url: '',
2958				beforeSend: function(jqXHR, settings) {},
2959				cache: false,
2960				complete: function(jqXHR, textStatus) {},
2961				crossDomain: false,
2962				error: function(jqXHR, textStatus, errorThrown) {},
2963				success: function(data, textStatus, jqXHR) {},
2964				global: true,
2965				ifModified: false,
2966				username: null,
2967				password: null,
2968				type: 'GET'
2969			},
2970			callback: {}
2971		}, opt);
2972
2973		var instant = ($.isArray(items) || typeof items == 'string') ? true : false;
2974
2975		items = $.isArray(items) ? items : new Array();
2976
2977		if (typeof args[0] == 'string') items[0] = args[0];
2978
2979		if (version_compare($.fn.jquery, '1.8', '>=')) {
2980			var iLB = new iLightBox($(this), options, items, instant);
2981			return {
2982				close: function() {
2983					iLB.closeAction();
2984				},
2985				fullscreen: function() {
2986					iLB.fullScreenAction();
2987				},
2988				moveNext: function() {
2989					iLB.moveTo('next');
2990				},
2991				movePrev: function() {
2992					iLB.moveTo('prev');
2993				},
2994				goTo: function(index) {
2995					iLB.goTo(index);
2996				},
2997				refresh: function() {
2998					iLB.refresh();
2999				},
3000				reposition: function() {
3001					(arguments.length > 0) ? iLB.repositionPhoto(true): iLB.repositionPhoto();
3002				},
3003				setOption: function(options) {
3004					iLB.setOption(options);
3005				},
3006				destroy: function() {
3007					iLB.closeAction();
3008					iLB.dispatchItemsEvents();
3009				}
3010			};
3011		} else {
3012			throw "The jQuery version that was loaded is too old. iLightBox requires jQuery 1.8+";
3013		}
3014
3015	};
3016
3017
3018	$.iLightBox = function() {
3019		return $.fn.iLightBox(arguments[0], arguments[1]);
3020	};
3021
3022	function getScrollXY() {
3023		var scrOfX = 0,
3024			scrOfY = 0;
3025		if (typeof(window.pageYOffset) == 'number') {
3026			//Netscape compliant
3027			scrOfY = window.pageYOffset;
3028			scrOfX = window.pageXOffset;
3029		} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
3030			//DOM compliant
3031			scrOfY = document.body.scrollTop;
3032			scrOfX = document.body.scrollLeft;
3033		} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
3034			//IE6 standards compliant mode
3035			scrOfY = document.documentElement.scrollTop;
3036			scrOfX = document.documentElement.scrollLeft;
3037		}
3038		return {
3039			x: scrOfX,
3040			y: scrOfY
3041		};
3042	}
3043
3044	(function() {
3045		// add new event shortcuts
3046		$.each(("touchstart touchmove touchend " +
3047			"tap taphold " +
3048			"swipe swipeleft swiperight " +
3049			"scrollstart scrollstop").split(" "), function(i, name) {
3050
3051			$.fn[name] = function(fn) {
3052				return fn ? this.bind(name, fn) : this.trigger(name);
3053			};
3054
3055			// jQuery < 1.8
3056			// if ($.attrFn) {
3057			// 	$.attrFn[name] = true;
3058			// }
3059		});
3060
3061		var tapSettings = {
3062			startEvent: 'touchstart.iTap',
3063			endEvent: 'touchend.iTap'
3064		};
3065
3066		// tap Event:
3067		$.event.special.itap = {
3068			setup: function() {
3069
3070				var self = this,
3071					$self = $(this),
3072					start, stop;
3073
3074				$self.bind(tapSettings.startEvent, function(event) {
3075					start = getScrollXY();
3076
3077					$self.one(tapSettings.endEvent, function(event) {
3078						stop = getScrollXY();
3079
3080						var orgEvent = event || window.event;
3081						event = $.event.fix(orgEvent);
3082						event.type = "itap";
3083
3084						if ((start && stop) && (start.x == stop.x && start.y == stop.y))($.event.dispatch || $.event.handle).call(self, event);
3085
3086						start = stop = undefined;
3087					});
3088				});
3089			},
3090
3091			teardown: function() {
3092				$(this).unbind(tapSettings.startEvent);
3093			}
3094		};
3095	}());
3096
3097
3098	//Fullscreen API
3099	(function() {
3100		fullScreenApi = {
3101				supportsFullScreen: false,
3102				isFullScreen: function() {
3103					return false;
3104				},
3105				requestFullScreen: function() {},
3106				cancelFullScreen: function() {},
3107				fullScreenEventName: '',
3108				prefix: ''
3109			},
3110			browserPrefixes = 'webkit moz o ms khtml'.split(' ');
3111
3112		// check for native support
3113		if (typeof document.cancelFullScreen != 'undefined') {
3114			fullScreenApi.supportsFullScreen = true;
3115		} else {
3116			// check for fullscreen support by vendor prefix
3117			for (var i = 0, il = browserPrefixes.length; i < il; i++) {
3118				fullScreenApi.prefix = browserPrefixes[i];
3119
3120				if (typeof document[fullScreenApi.prefix + 'CancelFullScreen'] != 'undefined') {
3121					fullScreenApi.supportsFullScreen = true;
3122
3123					break;
3124				}
3125			}
3126		}
3127
3128		// update methods to do something useful
3129		if (fullScreenApi.supportsFullScreen) {
3130			fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
3131
3132			fullScreenApi.isFullScreen = function() {
3133				switch (this.prefix) {
3134					case '':
3135						return document.fullScreen;
3136					case 'webkit':
3137						return document.webkitIsFullScreen;
3138					default:
3139						return document[this.prefix + 'FullScreen'];
3140				}
3141			}
3142			fullScreenApi.requestFullScreen = function(el) {
3143				return (this.prefix === '') ? el.requestFullScreen() : el[this.prefix + 'RequestFullScreen']();
3144			}
3145			fullScreenApi.cancelFullScreen = function(el) {
3146				return (this.prefix === '') ? document.cancelFullScreen() : document[this.prefix + 'CancelFullScreen']();
3147			}
3148		}
3149	}());
3150
3151	// Browser detect
3152	(function() {
3153		function uaMatch(ua) {
3154			ua = ua.toLowerCase();
3155
3156			var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
3157				/(webkit)[ \/]([\w.]+)/.exec(ua) ||
3158				/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
3159				/(msie) ([\w.]+)/.exec(ua) ||
3160				ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
3161
3162			return {
3163				browser: match[1] || "",
3164				version: match[2] || "0"
3165			};
3166		}
3167
3168		var matched = uaMatch(navigator.userAgent);
3169		browser = {};
3170
3171		if (matched.browser) {
3172			browser[matched.browser] = true;
3173			browser.version = matched.version;
3174		}
3175
3176		// Chrome is Webkit, but Webkit is also Safari.
3177		if (browser.chrome) {
3178			browser.webkit = true;
3179		} else if (browser.webkit) {
3180			browser.safari = true;
3181		}
3182	}());
3183
3184	// Feature detects
3185	(function() {
3186		var prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
3187		var el = document.createElement('div');
3188
3189		function testProp(prop) {
3190			for (var p = 0, pl = prefixes.length; p < pl; p++) {
3191				var prefixedProp = prefixes[p] ? prefixes[p] + prop.charAt(0).toUpperCase() + prop.slice(1) : prop;
3192				if (el.style[prefixedProp] !== undefined) {
3193					return prefixedProp;
3194				}
3195			}
3196		}
3197
3198		// Global support indicators
3199		transform = testProp('transform') || '';
3200		gpuAcceleration = testProp('perspective') ? 'translateZ(0) ' : '';
3201	}());
3202
3203
3204	/*
3205		PluginDetect v0.7.9
3206		www.pinlady.net/PluginDetect/license/
3207		[ getVersion onWindowLoaded BetterIE ]
3208		[ Flash QuickTime Shockwave ]
3209	*/
3210	var PluginDetect={version:"0.7.9",name:"PluginDetect",handler:function(c,b,a){return function(){c(b,a)}},openTag:"<",isDefined:function(b){return typeof b!="undefined"},isArray:function(b){return(/array/i).test(Object.prototype.toString.call(b))},isFunc:function(b){return typeof b=="function"},isString:function(b){return typeof b=="string"},isNum:function(b){return typeof b=="number"},isStrNum:function(b){return(typeof b=="string"&&(/\d/).test(b))},getNumRegx:/[\d][\d\.\_,-]*/,splitNumRegx:/[\.\_,-]/g,getNum:function(b,c){var d=this,a=d.isStrNum(b)?(d.isDefined(c)?new RegExp(c):d.getNumRegx).exec(b):null;return a?a[0]:null},compareNums:function(h,f,d){var e=this,c,b,a,g=parseInt;if(e.isStrNum(h)&&e.isStrNum(f)){if(e.isDefined(d)&&d.compareNums){return d.compareNums(h,f)}c=h.split(e.splitNumRegx);b=f.split(e.splitNumRegx);for(a=0;a<min(c.length,b.length);a++){if(g(c[a],10)>g(b[a],10)){return 1}if(g(c[a],10)<g(b[a],10)){return -1}}}return 0},formatNum:function(b,c){var d=this,a,e;if(!d.isStrNum(b)){return null}if(!d.isNum(c)){c=4}c--;e=b.replace(/\s/g,"").split(d.splitNumRegx).concat(["0","0","0","0"]);for(a=0;a<4;a++){if(/^(0+)(.+)$/.test(e[a])){e[a]=RegExp.$2}if(a>c||!(/\d/).test(e[a])){e[a]="0"}}return e.slice(0,4).join(",")},$$hasMimeType:function(a){return function(c){if(!a.isIE&&c){var f,e,b,d=a.isArray(c)?c:(a.isString(c)?[c]:[]);for(b=0;b<d.length;b++){if(a.isString(d[b])&&/[^\s]/.test(d[b])){f=navigator.mimeTypes[d[b]];e=f?f.enabledPlugin:0;if(e&&(e.name||e.description)){return f}}}}return null}},findNavPlugin:function(l,e,c){var j=this,h=new RegExp(l,"i"),d=(!j.isDefined(e)||e)?/\d/:0,k=c?new RegExp(c,"i"):0,a=navigator.plugins,g="",f,b,m;for(f=0;f<a.length;f++){m=a[f].description||g;b=a[f].name||g;if((h.test(m)&&(!d||d.test(RegExp.leftContext+RegExp.rightContext)))||(h.test(b)&&(!d||d.test(RegExp.leftContext+RegExp.rightContext)))){if(!k||!(k.test(m)||k.test(b))){return a[f]}}}return null},getMimeEnabledPlugin:function(k,m,c){var e=this,f,b=new RegExp(m,"i"),h="",g=c?new RegExp(c,"i"):0,a,l,d,j=e.isString(k)?[k]:k;for(d=0;d<j.length;
3210d++){if((f=e.hasMimeType(j[d]))&&(f=f.enabledPlugin)){l=f.description||h;a=f.name||h;if(b.test(l)||b.test(a)){if(!g||!(g.test(l)||g.test(a))){return f}}}}return 0},getPluginFileVersion:function(f,b){var h=this,e,d,g,a,c=-1;if(h.OS>2||!f||!f.version||!(e=h.getNum(f.version))){return b}if(!b){return e}e=h.formatNum(e);b=h.formatNum(b);d=b.split(h.splitNumRegx);g=e.split(h.splitNumRegx);for(a=0;a<d.length;a++){if(c>-1&&a>c&&d[a]!="0"){return b}if(g[a]!=d[a]){if(c==-1){c=a}if(d[a]!="0"){return b}}}return e},AXO:window.ActiveXObject,getAXO:function(a){var f=null,d,b=this,c={};try{f=new b.AXO(a)}catch(d){}return f},convertFuncs:function(f){var a,g,d,b=/^[\$][\$]/,c=this;for(a in f){if(b.test(a)){try{g=a.slice(2);if(g.length>0&&!f[g]){f[g]=f[a](f);delete f[a]}}catch(d){}}}},initObj:function(e,b,d){var a,c;if(e){if(e[b[0]]==1||d){for(a=0;a<b.length;a=a+2){e[b[a]]=b[a+1]}}for(a in e){c=e[a];if(c&&c[b[0]]==1){this.initObj(c,b)}}}},initScript:function(){var d=this,a=navigator,h,i=document,l=a.userAgent||"",j=a.vendor||"",b=a.platform||"",k=a.product||"";d.initObj(d,["$",d]);for(h in d.Plugins){if(d.Plugins[h]){d.initObj(d.Plugins[h],["$",d,"$$",d.Plugins[h]],1)}}d.convertFuncs(d);d.OS=100;if(b){var g=["Win",1,"Mac",2,"Linux",3,"FreeBSD",4,"iPhone",21.1,"iPod",21.2,"iPad",21.3,"Win.*CE",22.1,"Win.*Mobile",22.2,"Pocket\\s*PC",22.3,"",100];for(h=g.length-2;h>=0;h=h-2){if(g[h]&&new RegExp(g[h],"i").test(b)){d.OS=g[h+1];break}}};d.head=i.getElementsByTagName("head")[0]||i.getElementsByTagName("body")[0]||i.body||null;d.isIE=new Function("return/*@cc_on!@*/!1")();d.verIE=d.isIE&&(/MSIE\s*(\d+\.?\d*)/i).test(l)?parseFloat(RegExp.$1,10):null;d.verIEfull=null;d.docModeIE=null;if(d.isIE){var f,n,c=document.createElement("div");try{c.style.behavior="url(#default#clientcaps)";d.verIEfull=(c.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid")).replace(/,/g,".")}catch(f){}n=parseFloat(d.verIEfull||"0",10);d.docModeIE=i.documentMode||((/back/i).test(i.compatMode||"")?5:n)||d.verIE;d.verIE=n||d.docModeIE};d.ActiveXEnabled=false;if(d.isIE){var h,m=["Msxml2.XMLHTTP","Msxml2.DOMDocument","Microsoft.XMLDOM","ShockwaveFlash.ShockwaveFlash","TDCCtl.TDCCtl","Shell.UIHelper","Scripting.Dictionary","wmplayer.ocx"];for(h=0;h<m.length;h++){if(d.getAXO(m[h])){d.ActiveXEnabled=true;break}}};d.isGecko=(/Gecko/i).test(k)&&(/Gecko\s*\/\s*\d/i).test(l);
3210d.verGecko=d.isGecko?d.formatNum((/rv\s*\:\s*([\.\,\d]+)/i).test(l)?RegExp.$1:"0.9"):null;d.isChrome=(/Chrome\s*\/\s*(\d[\d\.]*)/i).test(l);d.verChrome=d.isChrome?d.formatNum(RegExp.$1):null;d.isSafari=((/Apple/i).test(j)||(!j&&!d.isChrome))&&(/Safari\s*\/\s*(\d[\d\.]*)/i).test(l);d.verSafari=d.isSafari&&(/Version\s*\/\s*(\d[\d\.]*)/i).test(l)?d.formatNum(RegExp.$1):null;d.isOpera=(/Opera\s*[\/]?\s*(\d+\.?\d*)/i).test(l);d.verOpera=d.isOpera&&((/Version\s*\/\s*(\d+\.?\d*)/i).test(l)||1)?parseFloat(RegExp.$1,10):null;d.addWinEvent("load",d.handler(d.runWLfuncs,d))},init:function(d){var c=this,b,d,a={status:-3,plugin:0};if(!c.isString(d)){return a}if(d.length==1){c.getVersionDelimiter=d;return a}d=d.toLowerCase().replace(/\s/g,"");b=c.Plugins[d];if(!b||!b.getVersion){return a}a.plugin=b;if(!c.isDefined(b.installed)){b.installed=null;b.version=null;b.version0=null;b.getVersionDone=null;b.pluginName=d}c.garbage=false;if(c.isIE&&!c.ActiveXEnabled&&d!=="java"){a.status=-2;return a}a.status=1;return a},fPush:function(b,a){var c=this;if(c.isArray(a)&&(c.isFunc(b)||(c.isArray(b)&&b.length>0&&c.isFunc(b[0])))){a.push(b)}},callArray:function(b){var c=this,a;if(c.isArray(b)){for(a=0;a<b.length;a++){if(b[a]===null){return}c.call(b[a]);b[a]=null}}},call:function(c){var b=this,a=b.isArray(c)?c.length:-1;if(a>0&&b.isFunc(c[0])){c[0](b,a>1?c[1]:0,a>2?c[2]:0,a>3?c[3]:0)}else{if(b.isFunc(c)){c(b)}}},getVersionDelimiter:",",$$getVersion:function(a){return function(g,d,c){var e=a.init(g),f,b,h={};if(e.status<0){return null};f=e.plugin;if(f.getVersionDone!=1){f.getVersion(null,d,c);if(f.getVersionDone===null){f.getVersionDone=1}}a.cleanup();b=(f.version||f.version0);b=b?b.replace(a.splitNumRegx,a.getVersionDelimiter):b;return b}},cleanup:function(){var a=this;if(a.garbage&&a.isDefined(window.CollectGarbage)){window.CollectGarbage()}},isActiveXObject:function(d,b){var f=this,a=false,g,c='<object width="1" height="1" style="display:none" '+d.getCodeBaseVersion(b)+">"+d.HTML+f.openTag+"/object>";if(!f.head){return a}f.head.insertBefore(document.createElement("object"),f.head.firstChild);f.head.firstChild.outerHTML=c;try{f.head.firstChild.classid=d.classID}catch(g){}try{if(f.head.firstChild.object){a=true}}catch(g){}try{if(a&&f.head.firstChild.readyState<4){f.garbage=true}}catch(g){}f.head.removeChild(f.head.firstChild);return a},codebaseSearch:function(f,b){var c=this;if(!c.ActiveXEnabled||!f){return null}if(f.BIfuncs&&f.BIfuncs.length&&f.BIfuncs[f.BIfuncs.length-1]!==null){c.callArray(f.BIfuncs)}var d,o=f.SEARCH,k={};if(c.isStrNum(b)){if(o.match&&o.min&&c.compareNums(b,o.min)<=0){return true}if(o.match&&o.max&&c.compareNums(b,o.max)>=0){return false}d=c.isActiveXObject(f,b);if(d&&(!o.min||c.compareNums(b,o.min)>0)){o.min=b}if(!d&&(!o.max||c.compareNums(b,o.max)<0)){o.max=b}return d};var e=[0,0,0,0],l=[].concat(o.digits),a=o.min?1:0,j,i,h,g,m,n=function(p,r){var q=[].concat(e);q[p]=r;return c.isActiveXObject(f,q.join(","))};if(o.max){g=o.max.split(c.splitNumRegx);for(j=0;j<g.length;j++){g[j]=parseInt(g[j],10)}if(g[0]<l[0]){l[0]=g[0]}}if(o.min){m=o.min.split(c.splitNumRegx);for(j=0;j<m.length;j++){m[j]=parseInt(m[j],10)}if(m[0]>e[0]){e[0]=m[0]}}if(m&&g){for(j=1;j<m.length;j++){if(m[j-1]!=g[j-1]){break}if(g[j]<l[j]){l[j]=g[j]}if(m[j]>e[j]){e[j]=m[j]}}}if(o.max){for(j=1;j<l.length;j++){if(g[j]>0&&l[j]==0&&l[j-1]<o.digits[j-1]){l[j-1]+=1;break}}};for(j=0;j<l.length;j++){h={};for(i=0;i<20;i++){if(l[j]-e[j]<1){break}d=round((l[j]+e[j])/2);if(h["a"+d]){break}h["a"+d]=1;if(n(j,d)){e[j]=d;a=1}else{l[j]=d}}l[j]=e[j];if(!a&&n(j,e[j])){a=1};if(!a){break}};return a?e.join(","):null},addWinEvent:function(d,c){var e=this,a=window,b;if(e.isFunc(c)){if(a.addEventListener){a.addEventListener(d,c,false)}else{if(a.attachEvent){a.attachEvent("on"+d,c)}else{b=a["on"+d];a["on"+d]=e.winHandler(c,b)}}}},winHandler:function(d,c){return function(){d();if(typeof c=="function"){c()}}},WLfuncs0:[],WLfuncs:[],runWLfuncs:function(a){var b={};a.winLoaded=true;a.callArray(a.WLfuncs0);a.callArray(a.WLfuncs);if(a.onDoneEmptyDiv){a.onDoneEmptyDiv()}},winLoaded:false,$$onWindowLoaded:function(a){return function(b){if(a.winLoaded){a.call(b)}else{a.fPush(b,a.WLfuncs)}}},div:null,divID:"plugindetect",divWidth:50,pluginSize:1,emptyDiv:function(){var d=this,b,h,c,a,f,g;if(d.div&&d.div.childNodes){for(b=d.div.childNodes.length-1;b>=0;b--){c=d.div.childNodes[b];if(c&&c.childNodes){for(h=c.childNodes.length-1;h>=0;h--){g=c.childNodes[h];try{c.removeChild(g)}catch(f){}}}if(c){try{d.div.removeChild(c)}catch(f){}}}}if(!d.div){a=document.getElementById(d.divID);if(a){d.div=a}}if(d.div&&d.div.parentNode){try{d.div.parentNode.removeChild(d.div)}catch(f){}d.div=null}},DONEfuncs:[],onDoneEmptyDiv:function(){var c=this,a,b;if(!c.winLoaded){return}if(c.WLfuncs&&c.WLfuncs.length&&c.WLfuncs[c.WLfuncs.length-1]!==null){return}for(a in c){b=c[a];if(b&&b.funcs){if(b.OTF==3){return}if(b.funcs.length&&b.funcs[b.funcs.length-1]!==null){return}}}for(a=0;a<c.DONEfuncs.length;a++){c.callArray(c.DONEfuncs)}
3210c.emptyDiv()},getWidth:function(c){if(c){var a=c.scrollWidth||c.offsetWidth,b=this;if(b.isNum(a)){return a}}return -1},getTagStatus:function(m,g,a,b){var c=this,f,k=m.span,l=c.getWidth(k),h=a.span,j=c.getWidth(h),d=g.span,i=c.getWidth(d);if(!k||!h||!d||!c.getDOMobj(m)){return -2}if(j<i||l<0||j<0||i<0||i<=c.pluginSize||c.pluginSize<1){return 0}if(l>=i){return -1}try{if(l==c.pluginSize&&(!c.isIE||c.getDOMobj(m).readyState==4)){if(!m.winLoaded&&c.winLoaded){return 1}if(m.winLoaded&&c.isNum(b)){if(!c.isNum(m.count)){m.count=b}if(b-m.count>=10){return 1}}}}catch(f){}return 0},getDOMobj:function(g,a){var f,d=this,c=g?g.span:0,b=c&&c.firstChild?1:0;try{if(b&&a){d.div.focus()}}catch(f){}return b?c.firstChild:null},setStyle:function(b,g){var f=b.style,a,d,c=this;if(f&&g){for(a=0;a<g.length;a=a+2){try{f[g[a]]=g[a+1]}catch(d){}}}},insertDivInBody:function(i,g){var f,c=this,h="pd33993399",b=null,d=g?window.top.document:window.document,a=d.getElementsByTagName("body")[0]||d.body;if(!a){try{d.write('<div id="'+h+'">.'+c.openTag+"/div>");b=d.getElementById(h)}catch(f){}}a=d.getElementsByTagName("body")[0]||d.body;if(a){a.insertBefore(i,a.firstChild);if(b){a.removeChild(b)}}},insertHTML:function(f,b,g,a,k){var l,m=document,j=this,p,o=m.createElement("span"),n,i;var c=["outlineStyle","none","borderStyle","none","padding","0px","margin","0px","visibility","visible"];var h="outline-style:none;border-style:none;padding:0px;margin:0px;visibility:visible;";if(!j.isDefined(a)){a=""}if(j.isString(f)&&(/[^\s]/).test(f)){f=f.toLowerCase().replace(/\s/g,"");p=j.openTag+f+' width="'+j.pluginSize+'" height="'+j.pluginSize+'" ';p+='style="'+h+'display:inline;" ';for(n=0;n<b.length;n=n+2){if(/[^\s]/.test(b[n+1])){p+=b[n]+'="'+b[n+1]+'" '}}p+=">";for(n=0;n<g.length;n=n+2){if(/[^\s]/.test(g[n+1])){p+=j.openTag+'param name="'+g[n]+'" value="'+g[n+1]+'" />'}}p+=a+j.openTag+"/"+f+">"}else{p=a}if(!j.div){i=m.getElementById(j.divID);if(i){j.div=i}else{j.div=m.createElement("div");j.div.id=j.divID}j.setStyle(j.div,c.concat(["width",j.divWidth+"px","height",(j.pluginSize+3)+"px","fontSize",(j.pluginSize+3)+"px","lineHeight",(j.pluginSize+3)+"px","verticalAlign","baseline","display","block"]));if(!i){j.setStyle(j.div,["position","absolute","right","0px","top","0px"]);j.insertDivInBody(j.div)}}if(j.div&&j.div.parentNode){j.setStyle(o,c.concat(["fontSize",(j.pluginSize+3)+"px","lineHeight",(j.pluginSize+3)+"px","verticalAlign","baseline","display","inline"]));try{o.innerHTML=p}catch(l){};try{j.div.appendChild(o)}catch(l){};return{span:o,winLoaded:j.winLoaded,tagName:f,outerHTML:p}}return{span:null,winLoaded:j.winLoaded,tagName:"",outerHTML:p}},Plugins:{quicktime:{mimeType:["video/quicktime","application/x-quicktimeplayer","image/x-macpaint","image/x-quicktime"],progID:"QuickTimeCheckObject.QuickTimeCheck.1",progID0:"QuickTime.QuickTime",classID:"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B",minIEver:7,HTML:'<param name="src" value="" /><param name="controller" value="false" />',getCodeBaseVersion:function(a){return'codebase="#version='+a+'"'},SEARCH:{min:0,max:0,match:0,digits:[16,128,128,0]},getVersion:function(c){var f=this,d=f.$,a=null,e=null,b;if(!d.isIE){if(d.hasMimeType(f.mimeType)){e=d.OS!=3?d.findNavPlugin("QuickTime.*Plug-?in",0):null;if(e&&e.name){a=d.getNum(e.name)}}}else{if(d.isStrNum(c)){b=c.split(d.splitNumRegx);if(b.length>3&&parseInt(b[3],10)>0){b[3]="9999"}c=b.join(",")}if(d.isStrNum(c)&&d.verIE>=f.minIEver&&f.canUseIsMin()>0){f.installed=f.isMin(c);f.getVersionDone=0;return}f.getVersionDone=1;if(!a&&d.verIE>=f.minIEver){a=f.CDBASE2VER(d.codebaseSearch(f))}if(!a){e=d.getAXO(f.progID);if(e&&e.QuickTimeVersion){a=e.QuickTimeVersion.toString(16);a=parseInt(a.charAt(0),16)+"."+parseInt(a.charAt(1),16)+"."+parseInt(a.charAt(2),16)}}}f.installed=a?1:(e?0:-1);f.version=d.formatNum(a,3)},cdbaseUpper:["7,60,0,0","0,0,0,0"],cdbaseLower:["7,50,0,0",null],cdbase2ver:[function(c,b){var a=b.split(c.$.splitNumRegx);return[a[0],a[1].charAt(0),a[1].charAt(1),a[2]].join(",")},null],CDBASE2VER:function(f){var e=this,c=e.$,b,a=e.cdbaseUpper,d=e.cdbaseLower;
3210if(f){f=c.formatNum(f);for(b=0;b<a.length;b++){if(a[b]&&c.compareNums(f,a[b])<0&&d[b]&&c.compareNums(f,d[b])>=0&&e.cdbase2ver[b]){return e.cdbase2ver[b](e,f)}}}return f},canUseIsMin:function(){var f=this,d=f.$,b,c=f.canUseIsMin,a=f.cdbaseUpper,e=f.cdbaseLower;if(!c.value){c.value=-1;for(b=0;b<a.length;b++){if(a[b]&&d.codebaseSearch(f,a[b])){c.value=1;break}if(e[b]&&d.codebaseSearch(f,e[b])){c.value=-1;break}}}f.SEARCH.match=c.value==1?1:0;return c.value},isMin:function(c){var b=this,a=b.$;return a.codebaseSearch(b,c)?0.7:-1}},flash:{mimeType:"application/x-shockwave-flash",progID:"ShockwaveFlash.ShockwaveFlash",classID:"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000",getVersion:function(){var b=function(i){if(!i){return null}var e=/[\d][\d\,\.\s]*[rRdD]{0,1}[\d\,]*/.exec(i);return e?e[0].replace(/[rRdD\.]/g,",").replace(/\s/g,""):null};var j=this,g=j.$,k,h,l=null,c=null,a=null,f,m,d;if(!g.isIE){m=g.hasMimeType(j.mimeType);if(m){f=g.getDOMobj(g.insertHTML("object",["type",j.mimeType],[],"",j));try{l=g.getNum(f.GetVariable("$version"))}catch(k){}}if(!l){d=m?m.enabledPlugin:null;if(d&&d.description){l=b(d.description)}if(l){l=g.getPluginFileVersion(d,l)}}}else{for(h=15;h>2;h--){c=g.getAXO(j.progID+"."+h);if(c){a=h.toString();break}}if(!c){c=g.getAXO(j.progID)}if(a=="6"){try{c.AllowScriptAccess="always"}catch(k){return"6,0,21,0"}}try{l=b(c.GetVariable("$version"))}catch(k){}if(!l&&a){l=a}}j.installed=l?1:-1;j.version=g.formatNum(l);return true}},shockwave:{mimeType:"application/x-director",progID:"SWCtl.SWCtl",classID:"clsid:166B1BCA-3F9C-11CF-8075-444553540000",getVersion:function(){var a=null,b=null,g,f,d=this,c=d.$;if(!c.isIE){f=c.findNavPlugin("Shockwave\\s*for\\s*Director");if(f&&f.description&&c.hasMimeType(d.mimeType)){a=c.getNum(f.description)}if(a){a=c.getPluginFileVersion(f,a)}}else{try{b=c.getAXO(d.progID).ShockwaveVersion("")}catch(g){}if(c.isString(b)&&b.length>0){a=c.getNum(b)}else{if(c.getAXO(d.progID+".8")){a="8"}else{if(c.getAXO(d.progID+".7")){a="7"}else{if(c.getAXO(d.progID+".1")){a="6"}}}}}d.installed=a?1:-1;d.version=c.formatNum(a)}},zz:0}};PluginDetect.initScript();
3211
3212	var gArgCountErr='The "%%" function requires an even number of arguments.\nArguments should be in the form "atttributeName", "attributeValue", ...',gTagAttrs=null,gQTGeneratorVersion=1;function AC_QuickTimeVersion(){return gQTGeneratorVersion}function _QTComplain(a,b){b=b.replace("%%",a);alert(b)}function _QTAddAttribute(a,b,c){var d;d=gTagAttrs[a+b];null==d&&(d=gTagAttrs[b]);return null!=d?(0==b.indexOf(a)&&null==c&&(c=b.substring(a.length)),null==c&&(c=b),c+'="'+d+'" '):""}function _QTAddObjectAttr(a,b){if(0==a.indexOf("emb#"))return"";0==a.indexOf("obj#")&&null==b&&(b=a.substring(4));return _QTAddAttribute("obj#",a,b)}function _QTAddEmbedAttr(a,b){if(0==a.indexOf("obj#"))return"";0==a.indexOf("emb#")&&null==b&&(b=a.substring(4));return _QTAddAttribute("emb#",a,b)}function _QTAddObjectParam(a,b){var c,d="",e=b?" />":">";-1==a.indexOf("emb#")&&(c=gTagAttrs["obj#"+a],null==c&&(c=gTagAttrs[a]),0==a.indexOf("obj#")&&(a=a.substring(4)),null!=c&&(d='  <param name="'+a+'" value="'+c+'"'+e+"\n"));return d}function _QTDeleteTagAttrs(){for(var a=0;a<arguments.length;a++){var b=arguments[a];delete gTagAttrs[b];delete gTagAttrs["emb#"+b];delete gTagAttrs["obj#"+b]}}function _QTGenerate(a,b,c){if(4>c.length||0!=c.length%2)return _QTComplain(a,gArgCountErr),"";gTagAttrs=[];gTagAttrs.src=c[0];gTagAttrs.width=c[1];gTagAttrs.height=c[2];gTagAttrs.classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";gTagAttrs.pluginspage="http://www.apple.com/quicktime/download/";a=c[3];if(null==a||""==a)a="6,0,2,0";gTagAttrs.codebase="http://www.apple.com/qtactivex/qtplugin.cab#version="+a;for(var d,e=4;e<c.length;e+=2)d=c[e].toLowerCase(),a=c[e+1],"name"==d||"id"==d?gTagAttrs.name=a:gTagAttrs[d]=a;c="<object "+_QTAddObjectAttr("classid")+_QTAddObjectAttr("width")+_QTAddObjectAttr("height")+_QTAddObjectAttr("codebase")+_QTAddObjectAttr("name","id")+_QTAddObjectAttr("tabindex")+_QTAddObjectAttr("hspace")+_QTAddObjectAttr("vspace")+_QTAddObjectAttr("border")+_QTAddObjectAttr("align")+_QTAddObjectAttr("class")+_QTAddObjectAttr("title")+_QTAddObjectAttr("accesskey")+_QTAddObjectAttr("noexternaldata")+">\n"+_QTAddObjectParam("src",b);e="  <embed "+_QTAddEmbedAttr("src")+_QTAddEmbedAttr("width")+_QTAddEmbedAttr("height")+_QTAddEmbedAttr("pluginspage")+_QTAddEmbedAttr("name")+_QTAddEmbedAttr("align")+_QTAddEmbedAttr("tabindex");_QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex","hspace","vspace","border","align","noexternaldata","class","title","accesskey");for(d in gTagAttrs)a=gTagAttrs[d],null!=a&&(e+=_QTAddEmbedAttr(d),c+=_QTAddObjectParam(d,b));return c+e+"> </embed>\n</object>"}function QT_GenerateOBJECTText(){return _QTGenerate("QT_GenerateOBJECTText",!1,arguments)};
3213
3214
3215	/*
3216		jQuery hashchange event v1.3
3217		https://github.com/cowboy/jquery-hashchange
3218		Copyright (c) 2010 "Cowboy" Ben Alman
3219		Dual licensed under the MIT and GPL licenses.
3220	*/
3221	(function(){function e(a){a=a||location.href;return"#"+a.replace(/^[^#]*#?(.*)$/,"$1")}var k=document,b,f=$.event.special,p=k.documentMode,m="oniLightBoxHashChange"in window&&(void 0===p||7<p);$.fn.iLightBoxHashChange=function(a){return a?this.bind("iLightBoxHashChange",a):this.trigger("iLightBoxHashChange")};$.fn.iLightBoxHashChange.delay=50;f.iLightBoxHashChange=$.extend(f.iLightBoxHashChange,{setup:function(){if(m)return!1;$(b.start)},teardown:function(){if(m)return!1;$(b.stop)}});b=function(){function a(){var c=
3222	e(),d=f(l);c!==l?(n(l=c,d),$(window).trigger("iLightBoxHashChange")):d!==l&&(location.href=location.href.replace(/#.*/,"")+d);g=setTimeout(a,$.fn.iLightBoxHashChange.delay)}var h={},g,l=e(),b=function(c){return c},n=b,f=b;h.start=function(){g||a()};h.stop=function(){g&&clearTimeout(g);g=void 0};browser.msie&&!m&&function(){var c,d;h.start=function(){c||(d=(d=$.fn.iLightBoxHashChange.src)&&d+e(),c=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){d||n(e());a()}).attr("src",d||
3223	"javascript:0").insertAfter("body")[0].contentWindow,k.onpropertychange=function(){try{"title"===event.propertyName&&(c.document.title=k.title)}catch(a){}})};h.stop=b;f=function(){return e(c.location.href)};n=function(a,d){var b=c.document,e=$.fn.iLightBoxHashChange.domain;
3223a!==d&&(b.title=k.title,b.open(),e&&b.write('<script>document.domain="'+e+'"\x3c/script>'),b.close(),c.location.hash=a)}}();return h}()})();
3224
3225	if (!Array.prototype.filter) {
3226		Array.prototype.filter = function(fun /*, thisp */ ) {
3227			"use strict";
3228
3229			if (this == null)
3230				throw new TypeError();
3231
3232			var t = Object(this);
3233			var len = t.length >>> 0;
3234			if (typeof fun != "function")
3235				throw new TypeError();
3236
3237			var res = [];
3238			var thisp = arguments[1];
3239			for (var i = 0; i < len; i++) {
3240				if (i in t) {
3241					var val = t[i]; // in case fun mutates this
3242					if (fun.call(thisp, val, i, t))
3243						res.push(val);
3244				}
3245			}
3246
3247			return res;
3248		};
3249	}
3250
3251	if (!Array.prototype.indexOf) {
3252		Array.prototype.indexOf = function(searchElement, fromIndex) {
3253			var k;
3254
3255			if (this == null) {
3256				throw new TypeError('"this" is null or not defined');
3257			}
3258
3259			var O = Object(this);
3260
3261			var len = O.length >>> 0;
3262
3263			if (len === 0) {
3264				return -1;
3265			}
3266
3267			var n = +fromIndex || 0;
3268
3269			if (abs(n) === Infinity) {
3270				n = 0;
3271			}
3272
3273			if (n >= len) {
3274				return -1;
3275			}
3276
3277			k = max(n >= 0 ? n : len - abs(n), 0);
3278
3279			while (k < len) {
3280				var kValue;
3281				if (k in O && O[k] === searchElement) {
3282					return k;
3283				}
3284				k++;
3285			}
3286			return -1;
3287		};
3288	}
3289
3290	if (!Array.prototype.lastIndexOf) {
3291		Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/ ) {
3292			"use strict";
3293
3294			if (this == null)
3295				throw new TypeError();
3296
3297			var t = Object(this);
3298			var len = t.length >>> 0;
3299			if (len === 0)
3300				return -1;
3301
3302			var n = len;
3303			if (arguments.length > 1) {
3304				n = Number(arguments[1]);
3305				if (n != n)
3306					n = 0;
3307				else if (n != 0 && n != (1 / 0) && n != -(1 / 0))
3308					n = (n > 0 || -1) * floor(abs(n));
3309			}
3310
3311			var k = n >= 0 ? min(n, len - 1) : len - abs(n);
3312
3313			for (; k >= 0; k--) {
3314				if (k in t && t[k] === searchElement)
3315					return k;
3316			}
3317			return -1;
3318		};
3319	}
3320})(jQuery, this);

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.