PageSourceSearch

https://www.yeditepesoft.com/UserFiles/themes/site/slider/js/layerslider.kreaturamediaae01.js

js yeditepesoft.com collected 2026-10-07 12:42:49 UTC 188,039 bytes, 5,887 lines download raw bytes

1/** SplitType
2  * A javascript utility that splits text into indivual lines words and characters
3  * that can be animated and styled independently.
4  * Date: May 2015
5  * @author: Luke Peavey
6  * @version: 0.8
7  * @license MIT
8  */
9var SplitType=function(t,e,n){"use strict";function i(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?m[j.call(t)]||"object":typeof t}function s(t){if("object"!=typeof t||null===t)return!1;var e=t.length;return 0===e||"number"==typeof e&&e>0&&e-1 in t}function l(t){var e={},n=function(t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i)}};n(arguments[0]);for(var i=1;i<arguments.length;i++){var s=arguments[i];"object"==typeof s&&null!==s&&n(s)}return e}function o(t){return"object"!=typeof t||null===t?!1:1===t.nodeType||3===t.nodeType||11===t.nodeType}function r(t){return t?{top:t.offsetTop,left:t.offsetLeft,width:t.offsetWidth,height:t.offsetHeight}:void 0}function a(){var t=e.createElement("style");return t.appendChild(e.createTextNode("")),e.head.appendChild(t),t.sheet}function c(t,e,n,i){"insertRule"in t?t.insertRule(e+"{"+n+"}",i||0):"addRule"in t&&t.addRule(e,n,i||0)}function p(t){var n=t||{},s=n.content,l=n.data,r=e.createElement(n.nodeName||b.nodeName);switch(r.className=((n["class"]||"")+" "+b.splitClass).trim(),n.style&&(r.style.cssText=n.style),"object"===i(l)&&Object.keys(l).forEach(function(t){r.dataset[t]=l[t]}),i(s)){case"object":o(s)&&r.appendChild(s);break;case"array":s.forEach(function(t){o(t)&&r.appendChild(t)});break;case"string":r.innerHTML=s}return r}function h(t){var n=[];if("string"==typeof t){var i=t.trim();t=1===i.split(" ").length&&i.indexOf(",")>-1&&i.indexOf(">")>-1&&"#"===i.charAt(0)?e.getElementById(i.substring(1)):e.querySelectorAll(i)}if(s(t))for(var l=t.length,r=0;l>r;r++)if(s(t[r]))for(var a=0,c=t[r].length;c>a;a++)o(t[r][a])&&n.push(t[r][a]);else o(t[r])&&n.push(t[r]);else o(t)&&(n=[t]);return n}function f(t,e){var n,i,s,l=this._SPLIT,o=l.settings,r=o.splitLines,a=o.splitWords,c=o.splitChars,h=o.isAbsolute,f=[],g=[],b=[],m=t.textContent.replace(/\s+/g," ").trim(),j=v();m.split(" ").forEach(function(t,e){c?(n=v(),t.split("").forEach(function(t,e,i){b.push(n.appendChild(s=p({"class":o.charClass,content:t,nodeName:"div",data:{last:r&&!a&&e===i.length-1}})))})):n=y(t),i=a||r?p({"class":o.wordClass,content:n}):n,j.appendChild(i),j.appendChild(C()),(a||r)&&g.push(i)},this),t.innerHTML="",t.appendChild(j),l.allWords=a?l.allWords.concat(g):[],l.allChars=c?l.allChars.concat(b):[],(r||h)&&(r&&(f=u.call(this,t,g,b),g=a?g:[]),h&&d.call(this,t,f,g,b))}function u(t,e,n){var i,s=this._SPLIT,l=s.settings,o=(l.splitLines,l.splitWords),r=l.splitChars,a=[],c=[],h=-999,f=v();for(e.forEach(function(t){i=t.offsetTop,i!==h&&(c=[],a.push(c),h=i),c.push(t)},this),a.forEach(function(t,e){var n=p({"class":l.lineClass});t.forEach(function(t,e){var i;o?i=t:r?(i=v(),[].slice.call(t.children).forEach(function(t){i.appendChild(t)})):i=y(t.textContent),n.appendChild(i),n.appendChild(C())}),f.appendChild(n),s.allLines.push(n),a.splice(e,1,n)},this);t.firstChild;)t.removeChild(t.firstChild);return t.appendChild(f),a}function d(e,n,i,s){var l,o=this._SPLIT,a=o.settings,c=(a.splitLines,a.splitWords,a.splitChars,e.offsetHeight),p=e.offsetWidth,h=[].concat(n,i,s),f=h.length,a=t.getComputedStyle(e);for(e.style.position="static"===a.position?"relative":a.position,e.style.height=c+"px",e.style.width=p+2+"px",l=0;f>l;l++)h[l].pos=r(h[l]);for(l=0;f>l;l++){var u=h[l];u.style.top=u.pos.top+"px",u.style.left=u.pos.left+"px",u.style.height=u.pos.height+"px",u.style.width=u.pos.width+"px",u.style.position="absolute"}}function g(t,e){if(!(!this instanceof g)){var n=this._SPLIT={settings:{},splitNodes:[],elements:[],allLines:[],allWords:[],allChars:[],originals:[]};n.settings=l(b,e),n.elements=h(t),n.elements.forEach(function(t,e){n.originals[e]=t.innerHTML}),this.split()}}var b={lineClass:"line",wordClass:"word",charClass:"char",splitClass:"split-item",split:"lines, words, chars",position:"rel",nodeName:"div",text:!1,get splitLines(){return-1!==this.split.indexOf("lines")},get splitWords(){return-1!==this.split.indexOf("words")},get splitChars(){return-1!==this.split.indexOf("chars")},get isAbsolute(){return"string"==typeof this.position&&"absolute"===this.position.toLowerCase()||this.absolute===!0}};Object.defineProperty(g,"settings",{get:function(){return b},set:function(t){b=l(b,t)}});var y=function(t){return e.createTextNode(t)},C=function(){return y(" ")},v=function(){return e.createDocumentFragment()},m={},j=m.toString;"Boolean Number String Function Array Object Null".split(" ").forEach(function(t){m["[object "+t+"]"]=t.toLowerCase()});var L=a();return c(L,".is-splitting","visibility: hidden; position: absolute;"),c(L,".split-item","display: inline-block; position: relative;"),g.prototype={split:function(e){var n=this._SPLIT,i=(n.settings,n.elements),s=[t.scrollX,t.scrollY];return n.allLines.length=n.allWords.length=n.allChars.length=0,n.settings=e?l(n.settings,e):n.settings,i.forEac
9h(function(t){t.parentElement.classList.add("is-splitting")}),i.forEach(function(t,e){f.call(this,t)},this),i.forEach(function(t){t.parentElement.classList.remove("is-splitting")}),t.scrollTo(s[0],s[1]),this},revert:function(){var t=this._SPLIT;t.allLines.length=t.allWords.length=t.allChars.length=0,t.elements.forEach(function(e,n){e.innerHTML=t.originals[n]})},get lines(){return this._SPLIT.allLines},get words(){return this._SPLIT.allWords},get chars(){return this._SPLIT.allChars}},g}(window,document);
10
11this.gsTransform = (function() {
12	var prop, t = {transform: 1, WebkitTransform: 1, MozTransform: 1, msTransform: 1, OTransform: 1, '': 0};
13	for (prop in t) if (prop in document.documentElement.style) break;
14	return prop;
15})();
16
17this.gsTransformOrigin = gsTransform ? gsTransform + 'Origin' : '';
18
19(this._gsQueue || (this._gsQueue = [])).push(function() {
20
21	function getPercent(value, size) {
22		if (value == undefined) return;
23		value = value.toString().toLowerCase();
24		switch (value) {
25			case 'top': case 'left': return 0;
26			case 'center': return 50;
27			case 'bottom': case 'right': return 100;
28		}
29		var percent = parseFloat(value);
30		if (value.indexOf('%') < 0) percent *= 100 / size;
31		return percent;
32	}
33
34	_gsDefine.plugin({
35		propName: "origin",
36		API: 2,
37		version: "0.2",
38
39		init: function(target, value, tween) {
40			var o = target.style[gsTransformOrigin].split(' ');
41			this.target = target;
42			this._x = getPercent(o[0], target.offsetWidth ) || 50;
43			this._y = getPercent(o[1], target.offsetHeight) || 50;
44			this._z = parseInt(o[2]) || 0;
45			o = value.trim().split(/\s+/);
46			this.x = getPercent(o[0], target.offsetWidth );
47			this.y = getPercent(o[1], target.offsetHeight);
48			this.z = parseInt(o[2]) || 0;
49			if (this._x == this.x) delete this.x;
50			if (this._y == this.y) delete this.y;
51			if (this._z == this.z) delete this.z;
52			return gsTransformOrigin && ('x' in this || 'y' in this || 'z' in this);
53		},
54
55		set: function(ratio) {
56			var x = this._x, y = this._y, z = this._z, r = ratio < 1 ? ratio : 1;
57			if ('x' in this) x = r * (this.x - x) + x;
58			if ('y' in this) y = r * (this.y - y) + y;
59			if ('z' in this) z = r * (this.z - z) + z;
60			this.target.style[gsTransformOrigin] = x+"% "+y+"% "+z+"px";
61			//console.log(this.target.style[gsTransformOrigin]);
62			// this.target._gsTransform.zOrigin = z; ???
63		}
64  });
65
66}), this._gsDefine && _gsQueue.pop()();
67
68function gsConvertEase(ease) {
69	var m = ease.match(/(easeInOut|easeIn|easeOut|ease)(.+)/);
70	return m ? window[ m[2] ][ m[1] ] : Linear.easeNone;
71}
72
73function gsRect(clip, w, h) {
74	var i, c = clip.trim().split(/[,\s]+/), d = [h, w];
75	for (i = 0; i < c.length; i++)
76		c[i] = c[i].indexOf('%') < 0 ? parseInt(c[i]) : parseFloat(c[i]) / 100 * d[i % 2];
77	if (c.length < 2) c[1] = c[0];
78	if (c.length < 3) c[2] = c[0];
79	if (c.length < 4) c[3] = c[1];
80	c[1] = d[1] - c[1];
81	c[2] = d[0] - c[2];
82	c.length = 4;
83	return 'rect('+ c.join() +')';
84}
85
86function lsShowNotice(lsobj,issue,ver){
87
88	var el;
89
90	if( typeof lsobj == 'string' ){
91		el = jQuery('#'+lsobj);
92	}else if( typeof lsobj == 'object' ){
93		el = lsobj;
94	}
95
96	var errorTitle, errorText;
97
98	switch(issue){
99		case 'jquery':
100		errorTitle = 'multiple jQuery issue';
101		errorText = 'It looks like that another plugin or your theme loads an extra copy of the jQuery library causing problems for LayerSlider to show your sliders.';
102		break;
103		case 'oldjquery':
104		errorTitle = 'old jQuery issue';
105		errorText = 'It looks like you are using an old version ('+ver+') of the jQuery library. LayerSlider requires at least version 1.7.0 or newer. Please update jQuery to 1.10.x or higher.</a>';
106		break;
107	}
108
109	el.addClass('ls-error');
110	el.append('<p class="ls-exclam">!</p>');
111	el.append('<p class="ls-error-title">LayerSlider: '+errorTitle+'</p>');
112	el.append('<p class="ls-error-text">'+errorText+'</p>');
113}
114
115(function($) {
116	window.lsjq = $;
117	// IMPROVEMENT v5.3.0 Fixed multiple Greensock issues
118
119	if( typeof kmGS !== 'undefined' ){
120		for(var prop in kmGS) {
121			this[prop] = kmGS[prop];
122		}
123	}
124
125	var scrollWidth; // calc scrollWidth
126	$(function() {
127		var outer = document.createElement("div");
128		outer.style.visibility = "hidden";
129		outer.style.width = "100px";
130		document.body.appendChild(outer);
131		var widthNoScroll = outer.offsetWidth;
132		outer.style.overflow = "scroll";
133		var inner = document.createElement("div");
134		inner.style.width = "100%";
135		outer.appendChild(inner);
136		var widthWithScroll = inner.offsetWidth;
137		outer.parentNode.removeChild(outer);
138		scrollWidth = widthNoScroll - widthWithScroll;
139	});
140
141	$.fn.layerSlider = function( options ){
142
143		// IMPROVEMENT v4.1.0 Checking jQuery version
144		// IMPROVEMENT v4.1.3 Changed required version from 1.7.2 to 1.7.0
145
146		var reqVer = '1.7.0';
147		var curVer = $.fn.jquery;
148		var el = $(this);
149
150		var checkVersions = function(v1,v2){
151
152			var v1parts = v1.split('.');
153			var v2parts = v2.split('.');
154
155			for (var i = 0; i < v1parts.length; ++i) {
156
157				if (v2parts.length == i) {
158					return false;
159				}
160
161				if(parseInt(v1parts[i]) == parseInt(v2parts[i])){
162					continue;
163				}else if (parseInt(v1parts[i]) > parseInt(v2parts[i])){
164					return false;
165				}else{
166					return true;
167				}
168			}
169
170			if (v1parts.length != v2parts.length) {
171				return true;
172			}
173
174			return true;
175		};
176
177		if( !checkVersions('1.8.0',curVer) ){
178			el.addClass('ls-norotate');
179		}
180
181		// Initializing if jQuery version is greater than 1.7.0
182
183		if( !checkVersions(reqVer,curVer) ){
184			lsShowNotice( el, 'oldjquery', curVer );
185		}else{
186
187			if( (typeof(options)).match('object|undefined') ){
188				return this.each(function(i){
189					new layerSlider(this, options);
190				});
191			}else{
192				if( options === 'data' ){
193					var lsData = $(this).data('LayerSlider').g;
194					if( lsData ){
195						return lsData;
196					}
197
198				// NEW FEATURES v5.2.0 option to get userInitData & defaultInitData
199
200				}else if( options === 'userInitData' ){
201					var lsInitData = $(this).data('LayerSlider').o;
202					if( lsInitData ){
203						return lsInitData;
204					}
205				}else if( options === 'defaultInitData' ){
206					var lsInitData = $(this).data('LayerSlider').defaults;
207					if( lsInitData ){
208						return lsInitData;
209					}
210
211				}else{
212					return this.each(function(i){
213
214						// Control functions: prev, next, start, stop & change
215
216						var lsData = $(this).data('LayerSlider');
217						if( lsData ){
218							if( !lsData.g.isAnimating && !lsData.g.isLoading ){
219								if( typeof options == 'number' ){
220									if( options > 0 && options < lsData.g.layersNum + 1 && options != lsData.g.curLayerIndex ){
221										lsData.change(options);
222									}
223								}else{
224									switch(options){
225										case 'prev':
226											lsData.o.cbPrev(lsData.g);
227											lsData.prev('clicked');
228											break;
229										case 'next':
230											lsData.o.cbNext(lsData.g);
231											lsData.next('clicked');
232											break;
233										case 'start':
234											if( !lsData.g.autoSlideshow ){
235												lsData.o.cbStart(lsData.g);
236												lsData.g.originalAutoSlideshow = true;
237												lsData.start();
238											}
239											break;
240									}
241								}
242							}
243							// if( options === 'debug' ){
244							// 	lsData.d.show();
245							// }
246							if( options === 'redraw' ){
247								lsData.resize();
248							}
249							if( ( lsData.g.autoSlideshow || ( !lsData.g.autoSlideshow && lsData.g.originalAutoSlideshow ) ) && options == 'stop' ){
250								lsData.o.cbStop(lsData.g);
251								lsData.g.originalAutoSlideshow = false;
252								lsData.g.curLayer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
253
254									// Clearing videoTimeouts
255
256									clearTimeout( $(this).data( 'videoTimer') );
257								});
258
259								lsData.stop();
260							}
261							if( options == 'forceStop'){
262								lsData.forcestop();
263							}
264						}
265					});
266				}
267			}
268		}
269	};
270
271	// LayerSlider methods
272
273	var layerSlider = function(el, options) {
274
275		var ls = this;
276		ls.$el = $(el).addClass('ls-container');
277		ls.$el.data('LayerSlider', ls);
278
279		ls.load = function(){
280
281			// Setting options (user settings) and global (not modificable) parameters
282
283			ls.defaults = layerSlider.options;
284			ls.o = $.extend({},ls.defaults, options);
285			ls.g = $.extend({},layerSlider.global);
286			ls.lt = $.extend({},layerSlider.layerTransitions );
287			ls.st = $.extend({},layerSlider.slideTransitions );
288
289			ls.g.enableCSS3 = $(el).hasClass('ls-norotate') ? false : true;
290
291
292			if (ls.o.fullPage) {
293				// Disable pause on hover in case of FullPage slider
294				ls.o.pauseOnHover = false;
295				// Set overflow hidden in case of FullPage slider
296				if (ls.o.thumbnailNavigation != 'always') {
297					ls.$el.css('overflow', 'hidden');
298				}
299			}
300
301			// NEW FEATURE v5.2.0 saving original HTML Markup
302
303			ls.g.originalMarkup = $(el).html();
304
305			if( ls.g.ie78 ){
306				ls.o.lazyLoad = false;
307			}
308
309			// WP parameters
310
311			if( ls.o.autoPauseSlideshow === 'enabled' ){
312				ls.o.autoPauseSlideshow = true;
313			}
314			if( ls.o.autoPauseSlideshow === 'disabled' ){
315				ls.o.autoPauseSlideshow = false;
316			}
317
318			// If layerslider.transitions.js is loaded...
319
320			if( typeof layerSliderTransitions !== 'undefined' ){
321				ls.t = $.extend({},layerSliderTransitions);
322			}
323
324			// If custom transitions are loaded...
325
326			if( typeof layerSliderCustomTransitions !== 'undefined' ){
327				ls.ct = $.extend({},layerSliderCustomTransitions);
328			}
329
330			// NEW IMPROVEMENT v3.6 forbid to call the init code more than once on the same element
331
332			if( !ls.g.initialized ){
333
334				ls.g.initialized = true;
335
336				// Added debug mode v3.5
337
338				// ls.debug();
339
340				if( $('html').find('meta[content*="WordPress"]').length ){
341					ls.g.wpVersion = $('html').find('meta[content*="WordPress"]').attr('content').split('WordPress')[1];
342				}
343
344				if( $('html').find('script[src*="layerslider"]').length ){
345					if( $('html').find('script[src*="layerslider"]').attr('src').indexOf('?') != -1 ){
346						ls.g.lswpVersion = $('html').find('script[src*="layerslider"]').attr('src').split('?')[1].split('=')[1];
347					}
348				}
349
350				// NEW LOAD METHOD v3.5
351				// FIXED v4.0 If the selected skin is already loaded, calling the ls.init() function immediately
352
353				if( !ls.o.skin || ls.o.skin == '' || !ls.o.skinsPath || ls.o.skinsPath == '' ){
354
355					// ls.d.aT('Loading without skin. Possibilities: mistyped skin and / or skinsPath.');
356
357					ls.init();
358				}else{
359
360					// ls.d.aT('Trying to load with skin: '+ls.o.skin, true);
361
362					// Applying skin
363
364					$(el).addClass('ls-'+ls.o.skin);
365
366					var skinStyle = ls.o.skinsPath+ls.o.skin+'/skin.css';
367
368					var cssContainer = $('head');
369
370					if( !$('head').length ){
371						cssContainer = $('body');
372					}
373
374					if( $('link[href="'+skinStyle+'"]').length ){
375
376						// ls.d.aU('Skin "'+ls.o.skin+'" is already loaded.');
377
378						curSkin = $('link[href="'+skinStyle+'"]');
379
380						if( !ls.g.loaded ){
381
382							ls.g.loaded = true;
383
384							// IMPROVEMENT v4.5.0 Added delay because of caching bugs
385
386					ls.g.t1 = setTimeout(function(){
387								ls.init();
388							},150);
389						}
390
391					}else{
392						if (document.createStyleSheet && !navigator.userAgent.match(/MSIE [6-8]/)){ // fix for out of memory in old IE
393							document.createStyleSheet(skinStyle);
394							var curSkin = $('link[href="'+skinStyle+'"]');
395						}else{
396							var curSkin = $('<link rel="stylesheet" href="'+skinStyle+'" type="text/css" />').appendTo( cssContainer );
397						}
398					}
399
400					// curSkin.load(); function for most of the browsers.
401
402					curSkin.load(function(){
403
404						if( !ls.g.loaded ){
405
406							// ls.d.aU('curSkin.load(); fired');
407
408							ls.g.loaded = true;
409
410							// IMPROVEMENT v4.5.0 Added delay because of caching bugs
411
412					ls.g.t2 = setTimeout(function(){
413								ls.init();
414							},150);
415						}
416					});
417
418					// $(window).load(); function for older webkit ( < v536 ).
419
420					$(window).load(function(){
421
422						if( !ls.g.loaded ){
423
424							// ls.d.aU('$(window).load(); fired');
425
426							ls.g.loaded = true;
427
428							// IMPROVEMENT v4.5.0 Added delay because of caching bugs
429
430					ls.g.t3 = setTimeout(function(){
431								ls.init();
432							},150);
433						}
434					});
435
436					// Fallback: if $(window).load(); not fired in 2 secs after $(document).ready(),
437					// curSkin.load(); not fired at all or the name of the skin and / or the skinsPath
438					// mistyped, we must call the init function manually.
439
440					ls.g.t4 = setTimeout( function(){
441
442						if( !ls.g.loaded ){
443
444							// ls.d.aT('Fallback mode: Neither curSkin.load(); or $(window).load(); were fired');
445
446							ls.g.loaded = true;
447							ls.init();
448						}
449					}, 1000);
450				}
451			}
452		};
453
454		ls.init = function(){
455
456			// NEW FEATURE v5.5.0 Appending the slider element into the element specified in appendTo
457
458			$(el).prependTo( $( ls.o.appendTo ) );
459
460			// IMPROVEMENT v4.0.1 Trying to add special ID to <body> or <html> (required to overwrite WordPresss global styles)
461
462			if( !$('html').attr('id') ){
463				$('html').attr('id','ls-global');
464			}else if( !$('body').attr('id') ){
465				$('body').attr('id','ls-global');
466			}
467
468			// NEW FEATURES v5.2.0 Hiding the slider on mobile devices, smaller resolutions
469			// or changing it to a static but responsive image
470
471			if( ls.g.isMobile() === true && ls.o.hideOnMobile === true ){
472				$(el).addClass('ls-forcehide');
473				$(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
474			}
475
476			var showHide = function(){
477
478				if( ls.o.hideOnMobile === true && ls.g.isMobile() === true ){
479					$(el).addClass('ls-forcehide');
480					$(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
481					ls.o.autoStart = false;
482				}else{
483					if( $(window).width() < ls.o.hideUnder || $(window).width() > ls.o.hideOver ){
484						$(el).addClass('ls-forcehide');
485						$(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
486					}else{
487						$(el).removeClass('ls-forcehide');
488						$(el).closest('.ls-wp-fullwidth-container').removeClass('ls-forcehide');
489					}
490				}
491			};
492
493			$(window).resize( function(){
494
495				showHide();
496			});
497
498			showHide();
499
500			// NEW FEATURE v1.7 making the slider responsive
501
502			ls.g.sliderWidth = function(){
503				return $(el).width();
504			}
505
506			ls.g.sliderHeight = function(){
507				return $(el).height();
508			}
509
510			// Compatibility mode v5.0.0
511			//	.ls-layer 	-> .ls-slide
512			//	.ls-s 		-> .ls-l
513
514			$(el).find('.ls-layer').removeClass('ls-layer').addClass('ls-slide');
515			$(el).find('.ls-slide > *[class*="ls-s"]').each(function(){
516				var oldDistanceNum = $(this).attr('class').split('ls-s')[1].split(' ')[0];
517				$(this).removeClass('ls-s'+oldDistanceNum).addClass('ls-l'+oldDistanceNum);
518			});
519
520
521			if( ls.o.firstLayer ){
522				ls.o.firstSlide = ls.o.firstLayer;
523			}
524			if( ls.o.animateFirstLayer === false ){
525				ls.o.animateFirstSlide = false;
526			}
527
528			// REPLACED FEATURE v2.0 If there is only ONE layer, instead of duplicating it, turning off slideshow and loops, hiding all controls, etc.
529
530			if( $(el).find('.ls-slide').length == 1 ){
531				ls.o.autoStart = false;
532				ls.o.navPrevNext = false;
533				ls.o.navStartStop = false;
534				ls.o.navButtons = false;
535				ls.o.loops = 0;
536				ls.o.forceLoopNum = false;
537				ls.o.autoPauseSlideshow	= true;
538				ls.o.firstSlide = 1;
539				ls.o.thumbnailNavigation = 'disabled';
540			}
541
542			// IMPROVEMENT v5.2.0 the original width of a full width slider should be always 100% even if the user forgot to set that value
543			// BUGFIX v5.3.0 An additional check required (with the original improvement full-width sliders with "normal" responsiveness couldn't be created)
544
545			if( $(el).parent().hasClass('ls-wp-fullwidth-helper') && ls.o.responsiveUnder !== 0 ){
546				$(el)[0].style.width = '100%';
547			}
548
549			// NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
550			// NEW FEATURE v3.5 responsiveUnder
551
552			if( ls.o.width ){
553				ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = '' + ls.o.width;
554			}else{
555				ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = $(el)[0].style.width;
556			}
557
558			if( ls.o.height ){
559				ls.g.sliderOriginalHeight = '' + ls.o.height;
560			}else{
561				ls.g.sliderOriginalHeight = $(el)[0].style.height;
562			}
563
564			if( ls.g.sliderOriginalWidth.indexOf('%') == -1 && ls.g.sliderOriginalWidth.indexOf('px') == -1 ){
565				ls.g.sliderOriginalWidth += 'px';
566			}
567
568			if( ls.g.sliderOriginalHeight.indexOf('%') == -1 && ls.g.sliderOriginalHeight.indexOf('px') == -1 ){
569				ls.g.sliderOriginalHeight += 'px';
570			}
571
572			if( ls.o.responsive && ls.g.sliderOriginalWidth.indexOf('px') != -1 && ls.g.sliderOriginalHeight.indexOf('px') != -1 ){
573				ls.g.responsiveMode = true;
574			}else{
575				ls.g.responsiveMode = false;
576			}
577
578			// IMPROVEMENT v3.0 preventing WordPress to wrap your sublayers in <code> or <p> elements
579
580			$(el).find('*[class*="ls-l"], *[class*="ls-bg"]').each(function(){
581				if( !$(this).parent().hasClass('ls-slide') ){
582					$(this).insertBefore( $(this).parent() );
583				}
584			});
585
586			$(el).find('.ls-slide').each(function(){
587				$(this).children(':not([class*="ls-"])').each(function(){
588					$(this).remove();
589				});
590
591				var hd = $('<div>').addClass('ls-gpuhack');
592				if( $(this).find('.ls-bg').length ){
593					hd.insertAfter( $(this).find('.ls-bg').eq('0') );
594				}else{
595					hd.prependTo( $(this) );
596				}
597			});
598
599			$(el).find('.ls-slide, *[class*="ls-l"]').each(function(){
600
601				if( $(this).data('ls') || $(this).attr('rel') || $(this).attr('style') ){
602					if( $(this).data('ls') ){
603						var params = $(this).data('ls').toLowerCase().split(';');
604					}else if( $(this).attr('rel') && $(this).attr('rel').indexOf(':') != -1 && $(this).attr('rel').indexOf(';') != -1 ){
605						var params = $(this).attr('rel').toLowerCase().split(';');
606					}else{
607						var params = $(this).attr('style').toLowerCase().split(';');
608					}
609					for(x=0;x<params.length;x++){
610						param = params[x].split(':');
611
612						if( param[0].indexOf('easing') != -1 ){
613							param[1] = ls.ieEasing( param[1] );
614						}
615
616						var p2 = '';
617						if( param[2] ){
618							p2 = ':'+$.trim(param[2]);
619						}
620
621						if( param[0] != ' ' && param[0] != '' ){
622							$(this).data( $.trim(param[0]), $.trim(param[1]) + p2 );
623						}
624					}
625				}
626
627				this.style.visibility = 'hidden'; // blink fix for slower devices
628
629				// NEW FEATURE v5.2.0 Starts the slider only if it is in the viewport
630
631				if( ls.o.startInViewport === true && ls.o.autoStart === true ){
632
633					ls.o.autoStart = false;
634					ls.g.originalAutoStart = true;
635				}
636
637				// NEW FEATURE v1.7 and v3.0 making the slider responsive - we have to use style.left instead of jQuery's .css('left') function!
638
639				var sl = $(this);
640
641				sl.data( 'originalLeft', sl[0].style.left );
642				sl.data( 'originalTop', sl[0].style.top );
643
644				if( $(this).is('a') && $(this).children().length > 0 ){
645					sl = $(this).children();
646				}
647
648				var _w = sl.width();
649				var _h = sl.height();
650
651				if( sl[0].style.width && sl[0].style.width.indexOf('%') != -1 ){
652					_w = sl[0].style.width;
653				}
654				if( sl[0].style.height && sl[0].style.height.indexOf('%') != -1 ){
655					_h = sl[0].style.height;
656				}
657
658				sl.data( 'originalWidth', _w );
659				sl.data( 'originalHeight', _h );
660
661				sl.data( 'originalPaddingLeft', sl.css('padding-left') );
662				sl.data( 'originalPaddingRight', sl.css('padding-right') );
663				sl.data( 'originalPaddingTop', sl.css('padding-top') );
664				sl.data( 'originalPaddingBottom', sl.css('padding-bottom') );
665
666				// iOS fade bug when GPU acceleration is enabled #1
667
668				var _o = typeof parseFloat( sl.css('opacity') ) == 'number'  ? Math.round( parseFloat( sl.css('opacity') ) * 100 ) / 100  : 1;
669				$(this).data( 'originalOpacity', _o );
670
671				if( sl.css('border-left-width').indexOf('px') == -1 ){
672					sl.data( 'originalBorderLeft', sl[0].style.borderLeftWidth );
673				}else{
674					sl.data( 'originalBorderLeft', sl.css('border-left-width') );
675				}
676				if( sl.css('border-right-width').indexOf('px') == -1 ){
677					sl.data( 'originalBorderRight', sl[0].style.borderRightWidth );
678				}else{
679					sl.data( 'originalBorderRight', sl.css('border-right-width') );
680				}
681				if( sl.css('border-top-width').indexOf('px') == -1 ){
682					sl.data( 'originalBorderTop', sl[0].style.borderTopWidth );
683				}else{
684					sl.data( 'originalBorderTop', sl.css('border-top-width') );
685				}
686				if( sl.css('border-bottom-width').indexOf('px') == -1 ){
687					sl.data( 'originalBorderBottom', sl[0].style.borderBottomWidth );
688				}else{
689					sl.data( 'originalBorderBottom', sl.css('border-bottom-width') );
690				}
691
692				sl.data( 'originalFontSize', sl.css('font-size') );
693				sl.data( 'originalLineHeight', sl.css('line-height') );
694			});
695
696			// CHANGED FEATURE v3.5 url- / deep linking layers
697
698			if( document.location.hash ){
699				for( var dl = 0; dl < $(el).find('.ls-slide').length; dl++ ){
700					if( $(el).find('.ls-slide').eq(dl).data('deeplink') == document.location.hash.split('#')[1] ){
701						ls.o.firstSlide = dl+1;
702					}
703				}
704			}
705
706			// NEW FEATURE v2.0 linkTo
707
708			$(el).find('*[class*="ls-linkto-"]').each(function(){
709				var lClasses = $(this).attr('class').split(' ');
710				for( var ll=0; ll<lClasses.length; ll++ ){
711					if( lClasses[ll].indexOf('ls-linkto-') != -1 ){
712						var linkTo = parseInt( lClasses[ll].split('ls-linkto-')[1] );
713						$(this).css({
714							cursor: 'pointer'
715						}).click(function(e){
716							e.preventDefault();
717							$(el).layerSlider( linkTo );
718						});
719					}
720				}
721			});
722
723			// Setting variables
724
725			ls.g.layersNum = $(el).find('.ls-slide').length;
726
727			// NEW FEATURE v3.5 randomSlideshow
728
729			if( ls.o.randomSlideshow && ls.g.layersNum > 2 ){
730				ls.o.firstSlide == 'random';
731				ls.o.twoWaySlideshow = false;
732			}else{
733				ls.o.randomSlideshow = false;
734			}
735
736			// NEW FEATURE v3.0 random firstSlide
737
738			if( ls.o.firstSlide == 'random' ){
739				ls.o.firstSlide = Math.floor(Math.random() * ls.g.layersNum+1);
740			}
741
742			ls.o.fisrtSlide = ls.o.fisrtSlide < ls.g.layersNum + 1 ? ls.o.fisrtSlide : 1;
743			ls.o.fisrtSlide = ls.o.fisrtSlide < 1 ? 1 : ls.o.fisrtSlide;
744
745			// NEW FEATURE v2.0 loops
746
747			ls.g.nextLoop = 1;
748
749			if( ls.o.animateFirstSlide ){
750				ls.g.nextLoop = 0;
751			}
752
753			// NEW FEATURE v2.0 videoPreview
754
755			ls.media.youtube.init();
756			ls.media.vimeo.init();
757			ls.media.html5.init();
758
759			// NEW FEATURE v1.7 animating first layer
760
761			if( ls.o.animateFirstSlide ){
762				ls.o.firstSlide = ls.o.firstSlide - 1 === 0 ? ls.g.layersNum : ls.o.firstSlide-1;
763			}
764
765			ls.g.curLayerIndex = ls.o.firstSlide;
766			ls.g.curLayer = $(el).find('.ls-slide:eq('+(ls.g.curLayerIndex-1)+')');
767
768			// Moving all layers to .ls-inner container
769
770			$(el).find('.ls-slide').wrapAll('<div class="ls-inner"></div>');
771			ls.g.i = $(el).find('.ls-inner');
772
773			// Creating HTML markup for layer transitions
774
775			ls.g.ltContainer = $('<div>').addClass('ls-lt-container').addClass('ls-overflow-hidden').css({
776				width : ls.g.i.width(),
777				height : ls.g.i.height()
778			}).prependTo( ls.g.i );
779
780			// NEW FEATURE v4.5.0 Timers
781
782			if( ls.o.showBarTimer ){
783				ls.g.barTimer = $('<div>').addClass('ls-bar-timer').appendTo( ls.g.i );
784			}
785
786			if( ls.o.showCircleTimer && !ls.g.ie78 ){
787				ls.g.circleTimer = $('<div>').addClass('ls-circle-timer').appendTo( ls.g.i );
788				ls.g.circleTimer.append( $('<div class="ls-ct-left"><div class="ls-ct-rotate"><div class="ls-ct-hider"><div class="ls-ct-half"></div></div></div></div><div class="ls-ct-right"><div class="ls-ct-rotate"><div class="ls-ct-hider"><div class="ls-ct-half"></div></div></div></div><div class="ls-ct-center"></div>') );
789			}
790
791			// NEW FEATURE v4.0 Adding loading indicator into the element
792
793			ls.g.li = $('<div>').css({
794				zIndex: -1,
795				display: 'none'
796			}).addClass('ls-loading-container').appendTo( $(el) );
797
798			$('<div>').addClass('ls-loading-indicator').appendTo( ls.g.li );
799
800			// Adding styles
801
802			if( $(el).css('position') == 'static' ){
803				$(el).css('position','relative');
804			}
805
806			// IMPROVEMENT & BUGFIX v4.6.0 Fixed transparent global background issue under IE7 & IE8
807
808			if( ls.o.globalBGImage ){
809				ls.g.i.css({
810					backgroundImage : 'url("'+ls.o.globalBGImage+'")',
811					backgroundPosition : ls.o.globalBGPosition,
812					backgroundSize : ls.o.globalBGSize,
813					backgroundRepeat : ls.o.globalBGRepeat,
814					backgroundAttachment : ls.o.globalBGBehaviour
815				});
816			}
817			ls.g.i.css({
818				backgroundColor : ls.o.globalBGColor
819			});
820
821			if( ls.o.globalBGColor == 'transparent' && ls.o.globalBGImage == false ){
822				ls.g.i.css({
823					background : 'none transparent !important'
824				});
825			}
826
827			// NEW FEATURES v5.0.0 Lazy-load & remove unnecessary width & height attributes from images
828
829			$(el).find('.ls-slide img').each(function(){
830
831				$(this).removeAttr('width').removeAttr('height');
832
833				if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
834
835					if( typeof $(this).data('src') !== 'string' ){
836
837						$(this).data('src', $(this).attr('src') );
838						var src = ls.o.skinsPath+'../css/blank.gif';
839						$(this).attr('src',src);
840					}
841				}else{
842					if( typeof $(this).data('src') === 'string' ){
843
844						$(this).attr('src',$(this).data('src'));
845						$(this).removeAttr('data-src');
846					}
847				}
848
849			});
850
851			// NEW FEATURE v5.0.0 Parallax layers by mousemove
852			if (ls.o.parallaxType != 'scroll') {
853				var parallaxLayers = $([]);
854
855				$(el).find('*:not(.ls-bg)').each(function(){
856
857					if( typeof $(this).data('parallaxlevel') !== 'undefined' && parseInt( $(this).data('parallaxlevel') ) !== 0 ){
858
859						parallaxLayers = parallaxLayers.add( $(this) );
860					}
861				});
862
863				ls.g.i.on('mouseenter',function(e){
864
865					ls.g.parallaxStartX = e.pageX - $(this).parent().offset().left;
866					ls.g.parallaxStartY = e.pageY - $(this).parent().offset().top;
867				});
868
869				ls.g.i.on('mousemove',function(e){
870
871					var mX0 = $(this).parent().offset().left + ls.g.parallaxStartX;
872					var mY0 = $(this).parent().offset().top + ls.g.parallaxStartY;
873
874					var mX = e.pageX - mX0;
875					var mY = e.pageY - mY0;
876
877					parallaxLayers.each(function(){
878
879						$(this).css({
880							marginLeft : -mX / 100 * parseInt( $(this).data('parallaxlevel') ),
881							marginTop : -mY / 100 * parseInt( $(this).data('parallaxlevel') )
882						});
883					});
884				});
885
886				ls.g.i.on('mouseleave',function(){
887
888					parallaxLayers.each(function(){
889
890						TweenLite.to( this, .4, {
891							css:{
892								marginLeft : 0,
893								marginTop : 0
894							}
895						});
896					});
897				});
898			}
899
900			// Creating navigation
901
902			if( ls.o.navPrevNext ){
903
904				$('<a class="ls-nav-prev" href="#" />').click(function(e){
905					e.preventDefault();
906					$(el).layerSlider('prev');
907				}).appendTo($(el));
908
909				$('<a class="ls-nav-next" href="#" />').click(function(e){
910					e.preventDefault();
911					$(el).layerSlider('next');
912				}).appendTo($(el));
913
914				if( ls.o.hoverPrevNext ){
915					$(el).find('.ls-nav-prev, .ls-nav-next').css({
916						display: 'none'
917					});
918
919					$(el).hover(
920						function(){
921 							if( !ls.g.forceHideControls ){
922								if( ls.g.ie78 ){
923									$(el).find('.ls-nav-prev, .ls-nav-next').css('display','block');
924								}else{
925									$(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeIn(300);
926								}
927							}
928						},
929						function(){
930							if( ls.g.ie78 ){
931								$(el).find('.ls-nav-prev, .ls-nav-next').css('display','none');
932							}else{
933								$(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeOut(300);
934							}
935						}
936					);
937				}
938			}
939
940			// Creating bottom navigation
941
942			if( ls.o.navStartStop || ls.o.navButtons ){
943
944				var bottomNav = $('<div class="ls-bottom-nav-wrapper" />').appendTo( $(el) );
945
946				ls.g.bottomWrapper = bottomNav;
947
948				if( ls.o.thumbnailNavigation == 'always' ){
949					bottomNav.addClass('ls-above-thumbnails');
950				}
951
952				if( ls.o.navButtons && ls.o.thumbnailNavigation != 'always' ){
953
954					$('<span class="ls-bottom-slidebuttons" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') );
955
956					// NEW FEATURE v3.5 thumbnailNavigation ('hover')
957
958					if( ls.o.thumbnailNavigation == 'hover' ){
959
960						var thumbs = $('<div class="ls-thumbnail-hover"><div class="ls-thumbnail-hover-inner"><div class="ls-thumbnail-hover-bg"></div><div class="ls-thumbnail-hover-img"><img></div><span></span></div></div>').appendTo( $(el).find('.ls-bottom-slidebuttons') );
961					}
962
963					for(x=1;x<ls.g.layersNum+1;x++){
964
965						var btn = $('<a href="#" />').appendTo( $(el).find('.ls-bottom-slidebuttons') ).click(function(e){
966							e.preventDefault();
967							$(el).layerSlider( ($(this).index() + 1) );
968						});
969
970						// NEW FEATURE v3.5 thumbnailNavigation ('hover')
971
972						if( ls.o.thumbnailNavigation == 'hover' ){
973
974							$(el).find('.ls-thumbnail-hover, .ls-thumbnail-hover-img').css({
975								width : ls.o.tnWidth,
976								height : ls.o.tnHeight
977							});
978
979							var th = $(el).find('.ls-thumbnail-hover');
980
981							var ti = th.find('img').css({
982								height : ls.o.tnHeight
983							});
984
985							var thi = $(el).find('.ls-thumbnail-hover-inner').css({
986								visibility : 'hidden',
987								display: 'block'
988							});
989
990							btn.hover(
991								function(){
992
993									var hoverLayer = $(el).find('.ls-slide').eq( $(this).index() );
994									var tnSrc;
995
996									if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
997
998										if( hoverLayer.find('.ls-tn').length ){
999											tnSrc = hoverLayer.find('.ls-tn').data('src');
1000										}else if( hoverLayer.find('.ls-videopreview').length ){
1001											tnSrc = hoverLayer.find('.ls-videopreview').attr('src');
1002										}else if( hoverLayer.find('.ls-bg').length ){
1003											tnSrc = hoverLayer.find('.ls-bg').data('src');
1004										}else{
1005											tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
1006										}
1007									}else{
1008
1009										if( hoverLayer.find('.ls-tn').length ){
1010											tnSrc = hoverLayer.find('.ls-tn').attr('src');
1011										}else if( hoverLayer.find('.ls-videopreview').length ){
1012											tnSrc = hoverLayer.find('.ls-videopreview').attr('src');
1013										}else if( hoverLayer.find('.ls-bg').length ){
1014											tnSrc = hoverLayer.find('.ls-bg').attr('src');
1015										}else{
1016											tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
1017										}
1018									}
1019
1020									$(el).find('.ls-thumbnail-hover-img').css({
1021										left: parseInt( th.css('padding-left') ),
1022										top: parseInt( th.css('padding-top') )
1023									});
1024
1025									ti.load(function(){
1026
1027										if( $(this).width() == 0 ){
1028											ti.css({
1029												position: 'relative',
1030												margin: '0 auto',
1031												left: 'auto'
1032											});
1033										}else{
1034											ti.css({
1035												position: 'absolute',
1036												marginLeft : - $(this).width() / 2,
1037												left: '50%'
1038											});
1039										}
1040									}).attr( 'src', tnSrc );
1041
1042									th.css({
1043										display: 'block'
1044									}).stop().animate({
1045										left: $(this).position().left + ( $(this).width() - th.outerWidth() ) / 2
1046									}, 250 );
1047
1048									thi.css({
1049										display : 'none',
1050										visibility : 'visible'
1051									}).stop().fadeIn(250);
1052								},
1053								function(){
1054									thi.stop().fadeOut(250, function(){
1055										th.css({
1056											visibility : 'hidden',
1057											display: 'block'
1058										});
1059									});
1060								}
1061							);
1062						}
1063					}
1064
1065					if( ls.o.thumbnailNavigation == 'hover' ){
1066
1067						thumbs.appendTo( $(el).find('.ls-bottom-slidebuttons') );
1068					}
1069
1070				}
1071
1072				if( ls.o.navStartStop ){
1073
1074					var buttonStart = $('<a class="ls-nav-start" href="#" />').click(function(e){
1075						e.preventDefault();
1076						$(el).layerSlider('start');
1077					}).prependTo( $(el).find('.ls-bottom-nav-wrapper') );
1078
1079					var buttonStop = $('<a class="ls-nav-stop" href="#" />').click(function(e){
1080						e.preventDefault();
1081						$(el).layerSlider('stop');
1082					}).appendTo( $(el).find('.ls-bottom-nav-wrapper') );
1083
1084				}else if( ls.o.thumbnailNavigation != 'always' ){
1085
1086					$('<span class="ls-nav-sides ls-nav-sideleft" />').prependTo( $(el).find('.ls-bottom-nav-wrapper') );
1087					$('<span class="ls-nav-sides ls-nav-sideright" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') );
1088				}
1089
1090				if( ls.o.hoverBottomNav && ls.o.thumbnailNavigation != 'always' ){
1091
1092					bottomNav.css({
1093						display: 'none'
1094					});
1095
1096					$(el).hover(
1097						function(){
1098							if( !ls.g.forceHideControls ){
1099								if( ls.g.ie78 ){
1100									bottomNav.css('display','block');
1101								}else{
1102									bottomNav.stop(true,true).fadeIn(300);
1103								}
1104							}
1105						},
1106						function(){
1107							if( ls.g.ie78 ){
1108								bottomNav.css('display','none');
1109							}else{
1110								bottomNav.stop(true,true).fadeOut(300);
1111							}
1112						}
1113					)
1114				}
1115			}
1116
1117			// NEW FEATURE v3x.5 thumbnailNavigation ('always')
1118
1119			if( ls.o.thumbnailNavigation == 'always' ){
1120
1121				ls.g.thumbsWrapper = $('<div class="ls-thumbnail-wrapper"></div>').appendTo( $(el) );
1122				var thumbs = $('<div class="ls-thumbnail"><div class="ls-thumbnail-inner"><div class="ls-thumbnail-slide-container"><div class="ls-thumbnail-slide"></div></div></div></div>').appendTo( ls.g.thumbsWrapper );
1123
1124				ls.g.thumbnails = $(el).find('.ls-thumbnail-slide-container');
1125
1126				if( !('ontouchstart' in window) ){
1127					ls.g.thumbnails.hover(
1128						function(){
1129							$(this).addClass('ls-thumbnail-slide-hover');
1130						},
1131						function(){
1132							$(this).removeClass('ls-thumbnail-slide-hover');
1133							ls.scrollThumb();
1134						}
1135					).mousemove(function(e){
1136
1137						var mL = parseInt(e.pageX - $(this).offset().left ) / $(this).width() * ( $(this).width() - $(this).find('.ls-thumbnail-slide').width() );
1138						$(this).find('.ls-thumbnail-slide').stop().css({
1139							marginLeft : mL
1140						});
1141					});
1142				}else{
1143					ls.g.thumbnails.addClass('ls-touchscroll');
1144				}
1145
1146				$(el).find('.ls-slide').each(function(){
1147
1148					var tempIndex = $(this).index();
1149					var tnSrc;
1150
1151					if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
1152
1153						if( $(this).find('.ls-tn').length ){
1154							tnSrc = $(this).find('.ls-tn').data('src');
1155						}else if( $(this).find('.ls-videopreview').length ){
1156							tnSrc = $(this).find('.ls-videopreview').attr('src');
1157						}else if( $(this).find('.ls-bg').length ){
1158							tnSrc = $(this).find('.ls-bg').data('src');
1159						}else{
1160							tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
1161						}
1162					}else{
1163
1164						if( $(this).find('.ls-tn').length ){
1165							tnSrc = $(this).find('.ls-tn').attr('src');
1166						}else if( $(this).find('.ls-videopreview').length ){
1167							tnSrc = $(this).find('.ls-videopreview').attr('src');
1168						}else if( $(this).find('.ls-bg').length ){
1169							tnSrc = $(this).find('.ls-bg').attr('src');
1170						}else{
1171							tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
1172						}
1173					}
1174
1175					var thumb = $('<a href="#" class="ls-thumb-' + tempIndex + '"><img src="'+tnSrc+'"></a>');
1176					thumb.appendTo( $(el).find('.ls-thumbnail-slide') );
1177
1178					if( !('ontouchstart' in window) ){
1179
1180						thumb.hover(
1181							function(){
1182								$(this).children().stop().fadeTo(300,ls.o.tnActiveOpacity/100);
1183							},
1184							function(){
1185								if( !$(this).children().hasClass('ls-thumb-active') ){
1186									$(this).children().stop().fadeTo(300,ls.o.tnInactiveOpacity/100);
1187								}
1188							}
1189						);
1190					}
1191
1192					thumb.click(function(e){
1193						e.preventDefault();
1194						$(el).layerSlider( tempIndex );
1195					});
1196				});
1197
1198				if( buttonStart && buttonStop ){
1199					var lsBottomBelowTN = ls.g.bottomWrapper = $('<div class="ls-bottom-nav-wrapper ls-below-thumbnails"></div>').appendTo( $(el) );
1200					buttonStart.clone().click(function(e){
1201						e.preventDefault();
1202						$(el).layerSlider('start');
1203					}).appendTo( lsBottomBelowTN );
1204					buttonStop.clone().click(function(e){
1205						e.preventDefault();
1206						$(el).layerSlider('stop');
1207					}).appendTo( lsBottomBelowTN );
1208				}
1209
1210				if( ls.o.hoverBottomNav ){
1211
1212					ls.g.thumbsWrapper.css('display','none');
1213
1214					if( lsBottomBelowTN ){
1215						ls.g.bottomWrapper = lsBottomBelowTN.css('display') == 'block' ? lsBottomBelowTN : $(el).find('.ls-above-thumbnails');
1216						ls.g.bottomWrapper.css('display','none');
1217					}
1218
1219					// BUGFIXES v4.1.3 Added checking of the bottomWrapper variable
1220
1221					$(el).hover(
1222						function(){
1223							$(el).addClass('ls-hover');
1224							if( !ls.g.forceHideControls ){
1225								if( ls.g.ie78 ){
1226									ls.g.thumbsWrapper.css('display','block');
1227									if( ls.g.bottomWrapper ){
1228										ls.g.bottomWrapper.css('display','block');
1229									}
1230								}else{
1231									ls.g.thumbsWrapper.stop(true,true).fadeIn(300);
1232									if( ls.g.bottomWrapper ){
1233										ls.g.bottomWrapper.stop(true,true).fadeIn(300);
1234									}
1235								}
1236							}
1237						},
1238						function(){
1239							$(el).removeClass('ls-hover');
1240							if( ls.g.ie78 ){
1241								ls.g.thumbsWrapper.css('display','none');
1242								if( ls.g.bottomWrapper ){
1243									ls.g.bottomWrapper.css('display','none');
1244								}
1245							}else{
1246								ls.g.thumbsWrapper.stop(true,true).fadeOut(300);
1247								if( ls.g.bottomWrapper ){
1248									ls.g.bottomWrapper.stop(true,true).fadeOut(300);
1249								}
1250							}
1251						}
1252					)
1253				}
1254			}
1255
1256			// Adding shadow wrapper
1257
1258			ls.g.shadow = $('<div class="ls-shadow"></div>').appendTo( $(el) );
1259			if( ls.g.shadow.css('display') == 'block' && !ls.g.shadow.find('img').length ){
1260				ls.g.showShadow = function(){
1261					ls.g.shadow.css({
1262						display: 'none',
1263						visibility: 'visible'
1264					}).fadeIn( 500, function(){
1265						ls.g.showShadow = false;
1266					});
1267				}
1268				ls.g.shadowImg = $('<img>').attr('src',ls.o.skinsPath+ls.o.skin+'/shadow.png').appendTo( ls.g.shadow );
1269				ls.g.shadowBtmMod = typeof parseInt( $(el).css('padding-bottom') ) == 'number' ? parseInt( $(el).css('padding-bottom') ) : 0;
1270			}
1271			ls.resizeShadow();
1272
1273			// Adding keyboard navigation if turned on and if number of layers > 1
1274
1275			if( ls.o.keybNav && $(el).find('.ls-slide').length > 1 ){
1276
1277				$('body').bind('keydown',function(e){
1278					if( !ls.g.isAnimating && !ls.g.isLoading ){
1279						if( e.which == 37 ){
1280							ls.o.cbPrev(ls.g);
1281							ls.prev('clicked');
1282						}else if( e.which == 39 ){
1283							ls.o.cbNext(ls.g);
1284							ls.next('clicked');
1285						}
1286					}
1287				});
1288			}
1289
1290			// Adding touch-control navigation if number of layers > 1
1291
1292			if('ontouchstart' in window && $(el).find('.ls-slide').length > 1 && ls.o.touchNav ){
1293
1294			   ls.g.i.bind('touchstart', function( e ) {
1295					var t = e.touches ? e.touches : e.originalEvent.touches;
1296					if( t.length == 1 ){
1297						ls.g.touchStartX = ls.g.touchEndX = t[0].clientX;
1298					}
1299			    });
1300
1301			   ls.g.i.bind('touchmove', function( e ) {
1302					var t = e.touches ? e.touches : e.originalEvent.touches;
1303					if( t.length == 1 ){
1304						ls.g.touchEndX = t[0].clientX;
1305					}
1306					if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){
1307						e.preventDefault();
1308					}
1309			    });
1310
1311				ls.g.i.bind('touchend',function( e ){
1312					if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){
1313						if( ls.g.touchStartX - ls.g.touchEndX > 0 ){
1314							ls.o.cbNext(ls.g);
1315							$(el).layerSlider('next');
1316						}else{
1317							ls.o.cbPrev(ls.g);
1318							$(el).layerSlider('prev');
1319						}
1320					}
1321				});
1322			}
1323
1324			// Feature: pauseOnHover (if number of layers > 1)
1325
1326			if( ls.o.pauseOnHover == true && $(el).find('.ls-slide').length > 1 ){
1327
1328				// BUGFIX v1.6 stop was not working because of pause on hover
1329
1330				ls.g.i.hover(
1331					function(){
1332
1333						// Calling cbPause callback function
1334
1335						ls.o.cbPause(ls.g);
1336						if( ls.g.autoSlideshow ){
1337							ls.g.paused = true;
1338							ls.stop();
1339
1340							// Stopping the animation of Timers
1341
1342							if( ls.g.barTimer ){
1343								ls.g.barTimer.stop();
1344							}
1345
1346							if( ls.g.circleTimer ){
1347								if( ls.g.cttl ){
1348									ls.g.cttl.pause();
1349								}
1350							}
1351							ls.g.pausedSlideTime = new Date().getTime();
1352						}
1353					},
1354					function(){
1355						if( ls.g.paused == true ){
1356							ls.start();
1357							ls.g.paused = false;
1358						}
1359					}
1360				);
1361			}
1362
1363			ls.resizeSlider();
1364
1365			// NEW FEATURE v1.7 added yourLogo
1366
1367			if( ls.o.yourLogo ){
1368				ls.g.yourLogo = $('<img>').addClass('ls-yourlogo').appendTo($(el)).attr('style', ls.o.yourLogoStyle ).css({
1369					visibility: 'hidden',
1370					display: 'bock'
1371				}).load(function(){
1372
1373					// NEW FEATURE v3.0 added responsive yourLogo
1374
1375					var logoTimeout = 0;
1376
1377					if( !ls.g.yourLogo ){
1378						logoTimeout = 1000;
1379					}
1380
1381					setTimeout( function(){
1382
1383						ls.g.yourLogo.data( 'originalWidth', ls.g.yourLogo.width() );
1384						ls.g.yourLogo.data( 'originalHeight', ls.g.yourLogo.height() );
1385						if( ls.g.yourLogo.css('left') != 'auto' ){
1386							ls.g.yourLogo.data( 'originalLeft', ls.g.yourLogo[0].style.left );
1387						}
1388						if( ls.g.yourLogo.css('right') != 'auto' ){
1389							ls.g.yourLogo.data( 'originalRight', ls.g.yourLogo[0].style.right );
1390						}
1391						if( ls.g.yourLogo.css('top') != 'auto' ){
1392							ls.g.yourLogo.data( 'originalTop', ls.g.yourLogo[0].style.top );
1393						}
1394						if( ls.g.yourLogo.css('bottom') != 'auto' ){
1395							ls.g.yourLogo.data( 'originalBottom', ls.g.yourLogo[0].style.bottom );
1396						}
1397
1398						// NEW FEATURES v1.8 added yourLogoLink & yourLogoTarget
1399
1400						if( ls.o.yourLogoLink != false ){
1401							$('<a>').appendTo($(el)).attr( 'href', ls.o.yourLogoLink ).attr('target', ls.o.yourLogoTarget ).css({
1402								textDecoration : 'none',
1403								outline : 'none'
1404							}).append( ls.g.yourLogo );
1405						}
1406
1407						ls.g.yourLogo.css({
1408							display: 'none',
1409							visibility: 'visible'
1410						});
1411
1412						ls.resizeYourLogo();
1413
1414					}, logoTimeout );
1415
1416				}).attr( 'src', ls.o.yourLogo );
1417			}
1418
1419			// NEW FEATURE v1.7 added window resize function for make responsive layout better
1420
1421			ls.resize.width = $(window).width();
1422			ls.resize.height = $(window).height();
1423
1424			$(window).resize(function(){
1425				ls.resize();
1426			});
1427
1428			// NEW FEATURE v5.x scroll parallax effect
1429			if (ls.o.parallaxType == 'scroll' || ls.o.slideParallax > 0) {
1430				$(window).on('scroll.ls resize.ls', ls.onscroll);
1431
1432				if (ls.o.slideParallax > 0) {
1433					ls.g.i.css('overflow', 'hidden');
1434				}
1435			}
1436
1437			// BUGFIX v5.3.0 Responsiveness not worked in some cases while changed orientation on mobile devices
1438
1439			$(window).on('orientationchange',function(){
1440
1441				$(window).resize();
1442			});
1443
1444			ls.g.showSlider = true;
1445
1446			// NEW FEATURE v1.7 animating first slide
1447
1448			if( ls.o.animateFirstSlide == true ){
1449				if( ls.o.autoStart ){
1450					ls.g.autoSlideshow = true;
1451					$(el).find('.ls-nav-start').addClass('ls-nav-start-active');
1452				}else{
1453					$(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
1454				}
1455				ls.next();
1456			}else if( typeof ls.g.curLayer[0] !== 'undefined' ){
1457				ls.imgPreload(ls.g.curLayer,function(){
1458					ls.g.curLayer.fadeIn(ls.o.sliderFadeInDuration, function(){
1459
1460						ls.g.isLoading = false;
1461
1462						$(this).addClass('ls-active');
1463
1464						// NEW FEATURE v2.0 autoPlayVideos
1465
1466						if( ls.o.autoPlayVideos ){
1467							$(this).delay( $(this).data('delayin') + 25 ).queue(function(){
1468
1469								// YouTube & Vimeo videos
1470
1471								$(this).find('.ls-videopreview').click();
1472
1473								// HTML5 videos
1474
1475								$(this).find('video, audio').each(function(){
1476									if( typeof $(this)[0].currentTime !== 0){
1477										$(this)[0].currentTime = 0;
1478									}
1479									$(this).click();
1480								});
1481
1482								$(this).dequeue();
1483							});
1484						}
1485
1486						// NEW FEATURE v3.0 showUntil sublayers
1487
1488						ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){
1489
1490							// Setting showUntilTimers
1491
1492							var cursub = $(this);
1493
1494							// IMPROVEMENT v5.2.0 video layers with auto play will skip showuntil feature
1495
1496							if( ( !cursub.hasClass('ls-video-layer') || ( cursub.hasClass('ls-video-layer') && ls.o.autoPlayVideos === false ) ) && cursub.data('showuntil') > 0 ){
1497
1498								// IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary
1499
1500								cursub.data('showUntilTimer', setTimeout(function(){
1501									ls.sublayerShowUntil( cursub );
1502								}, cursub.data('showuntil') ));
1503							}
1504						});
1505					});
1506
1507					ls.changeThumb(ls.g.curLayerIndex)
1508
1509					// If autoStart is true
1510
1511					if( ls.o.autoStart ){
1512						ls.g.isLoading = false;
1513						ls.start();
1514					}else{
1515						$(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
1516					}
1517				});
1518			}
1519
1520			// NEW FEATURE: HOVER SUBLAYER
1521
1522			function initHover(node) {
1523				// init hover transition
1524				var $node = $(node);
1525				var data = $node.data();
1526				var duration = data.durationhover == '' || !('durationhover' in data) ? 0.5 : parseInt(data.durationhover) / 1000 || 0.01;
1527				var ease = data.easinghover || 'easeOutQuint';
1528				var originalOpacity = data.originalOpacity || 1;
1529				var lml = parseInt(data.offsetxhover || 0);
1530				var lmt = parseInt(data.offsetyhover || 0);
1531
1532				var transition = {
1533					paused: true,
1534					ease: gsConvertEase(ease),
1535					css: {
1536						opacity: parseFloat('opacityhover' in data ? data.opacityhover : originalOpacity),
1537						transformOrigin: data.transformoriginhover,
1538						x: lml * ls.g.ratio,
1539						y: lmt * ls.g.ratio,
1540						rotation: parseInt(data.rotatehover || 0),
1541						rotationX: parseInt(data.rotatexhover || 0),
1542						rotationY: parseInt(data.rotateyhover || 0),
1543						skewX: parseInt(data.skewxhover || 0),
1544						skewY: parseInt(data.skewyhover || 0),
1545						scaleX: parseFloat('scalexhover' in data ? data.scalexhover : 1),
1546						scaleY: parseFloat('scaleyhover' in data ? data.scaleyhover : 1)
1547					},
1548					data: {x: lml, y: lmt}
1549				};
1550				transition.reverseEase = gsConvertEase(data.easingreverse || ease);
1551				transition.reverseDuration = data.durationreverse == '' || !('durationreverse' in data) ? duration : parseInt(data.durationreverse) / 1000 || 0.01;
1552
1553				data.inithover = {
1554					opacity: originalOpacity,
1555					x: 0,
1556					y: 0,
1557					rotation: 0,
1558					rotationX: 0,
1559					rotationY: 0,
1560					skewX: 0,
1561					skewY: 0,
1562					scaleX: 1,
1563					scaleY: 1
1564				};
1565
1566				if (data.backgroundhover) {
1567					data.inithover.backgroundColor = $node.css('backgroundColor');
1568					transition.css.backgroundColor = data.backgroundhover;
1569				}
1570				if (data.colorhover) {
1571					data.inithover.color = $node.css('color');
1572					transition.css.color = data.colorhover;
1573				}
1574				if (data.borderradiushover) {
1575					data.inithover.borderRadius =
1576						$node.css('border-top-left-radius')+' '+$node.css('border-top-right-radius')+' '+
1577						$node.css('border-bottom-right-radius')+' '+$node.css('border-bottom-left-radius');
1578					transition.css.borderRadius = data.borderradiushover;
1579					transition.css.overflow = 'hidden';
1580				}
1581				data.hover = TweenLite.to(node, duration, transition);
1582			}
1583
1584			$(el).on('mouseenter.ls', '.ls-mover', function(e) {
1585				var data = $(this).data();
1586				if (data.status == 'in') {
1587					// handle mouseenter during transitionIn
1588					data.tr.vars.triggerHover = function() {
1589						initHover(data.tr.target);
1590						data.hover.play();
1591					};
1592				} else {	// handle mouseenter after transitionIn
1593					if (!data.hover) initHover(this);
1594					if (data.hout && !data.hout.paused()) {
1595						var pr = data.hout.pause().progress();
1596						var duration = data.hover.duration() - data.hout.duration() * data.hout.ratio;
1597						data.hout.kill();
1598					} else {
1599						var pr = data.hover.pause().progress();
1600						var duration = data.hover.duration() * (1 - data.hover.ratio);
1601					}
1602					if (pr > 0) { // transition not finished
1603						data.hin = TweenLite.to(this, duration, {
1604							ease: data.hover.vars.ease,
1605							css: data.hover.vars.css,
1606						});
1607					} else {	// transition already finished
1608						data.hover.progress(0);
1609						data.hover.timeScale(1);
1610						data.hover._ease = data.hover.vars.ease;
1611						data.hover._easePower = data.hover._ease._power;
1612						data.hover._easeType = data.hover._ease._type;
1613						data.hover.play();
1614					}
1615				}
1616			}).on('mouseleave.ls', '.ls-mover', function() {
1617				var data = $(this).data();
1618				if (data.status == 'in') {
1619					// handle mouseleave during transitionIn
1620					clearTimeout(data.timeouthover);
1621				} else {	// handle mouseleave after transitionIn
1622					if (data.hin && !data.hin.paused()) {
1623						var pr = data.hin.pause().progress();
1624						var duration = data.hin.duration() * data.hin.ratio + data.hover.duration() - data.hin.duration();
1625						data.hin.kill();
1626					} else {
1627						var pr = data.hover.pause().progress();
1628						var duration = data.hover.duration() * data.hover.ratio;
1629					}
1630					if (pr < 1) { // transition not finished
1631						data.hover.pause();
1632						var hout = {
1633							overwrite: 0,
1634							paused: true,
1635							ease: data.hover.vars.reverseEase,
1636							css: data.inithover
1637						};
1638						data.hout = TweenLite.from(this, duration, hout);
1639						data.hout.progress(1);
1640						data.hout.reverse();
1641					} else {	// transition already finished
1642						data.hover.progress(1);
1643						data.hover._ease = data.hover.vars.reverseEase;
1644						data.hover._easePower = data.hover._ease._power;
1645						data.hover._easeType = data.hover._ease._type;
1646						data.hover.timeScale(data.hover.duration() / data.hover.vars.reverseDuration);
1647						data.hover.reverse();
1648					}
1649				}
1650			});
1651
1652			// NEW FEATURE v1.7 added cbInit function
1653
1654			ls.o.cbInit($(el));
1655		};
1656
1657		ls.resize = function(){
1658				// BUGFIX: don't resize slider when width and height didn't change (iPhone/iPad/iPod scroll fix)
1659				var width = $(window).width(), height = $(window).height();
1660				if (ls.resize.width == width && ls.resize.height == height) return;
1661				ls.resize.width = width, ls.resize.height = height;
1662
1663				ls.g.resize = true;
1664
1665				if( !ls.g.isAnimating ){
1666
1667					ls.makeResponsive( ls.g.curLayer, function(){
1668						if( ls.g.ltContainer ){
1669							ls.g.ltContainer.empty();
1670						}
1671						ls.g.resize = false;
1672					});
1673					if( ls.g.yourLogo ){
1674						ls.resizeYourLogo();
1675					}
1676				}
1677		};
1678
1679		ls.onscroll = function(event) {
1680
1681			var isEnabled = !ls.g.isMobile() || ls.o.parallaxScrollOnMobile;
1682			var scrollDur = event ? ls.o.parallaxScrollDuration / 1000 : 0;
1683			var scrollTop = $(window).scrollTop();
1684			var offsetTop = ls.g.i.offset().top;
1685			ls.g.scrollTop = scrollTop > offsetTop ? scrollTop - offsetTop : 0;
1686			ls.g.slideTop = ls.g.scrollTop * ls.o.slideParallax / 10;
1687
1688			var nextBg = ls.g.nextLayer[0].children[0];
1689			if (isEnabled && $(nextBg).hasClass('ls-bg')) {
1690				TweenLite.to(nextBg, scrollDur, { y: ls.g.slideTop });
1691			}
1692			if (isEnabled && ls.g.ltContainer) {
1693				TweenLite.to(ls.g.ltContainer[0], scrollDur, { y: ls.g.slideTop });
1694			}
1695			if (isEnabled && ls.o.parallaxType == 'scroll') {
1696				if (ls.o.parallaxOrigin == 'center')
1697					ls.g.scrollY = ($(window).height() - ls.g.sliderHeight()) / 2 + scrollTop - offsetTop;
1698				else if (ls.o.parallaxOrigin == 'bottom')
1699					ls.g.scrollY = ($(window).height() - ls.g.sliderHeight()) + scrollTop - offsetTop;
1700				else // top (default)
1701					ls.g.scrollY = ls.g.scrollTop;
1702
1703				ls.g.nextLayer.find('[data-ls*=parallaxlevel]').each(function() {
1704					TweenLite.to(this, scrollDur, { marginTop: ls.g.scrollY * $(this).data('parallaxlevel') / 10 });
1705				});
1706			}
1707		};
1708
1709		ls.start = function(){
1710
1711			if( ls.g.autoSlideshow ){
1712				if( ls.g.prevNext == 'prev' && ls.o.twoWaySlideshow ){
1713					ls.prev();
1714				}else{
1715					ls.next();
1716				}
1717			}else{
1718				ls.g.autoSlideshow = true;
1719				if( !ls.g.isAnimating && !ls.g.isLoading ){
1720					ls.timer();
1721				}
1722			}
1723
1724			$(el).find('.ls-nav-start').addClass('ls-nav-start-active');
1725			$(el).find('.ls-nav-stop').removeClass('ls-nav-stop-active');
1726		};
1727
1728		ls.timer = function(){
1729
1730			if( $(el).find('.ls-active').data('ls') ){
1731				var sD = ls.st.slideDelay;
1732			}else{
1733				var sD = ls.o.slideDelay;
1734			}
1735
1736			var delaytime = $(el).find('.ls-active').data('slidedelay') ? parseInt( $(el).find('.ls-active').data('slidedelay') ) : sD;
1737
1738			// BUGFIX v3.0 delaytime did not work on first layer if animateFirstSlide was set to off
1739			// BUGFIX v3.5 delaytime did not work on all layers in standalone version after bugfix 3.0 :)
1740
1741			if( !ls.o.animateFirstSlide && !$(el).find('.ls-active').data('slidedelay') ){
1742				var tempD = $(el).find('.ls-slide:eq('+(ls.o.firstSlide-1)+')').data('slidedelay');
1743				delaytime = tempD ? tempD : sD;
1744			}
1745
1746			clearTimeout( ls.g.slideTimer );
1747
1748			// NEW FEATURE v4.5.0 Timers
1749
1750			if( ls.g.pausedSlideTime ){
1751				if( !ls.g.startSlideTime ){
1752					ls.g.startSlideTime = new Date().getTime();
1753				}
1754				if( ls.g.startSlideTime > ls.g.pausedSlideTime ){
1755					ls.g.pausedSlideTime =  new Date().getTime();
1756				}
1757				if(! ls.g.curSlideTime ){
1758					ls.g.curSlideTime = delaytime;
1759				}
1760				ls.g.curSlideTime -= (ls.g.pausedSlideTime - ls.g.startSlideTime);
1761				ls.g.pausedSlideTime = false;
1762				ls.g.startSlideTime = new Date().getTime();
1763			}else{
1764				ls.g.curSlideTime = delaytime;
1765				ls.g.startSlideTime = new Date().getTime();
1766			}
1767
1768			// BUGFIX v4.6.0 fixed Bar Timer animation on the fisrt slide if animateFirstSlide is false
1769
1770			ls.g.curSlideTime = parseInt( ls.g.curSlideTime );
1771
1772			ls.g.slideTimer = setTimeout(function(){
1773				ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
1774				ls.start();
1775			}, ls.g.curSlideTime );
1776
1777			// Animating Timers
1778
1779			if( ls.g.barTimer ){
1780				ls.g.barTimer.animate({
1781					width : ls.g.sliderWidth()
1782				}, ls.g.curSlideTime, 'linear', function(){
1783					$(this).css({
1784						width: 0
1785					});
1786				});
1787			}
1788
1789			if( ls.g.circleTimer ){
1790
1791				var ct1 = ls.g.circleTimer.find('.ls-ct-right .ls-ct-rotate');
1792				var ct2 = ls.g.circleTimer.find('.ls-ct-left .ls-ct-rotate');
1793
1794				if( ls.g.circleTimer.css('display') == 'none' ){
1795
1796					ct1.css({
1797						rotate : 0
1798					});
1799
1800					ct2.css({
1801						rotate : 0
1802					});
1803
1804					ls.g.circleTimer.fadeIn(350);
1805				}
1806
1807				if( !ls.g.cttl ){
1808					ls.g.cttl = new TimelineLite();
1809					ls.g.cttl.add( TweenLite.fromTo(ct1[0],delaytime/2000,{
1810						rotation : 0
1811					},{
1812						ease : Linear.easeNone,
1813						rotation : 180,
1814						onReverseComplete : function(){
1815							ls.g.cttl = false;
1816						}
1817					}));
1818					ls.g.cttl.add( TweenLite.fromTo(ct2[0],delaytime/2000,{
1819						rotation : 0
1820					},{
1821						ease : Linear.easeNone,
1822						rotation : 180
1823					}));
1824				}else{
1825					ls.g.cttl.resume();
1826				}
1827
1828			}
1829		};
1830
1831		ls.stop = function(){
1832
1833			// Stopping Timers
1834
1835			ls.g.pausedSlideTime = new Date().getTime();
1836
1837			if( ls.g.barTimer ){
1838				ls.g.barTimer.stop();
1839			}
1840
1841			if( ls.g.circleTimer ){
1842				if( ls.g.cttl ){
1843					ls.g.cttl.pause();
1844				}
1845			}
1846
1847			if( !ls.g.paused && !ls.g.originalAutoSlideshow ){
1848				$(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
1849				$(el).find('.ls-nav-start').removeClass('ls-nav-start-active');
1850			}
1851			clearTimeout( ls.g.slideTimer );
1852			ls.g.autoSlideshow = false;
1853		};
1854
1855		ls.forcestop = function(){
1856
1857			clearTimeout( ls.g.slideTimer );
1858			ls.g.autoSlideshow = false;
1859
1860			clearTimeout( ls.g.t1 );
1861			clearTimeout( ls.g.t2 );
1862			clearTimeout( ls.g.t3 );
1863			clearTimeout( ls.g.t4 );
1864			clearTimeout( ls.g.t5 );
1865
1866			if( ls.g.barTimer ){
1867				ls.g.barTimer.stop();
1868			}
1869
1870			if( ls.g.circleTimer ){
1871				if( ls.g.cttl ){
1872					ls.g.cttl.pause();
1873				}
1874			}
1875
1876			$(el).find('*').stop(true,false).dequeue();
1877			$(el).find('.ls-slide >').each(function(){
1878				if( $(this).data('tr') ){
1879					$(this).data('tr').pause();
1880				}
1881			});
1882
1883			if( !ls.g.paused && !ls.g.originalAutoSlideshow ){
1884				$(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
1885				$(el).find('.ls-nav-start').removeClass('ls-nav-start-active');
1886			}
1887		};
1888
1889		ls.restart = function(){
1890
1891			$(el).find('*').stop();
1892			clearTimeout( ls.g.slideTimer );
1893			ls.change(ls.g.curLayerIndex,ls.g.prevNext);
1894		};
1895
1896		// Because of an ie7 bug, we have to check & format the strings correctly
1897
1898		ls.ieEasing = function( e ){
1899
1900			// BUGFIX v1.6 and v1.8 some type of animations didn't work properly
1901
1902			if( $.trim(e.toLowerCase()) == 'swing' || $.trim(e.toLowerCase()) == 'linear'){
1903				return e.toLowerCase();
1904			}else{
1905				return e.replace('easeinout','easeInOut').replace('easein','easeIn').replace('easeout','easeOut').replace('quad','Quad').replace('quart','Quart').replace('cubic','Cubic').replace('quint','Quint').replace('sine','Sine').replace('expo','Expo').replace('circ','Circ').replace('elastic','Elastic').replace('back','Back').replace('bounce','Bounce');
1906			}
1907		};
1908
1909		// Calculating prev layer
1910
1911		ls.prev = function(clicked){
1912
1913			// NEW FEATURE v2.0 loops
1914
1915			if( ls.g.curLayerIndex < 2 ){
1916				ls.g.nextLoop += 1;
1917			}
1918
1919			if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){
1920				ls.g.nextLoop = 0;
1921				ls.stop();
1922				if( ls.o.forceLoopNum == false ){
1923					ls.o.loops = 0;
1924				}
1925			}else{
1926				var prev = ls.g.curLayerIndex < 2 ? ls.g.layersNum : ls.g.curLayerIndex - 1;
1927				ls.g.prevNext = 'prev';
1928				ls.change(prev,ls.g.prevNext);
1929			}
1930		};
1931
1932		// Calculating next layer
1933
1934		ls.next = function(clicked){
1935
1936			// NEW FEATURE v2.0 loops
1937
1938			if( !ls.o.randomSlideshow ){
1939
1940				if( !(ls.g.curLayerIndex < ls.g.layersNum) ){
1941					ls.g.nextLoop += 1;
1942				}
1943
1944				if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){
1945
1946					ls.g.nextLoop = 0;
1947					ls.stop();
1948					if( ls.o.forceLoopNum == false ){
1949						ls.o.loops = 0;
1950					}
1951				}else{
1952
1953					var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1;
1954					ls.g.prevNext = 'next';
1955					ls.change(next,ls.g.prevNext);
1956				}
1957			}else if( !clicked ){
1958
1959				// NEW FEATURE v3.5 randomSlideshow
1960
1961				var next = ls.g.curLayerIndex;
1962
1963				var calcRand = function(){
1964
1965					next = Math.floor(Math.random() * ls.g.layersNum) + 1;
1966
1967					if( next == ls.g.curLayerIndex ){
1968
1969						calcRand();
1970					}else{
1971						ls.g.prevNext = 'next';
1972						ls.change(next,ls.g.prevNext);
1973					}
1974				}
1975
1976				calcRand();
1977			}else if( clicked ){
1978
1979				var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1;
1980				ls.g.prevNext = 'next';
1981				ls.change(next,ls.g.prevNext);
1982			}
1983
1984		};
1985
1986		// ls.media > EMBEDDED VIDEO & AUDIO FUNCTIONS > added in v5.6.0
1987
1988		ls.media = {
1989
1990			youtube : {
1991
1992				// BUGFIX v5.6.0 Fixed YouTube Iframe Player API issue
1993
1994				init : function(){
1995
1996					// IMPROVEMENT v4.6.0 http / https support of embedded videos
1997
1998					var HTTP = document.location.href.indexOf('file:') === -1 ? '' : 'http:';
1999
2000					// Youtube videos
2001
2002					var youTube = $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"]');
2003
2004					// UPDATE v5.5.0 Changed to YouTube iFrame Player API 3.0
2005
2006					if( youTube.length ){
2007
2008						$('<script>').attr({
2009							'src' : HTTP + '//www.youtube.com/iframe_api',
2010							'type' : 'text/javascript'
2011						}).appendTo('head');
2012
2013						var numOfYouTube = youTube.length;
2014
2015						window.onYouTubeIframeAPIReady = function(){
2016
2017							youTube.each(function(){
2018
2019								// BUGFIX v4.1.0 Firefox embedded video fix
2020
2021								$(this).parent().addClass('ls-video-layer');
2022
2023								if( $(this).parent('[class*="ls-l"]') ){
2024
2025									var http = HTTP;
2026
2027									var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() );
2028
2029									$('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').attr('src',  http + '//img.youtube.com/vi/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '/' + ls.o.youtubePreview );
2030
2031									$('<div>').appendTo( vpContainer ).addClass('ls-playvideo');
2032
2033									$(this).parent().css({
2034										width : $(this).width(),
2035										height : $(this).height()
2036									}).click(function(){
2037
2038										var iframe = $(this).find('iframe');
2039
2040										iframe.css('display','block');
2041
2042										// IMPROVEMENT v5.2.0 if video playing is in progress, video layers with auto play will skip showuntil feature
2043
2044										if( $(this).data('showuntil') > 0 && $(this).data('showUntilTimer') ){
2045											clearTimeout( $(this).data('showUntilTimer') );
2046										}
2047
2048										if( !ls.g.pausedByVideo ){
2049
2050											ls.g.isAnimating = true;
2051
2052											if( ls.g.paused ){
2053												if( ls.o.autoPauseSlideshow != false ){
2054													ls.g.paused = false;
2055												}
2056												ls.g.originalAutoSlideshow = true;
2057											}else{
2058												ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
2059											}
2060
2061											if( ls.o.autoPauseSlideshow != false ){
2062												ls.stop();
2063											}
2064
2065											ls.g.pausedByVideo = true;
2066										}
2067
2068										if( typeof iframe.data('ytplayer') == 'undefined' ){
2069
2070											iframe.attr('src', src );
2071
2072											var videoEnded = function(event){
2073												if( event.data === 0 ){
2074													ls.g.numYouTubeCurSlide += 1;
2075													if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){
2076														if( ls.g.numYouTubeCurSlide == ls.g.curLayer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"]').length ){
2077															ls.g.curSlideTime = 1;
2078															ls.start();
2079														}
2080													}
2081												}
2082											}
2083
2084											var onPlayerReady = function(event){
2085												event.target.playVideo();
2086											}
2087
2088											iframe.data('ytplayer', new YT.Player( iframe[0], {
2089												events : {
2090													'onReady': onPlayerReady,
2091													'onStateChange' : videoEnded
2092												}
2093											}));
2094										}else{
2095											iframe.data('ytplayer').seekTo(0).playVideo();
2096										}
2097
2098
2099										$(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){
2100
2101											ls.g.isAnimating = false;
2102											if( ls.g.resize == true ){
2103												ls.makeResponsive( ls.g.curLayer, function(){
2104													ls.g.resize = false;
2105												});
2106											}
2107										});
2108									});
2109
2110									http = $(this).attr('src').indexOf('http') === -1 ? HTTP : '';
2111
2112									var src = http + $(this).attr('src');
2113
2114									var sep = '&';
2115									if( src.indexOf('?') == -1 ){
2116										sep = '?';
2117									}
2118
2119									// BUGFIX v5.6.0 We don't need autoplay parameter any more
2120
2121									if( src.indexOf('autoplay') == -1 ){
2122										src += sep;
2123									}else{
2124										src.replace('autoplay=1','autoplay=0');
2125									}
2126
2127									// BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE)
2128									// fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug
2129									// UPDATE v5.5.0 Changed to YouTube iFrame Player API 3.0
2130
2131									src += '&wmode=opaque&html5=1&enablejsapi=1&version=3';
2132
2133									$(this).data( 'videoSrc', src );
2134
2135									$(this).data( 'originalWidth', $(this).attr('width') );
2136									$(this).data( 'originalHeight', $(this).attr('height') );
2137
2138									$(this).attr('src', '');
2139
2140								}
2141							});
2142						};
2143					}
2144				},
2145
2146				play : function( video ){
2147
2148				},
2149
2150				stop : function( video ){
2151
2152					video.parent().find('.ls-vpcontainer').fadeIn(ls.g.v.fi,function(){
2153
2154						video.parent().find('iframe').data('ytplayer').stopVideo();
2155						video.parent().find('iframe').css('display','none');
2156					});
2157				}
2158			},
2159
2160			vimeo : {
2161
2162				init : function(){
2163
2164					// IMPROVEMENT v4.6.0 http / https support of embedded videos
2165
2166					var HTTP = document.location.href.indexOf('file:') === -1 ? '' : 'http:';
2167
2168					// Vimeo videos
2169
2170					$(el).find('iframe[src*="player.vimeo"]').each(function(){
2171
2172						// BUGFIX v4.1.0 Firefox embedded video fix
2173
2174						$(this).parent().addClass('ls-video-layer');
2175
2176						if( $(this).parent('[class*="ls-l"]') ){
2177
2178							var iframe = $(this);
2179							var http = HTTP;
2180
2181							// Getting thumbnail
2182
2183							var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() );
2184
2185							$.getJSON( http + '//vimeo.com/api/v2/video/'+ ( $(this).attr('src').split('video/')[1].split('?')[0] ) +'.json?callback=?', function(data){
2186
2187								$('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').attr('src', data[0]['thumbnail_large'] );
2188
2189								iframe.data( 'videoDuration', parseInt( data[0]['duration'] ) * 1000 );
2190								$('<div>').appendTo( vpContainer ).addClass('ls-playvideo');
2191							});
2192
2193
2194							$(this).parent().css({
2195								width : $(this).width(),
2196								height : $(this).height()
2197							}).click(function(){
2198
2199								// IMPROVEMENT v5.2.0 if video playing is in progress, video layers with auto play will skip showuntil feature
2200
2201								if( $(this).data('showuntil') > 0 && $(this).data('showUntilTimer') ){
2202									clearTimeout( $(this).data('showUntilTimer') );
2203								}
2204
2205								ls.g.isAnimating = true;
2206
2207								if( ls.g.paused ){
2208									if( ls.o.autoPauseSlideshow != false ){
2209										ls.g.paused = false;
2210									}
2211									ls.g.originalAutoSlideshow = true;
2212								}else{
2213									ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
2214								}
2215
2216								if( ls.o.autoPauseSlideshow != false ){
2217									ls.stop();
2218								}
2219
2220								ls.g.pausedByVideo = true;
2221
2222								http = $(this).find('iframe').data('videoSrc').indexOf('http') === -1 ? HTTP : '';
2223
2224								$(this).find('iframe').attr('src', http + $(this).find('iframe').data('videoSrc') );
2225								$(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){
2226									if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){
2227										var videoTimer = setTimeout(function() {
2228												ls.start();
2229										}, iframe.data( 'videoDuration') - ls.g.v.d );
2230										iframe.data( 'videoTimer', videoTimer );
2231									}
2232									ls.g.isAnimating = false;
2233									if( ls.g.resize == true ){
2234										ls.makeResponsive( ls.g.curLayer, function(){
2235											ls.g.resize = false;
2236										});
2237									}
2238								});
2239							});
2240
2241							var sep = '&';
2242
2243							if( $(this).attr('src').indexOf('?') == -1 ){
2244								sep = '?';
2245							}
2246
2247							// BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE)
2248							// fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug
2249
2250							var videoFix = '&wmode=opaque';
2251
2252							// BUGFIX v5.1.0 Fixed autoplay parameter
2253
2254							if( $(this).attr('src').indexOf('autoplay') == -1 ){
2255								$(this).data( 'videoSrc', $(this).attr('src') + sep + 'autoplay=1' + videoFix );
2256							}else{
2257								$(this).data( 'videoSrc', $(this).attr('src').replace('autoplay=0','autoplay=1') + videoFix );
2258							}
2259
2260							$(this).data( 'originalWidth', $(this).attr('width') );
2261							$(this).data( 'originalHeight', $(this).attr('height') );
2262							$(this).attr('src','');
2263						}
2264					});
2265				},
2266
2267				play : function( video ){
2268
2269				},
2270
2271				stop : function( video ){
2272
2273					video.parent().find('.ls-vpcontainer').fadeIn(ls.g.v.fi,function(){
2274
2275						video.parent().find('iframe').attr('src','');
2276					});
2277				}
2278			},
2279
2280			html5 : {
2281
2282				init : function(){
2283
2284					// NEW FEATURE v5.0.0 HTML5 Video & Audio Support
2285
2286					$(el).find('video, audio').each(function(){
2287
2288						// BUGFIX v5.1.0 fixed HTML5 video sizing issue (again :)
2289
2290						var ow = typeof $(this).attr('width') !== 'undefined' ? $(this).attr('width') : '640';
2291						var oh = typeof $(this).attr('height') !== 'undefined' ? $(this).attr('height') : '' + $(this).height();
2292
2293						if( ow.indexOf('%') === -1 ){
2294							ow = parseInt( ow );
2295						}
2296
2297						if( oh.indexOf('%') === -1 ){
2298							oh = parseInt( oh );
2299						}
2300
2301						if( ow === '100%' && ( oh === 0 || oh === '0' || oh === '100%' ) ){
2302							$(this).attr('height', '100%');
2303							oh = 'auto';
2304						}
2305
2306						$(this).parent().addClass('ls-video-layer').css({
2307							width : ow,
2308							height : oh
2309						}).data({
2310							originalWidth : ow,
2311							originalHeight : oh
2312						});
2313
2314						var curVideo = $(this);
2315
2316						// BUGFIX v5.3.0 'ended' function removed from 'click' function due to multiply
2317
2318						$(this).on('ended', function(){
2319							if( ls.o.autoPauseSlideshow === 'auto' && ls.g.originalAutoSlideshow === true ){
2320								ls.start();
2321							}
2322						});
2323
2324						$(this).removeAttr('width').removeAttr('height').css({
2325							width : '100%',
2326							height : '100%'
2327						}).click(function(e){
2328
2329							// BUGFIX v5.3.0 autoplay didn't work in all cases
2330
2331							if( !ls.g.pausedByVideo ){
2332
2333								if( this.paused ){
2334									e.preventDefault();
2335								}
2336
2337								this.play();
2338
2339								ls.g.isAnimating = true;
2340
2341								if( ls.g.paused ){
2342									if( ls.o.autoPauseSlideshow !== false ){
2343										ls.g.paused = false;
2344									}
2345									ls.g.originalAutoSlideshow = true;
2346								}else{
2347									ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
2348								}
2349
2350								if( ls.o.autoPauseSlideshow !== false ){
2351									ls.stop();
2352								}
2353
2354								ls.g.pausedByVideo = true;
2355								ls.g.isAnimating = false;
2356
2357								if( ls.g.resize === true ){
2358									ls.makeResponsive( ls.g.curLayer, function(){
2359										ls.g.resize = false;
2360									});
2361								}
2362							}
2363						});
2364					});
2365				},
2366
2367				play : function( video ){
2368
2369				},
2370
2371				stop : function( video ){
2372
2373					video[0].pause();
2374				}
2375			}
2376		};
2377
2378		ls.change = function(num,prevnext){
2379
2380			// Stopping Timers if needed
2381
2382			ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
2383
2384			// IMPROVEMENT v4.6.0 Bar Timer animation
2385
2386			if( ls.g.barTimer ){
2387				ls.g.barTimer.stop().delay(300).animate({
2388					width: 0
2389				},450);
2390			}
2391			if( ls.g.circleTimer ){
2392				ls.g.circleTimer.fadeOut(500);
2393				if( ls.g.cttl ){
2394					ls.g.cttl.reverse().duration(.35);
2395				}
2396			}
2397
2398			// NEW FEATURE v2.0 videoPreview & autoPlayVideos
2399
2400			if( ls.g.pausedByVideo == true ){
2401				ls.g.pausedByVideo = false;
2402				ls.g.autoSlideshow = ls.g.originalAutoSlideshow;
2403
2404				ls.g.curLayer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"]').each(function(){
2405
2406					ls.media.youtube.stop( $(this) );
2407				});
2408
2409				ls.g.curLayer.find('iframe[src*="player.vimeo"]').each(function(){
2410
2411					ls.media.vimeo.stop( $(this) );
2412				});
2413
2414				ls.g.curLayer.find('video, audio').each(function(){
2415
2416					ls.media.html5.stop( $(this) );
2417				});
2418			}
2419
2420			$(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
2421
2422				// Clearing videoTimeouts
2423
2424				clearTimeout( $(this).data( 'videoTimer') );
2425			});
2426
2427			clearTimeout( ls.g.slideTimer );
2428			ls.g.nextLayerIndex = num;
2429			ls.g.nextLayer = $(el).find('.ls-slide:eq('+(ls.g.nextLayerIndex-1)+')');
2430
2431			// update active bullet
2432			$(el).find('.ls-bottom-slidebuttons a').removeClass('ls-nav-active').eq(num - 1).addClass('ls-nav-active');
2433
2434			// BUGFIX v1.6 fixed wrong directions of animations if navigating b
2434y slidebuttons
2435
2436			if( !prevnext ){
2437
2438				if( ls.g.curLayerIndex < ls.g.nextLayerIndex ){
2439					ls.g.prevNext = 'next';
2440				}else{
2441					ls.g.prevNext = 'prev';
2442				}
2443			}
2444
2445			// Added timeOut to wait for the fade animation of videoPreview image...
2446
2447			var timeOut = 0;
2448
2449			if( $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').length > 0 ){
2450				timeOut = ls.g.v.fi;
2451			}
2452
2453			if( typeof ls.g.nextLayer[0] !== 'undefined' ){
2454				ls.imgPreload(ls.g.nextLayer,function(){
2455					ls.animate();
2456				});
2457			}
2458		};
2459
2460		// Preloading images
2461
2462		ls.imgPreload = function(layer,callback){
2463
2464			ls.g.isLoading = true;
2465
2466			// Showing slider for the first time
2467
2468			if( ls.g.showSlider ){
2469				$(el).css({
2470					visibility : 'visible'
2471				});
2472			}
2473
2474			// If image preload is on
2475
2476			if( ls.o.imgPreload ){
2477
2478				var preImages = [];
2479				var preloaded = 0;
2480
2481				// NEW FEATURE v1.8 Preloading background images of layers
2482
2483				if( layer.css('background-image') != 'none' && layer.css('background-image').indexOf('url') != -1 && !layer.hasClass('ls-preloaded') && !layer.hasClass('ls-not-preloaded') ){
2484					var bgi = layer.css('background-image');
2485					bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, '');
2486					preImages[preImages.length] = [bgi, layer];
2487				}
2488
2489				// Images inside layers
2490
2491				layer.find('img:not(.ls-preloaded, .ls-not-preloaded)').each(function(){
2492
2493					// NEW FEATURE v5.0.0 Lazy-load
2494
2495					if( ls.o.lazyLoad === true ){
2496						$(this).attr('src',$(this).data('src'));
2497					}
2498					preImages[preImages.length] = [$(this).attr('src'), $(this)];
2499				});
2500
2501				// Background images inside layers
2502
2503				layer.find('*').each(function(){
2504
2505					// BUGFIX v1.7 fixed preload bug with sublayers with gradient backgrounds
2506
2507					if( $(this).css('background-image') != 'none' && $(this).css('background-image').indexOf('url') != -1 && !$(this).hasClass('ls-preloaded') && !$(this).hasClass('ls-not-preloaded') ){
2508						var bgi = $(this).css('background-image');
2509						bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, '');
2510						preImages[preImages.length] = [bgi, $(this)];
2511					}
2512				});
2513
2514				// BUGFIX v1.7 if there are no images in a layer, calling the callback function
2515
2516				if(preImages.length == 0){
2517
2518					$('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
2519						visibility : 'visible'
2520					});
2521
2522					ls.makeResponsive(layer, callback);
2523				}else{
2524
2525					// NEW FEATURE v4.0 Showing loading indicator
2526
2527					if( ls.g.ie78 ){
2528						ls.g.li.css('display','block');
2529					}else{
2530
2531						// BUGIFX v4.1.3 Adding delay to the showing of the loading indicator
2532
2533						ls.g.li.delay(400).fadeIn(300);
2534					}
2535
2536					var afterImgLoad = function(){
2537
2538						// NEW FEATURE v4.0 Hiding loading indicator
2539
2540						ls.g.li.stop(true,true).css({
2541							display: 'none'
2542						});
2543
2544						$('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
2545							visibility : 'visible'
2546						});
2547
2548						// We love you so much IE... -.-
2549
2550						if( navigator.userAgent.indexOf('Trident/7') !== -1 || ls.g.ie78 ){
2551							setTimeout(function(){
2552								ls.makeResponsive(layer, callback);
2553							},50);
2554						}else{
2555							ls.makeResponsive(layer, callback);
2556						}
2557
2558					};
2559
2560					for(x=0;x<preImages.length;x++){
2561
2562						$('<img>').data('el',preImages[x]).load(function(){
2563
2564							$(this).data('el')[1].addClass('ls-preloaded');
2565
2566							if( ++preloaded == preImages.length ){
2567
2568								afterImgLoad();
2569							}
2570						}).error(function(){
2571							var imgURL = $(this).data('el')[0].substring($(this).data('el')[0].lastIndexOf("/") + 1, $(this).data('el')[0].length);
2572							if( window.console ){
2573								console.log('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
2574							}else{
2575								alert('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
2576							}
2577
2578							$(this).addClass('ls-not-preloaded');
2579
2580							// IMPROVEMENT v5.2.0 The slider should not stop even if an image cannot be loaded
2581
2582							if( ++preloaded == preImages.length ){
2583
2584								afterImgLoad();
2585							}
2586
2587						}).attr('src',preImages[x][0]);
2588					}
2589				}
2590			}else{
2591
2592				$('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
2593					visibility : 'visible'
2594				});
2595
2596				ls.makeResponsive(layer, callback);
2597			}
2598		};
2599
2600		// NEW FEATURE v1.7 making the slider responsive
2601
2602		ls.makeResponsive = function(layer, callback ){
2603
2604			layer.css({
2605				visibility: 'hidden',
2606				display: 'block'
2607			});
2608
2609			if( ls.g.showShadow ){
2610				ls.g.showShadow();
2611			}
2612
2613			ls.resizeSlider();
2614
2615			if( ls.o.thumbnailNavigation == 'always' ){
2616				ls.resizeThumb();
2617			}
2618
2619			// responsiveUnder fix for fullPage
2620			if (ls.o.fullPage) {
2621				ls.o.responsiveUnder = ls.o.layersContainer;
2622			}
2623
2624			// if fullpage, change slide image size to cover
2625			var imgsize = ls.o.fullPage ? 'cover' : layer.data('imgsize') || 'auto';
2626			// init slide img position
2627			var imgpos = (layer.data('imgposition') || '50% 50%').trim().split(/\s+/);
2628			imgpos[0] = parseInt(imgpos[0]) / 100;
2629			imgpos[1] = parseInt(imgpos[1]) / 100;
2630
2631			if (imgsize == 'cover') {
2632				var _cow = ls.g.layersOriginalContainer;				// container original width
2633				var _soh = parseInt(ls.g.sliderOriginalHeight);	// slider original height
2634				var _sw = ls.g.sliderWidth();				// slider width
2635				var _sh = ls.g.sliderHeight();			// slider height
2636				var _cw = _sw > _cow ? _cow : _sw;	// conainer widt
2637				var _ch = _cw / _cow * _soh;				// container height
2638				var _pt = _sw / _cow < ls.g.ratioY || ls.g.ratio == 1 ? (_sh - _ch) / 2 : 0;
2639			} else {
2640				var _pt = 0;
2641			}
2642			var layers = layer.children();
2643			layers.each(function(){
2644
2645				var sl = $(this);
2646
2647				// positioning
2648
2649				var ol = sl.data('originalLeft') ? sl.data('originalLeft') : '0';
2650				var ot = sl.data('originalTop') ? sl.data('originalTop') : '0';
2651
2652				if( sl.is('a') && sl.children().length > 0 ){
2653					sl.css({
2654						display : 'block'
2655					});
2656					sl = sl.children();
2657				}
2658
2659				var ow = 'auto';
2660				var oh = 'auto';
2661
2662				if( sl.data('originalWidth') ){
2663
2664					if( typeof sl.data('originalWidth') == 'number' ){
2665						ow = parseInt( sl.data('originalWidth') ) * ls.g.ratio;
2666					}else if( sl.data('originalWidth').indexOf('%') != -1 ){
2667						ow = sl.data('originalWidth');
2668					}
2669				}
2670
2671				if( sl.data('originalHeight') ){
2672					if( typeof sl.data('originalHeight') == 'number' ){
2673						oh = parseInt( sl.data('originalHeight') ) * ls.g.ratio;
2674					}else if( sl.data('originalHeight').indexOf('%') != -1 ){
2675						oh = sl.data('originalHeight');
2676					}
2677				}
2678
2679				// padding
2680
2681				var opl = sl.data('originalPaddingLeft') ? parseInt( sl.data('originalPaddingLeft') ) * ls.g.ratio : 0;
2682				var opr = sl.data('originalPaddingRight') ? parseInt( sl.data('originalPaddingRight') ) * ls.g.ratio : 0;
2683				var opt = sl.data('originalPaddingTop') ? parseInt( sl.data('originalPaddingTop') ) * ls.g.ratio : 0;
2684				var opb = sl.data('originalPaddingBottom') ? parseInt( sl.data('originalPaddingBottom') ) * ls.g.ratio : 0;
2685
2686				// border
2687
2688				var obl = sl.data('originalBorderLeft') ? parseInt( sl.data('originalBorderLeft') ) * ls.g.ratio : 0;
2689				var obr = sl.data('originalBorderRight') ? parseInt( sl.data('originalBorderRight') ) * ls.g.ratio : 0;
2690				var obt = sl.data('originalBorderTop') ? parseInt( sl.data('originalBorderTop') ) * ls.g.ratio : 0;
2691				var obb = sl.data('originalBorderBottom') ? parseInt( sl.data('originalBorderBottom') ) * ls.g.ratio : 0;
2692
2693				// font
2694
2695				var ofs = sl.data('originalFontSize');
2696				var olh = sl.data('originalLineHeight');
2697
2698				// NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
2699				// NEW FEATURE v3.5 added responsiveUnder
2700
2701				if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
2702
2703					if( sl.is('img') && !sl.hasClass('ls-bg') && sl.attr('src') ){
2704
2705						sl.css({
2706							width: 'auto',
2707							height: 'auto'
2708						});
2709
2710						// IMPROVEMENT v4.5.0 Images can have now starting width / height
2711
2712						if( ( ow == 0 || ow == 'auto' ) && typeof oh == 'number' && oh != 0 ){
2713							ow = ( oh / sl.height() ) * sl.width();
2714						}
2715
2716						if( ( oh == 0 || oh == 'auto' ) && typeof ow == 'number' && ow != 0 ){
2717							oh = ( ow / sl.width() ) * sl.height();
2718						}
2719
2720						if( ow == 'auto'){
2721							if (oh.indexOf && oh.indexOf('%') > -1) {
2722								var ohr = parseFloat(oh)/100 * sl.closest('.ls-container').height() / sl.height();
2723								ow = sl.width() * ohr;
2724							} else
2725								ow = sl.width() * ls.g.ratio;
2726						}
2727
2728						if( oh == 'auto'){
2729							if (ow.indexOf && ow.indexOf('%') > -1) { // !!! fix for keep image ratio when width is in %
2730								var owr = parseFloat(ow)/100 * sl.closest('.ls-container').width() / sl.width();
2731								oh = sl.height() * owr;
2732							}
2733							else
2734								oh = sl.height() * ls.g.ratio;
2735						}
2736
2737						sl.css({
2738							width : ow,
2739							height : oh
2740						});
2741					}
2742
2743					if( !sl.is('img') ){
2744						sl.css({
2745							width : ow,
2746							height : oh,
2747							'font-size' : parseInt(ofs) * ls.g.ratio +'px',
2748							'line-height' : parseInt(olh) * ls.g.ratio + 'px'
2749						});
2750
2751						// bugfix for splittext on safari mobile
2752						if (navigator.userAgent.match(/iPad|iPod|iPhone/i)) {
2753							var split = sl.data('split');
2754							if (split) {
2755								var types = [];
2756								split.chars.length && types.push('chars');
2757								split.words.length && types.push('words');
2758								split.lines.length && types.push('lines');
2759								split.split({ split: types.join(',') });
2760								sl.css('visibility', '');
2761							}
2762						}
2763					}
2764
2765					if( sl.is('div') && sl.find('iframe').data('videoSrc') ){
2766
2767						var videoIframe = sl.find('iframe');
2768						videoIframe.attr('width', parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio ).attr('height', parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio );
2769
2770						sl.css({
2771							width : parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio,
2772							height : parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio
2773						});
2774					}
2775
2776					sl.css({
2777						padding : opt + 'px ' + opr + 'px ' + opb + 'px ' + opl + 'px ',
2778						borderLeftWidth : obl + 'px',
2779						borderRightWidth : obr + 'px',
2780						borderTopWidth : obt + 'px',
2781						borderBottomWidth : obb + 'px'
2782					});
2783					// if hover is added to the layer
2784					var hover = sl.data('hover');
2785					if (hover) {
2786						//sl.data('connecthover') ? sl.parent().trigger('mouseleave') : sl.trigger('mouseleave');
2787						var hin = sl.data('hin');
2788						if (hin) {
2789							hin.kill();
2790							sl.removeData('hin');
2791						}
2792						var hout = sl.data('hout');
2793						if (hout) {
2794							hout.kill();
2795							sl.removeData('hout');
2796						}
2797						clearTimeout(sl.data('timeouthover'));
2798						hover.kill();
2799						sl.removeData('hover');
2800
2801						var inithover = sl.data('inithover');
2802						TweenLite.set(hover.target, {css: inithover});
2803					}
2804				}
2805
2806				// If it is NOT a bg sublayer
2807
2808				if( !sl.hasClass('ls-bg') ){
2809
2810					var sl2 = sl;
2811
2812					if( sl.parent().is('a') ){
2813						sl = sl.parent();
2814					}
2815
2816					// NEW FEATURE v3.5 sublayerContainer
2817
2818					var slC = 0;
2819					if( ls.o.layersContainer ){
2820						slC = ls.o.layersContainer > 0 ? ( ls.g.sliderWidth() - ls.o.layersContainer ) / 2 : 0;
2821					}else if( ls.o.sublayerContainer ){
2822						slC = ls.o.sublayerContainer > 0 ? ( ls.g.sliderWidth() - ls.o.sublayerContainer ) / 2 : 0;
2823					}
2824					slC = slC < 0 ? 0 : slC;
2825
2826					// (RE)positioning sublayer (left property)
2827
2828					if( ol.indexOf('%') != -1 ){
2829						var leftPercent = parseFloat(ol);
2830						if (leftPercent == 0)
2831							sl.css('left', ls.g.sliderWidth() / 100 * leftPercent);
2832						else if (leftPercent == 100)
2833							sl.css('left', ls.g.sliderWidth() / 100 * leftPercent - sl2.outerWidth());
2834						else
2835							sl.css('left', ls.g.sliderWidth() / 100 * leftPercent - sl2.outerWidth() / 2);
2836					}else if( slC > 0 || ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
2837						sl.css('left', slC + parseInt(ol) * ls.g.ratio);
2838					}
2839
2840					// (RE)positioning sublayer (top property)
2841
2842					if( ot.indexOf('%') != -1 ){
2843						var topPercent = parseFloat(ot);
2844						if (topPercent == 0)
2845							sl.css('top', ls.g.sliderHeight() / 100 * topPercent);
2846						else if (topPercent == 100)
2847							sl.css('top', ls.g.sliderHeight() / 100 * topPercent - sl2.outerHeight());
2848						else
2849							sl.css('top', ls.g.sliderHeight() / 100 * topPercent - sl2.outerHeight() / 2);
2850					}else if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
2851						sl.css('top', parseInt(ot) * ls.g.ratio + _pt);
2852					}
2853
2854				}else{
2855
2856					var inner = ls.g.i;
2857					var iw = inner.width();
2858					var ih = inner.height();
2859
2860					sl.css({
2861						width : 'auto',
2862						height : 'auto'
2863					});
2864
2865					ow = sl.width();
2866					oh = sl.height();
2867
2868					// IMPROVEMENT v4.5.0 Resizing smaller background images in full width mode as well to fill the whole slide
2869					if (imgsize == 'cover') { // cover or fullsize
2870						if (ow / oh < iw / ih) {
2871							sl.css({
2872								width: iw,
2873								height: iw / ow * oh,
2874								marginLeft: 0,
2875								marginTop: (_sh - oh / ow * _sw) * imgpos[1]
2876							});
2877						} else {
2878							sl.css({
2879								width: ih / oh * ow,
2880								height: ih,
2881								marginLeft: (_sw - ow / oh * _sh) * imgpos[0],
2882								marginTop: 0
2883							});
2884						}
2885					}	else if (imgsize == 'contain') { // contain
2886						if (ow / oh < iw / ih) {
2887							sl.css({
2888								width: ih / oh * ow,
2889								height: ih,
2890								marginLeft: (ls.g.sliderWidth() - ih / oh * ow) * imgpos[0],
2891								marginTop: 0
2892							});
2893						} else {
2894							sl.css({
2895								width: iw,
2896								height: iw / ow * oh,
2897								marginLeft: 0,
2898								marginTop: (ls.g.sliderHeight() - oh / ow * _sw) * imgpos[1]
2899							});
2900						}
2901					} else if (imgsize == 'stretch') { // stretch
2902						sl.css({
2903							width: ls.g.sliderWidth(),
2904							height: ls.g.sliderHeight(),
2905							marginLeft: 0,
2906							marginTop: 0
2907						});
2908					} else { // auto
2909						var or = ls.g.ratio;
2910
2911						if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
2912							if( ls.g.sliderWidth() > ow ){
2913								or = ls.g.sliderWidth() / ow;
2914								if( ls.g.sliderHeight() > oh * or ){
2915									or = ls.g.sliderHeight() / oh;
2916								}
2917							}else if( ls.g.sliderHeight() > oh ){
2918								or = ls.g.sliderHeight() / oh;
2919								if( ls.g.sliderWidth() > ow * or ){
2920									or = ls.g.sliderWidth() / ow;
2921								}
2922							}
2923						}
2924
2925						sl.css({
2926							width : ow * or,
2927							height : oh * or,
2928							marginLeft : (iw - ow * or) * imgpos[0],
2929							marginTop : (ih - oh * or) * imgpos[1]
2930						});
2931					}
2932//					$('#w2 span:eq(0)').html( ( inner.width() / 2 ) - Math.round( ow * or / 2 ) );
2933				}
2934			});
2935
2936			layer.css({
2937				display: 'none',
2938				visibility: 'visible'
2939			});
2940
2941			// Resizing shadow
2942
2943			ls.resizeShadow();
2944
2945			callback();
2946
2947			$(this).dequeue();
2948		};
2949
2950		// Resizing shadow
2951
2952		ls.resizeShadow = function(){
2953			if( ls.g.shadowImg ){
2954				var resizeShadow = function(){
2955					if( ls.g.shadowImg.height() > 0 ){
2956						if( ls.g.shadowBtmMod > 0 ){
2957							ls.g.shadow.css({
2958								height: ls.g.shadowImg.height() / 2
2959							});
2960						}else{
2961							ls.g.shadow.css({
2962								height: ls.g.shadowImg.height(),
2963								marginTop: - ls.g.shadowImg.height() / 2
2964							});
2965						}
2966					}else{
2967						setTimeout(function(){
2968							resizeShadow();
2969						},50);
2970					}
2971				};
2972
2973				resizeShadow();
2974			}
2975		};
2976
2977		// Resizing the slider
2978
2979		ls.resizeSlider = function(){
2980
2981			if( ls.o.responsiveUnder > 0 ){
2982
2983				if( $(window).width() < ls.o.responsiveUnder ){
2984					ls.g.responsiveMode = true;
2985					ls.g.sliderOriginalWidth = ls.o.responsiveUnder + 'px';
2986				}else{
2987					ls.g.responsiveMode = false;
2988					ls.g.sliderOriginalWidth = ls.g.sliderOriginalWidthRU;
2989					ls.g.ratio = 1;
2990				}
2991			}
2992
2993			// BUGFIX 5.3.0 Fixed full-width resize issue
2994
2995			if( $(el).closest('.ls-wp-fullwidth-container').length ){
2996
2997					$(el).closest('.ls-wp-fullwidth-helper').css({
2998						width : $(window).width()
2999					});
3000			}
3001
3002			if (ls.o.fullPage) {
3003				ls.g.responsiveMode = true;
3004				ls.g.sliderHeight = function() {
3005					var vh = $(window).height();
3006					if (ls.o.reduceHeight) $(ls.o.reduceHeight).each(function() {
3007						vh -= $(this).outerHeight();
3008					})
3009					return vh;
3010				};
3011
3012				if (ls.g.layersOriginalContainer == undefined) {
3013					ls.g.layersOriginalContainer = ls.o.layersContainer;
3014				}
3015				var _soh = parseInt(ls.g.sliderOriginalHeight);	// slider original heigh
3016				var _sh = ls.g.sliderHeight();			// slider height
3017
3018				if (_sh < _soh) {
3019					ls.o.layersContainer = _sh / _soh * ls.g.layersOriginalContainer;
3020				} else {
3021					ls.o.layersContainer = ls.g.layersOriginalContainer;
3022				}
3023			}
3024
3025			// NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
3026
3027			if( ls.g.responsiveMode ){
3028
3029				var parent = $(el).parent();
3030
3031				// BUGFIX v4.0 there is no need to subtract the values of the left and right paddings of the container element!
3032
3033				if (ls.g.sliderOriginalWidthRU == "100%") {
3034					// BUGFIX: resize full-width slide
3035					$(el).css({
3036						width : $(window).width()
3037					});
3038				} else {
3039					$(el).css({
3040						width : parent.width() - parseInt($(el).css('padding-left')) - parseInt($(el).css('padding-right'))
3041					});
3042				}
3043
3044				if (ls.o.fullPage) {
3045					$(el).height( _sh );
3046					ls.g.ratio = $(el).width() / ls.g.layersOriginalContainer;
3047					ls.g.ratioY = _sh / _soh;
3048					if (ls.g.ratioY < ls.g.ratio) {
3049						ls.g.ratio = ls.g.ratioY < 1 ? ls.g.ratioY : 1;
3050					} else {
3051						ls.g.ratio = ls.g.ratio < 1 ? ls.g.ratio : 1;
3052					}
3053				} else {
3054					ls.g.ratio = $(el).width() / parseInt( ls.g.sliderOriginalWidth );
3055					$(el).css({
3056						height : ls.g.ratio * parseInt( ls.g.sliderOriginalHeight )
3057					});
3058				}
3059
3060			}else{
3061				ls.g.ratio = 1;
3062				$(el).css({
3063					width : ls.g.sliderOriginalWidth,
3064					height : ls.g.sliderOriginalHeight
3065				});
3066			}
3067
3068			// WP fullWidth mode (originally forceResponsive mode)
3069
3070			if( $(el).closest('.ls-wp-fullwidth-container').length ){
3071
3072				$(el).closest('.ls-wp-fullwidth-helper').css({
3073					height : $(el).outerHeight(true)
3074				});
3075
3076				$(el).closest('.ls-wp-fullwidth-container').css({
3077					height : $(el).outerHeight(true)
3078				});
3079
3080				var helper = $(el).closest('.ls-wp-fullwidth-helper');
3081				var node = helper[0].parentNode, offsetLeft = 0;
3082				do {
3083					offsetLeft += node.offsetLeft;
3084					node = node.offsetParent;
3085				} while (node && !$(node).is('html, .sm-content-inner'));
3086
3087				var scroll = $(node).is('.sm-content-inner') && node.offsetHeight > node.parentNode.offsetHeight ? scrollWidth : 0;
3088
3089				helper.css({
3090					width : $(window).width() - scroll,
3091					left : -offsetLeft
3092				});
3093				ls.g.sliderWidth = function(){
3094					return $(window).width() - scroll;
3095				}
3096
3097				if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
3098
3099					var percentWidth = parseInt( ls.g.sliderOriginalWidth );
3100					var newWidth = $('body').outerWidth() / 100 * percentWidth - ( $(el).outerWidth() - $(el).width() );
3101					$(el).width( newWidth - scroll );
3102				}
3103			}
3104
3105			$(el).find('.ls-inner, .ls-lt-container').css({
3106				width : ls.g.sliderWidth(),
3107				height : ls.g.sliderHeight()
3108			});
3109
3110			// BUGFIX v2.0 fixed width problem if firstSlide is not 1
3111
3112			if( ls.g.curLayer && ls.g.nextLayer ){
3113
3114				ls.g.curLayer.css({
3115					width : ls.g.sliderWidth(),
3116					height : ls.g.sliderHeight()
3117				});
3118
3119				ls.g.nextLayer.css({
3120					width : ls.g.sliderWidth(),
3121					height : ls.g.sliderHeight()
3122				});
3123
3124			}else{
3125
3126				$(el).find('.ls-slide').css({
3127					width : ls.g.sliderWidth(),
3128					height : ls.g.sliderHeight()
3129				});
3130			}
3131		};
3132
3133		// NEW FEATURE v3.0 added responsive yourLogo
3134
3135		ls.resizeYourLogo = function(){
3136
3137			ls.g.yourLogo.css({
3138				width : ls.g.yourLogo.data( 'originalWidth' ) * ls.g.ratio,
3139				height : ls.g.yourLogo.data( 'originalHeight' ) * ls.g.ratio
3140			});
3141
3142			if( ls.g.ie78 ){
3143				ls.g.yourLogo.css('display','block');
3144			}else{
3145				ls.g.yourLogo.fadeIn(300);
3146			}
3147
3148			var oL = oR = oT = oB = 'auto';
3149
3150			if( ls.g.yourLogo.data( 'originalLeft' ) && ls.g.yourLogo.data( 'originalLeft' ).indexOf('%') != -1 ){
3151				oL = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-left') );
3152			}else{
3153				oL = parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) * ls.g.ratio;
3154			}
3155
3156			if( ls.g.yourLogo.data( 'originalRight' ) && ls.g.yourLogo.data( 'originalRight' ).indexOf('%') != -1 ){
3157				oR = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalRight' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-right') );
3158			}else{
3159				oR = parseInt( ls.g.yourLogo.data( 'originalRight' ) ) * ls.g.ratio;
3160			}
3161
3162			if( ls.g.yourLogo.data( 'originalTop' ) && ls.g.yourLogo.data( 'originalTop' ).indexOf('%') != -1 ){
3163				oT = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalTop' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-top') );
3164			}else{
3165				oT = parseInt( ls.g.yourLogo.data( 'originalTop' ) ) * ls.g.ratio;
3166			}
3167
3168			if( ls.g.yourLogo.data( 'originalBottom' ) && ls.g.yourLogo.data( 'originalBottom' ).indexOf('%') != -1 ){
3169				oB = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-bottom') );
3170			}else{
3171				oB = parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) * ls.g.ratio;
3172			}
3173
3174			ls.g.yourLogo.css({
3175				left : oL,
3176				right : oR,
3177				top : oT,
3178				bottom : oB
3179			});
3180		};
3181
3182		// NEW FEATURE v3.5 thumbnailNavigation ('always')
3183
3184		// Resizing thumbnails
3185
3186		ls.resizeThumb = function(){
3187
3188			ls.bottomNavSizeHelper('on');
3189
3190			var sliderW = ls.g.sliderOriginalWidth.indexOf('%') == -1 ? parseInt( ls.g.sliderOriginalWidth ) 
3190: ls.g.sliderWidth();
3191
3192			$(el).find('.ls-thumbnail-slide a').css({
3193				width : parseInt( ls.o.tnWidth * ls.g.ratio ),
3194				height : parseInt( ls.o.tnHeight * ls.g.ratio )
3195			});
3196
3197			$(el).find('.ls-thumbnail-slide a:last').css({
3198				margin: 0
3199			});
3200
3201			$(el).find('.ls-thumbnail-slide').css({
3202				height : parseInt( ls.o.tnHeight * ls.g.ratio )
3203			});
3204
3205			var tn = $(el).find('.ls-thumbnail');
3206
3207			var originalWidth = ls.o.tnContainerWidth.indexOf('%') == -1 ? parseInt( ls.o.tnContainerWidth ) : parseInt( sliderW / 100 * parseInt( ls.o.tnContainerWidth ) );
3208
3209			tn.css({
3210				width : originalWidth * Math.floor( ls.g.ratio * 100 ) / 100
3211			});
3212
3213			if( tn.width() > $(el).find('.ls-thumbnail-slide').width() ){
3214				tn.css({
3215					width : $(el).find('.ls-thumbnail-slide').width()
3216				});
3217			}
3218
3219			ls.bottomNavSizeHelper('off');
3220		};
3221
3222		// Changing thumbnails
3223
3224		ls.changeThumb = function(index){
3225
3226			var curIndex = index ? index : ls.g.nextLayerIndex;
3227
3228			$(el).find('.ls-thumbnail-slide a:not(.ls-thumb-'+curIndex+')').children().each(function(){
3229				$(this).removeClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnInactiveOpacity/100);
3230			});
3231
3232			$(el).find('.ls-thumbnail-slide a.ls-thumb-'+curIndex).children().addClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnActiveOpacity/100);
3233		};
3234
3235		// Scrolling thumbnails
3236
3237		ls.scrollThumb = function(){
3238
3239			if( !$(el).find('.ls-thumbnail-slide-container').hasClass('ls-thumbnail-slide-hover') ){
3240				var curThumb = $(el).find('.ls-thumb-active').length ? $(el).find('.ls-thumb-active').parent() : false;
3241				if( curThumb ){
3242					var thumbCenter = curThumb.position().left + curThumb.width() / 2;
3243					var mL = $(el).find('.ls-thumbnail-slide-container').width() / 2 - thumbCenter;
3244					mL = mL < $(el).find('.ls-thumbnail-slide-container').width() - $(el).find('.ls-thumbnail-slide').width() ? $(el).find('.ls-thumbnail-slide-container').width() - $(el).find('.ls-thumbnail-slide').width() : mL;
3245					mL = mL > 0 ? 0 : mL;
3246					$(el).find('.ls-thumbnail-slide').animate({
3247						marginLeft : mL
3248					}, 600 );
3249				}
3250			}
3251		};
3252
3253		// IMPROVEMENT v4.1.3 Changed the working of some Thumbnail and Bottom Navigation features
3254
3255		ls.bottomNavSizeHelper = function(val){
3256
3257			if( ls.o.hoverBottomNav && !$(el).hasClass('ls-hover') ){
3258				switch(val){
3259					case 'on':
3260						ls.g.thumbsWrapper.css({
3261							visibility: 'hidden',
3262							display: 'block'
3263						});
3264					break;
3265					case 'off':
3266						ls.g.thumbsWrapper.css({
3267							visibility: 'visible',
3268							display: 'none'
3269						});
3270					break;
3271				}
3272			}
3273		};
3274
3275		// Animating layers and sublayers
3276
3277		ls.animate = function(){
3278
3279			/* GLOBAL (used by both old and new transitions ) */
3280
3281					ls.g.numYouTubeCurSlide = 0;
3282
3283					// Changing variables
3284					// BUGFIX v4.6.0 If there is only one layer, there is no need to set ls.g.isAnimating to true
3285
3286					if( $(el).find('.ls-slide').length > 1 ){
3287						ls.g.isAnimating = true;
3288					}
3289
3290					ls.g.isLoading = false;
3291
3292					// Clearing timeouts
3293
3294					clearTimeout( ls.g.slideTimer );
3295					clearTimeout( ls.g.changeTimer );
3296
3297					ls.g.stopLayer = ls.g.curLayer;
3298
3299					// Calling cbAnimStart callback function
3300
3301					ls.o.cbAnimStart(ls.g);
3302
3303					// NEW FEATURE v3.5 thumbnailNavigation ('always')
3304
3305					if( ls.o.thumbnailNavigation == 'always' ){
3306
3307						// ChangeThumb
3308
3309						ls.changeThumb();
3310
3311						// ScrollThumb
3312
3313						if( !('ontouchstart' in window) ){
3314							ls.scrollThumb();
3315						}
3316					}
3317
3318					// Adding .ls-animating class to next layer
3319
3320					ls.g.nextLayer.addClass('ls-animating');
3321
3322			/* OLD layer transitions (version 3.x) */
3323
3324					// Setting position and styling of current and next layers
3325
3326					var curLayerLeft = curLayerRight = curLayerTop = curLayerBottom = nextLayerLeft = nextLayerRight = nextLayerTop = nextLayerBottom = layerMarginLeft = layerMarginRight = layerMarginTop = layerMarginBottom = 'auto';
3327					var curLayerWidth = nextLayerWidth = ls.g.sliderWidth();
3328					var curLayerHeight = nextLayerHeight = ls.g.sliderHeight();
3329
3330					// Calculating direction
3331
3332					var prevOrNext = ls.g.prevNext == 'prev' ? ls.g.curLayer : ls.g.nextLayer;
3333					var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection;
3334
3335					// Setting the direction of sliding
3336
3337					var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection];
3338
3339					if( slideDirection == 'left' || slideDirection == 'right' ){
3340						curLayerWidth = curLayerTop = nextLayerWidth = nextLayerTop = 0;
3341						layerMarginTop = 0;
3342					}
3343					if( slideDirection == 'top' || slideDirection == 'bottom' ){
3344						curLayerHeight = curLayerLeft = nextLayerHeight = nextLayerLeft = 0;
3345						layerMarginLeft = 0;
3346					}
3347
3348					switch(slideDirection){
3349						case 'left':
3350							curLayerRight = nextLayerLeft = 0;
3351							layerMarginLeft = -ls.g.sliderWidth();
3352							break;
3353						case 'right':
3354							curLayerLeft = nextLayerRight = 0;
3355							layerMarginLeft = ls.g.sliderWidth();
3356							break;
3357						case 'top':
3358							curLayerBottom = nextLayerTop = 0;
3359							layerMarginTop = -ls.g.sliderHeight();
3360							break;
3361						case 'bottom':
3362							curLayerTop = nextLayerBottom = 0;
3363							layerMarginTop = ls.g.sliderHeight();
3364							break;
3365					}
3366
3367					// Setting start positions and styles of layers
3368
3369					ls.g.curLayer.css({
3370						left : curLayerLeft,
3371						right : curLayerRight,
3372						top : curLayerTop,
3373						bottom : curLayerBottom
3374					});
3375					ls.g.nextLayer.css({
3376						width : nextLayerWidth,
3377						height : nextLayerHeight,
3378						left : nextLayerLeft,
3379						right : nextLayerRight,
3380						top : nextLayerTop,
3381						bottom : nextLayerBottom
3382					});
3383
3384					// Creating variables for the OLD transitions of CURRENT LAYER
3385
3386					// BUGFIX v1.6 fixed some wrong parameters of current layer
3387					// BUGFIX v1.7 fixed using of delayout of current layer
3388
3389					var curDelay = ls.g.curLayer.data('delayout') ? parseInt(ls.g.curLayer.data('delayout')) : ls.o.delayOut;
3390
3391					var curDuration = ls.g.curLayer.data('durationout') ? parseInt(ls.g.curLayer.data('durationout')) : ls.o.durationOut;
3392					var curEasing = ls.g.curLayer.data('easingout') ? ls.g.curLayer.data('easingout') : ls.o.easingOut;
3393
3394					// Creating variables for the OLD transitions of NEXT LAYER
3395
3396					var nextDelay = ls.g.nextLayer.data('delayin') ? parseInt(ls.g.nextLayer.data('delayin')) : ls.o.delayIn;
3397					var nextDuration = ls.g.nextLayer.data('durationin') ? parseInt(ls.g.nextLayer.data('durationin')) : ls.o.durationIn;
3398
3399					// BUGFIX v5.2.0 duration cannot be 0
3400
3401					if( nextDuration === 0 ){ nextDuration = 1 }
3402					var nextEasing = ls.g.nextLayer.data('easingin') ? ls.g.nextLayer.data('easingin') : ls.o.easingIn;
3403
3404					var curLayer = function(){
3405
3406						// BUGFIX v1.6 added an additional delaytime to current layer to fix the '1px gap' bug
3407						// BUGFIX v3.0 modified from curDuration / 80 to curDuration / 15
3408
3409						ls.g.curLayer.delay( curDelay + curDuration / 15).animate({
3410							width : curLayerWidth,
3411							height : curLayerHeight
3412						}, curDuration, curEasing,function(){
3413
3414							curLayerCallback();
3415						});
3416					};
3417
3418					var curLayerCallback = function(){
3419
3420						// Stopping current sublayer animations if needed (they are not visible at this point).
3421
3422						ls.g.stopLayer.find(' > *[class*="ls-l"]').each(function(){
3423							if( $(this).data('tr') ){
3424								$(this).data('tr').kill();
3425							}
3426
3427							$(this).css({
3428								filter: 'none'
3429							});
3430						});
3431
3432						// Setting current layer
3433
3434						ls.g.curLayer = ls.g.nextLayer;
3435
3436						// IMPROVEMENT v5.2.0 added prevLayerIndex and fixing curLayerIndex (nextLayerIndex is the same as curLayerIndex because the slider doesn't know at this point which slide will be the next)
3437
3438						ls.g.prevLayerIndex = ls.g.curLayerIndex;
3439						ls.g.curLayerIndex = ls.g.nextLayerIndex;
3440
3441						ls.o.cbAnimStop(ls.g);
3442
3443						// NEW FEATURE v5.0.0 Lazy-load (preloading here the images of the next layer)
3444
3445						if( ls.o.imgPreload && ls.o.lazyLoad ){
3446
3447							var preLayerIndex = ls.g.curLayerIndex == ls.g.layersNum ? 1 : ls.g.curLayerIndex + 1;
3448							$(el).find('.ls-slide').eq(preLayerIndex-1).find('img:not(.ls-preloaded)').each(function(){
3449								$(this).load(function(){
3450									$(this).addClass('ls-preloaded');
3451								}).error(function(){
3452									var imgURL = $(this).data('src').substring($(this).data('src').lastIndexOf("/") + 1, $(this).data('src').length);
3453									if( window.console ){
3454										console.log('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
3455									}else{
3456										alert('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
3457									}
3458									$(this).addClass('ls-not-preloaded');
3459								}).attr('src', $(this).data('src'));
3460							});
3461						}
3462
3463						// Changing some css classes
3464
3465						$(el).find('.ls-slide').removeClass('ls-active');
3466						$(el).find('.ls-slide:eq(' + ( ls.g.curLayerIndex - 1 ) + ')').addClass('ls-active').removeClass('ls-animating');
3467
3468						// Setting timer if needed
3469
3470						if( ls.g.autoSlideshow ){
3471							ls.timer();
3472						}
3473
3474						// Changing variables
3475
3476						ls.g.isAnimating = false;
3477						if( ls.g.resize == true ){
3478							ls.makeResponsive( ls.g.curLayer, function(){
3479								ls.g.resize = false;
3480							});
3481						}
3482					};
3483
3484					var curSubLayers = function(sublayersDurationOut){
3485
3486						ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){
3487
3488							if( !$(this).data('transitiontype') ){
3489								ls.transitionType( $(this) );
3490							}
3491
3492							// BUGFIX v5.1.0 Removing ls-videohack class before starting transition
3493
3494							$(this).removeClass('ls-videohack');
3495
3496							var curSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection;
3497							var lml, lmt;
3498
3499							switch(curSubSlideDir){
3500								case 'left':
3501									lml = -ls.g.sliderWidth();
3502									lmt = 0;
3503									break;
3504								case 'right':
3505									lml = ls.g.sliderWidth();
3506									lmt = 0;
3507									break;
3508								case 'top':
3509									lmt = -ls.g.sliderHeight();
3510									lml = 0;
3511									break;
3512								case 'bottom':
3513									lmt = ls.g.sliderHeight();
3514									lml = 0;
3515									break;
3516								case 'fade':
3517									lmt = 0;
3518									lml = 0;
3519									break;
3520							}
3521
3522							// NEW FEATURE v1.6 added slideoutdirection to sublayers
3523							// NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
3524
3525							if( $(this).data('transitiontype') === 'new' ){
3526								var curSubSlideOutDir = 'new';
3527							}else{
3528								var curSubSlideOutDir = $(this).data('slideoutdirection') ? $(this).data('slideoutdirection') : false;
3529							}
3530
3531							var curSubSplit = $(this).data('splitout') ? $(this).data('splitout') : ls.lt.splitOut;
3532							var curSubShift = $(this).data('shiftout') ? $(this).data('shiftout') : ls.lt.shiftOut;
3533
3534							switch(curSubSlideOutDir){
3535								case 'left':
3536									lml = ls.g.sliderWidth();
3537									lmt = 0;
3538									break;
3539								case 'right':
3540									lml = -ls.g.sliderWidth();
3541									lmt = 0;
3542									break;
3543								case 'top':
3544									lmt = ls.g.sliderHeight();
3545									lml = 0;
3546									break;
3547								case 'bottom':
3548									lmt = -ls.g.sliderHeight();
3549									lml = 0;
3550									break;
3551								case 'fade':
3552									lmt = 0;
3553									lml = 0;
3554									break;
3555								case 'new':
3556									var xout = $(this).data('offsetxout');
3557									if( xout ){
3558										var cycle = xout.trim().split(/[,\s]+/);
3559										$.each(cycle, function(i, xout) {
3560											if( xout === 'left' ){
3561												cycle[i] = ls.g.sliderWidth();
3562											}else if( xout === 'right' ){
3563												cycle[i] = -ls.g.sliderWidth();
3564											}else{
3565												cycle[i] = xout.indexOf('%') < 0 ? parseInt(xout) * ls.g.ratio : parseFloat(xout) / 100 * el.outerWidth();
3566											}
3567										});
3568										lml = curSubSplit && cycle.length > 1 ? cycle : cycle[0];
3569									}else{
3570										lml = ls.lt.offsetXOut;
3571									}
3572									var yout = $(this).data('offsetyout');
3573									if( yout ){
3574										var cycle = yout.trim().split(/[,\s]+/);
3575										$.each(cycle, function(i, yout) {
3576											if( yout === 'top' ){
3577												cycle[i] = ls.g.sliderHeight();
3578											}else if( yout === 'bottom' ){
3579												cycle[i] = -ls.g.sliderHeight();
3580											}else{
3581												cycle[i] = yout.indexOf('%') < 0 ? parseInt(yout) * ls.g.ratio : parseFloat(yout) / 100 * el.outerHeight();
3582											}
3583										});
3584										lmt = curSubSplit && cycle.length > 1 ? cycle : cycle[0];
3585									}else{
3586										lmt = ls.lt.offsetYOut;
3587									}
3588									break;
3589							}
3590
3591							// NEW FEATURES v4.5.0 Rotating & Scaling sublayers
3592							// BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
3593							// NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
3594
3595							var curSubRotate, curSubRotateX, curSubRotateY, curSubScale, curSubSkewX, curSubSkewY, curSubScaleX, curSubScaleY, curSubClip;
3596
3597							curSubRotate = $(this).data('rotateout') ? $(this).data('rotateout') : ls.lt.rotateOut;
3598							curSubRotateX = $(this).data('rotatexout') ? $(this).data('rotatexout') : ls.lt.rotateXOut;
3599							curSubRotateY = $(this).data('rotateyout') ? $(this).data('rotateyout') : ls.lt.rotateYOut;
3600							curSubScale = $(this).data('scaleout') ? $(this).data('scaleout') : ls.lt.scaleOut;
3601							curSubSkewX = $(this).data('skewxout') ? $(this).data('skewxout') : ls.lt.skewXOut;
3602							curSubSkewY = $(this).data('skewyout') ? $(this).data('skewyout') : ls.lt.skewYOut;
3603							if( curSubScale === 1 ){
3604								curSubScaleX = $(this).data('scalexout') ? $(this).data('scalexout') : ls.lt.scaleXOut;
3605								curSubScaleY = $(this).data('scaleyout') ? $(this).data('scaleyout') : ls.lt.scaleYOut;
3606							}else{
3607								curSubScaleX = curSubScaleY = curSubScale;
3608							}
3609							curSubClip = $(this).data('clipout') ? $(this).data('clipout') : ls.lt.clipOut;
3610
3611							var too = $(this).data('transformoriginout') ? $(this).data('transformoriginout').split(' ') : ls.lt.transformOriginOut;
3612							for(var t =0;t<too.length;t++){
3613								if( too[t].indexOf('%') === -1 && too[t].indexOf('left') !== -1 && too[t].indexOf('right') !== -1 && too[t].indexOf('top') !== -1 && too[t].indexOf('bottom') !== -1 ){
3614									too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px';
3615								}
3616							}
3617							var curSubTransformOrigin = too.join(' ');
3618							var curSubPerspective = $(this).data('perspectiveout') ? $(this).data('perspectiveout') : ls.lt.perspectiveOut;
3619
3620							// IMPROVEMENT v4.0 Distance (P.level): -1
3621
3622							var endLeft = parseInt( $(this).css('left') );
3623							var endTop = parseInt( $(this).css('top') );
3624
3625							var curSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] );
3626
3627							var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight();
3628							var modX = parseInt( curSubRotate ) === 0 ? $(this).outerWidth() : wh;
3629							var modY = parseInt( curSubRotate ) === 0 ? $(this).outerHeight() : wh;
3630
3631							if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetxout') === 'left' || $(this).data('offsetxout') === 'right' ) ){
3632								if( lml < 0 ){
3633									lml = ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100;
3634								}else if( lml > 0 ){
3635									lml = - (endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100);
3636								}
3637							}
3638
3639							if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetyout') === 'top' || $(this).data('offsetyout') === 'bottom' ) ){
3640								if( lmt < 0 ){
3641									lmt = ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100;
3642								}else if( lmt > 0 ){
3643									lmt = - (endTop + ( curSubScaleY / 2 + .5 ) * modY + 100);
3644								}
3645							}
3646
3647							if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){
3648								var curSubPar = 1;
3649							}else{
3650								var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut;
3651								var curSubPar = curSubPLevel * curSubParMod;
3652								lml *= -curSubPar;
3653								lmt *= -curSubPar;
3654							}
3655
3656							if( $(this).data('transitiontype') === 'new' ){
3657								var deO = ls.lt.delayOut;
3658								var duO = ls.lt.durationOut;
3659								var eO = ls.lt.easingOut;
3660							}else{
3661								var deO = ls.o.delayOut;
3662								var duO = ls.o.durationOut;
3663								var eO = ls.o.easingOut;
3664							}
3665
3666							var curSubDelay = $(this).data('delayout') ? parseInt($(this).data('delayout')) : deO;
3667							var curSubTime = $(this).data('durationout') ? parseInt($(this).data('durationout')) : duO;
3668
3669							// BUGFIX v5.2.0 duration cannot be 0
3670
3671							if( curSubTime === 0 ){ curSubTime = 1 }
3672							var curSubEasing = $(this).data('easingout') ? $(this).data('easingout') : eO;
3673
3674							// On new layer transitions, all sublayer will be slide / fade out in 500ms without any delays
3675
3676							if(sublayersDurationOut){
3677								curSubDelay = 0;
3678								curSubTime = sublayersDurationOut;
3679								// curSubEasing = 'easeInExpo';
3680							}
3681
3682							// Clearing showUntilTimers
3683
3684							if( $(this).data('showUntilTimer') ){
3685								clearTimeout( $(this).data('showUntilTimer') );
3686							}
3687
3688							var el = $(this);
3689
3690							var css = {
3691								transformOrigin : curSubTransformOrigin,
3692								transformPerspective : curSubPerspective
3693							};
3694
3695							var transition = {
3696								x : lml,
3697								y : lmt,
3698								rotation : curSubRotate,
3699								rotationX : curSubRotateX,
3700								rotationY : curSubRotateY,
3701								skewX : curSubSkewX,
3702								skewY : curSubSkewY,
3703								scaleX : curSubScaleX,
3704								scaleY : curSubScaleY,
3705								delay : curSubDelay/1000,
3706								ease : curSubEasing,
3707								onComplete : function() {
3708									el.data('status', 'forceoutend');
3709									el.css({visibility: 'hidden', clip: ''});
3710								}
3711							};
3712
3713							if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir === 'fade' ) || ( $(this).data('fadeout') !== 'false' && $(this).data('transitiontype') === 'new' ) ){
3714								transition.opacity = 0;
3715							}
3716
3717							if (curSubClip) {
3718								var ow = $(this).outerWidth(), oh = $(this).outerHeight();
3719								css.clip = 'rect(0 '+ow+' '+oh+' 0)';
3720								transition.clip = gsRect(curSubClip, ow, oh);
3721							}
3722
3723							var hover = $(this).removeClass('ls-mover').data('hover');
3724							if (hover) {
3725								hover.kill();
3726								var t = this._gsTransform;
3727								if (t.rotation || t.rotationX || t.rotationY || t.scaleX != 1 || t.scaleY != 1) {
3728									transition.origin = css.transformOrigin;
3729									delete css.transformOrigin;
3730								}
3731							}
3732
3733							if( $(this).data('tr') ){
3734								$(this).data('tr').kill();
3735							}
3736
3737							// don't run again the out transition when it has been ended
3738							if ($(this).data('status') == 'outend') return;
3739							// update status
3740							$(this).data('status', 'forceout');
3741
3742							var splitOut = $(this).is('img, div') ? [] : curSubSplit.split('_');
3743							// if splittext is enabled for transition out
3744							if (splitOut[0]) {
3745								var text = $(this).data('split'),
3746										ns = text[ splitOut[0] ],
3747										nodes;
3748								if (splitOut[1] == 'asc') {
3749									nodes = ns;
3750								} else if (splitOut[1] == 'desc') {
3751									nodes = ns.slice(0).reverse();
3752								} else if (splitOut[1] == 'rand') {
3753									nodes = ns.slice(0).sort(function() { return 0.5 - Math.random() });
3754								} else if (splitOut[1] == 'center') {
3755									var i, c = Math.floor(ns.length / 2);
3756									nodes = [ ns[c] ];
3757									for (i = 1; i <= c; i++) nodes.push(ns[c - i], ns[c + i]);
3758									nodes.length = ns.length;
3759								} else if (splitOut[1] == 'edge') {
3760									var i, c = Math.floor(ns.length / 2);
3761									nodes = [ ns[0] ];
3762									for (i = 1; i <= c; i++) nodes.push(ns[ns.length - i], ns[i]);
3763									nodes.length = ns.length;
3764								}
3765								TweenLite.set(nodes, css);
3766								var tl = new TimelineLite({paused: true, onComplete: transition.onComplete});
3767								delete transition.onComplete;
3768
3769								transition.cycle = {};
3770								if (transition.x.length) {
3771									transition.cycle.x = transition.x;
3772									delete transition.x;
3773								}
3774								if (transition.y.length) {
3775									transition.cycle.y = transition.y;
3776									delete transition.y;
3777								}
3778
3779								tl.staggerTo(nodes, curSubTime/1000, transition, curSubShift/1000);
3780								$(this).data('tr', tl);
3781								tl.duration(curSubTime/1000);	// fix for call onComplete event before it will be killed
3782								tl.play();
3783							}else {
3784								TweenLite.set(this, css);
3785								$(this).data('tr', TweenLite.to(this, curSubTime/1000, transition));
3786							}
3787
3788						});
3789					};
3790
3791					var nextLayer = function(){
3792
3793						ls.g.nextLayer.delay( curDelay + nextDelay ).animate({
3794							width : ls.g.sliderWidth(),
3795							height : ls.g.sliderHeight()
3796						}, nextDuration, nextEasing );
3797					};
3798
3799					var nextSubLayers = function(){
3800
3801						if( ls.g.totalDuration ){
3802							curDelay = 0;
3803						}
3804
3805						// Needed for the Timeline
3806						if( typeof ls.o.cbTimeLineStart === 'function' ){
3807							ls.o.cbTimeLineStart(ls.g, curDelay+nextDelay );
3808						}
3809
3810						ls.g.nextLayer.find(' > *[class*="ls-l"]').each(function(){
3811							var cursub = $(this);
3812							var nextSubShift = $(this).data('shiftin') ? $(this).data('shiftin') : ls.lt.shiftIn;
3813							var nextSubSplit = $(this).data('splitin') ? $(this).data('splitin') : ls.lt.splitIn;
3814
3815							// Replacing global parameters with unique if need
3816							// NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
3817
3818							if( !$(this).data('transitiontype') ){
3819								ls.transitionType( $(this) );
3820							}
3821
3822							if( $(this).data('transitiontype') === 'new' ){
3823								var nextSubSlideDir = 'new';
3824							}else{
3825								var nextSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection;
3826							}
3827							var lml, lmt;
3828
3829							switch(nextSubSlideDir){
3830								case 'left':
3831									lml = -ls.g.sliderWidth();
3832									lmt = 0;
3833									break;
3834								case 'right':
3835									lml = ls.g.sliderWidth();
3836									lmt = 0;
3837									break;
3838								case 'top':
3839									lmt = -ls.g.sliderHeight();
3840									lml = 0;
3841									break;
3842								case 'bottom':
3843									lmt = ls.g.sliderHeight();
3844									lml = 0;
3845									break;
3846								case 'fade':
3847									lmt = 0;
3848									lml = 0;
3849									break;
3850								case 'new':
3851									var xin = $(this).data('offsetxin');
3852									if( xin ){
3853										var cycle = xin.trim().split(/[,\s]+/);
3854										$.each(cycle, function(i, xin) {
3855											if( xin === 'left' ){
3856												cycle[i] = -ls.g.sliderWidth();
3857											}else if( xin === 'right' ){
3858												cycle[i] = ls.g.sliderWidth();
3859											}else{
3860												cycle[i] = xin.indexOf('%') < 0 ? parseInt(xin) * ls.g.ratio : parseFloat(xin) / 100 * cursub.outerWidth();
3861											}
3862										});
3863										lml = nextSubSplit && cycle.length > 1 ? cycle : cycle[0];
3864									}else{
3865										lml = ls.lt.offsetXIn;
3866									}
3867									var yin = $(this).data('offsetyin');
3868									if( yin ){
3869										var cycle = yin.trim().split(/[,\s]+/);
3870										$.each(cycle, function(i, yin) {
3871											if( yin === 'top' ){
3872												cycle[i] = -ls.g.sliderHeight();
3873											}else if( yin === 'bottom' ){
3874												cycle[i] = ls.g.sliderHeight();
3875											}else{
3876												cycle[i] = yin.indexOf('%') < 0 ? parseInt(yin) * ls.g.ratio : parseFloat(yin) / 100 * cursub.outerHeight();
3877											}
3878										});
3879										lmt = nextSubSplit && cycle.length > 1 ? cycle : cycle[0];
3880									}else{
3881										lmt = ls.lt.offsetYIn;
3882									}
3883									break;
3884							}
3885
3886							// NEW FEATURE v4.5.0 Rotating & Scaling sublayers
3887							// BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
3888							// NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
3889
3890							var nextSubRotate, nextSubRotateX, nextSubRotateY, nextSubScale, nextSubSkewX, nextSubSkewY, nextSubScaleX, nextSubScaleY, nextSubClip;
3891							nextSubRotate = $(this).data('rotatein') ? $(this).data('rotatein') : ls.lt.rotateIn;
3892							nextSubRotateX = $(this).data('rotatexin') ? $(this).data('rotatexin') : ls.lt.rotateXIn;
3893							nextSubRotateY = $(this).data('rotateyin') ? $(this).data('rotateyin') : ls.lt.rotateYIn;
3894							nextSubScale = $(this).data('scalein') ? $(this).data('scalein') : ls.lt.scaleIn;
3895							nextSubSkewX = $(this).data('skewxin') ? $(this).data('skewxin') : ls.lt.skewXIn;
3896							nextSubSkewY = $(this).data('skewyin') ? $(this).data('skewyin') : ls.lt.skewYIn;
3897							if( nextSubScale === 1 ){
3898								nextSubScaleX = $(this).data('scalexin') ? $(this).data('scalexin') : ls.lt.scaleXIn;
3899								nextSubScaleY = $(this).data('scaleyin') ? $(this).data('scaleyin') : ls.lt.scaleYIn;
3900							}else{
3901								nextSubScaleX = nextSubScaleY = nextSubScale;
3902							}
3903							nextSubClip = $(this).data('clipin') ? $(this).data('clipin') : ls.lt.clipIn;
3904
3905							var toi = $(this).data('transformoriginin') ? $(this).data('transformoriginin').split(' ') : ls.lt.transformOriginIn;
3906							for(var t =0;t<toi.length;t++){
3907								if( toi[t].indexOf('%') === -1 && toi[t].indexOf('left') !== -1 && toi[t].indexOf('right') !== -1 && toi[t].indexOf('top') !== -1 && toi[t].indexOf('bottom') !== -1 ){
3908									toi[t] = '' + parseInt( toi[t] ) * ls.g.ratio + 'px';
3909								}
3910							}
3911							var nextSubTransformOrigin = toi.join(' ');
3912							var nextSubPerspective = $(this).data('perspectivein') ? $(this).data('perspectivein') : ls.lt.perspectiveIn;
3913
3914							// IMPROVEMENT v4.0 Distance (P.level): -1
3915
3916							var endLeft = parseInt( $(this).css('left') );
3917							var endTop = parseInt( $(this).css('top') );
3918
3919							var nextSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] );
3920
3921							// BUGFIX v5.0.1 Fixed the starting position of layers with percentage value of width
3922
3923							if( $(this)[0].style.width.indexOf('%') !== -1 ){
3924								$(this).css({
3925									width: ls.g.sliderWidth() / 100 * parseInt( $(this)[0].style.width )
3926								});
3927							}
3928
3929							var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight();
3930							var modX = parseInt( nextSubRotate ) === 0 ? $(this).outerWidth() : wh;
3931							var modY = parseInt( nextSubRotate ) === 0 ? $(this).outerHeight() : wh;
3932
3933							if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetxin') === 'left' || $(this).data('offsetxin') === 'right' ) ){
3934
3935								if( lml < 0 ){
3936									lml = - ( endLeft + ( nextSubScaleX / 2 + .5 ) * modX + 100  );
3937								}else if( lml > 0 ){
3938									lml = ls.g.sliderWidth() - endLeft + ( nextSubScaleX / 2 - .5 ) * modX + 100;
3939								}
3940							}
3941
3942							if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetyin') === 'top' || $(this).data('offsetyin') === 'bottom' ) ){
3943
3944								if( lmt < 0 ){
3945									lmt = - ( endTop + ( nextSubScaleY / 2 + .5 ) * modY + 100  );
3946								}else if( lmt > 0 ){
3947									lmt = ls.g.sliderHeight() - endTop + ( nextSubScaleY / 2 - .5 ) * modY + 100;
3948								}
3949							}
3950
3951							if( nextSubPLevel === -1 || nextSubSlideDir === 'new'){
3952								var nextSubPar = 1;
3953							}else{
3954								var nextSubParMod = ls.g.nextLayer.data('parallaxin') ? parseInt(ls.g.nextLayer.data('parallaxin')) : ls.o.parallaxIn;
3955								var nextSubPar = nextSubPLevel * nextSubParMod;
3956								lml *= nextSubPar;
3957								lmt *= nextSubPar;
3958							}
3959
3960							if( $(this).data('transitiontype') === 'new' ){
3961								var deI = ls.lt.delayIn;
3962								var duI = ls.lt.durationIn;
3963								var eI = ls.lt.easingIn;
3964							}else{
3965								var deI = ls.o.delayIn;
3966								var duI = ls.o.durationIn;
3967								var eI = ls.o.easingIn;
3968							}
3969
3970							var nextSubDelay = $(this).data('delayin') ? parseInt($(this).data('delayin')) : deI;
3971							var nextSubTime = $(this).data('durationin') ? parseInt($(this).data('durationin')) : duI;
3972							var nextSubEasing = $(this).data('easingin') ? $(this).data('easingin') : eI;
3973
3974							var nextSubCallback = function(){
3975
3976								// BUGFIX v5.1.0 Removing transition property from video layers
3977
3978								if( cursub.hasClass('ls-video-layer') ){
3979									cursub.addClass('ls-videohack');
3980								}
3981
3982								// NEW FEATURE v2.0 autoPlayVideos
3983
3984								if( ls.o.autoPlayVideos == true ){
3985
3986									// YouTube & Vimeo videos
3987
3988									cursub.find('.ls-videopreview').click();
3989
3990									// HTML5 videos
3991
3992									cursub.find('video, audio').each(function(){
3993										if( typeof this.currentTime !== 0){
3994											this.currentTime = 0;
3995										}
3996										$(this).click();
3997									});
3998								}
3999
4000								// NEW FEATURE v3.0 showUntil sublayers
4001								// IMPROVEMENT v5.2.0 video layers with auto play will skip showuntil feature
4002
4003								if( ( !cursub.hasClass('ls-video-layer') || ( cursub.hasClass('ls-video-layer') && ls.o.autoPlayVideos === false ) ) && cursub.data('showuntil') > 0 ){
4004
4005									// IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary
4006
4007									cursub.data('showUntilTimer', setTimeout(function(){
4008										ls.sublayerShowUntil( cursub );
4009									}, cursub.data('showuntil') ));
4010								}
4011							};
4012
4013							if (ls.o.parallaxType != 'scroll') {
4014								$(this).css({ marginLeft: 0, marginTop: 0 });
4015							}
4016
4017							var css = {
4018								visibility : 'visible',
4019								opacity: $(this).data( 'originalOpacity' ),
4020								transformPerspective : nextSubPerspective,
4021								transformOrigin : nextSubTransformOrigin,
4022								x : lml,
4023								y : lmt,
4024								rotation: parseFloat(nextSubRotate), // !!! skewY bug (try from instead of fromTo)
4025								rotationX : nextSubRotateX,
4026								rotationY : nextSubRotateY,
4027								skewX : nextSubSkewX,
4028								skewY : nextSubSkewY,
4029								scaleX : nextSubScaleX,
4030								scaleY : nextSubScaleY
4031							};
4032
4033							var transition = {
4034								css: {
4035									x : 0,
4036									y : 0,
4037									rotation : 0,
4038									rotationX : 0,
4039									rotationY : 0,
4040									skewX : 0,
4041									skewY : 0,
4042									scaleX : 1,
4043									scaleY : 1
4044								},
4045								ease : nextSubEasing,
4046								delay : nextSubDelay/1000,
4047								onComplete : function() {
4048									cursub.data('status', 'inend');
4049									cursub.css('clip', '');
4050									this.vars.triggerHover && this.vars.triggerHover();
4051									nextSubCallback();
4052								}
4053							};
4054
4055							if( nextSubSlideDir.indexOf('fade') != -1 || ( $(this).data('fadein') !== 'false' && $(this).data('transitiontype') === 'new' ) ){
4056								css['opacity'] = 0;
4057								transition.css['opacity'] = $(this).data( 'originalOpacity' );
4058							}
4059
4060							if (nextSubClip) {
4061								var ow = cursub.outerWidth(), oh = cursub.outerHeight();
4062								css.clip = gsRect(nextSubClip, ow, oh);
4063								transition.css.clip = 'rect(0 '+ow+' '+oh+' 0)';
4064							}
4065
4066							// init hover
4067							if (cursub.data('enablehover') == 1 || cursub.data('enablehover') == 'true') {
4068								cursub.addClass('ls-mover')
4069							}
4070
4071							if( $(this).data('tr') ){
4072								$(this).data('tr').kill();
4073							}
4074
4075							// disable splittext in case of img / div
4076							var splitIn = [],  splitOut = [];
4077							if (!$(this).is('img, div')) {
4078								// split text: use splitIn and splitOut values for split type
4079								splitIn = nextSubSplit.split('_'),
4080								splitOut = (cursub.data('splitout') || ls.lt.splitOut).split('_');
4081								if (!$(this).data('split') && (splitIn[0] || splitOut[0])) {
4082									var stype = {};
4083									stype[ splitIn[0] ] = stype[ splitOut[0] ] = true;
4084									if (stype.chars) stype.words = true; // !!! layout fix for animated chars
4085									$(this).data('split', new SplitType(this, { split: Object.keys(stype).join() }));
4086								}
4087							}
4088
4089							var reset = {visibility: '', opacity: '', clip: ''};
4090							reset[gsTransform] = '';
4091
4092							// update status
4093							$(this).data('status', 'in');
4094
4095
4096							// if split text is enabled for transition in
4097							if (splitIn[0]) {
4098								var text = $(this).data('split'),
4099										ns = text[ splitIn[0] ],
4100										nodes;
4101								if (splitIn[1] == 'asc') {
4102									nodes = ns;
4103								} else if (splitIn[1] == 'desc') {
4104									nodes = ns.slice(0).reverse();
4105								} else if (splitIn[1] == 'rand') {
4106									nodes = ns.slice(0).sort(function() {return 0.5 - Math.random()});
4107								} else if (splitIn[1] == 'center') {
4108									var i, c = Math.floor(ns.length / 2);
4109									nodes = [ ns[c] ];
4110									for (i = 1; i <= c; i++) nodes.push(ns[c - i], ns[c + i]);
4111									nodes.length = ns.length;
4112								} else if (splitIn[1] == 'edge') {
4113									var i, c = Math.floor(ns.length / 2);
4114									nodes = [ ns[0] ];
4115									for (i = 1; i <= c; i++) nodes.push(ns[ns.length - i], ns[i]);
4116									nodes.length = ns.length;
4117								}
4118
4119								// is it necessary? $(nodes).css('visibility', 'hidden') // blink fix for slower devices
4120
4121								this.style.opacity = transition.css.opacity;
4122								transition.css.opacity = 1;
4123								var tl = new TimelineLite({paused: true, onComplete: transition.onComplete});
4124								delete transition.onComplete;
4125
4126								// Cycle support for splitText
4127								css.cycle = {};
4128								if (css.x.length) {
4129									css.cycle.x = css.x;
4130									delete css.x;
4131								}
4132								if (css.y.length) {
4133									css.cycle.y = css.y;
4134									delete css.y;
4135								}
4136								// reset splitText CSS
4137								if (splitIn[0] || splitOut[0]) {
4138									$('.line, .word, .char', this).add(this).css(reset).each(function() { delete this._gsTransform });
4139								}
4140								tl.staggerFromTo(nodes, nextSubTime/1000, css, transition, nextSubShift/1000);
4141								$(this).data('tr', tl);
4142								tl.play();
4143							}
4144							else {
4145								// reset splitText CSS
4146								if (splitIn[0] || splitOut[0]) {
4147									$('.line, .word, .char', this).css(reset).each(function() { delete this._gsTransform });
4148								}
4149								$(this).data('tr', TweenLite.fromTo(this, nextSubTime/1000, css, transition) );
4150							}
4151						});
4152
4153						if (ls.o.parallaxType == 'scroll') {
4154							ls.onscroll();
4155						}
4156					};
4157
4158			/* NEW FEATURE v4.0 2D & 3D Layer Transitions */
4159
4160					// Selecting ONE transition (random)
4161					// If the browser doesn't support CSS3 3D, 2D fallback mode will be used instead
4162					// In this case, if user didn't specify any 2D transitions, a random will be selected
4163
4164					var selectTransition = function(){
4165
4166						// fix for random 2D & 3D transitions
4167						var D = [];
4168						if ( ls.g.nextLayer.data('transition3d') || ls.g.nextLayer.data('customtransition3d') ){
4169							D.push(3);
4170						}
4171						if ( ls.g.nextLayer.data('transition2d') || ls.g.nextLayer.data('customtransition2d') || !lsSupport3D( $(el) ) ) {
4172							D.push(2);
4173						}
4174						if (D.length == 1) {
4175							D.push(D[0]);
4176						}
4177						if( D[Math.floor(Math.random() * 2)] == 3 ){
4178
4179							if( ls.g.nextLayer.data('transition3d') && ls.g.nextLayer.data('customtransition3d') ){
4180								var rnd = Math.floor(Math.random() * 2);
4181								var rndT = [['3d',ls.g.nextLayer.data('transition3d')],['custom3d',ls.g.nextLayer.data('customtransition3d')]];
4182								getTransitionType(rndT[rnd][0],rndT[rnd][1]);
4183							}else if( ls.g.nextLayer.data('transition3d') ){
4184								getTransitionType('3d',ls.g.nextLayer.data('transition3d'));
4185							}else{
4186								getTransitionType('custom3d',ls.g.nextLayer.data('customtransition3d'));
4187							}
4188
4189						}else{
4190
4191							if( ls.g.nextLayer.data('transition2d') && ls.g.nextLayer.data('customtransition2d') ){
4192								var rnd = Math.floor(Math.random() * 2);
4193								var rndT = [['2d',ls.g.nextLayer.data('transition2d')],['custom2d',ls.g.nextLayer.data('customtransition2d')]];
4194								getTransitionType(rndT[rnd][0],rndT[rnd][1]);
4195							}else if( ls.g.nextLayer.data('transition2d') ){
4196								getTransitionType('2d',ls.g.nextLayer.data('transition2d'));
4197							}else if( ls.g.nextLayer.data('customtransition2d') ){
4198								getTransitionType('custom2d',ls.g.nextLayer.data('customtransition2d'));
4199							}else{
4200								getTransitionType('2d','1');
4201							}
4202						}
4203					};
4204
4205					// Needed by the demo page
4206
4207					var selectCustomTransition = function(){
4208
4209						if( lsSupport3D( $(el) ) && LSCustomTransition.indexOf('3d') != -1 ){
4210							getTransitionType('3d',LSCustomTransition.split(':')[1]);
4211						}else{
4212							if( LSCustomTransition.indexOf('3d') != -1){
4213								getTransitionType('2d','all');
4214							}else{
4215								getTransitionType('2d',LSCustomTransition.split(':')[1]);
4216							}
4217						}
4218					};
4219
4220					// Choosing layer transition type (2d, 3d, or both)
4221
4222					var getTransitionType = function(type,transitionlist){
4223
4224						var tr = type.indexOf('custom') == -1 ? ls.t : ls.ct;
4225						var tt = '3d', lt, number;
4226
4227						if( type.indexOf('2d') != -1 ){
4228							tt = '2d';
4229						}
4230
4231						if( transitionlist.indexOf('last') != -1 ){
4232							number = tr['t'+tt].length-1;
4233							lt = 'last';
4234						}else if( transitionlist.indexOf('all') != -1){
4235							number = Math.floor(Math.random() * lsCountProp(tr['t'+tt]) );
4236							lt = 'random from all';
4237						}else{
4238							var t = transitionlist.split(',');
4239							var l = t.length;
4240							number = parseInt(t[Math.floor(Math.random() * l)])-1;
4241							lt = 'random from specified';
4242						}
4243
4244						slideTransition(tt,tr['t'+tt][number]);
4245
4246//						$('.test').html('Originals:<br><br>t3D: '+ls.g.nextLayer.data('transition3d')+'<br>t2D: '+ls.g.nextLayer.data('transition2d')+'<br>custom3D: '+ls.g.nextLayer.data('customtransition3d')+'<br>custom2D: '+ls.g.nextLayer.data('customtransition2d')+'<br><br>Support 3D: '+lsSupport3D( $(el) )+'<br><br>Selected transition:<br><br>Type: '+type+' ('+lt+')<br>Number in transition list: '+(number+1)+'<br>Name of the transition: '+tr['t'+tt][number]['name']);
4247					};
4248
4249					// The slideTransition function
4250
4251					var slideTransition = function(type,prop){
4252
4253						var inner = ls.g.i;
4254
4255						// sublayersDurationOut - for future usage
4256
4257						var sublayersDurationOut = ls.g.curLayer.find('*[class*="ls-l"]').length > 0 ? 1000 : 0;
4258
4259						// Detecting a carousel transition - Transition name must have the carousel string
4260
4261						var carousel = prop.name.toLowerCase().indexOf('carousel') == -1 ? false : true;
4262
4263						// Detecting a crossfade transition - Transition name must have the crossfad string
4264
4265						var crossfade = prop.name.toLowerCase().indexOf('crossfad') == -1 ? false : true;
4266
4267						// Calculating cols and rows
4268
4269						var cols = typeof(prop.cols);
4270						var rows = typeof(prop.rows);
4271
4272						switch( cols ){
4273							case 'number':
4274								cols = prop.cols;
4275							break;
4276							case 'string':
4277								cols = Math.floor( Math.random() * ( parseInt( prop.cols.split(',')[1] ) - parseInt( prop.cols.split(',')[0] ) + 1) ) + parseInt( prop.cols.split(',')[0] );
4278							break;
4279							default:
4280								cols = Math.floor( Math.random() * ( prop.cols[1] - prop.cols[0] + 1) ) + prop.cols[0];
4281							break;
4282						}
4283
4284						switch( rows ){
4285							case 'number':
4286								rows = prop.rows;
4287							break;
4288							case 'string':
4289								rows = Math.floor( Math.random() * ( parseInt( prop.rows.split(',')[1] ) - parseInt( prop.rows.split(',')[0] ) + 1) ) + parseInt( prop.rows.split(',')[0] );
4290							break;
4291							default:
4292								rows = Math.floor( Math.random() * ( prop.rows[1] - prop.rows[0] + 1) ) + prop.rows[0];
4293							break;
4294						}
4295
4296						if( ( ls.g.isMobile() == true && ls.o.optimizeForMobile == true ) || ( ls.g.ie78 && ls.o.optimizeForIE78 == true ) ){
4297
4298							// Reducing cols in three steps
4299
4300							if( cols >= 15 ){
4301								cols = 7;
4302							}else if( cols >= 5 ){
4303								cols = 4;
4304							}else if( cols >= 4 ){
4305								cols = 3;
4306							}else if( cols > 2 ){
4307								cols = 2;
4308							}
4309
4310							// Reducing rows in three steps
4311
4312							if( rows >= 15 ){
4313								rows = 7;
4314							}else if( rows >= 5 ){
4315								rows = 4;
4316							}else if( rows >= 4 ){
4317								rows = 3;
4318							}else if( rows > 2 ){
4319								rows = 2;
4320							}
4321
4322							// Reducing more :)
4323
4324							if( rows > 2 && cols > 2 ){
4325								rows = 2;
4326								if( cols > 4){
4327									cols = 4;
4328								}
4329							}
4330						}
4331
4332						var tileWidth = ls.g.i.width() / cols;
4333						var tileHeight = ls.g.i.height() / rows;
4334
4335						// Init HTML markup for layer transitions
4336
4337						ls.g.ltContainer.stop(true,true).empty().css({
4338							display : 'block',
4339							width : inner.width(),
4340							height : inner.height()
4341						});
4342
4343						// Setting size
4344
4345						var restW = inner.width() - Math.floor(tileWidth) * cols;
4346						var restH = inner.height() - Math.floor(tileHeight) * rows;
4347
4348						var tileSequence = [];
4349
4350						// IMPROVEMENT v4.1.3 Array-randomizer is now a local function
4351						// Randomize array function
4352
4353						tileSequence.randomize = function() {
4354						  var i = this.length, j, tempi, tempj;
4355						  if ( i == 0 ) return false;
4356						  while ( --i ) {
4357						     j       = Math.floor( Math.random() * ( i + 1 ) );
4358						     tempi   = this[i];
4359						     tempj   = this[j];
4360						     this[i] = tempj;
4361						     this[j] = tempi;
4362						  }
4363						  return this;
4364						}
4365
4366						for(var ts=0; ts<cols * rows; ts++){
4367							tileSequence.push(ts);
4368						}
4369
4370						// Setting the sequences of the transition
4371
4372						switch( prop.tile.sequence ){
4373							case 'reverse':
4374								tileSequence.reverse();
4375							break;
4376							case 'col-forward':
4377								tileSequence = lsOrderArray(rows,cols,'forward');
4378							break;
4379							case 'col-reverse':
4380								tileSequence = lsOrderArray(rows,cols,'reverse');
4381							break;
4382							case 'random':
4383								tileSequence.randomize();
4384							break;
4385						}
4386
4387						var curBG = ls.g.curLayer.find('.ls-bg');
4388						var nextBG = ls.g.nextLayer.find('.ls-bg');
4389
4390						// IMPROVEMENT v4.6.0 If current and next layer both have no BG, skipping the slide transition
4391
4392						if( curBG.length == 0 && nextBG.length == 0 ){
4393							type = '2d';
4394							prop = $.extend(true, {}, ls.t['t2d'][0]);
4395							prop.transition.duration = 1
4396							prop.tile.delay = 0;
4397						}
4398
4399						if( type == '3d' ){
4400							ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay;
4401
4402							var stepDuration = 0;
4403
4404							if( prop.before && prop.before.duration ){
4405								stepDuration += prop.before.duration;
4406							}
4407							if( prop.animation && prop.animation.duration ){
4408								stepDuration += prop.animation.duration;
4409							}
4410							if( prop.after && prop.after.duration ){
4411								stepDuration += prop.after.duration;
4412							}
4413
4414							ls.g.totalDuration += stepDuration;
4415
4416							var stepDelay = 0;
4417
4418							if( prop.before && prop.before.delay ){
4419								stepDelay += prop.before.delay;
4420							}
4421							if( prop.animation && prop.animation.delay ){
4422								stepDelay += prop.animation.delay;
4423							}
4424							if( prop.after && prop.after.delay ){
4425								stepDelay += prop.after.delay;
4426							}
4427
4428							ls.g.totalDuration += stepDelay;
4429
4430						}else{
4431							ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay + prop.transition.duration;
4432
4433							// IMPROVEMENT v4.5.0 Creating separated containers for current and next tiles
4434
4435							ls.g.curTiles = $('<div>').addClass('ls-curtiles').appendTo( ls.g.ltContainer );
4436							ls.g.nextTiles = $('<div>').addClass('ls-nexttiles').appendTo( ls.g.ltContainer );
4437						}
4438
4439						var pn = ls.g.prevNext;
4440
4441						// Creating cuboids for 3d or tiles for 2d transition (cols * rows)
4442
4443						for(var tiles=0; tiles < cols * rows; tiles++){
4444
4445							var rW = tiles%cols == 0 ? restW : 0;
4446							var rH = tiles > (rows-1)*cols-1 ? restH : 0;
4447
4448							var tile = $('<div>').addClass('ls-lt-tile').css({
4449								width : Math.floor(tileWidth) + rW,
4450								height : Math.floor(tileHeight) + rH
4451							}).appendTo( ls.g.ltContainer );
4452
4453							var curTile, nextTile;
4454
4455							// If current transition is a 3d transition
4456
4457							if( type == '3d' ){
4458
4459								tile.addClass('ls-3d-container');
4460
4461								var W = Math.floor(tileWidth) + rW;
4462								var H = Math.floor(tileHeight) + rH;
4463								var D;
4464
4465								if( prop.animation.direction == 'horizontal' ){
4466									if( Math.abs(prop.animation.transition.rotateY) > 90 && prop.tile.depth != 'large' ){
4467										D = Math.floor( W / 7 ) + rW;
4468									}else{
4469										D = W;
4470									}
4471								}else{
4472									if( Math.abs(prop.animation.transition.rotateX) > 90 && prop.tile.depth != 'large' ){
4473										D = Math.floor( H / 7 ) + rH;
4474									}else{
4475										D = H;
4476									}
4477								}
4478
4479								var W2 = W/2;
4480								var H2 = H/2;
4481								var D2 = D/2;
4482
4483								// createCuboids function will append cuboids with their style settings to their container
4484
4485								var createCuboids = function(c,a,w,h,tx,ty,tz,rx,ry){
4486									TweenLite.set($('<div>'), {
4487										width: w, height: h,
4488										x: tx, y: ty, z: tz,
4489										rotationX: rx, rotationY: ry
4490									}).target.addClass(c).appendTo(a);
4491								};
4492
4493								createCuboids('ls-3d-box',tile,0,0,0,0,-D2,0,0);
4494
4495								var backRotX = 0
4496								var topRotX = 0
4497								var bottomRotX = 0
4498
4499								if( prop.animation.direction == 'vertical' && Math.abs(prop.animation.transition.rotateX) > 90){
4500									createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,180,0);
4501								}else{
4502									createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,0,180);
4503								}
4504
4505								createCuboids('ls-3d-bottom',tile.find('.ls-3d-box'),W,D,-W2,H2-D2,0,-90,0
4505);
4506								createCuboids('ls-3d-top',tile.find('.ls-3d-box'),W,D,-W2,-H2-D2,0,90,0);
4507								createCuboids('ls-3d-front',tile.find('.ls-3d-box'),W,H,-W2,-H2,D2,0,0);
4508								createCuboids('ls-3d-left',tile.find('.ls-3d-box'),D,H,-W2-D2,-H2,0,0,-90);
4509								createCuboids('ls-3d-right',tile.find('.ls-3d-box'),D,H,W2-D2,-H2,0,0,90);
4510
4511								curTile = tile.find('.ls-3d-front');
4512
4513								if( prop.animation.direction == 'horizontal' ){
4514									if( Math.abs(prop.animation.transition.rotateY) > 90 ){
4515										nextTile = tile.find('.ls-3d-back');
4516									}else{
4517										nextTile = tile.find('.ls-3d-left, .ls-3d-right');
4518									}
4519								}else{
4520									if( Math.abs(prop.animation.transition.rotateX) > 90 ){
4521										nextTile = tile.find('.ls-3d-back');
4522									}else{
4523										nextTile = tile.find('.ls-3d-top, .ls-3d-bottom');
4524									}
4525								}
4526
4527								// Animating cuboids
4528
4529								var curCubDelay = tileSequence[tiles] * prop.tile.delay;
4530
4531								var curCub = ls.g.ltContainer.find('.ls-3d-container:eq('+tiles+') .ls-3d-box');
4532
4533								var tl = new TimelineLite();
4534
4535								if( prop.before && prop.before.transition ){
4536									prop.before.transition.delay = prop.before.transition.delay ? (prop.before.transition.delay + curCubDelay)/1000 : curCubDelay/1000;
4537									tl.to( curCub[0],prop.before.duration/1000,lsConvertTransition( prop.before.transition, prop.before.easing ));
4538								}else{
4539									prop.animation.transition.delay = prop.animation.transition.delay ? (prop.animation.transition.delay + curCubDelay)/1000 : curCubDelay/1000;
4540								}
4541
4542								tl.to( curCub[0],prop.animation.duration/1000,lsConvertTransition( prop.animation.transition, prop.animation.easing ));
4543
4544								if( prop.after ){
4545									if( !prop.after.transition ){
4546										prop.after.transition = {};
4547									}
4548									tl.to( curCub[0],prop.after.duration/1000,lsConvertTransition( prop.after.transition, prop.after.easing, 'after' ));
4549								}
4550
4551							}else{
4552
4553								// If current transition is a 2d transition
4554
4555								var T1 = L1 = T2 = L2 = 'auto';
4556								var O1 = O2 = 1;
4557
4558								if( prop.transition.direction == 'random' ){
4559									var dir = ['top','bottom','right','left'];
4560									var direction = dir[Math.floor(Math.random() * dir.length )];
4561								}else{
4562									var direction = prop.transition.direction;
4563								}
4564
4565								// IMPROVEMENT v4.5.0 Reversing animation directions if slider is moving backwards
4566
4567								if( prop.name.toLowerCase().indexOf('mirror') != -1 && tiles%2 == 0 ){
4568									if( pn == 'prev' ){
4569										pn = 'next';
4570									}else{
4571										pn = 'prev';
4572									}
4573								}
4574
4575								if( pn == 'prev' ){
4576
4577									switch( direction ){
4578										case 'top':
4579											direction = 'bottom';
4580										break;
4581										case 'bottom':
4582											direction = 'top';
4583										break;
4584										case 'left':
4585											direction = 'right';
4586										break;
4587										case 'right':
4588											direction = 'left';
4589										break;
4590										case 'topleft':
4591											direction = 'bottomright';
4592										break;
4593										case 'topright':
4594											direction = 'bottomleft';
4595										break;
4596										case 'bottomleft':
4597											direction = 'topright';
4598										break;
4599										case 'bottomright':
4600											direction = 'topleft';
4601										break;
4602									}
4603								}
4604
4605								switch( direction ){
4606									case 'top':
4607										T1 = T2 = -tile.height();
4608										L1 = L2 = 0;
4609									break;
4610									case 'bottom':
4611										T1 = T2 = tile.height();
4612										L1 = L2 = 0;
4613									break;
4614									case 'left':
4615										T1 = T2 = 0;
4616										L1 = L2 = -tile.width();
4617									break;
4618									case 'right':
4619										T1 = T2 = 0;
4620										L1 = L2 = tile.width();
4621									break;
4622									case 'topleft':
4623										T1 = tile.height();
4624										T2 = 0;
4625										L1 = tile.width();
4626										L2 = 0;
4627									break;
4628									case 'topright':
4629										T1 = tile.height();
4630										T2 = 0;
4631										L1 = - tile.width();
4632										L2 = 0;
4633									break;
4634									case 'bottomleft':
4635										T1 = - tile.height();
4636										T2 = 0;
4637										L1 = tile.width();
4638										L2 = 0;
4639									break;
4640									case 'bottomright':
4641										T1 = - tile.height();
4642										T2 = 0;
4643										L1 = - tile.width();
4644										L2 = 0;
4645									break;
4646								}
4647
4648								ls.g.scale2D = prop.transition.scale ? prop.transition.scale : 1;
4649
4650								if( carousel == true && ls.g.scale2D != 1 ){
4651
4652									T1 = T1 / 2;
4653									T2 = T2 / 2;
4654									L1 = L1 / 2;
4655									L2 = L2 / 2;
4656								}
4657
4658								// Selecting the type of the transition
4659
4660//								if( !ls.g.ie78 || ( ls.g.ie78 && !ls.o.optimizeForIE78 ) ||  ( ls.g.ie78 && ls.o.optimizeForIE78 == true && prop.name.toLowerCase().indexOf('crossfade') != -1 ) ){
4661									switch( prop.transition.type ){
4662										case 'fade':
4663											T1 = T2 = L1 = L2 = 0;
4664											O1 = 0;
4665											O2 = 1;
4666										break;
4667										case 'mixed':
4668										O1 = 0;
4669										O2 = 1;
4670										if( ls.g.scale2D == 1 ){
4671											T2 = L2 = 0;
4672										}
4673										break;
4674									}
4675//								}
4676
4677								// IMPROVEMENT v4.5.0 Implemented Rotation and Scale into 2D Transitions
4678
4679								if((( prop.transition.rotate || prop.transition.rotateX || prop.transition.rotateY ) || ls.g.scale2D != 1 ) && !ls.g.ie78 && prop.transition.type != 'slide' ){
4680									tile.css({
4681										overflow : 'visible'
4682									});
4683								}else{
4684									tile.css({
4685										overflow : 'hidden'
4686									});
4687								}
4688
4689								if( carousel == true){
4690									ls.g.curTiles.css({
4691										overflow: 'visible'
4692									});
4693								}else{
4694									ls.g.curTiles.css({
4695										overflow: 'hidden'
4696									});
4697								}
4698
4699								if( crossfade == true || prop.transition.type == 'slide' || carousel == true ){
4700									var tileInCur = tile.appendTo( ls.g.curTiles );
4701									var tileInNext = tile.clone().appendTo( ls.g.nextTiles );
4702									curTile = $('<div>').addClass('ls-curtile').appendTo( tileInCur );
4703								}else{
4704									var tileInNext = tile.appendTo( ls.g.nextTiles );
4705								}
4706
4707								nextTile = TweenLite.set($('<div>'), {
4708									x : -L1,
4709									y : -T1,
4710									opacity : O1
4711								}).target.addClass('ls-nexttile').appendTo( tileInNext );
4712
4713								// Animating tiles
4714
4715								var curTileDelay = tileSequence[tiles] * prop.tile.delay;
4716
4717								// IMPROVEMENT v4.5.0 Implemented various types of rotations into 2D Transitions
4718
4719								var r = prop.transition.rotate ? prop.transition.rotate : 0;
4720								var rX = prop.transition.rotateX ? prop.transition.rotateX : 0;
4721								var rY = prop.transition.rotateY ? prop.transition.rotateY : 0;
4722
4723								// Reversing rotation degrees if slider is moving backwards
4724
4725								if( pn == 'prev' ){
4726									r = -r;
4727									rX = -rX;
4728									rY = -rY;
4729								}
4730
4731								TweenLite.fromTo(nextTile[0],prop.transition.duration/1000,{
4732									rotation : r,
4733									rotationX : rX,
4734									rotationY : rY,
4735									scale : ls.g.scale2D
4736								},{
4737									delay : curTileDelay / 1000,
4738									x : 0,
4739									y : 0,
4740									opacity : O2,
4741									rotation : 0,
4742									rotationX : 0,
4743									rotationY : 0,
4744									scale : 1,
4745									ease : prop.transition.easing
4746								});
4747
4748								// IMPROVEMENT v5.0.0 Smart crossfading for semi-transparent PNG and different size JPG backgrounds
4749
4750								if(
4751									crossfade == true && (
4752										nextBG.length < 1 || (
4753											nextBG.length > 0 && (
4754												nextBG.attr('src').toLowerCase().indexOf('png') != -1 || (
4755													nextBG.width() < ls.g.sliderWidth() || nextBG.height() < ls.g.sliderHeight()
4756												)
4757											)
4758										)
4759									)
4760								){
4761									TweenLite.to(curTile[0],prop.transition.duration/1000,{
4762										delay : curTileDelay / 1000,
4763										opacity : 0,
4764										ease : prop.transition.easing
4765									});
4766								}
4767
4768								if( ( prop.transition.type == 'slide' || carousel == true ) && prop.name.toLowerCase().indexOf('mirror') == -1 ){
4769
4770									var r2 = 0;
4771
4772									if( r != 0 ){
4773										r2 = -r;
4774									}
4775
4776									TweenLite.to(curTile[0],prop.transition.duration/1000,{
4777										delay : curTileDelay / 1000,
4778										x : L2,
4779										y : T2,
4780										rotation : r2,
4781										scale : ls.g.scale2D,
4782										opacity: O1,
4783										ease : prop.transition.easing
4784									});
4785								}
4786							}
4787
4788							// Appending the background images of current and next layers into the tiles on both of 2d & 3d transitions
4789							// BUGFIX v5.0.0 added Math.floor to prevent '1px bug' under Safari and Firefox
4790
4791							if( curBG.length ){
4792								if( type == '3d' || ( type == '2d' && ( crossfade == true || prop.transition.type == 'slide' || carousel == true ) ) ){
4793									var tilePos = tile.position();
4794									curTile.append($('<img>').attr('src', curBG.attr('src')).css({
4795										width : curBG[0].style.width,
4796										height : curBG[0].style.height,
4797										marginLeft : parseFloat(curBG.css('margin-left')) - tilePos.left,
4798										marginTop : parseFloat(curBG.css('margin-top')) - tilePos.top
4799									}));
4800								}else if( ls.g.curTiles.children().length == 0 ){
4801									ls.g.curTiles.append($('<img>').attr('src', curBG.attr('src')).css({
4802										width : curBG[0].style.width,
4803										height : curBG[0].style.height,
4804										marginLeft : parseFloat(curBG.css('margin-left')),
4805										marginTop : parseFloat(curBG.css('margin-top'))
4806									}));
4807
4808								}
4809							}
4810
4811							if( nextBG.length ){
4812								var tilePos = tile.position();
4813								nextTile.append($('<img>').attr('src', nextBG.attr('src') ).css({
4814									width : nextBG[0].style.width,
4815									height : nextBG[0].style.height,
4816									marginLeft : parseFloat(nextBG.css('margin-left')) - tilePos.left,
4817									marginTop : parseFloat(nextBG.css('margin-top')) - tilePos.top
4818								}));
4819							}
4820						}
4821
4822						// Storing current and next layer elements in a local variable (needed by setTimeout functions in some cases)
4823
4824						var curLayer = ls.g.curLayer;
4825						var nextLayer = ls.g.nextLayer;
4826
4827						// Hiding the background image of the current and next layers (immediately)
4828
4829						setTimeout(function(){
4830							curLayer.find('.ls-bg').css({
4831								visibility : 'hidden'
4832							});
4833						},50);
4834
4835						nextLayer.find('.ls-bg').css({
4836							visibility : 'hidden'
4837						});
4838						ls.g.ltContainer.removeClass('ls-overflow-hidden');
4839
4840						// Sliding out the sublayers of the current layer
4841						// (immediately, delay out and duration out properties are not applied to the sublayers during the new layer transitions)
4842
4843						curSubLayers(sublayersDurationOut);
4844
4845						// BUGFIX v5.2.0 prevents background flickering in some cases
4846
4847						if( sublayersDurationOut === 0 ){
4848							sublayersDurationOut = 10;
4849						}
4850
4851						// Hiding current layer after its sublayers animated out
4852
4853						setTimeout(function(){
4854							curLayer.css({
4855								width: 0
4856							});
4857						}, sublayersDurationOut );
4858
4859						// Calculating next layer delay
4860
4861						var nextLayerTimeShift = parseInt(nextLayer.data('timeshift')) ? parseInt(nextLayer.data('timeshift')) : 0;
4862						var nextLayerDelay = ls.g.totalDuration + nextLayerTimeShift > 0 ? ls.g.totalDuration + nextLayerTimeShift : 0;
4863
4864						// Showing next layer and sliding sublayers of the next layer in after the current layer transition ended
4865
4866						setTimeout(function(){
4867							if( ls.g.resize == true ){
4868								ls.g.ltContainer.empty();
4869								curLayer.removeClass('ls-active');
4870								ls.makeResponsive( nextLayer, function(){
4871									ls.g.resize = false;
4872								});
4873							}
4874
4875							// Sliding in / fading in the sublayers of the next layer
4876
4877							nextSubLayers();
4878
4879							// NEW FEATURE v4.6.0 Hiding background if the next layer has png BG or has no BG
4880							// BUGFIX v4.6.1 Changed some properties to prevent flickering
4881
4882							if( nextLayer.find('.ls-bg').length < 1 || ( nextLayer.find('.ls-bg').length > 0 && nextLayer.find('.ls-bg').attr('src').toLowerCase().indexOf('png') != -1 ) ){
4883
4884								ls.g.ltContainer.delay(350).fadeOut(300,function(){
4885									$(this).empty().show();
4886								});
4887							}
4888
4889							// Displaying the next layer (immediately)
4890
4891							nextLayer.css({
4892								width : ls.g.sliderWidth(),
4893								height : ls.g.sliderHeight()
4894							});
4895						}, nextLayerDelay );
4896
4897						// BUGFIX v5.0.1 Added a minimal value of ls.g.totalDuration
4898						// CHANGED in v5.1.0 due to a fading issue in carousel transition
4899
4900						if( ls.g.totalDuration < 300 ){
4901							ls.g.totalDuration = 1000;
4902						}
4903
4904						// Changing visibility to visible of the background image of the next layer and overflow to hidden of .ls-lt-container after the transition and calling callback function
4905
4906						setTimeout(function(){
4907							ls.g.ltContainer.addClass('ls-overflow-hidden');
4908
4909							nextLayer.addClass('ls-active');
4910
4911							if( nextLayer.find('.ls-bg').length ){
4912
4913								nextLayer.find('.ls-bg').css({
4914									display : 'none',
4915									visibility : 'visible'
4916								});
4917								if( ls.g.ie78 ){
4918									nextLayer.find('.ls-bg').css('display','block');
4919									setTimeout(function(){
4920										curLayerCallback();
4921									},500);
4922								}else{
4923									nextLayer.find('.ls-bg').fadeIn(500, function(){
4924										curLayerCallback();
4925									});
4926								}
4927							}else{
4928								curLayerCallback();
4929							}
4930
4931						}, ls.g.totalDuration );
4932					};
4933
4934
4935
4936			/* Selecting and running the transition */
4937
4938					// NEW FEATURE v5.2.0 Starts the slider only if it is in the viewport
4939
4940					var startInViewport = function(){
4941
4942						ls.g.nextLayer.find(' > *[class*="ls-l"]').each(function(){
4943
4944							$(this).css({
4945								visibility : 'hidden'
4946							});
4947						});
4948
4949						ls.g.sliderTop = $(el).offset().top;
4950
4951						$(window).load(function(){
4952							setTimeout(function(){
4953
4954								ls.g.sliderTop = $(el).offset().top;
4955							}, 20);
4956						});
4957
4958						var eventClass = el.id || 'ls'+Date.now();
4959
4960						var isSliderInViewport = function(){
4961							if( $(window).scrollTop() + $(window).height() - ( ls.g.sliderHeight() / 2 ) > ls.g.sliderTop ){
4962								ls.g.firstSlideAnimated = true;
4963								if( ls.g.originalAutoStart === true ){
4964									//ls.g.autoSlideshow = true;
4965								 	ls.o.autoStart = true;
4966								 	ls.start();
4967								}
4968								nextSubLayers();
4969								$(window).off('scroll.'+eventClass);
4970							}
4971						}
4972						isSliderInViewport();
4973
4974						if( !ls.g.firstSlideAnimated ){
4975							if (ls.g.isMobile())
4976								$(window).on('scroll.'+eventClass, function(){
4977									clearTimeout(isSliderInViewport.timeout);
4978									isSliderInViewport.timeout = setTimeout(function() {
4979										isSliderInViewport();
4980									}, 150);
4981								});
4982							else
4983								$(window).on('scroll.'+eventClass, function(){
4984									isSliderInViewport();
4985								});
4986						}
4987					};
4988
4989					var tType = ( ( ls.g.nextLayer.data('transition3d') || ls.g.nextLayer.data('transition2d') ) && ls.t ) || ( ( ls.g.nextLayer.data('customtransition3d') || ls.g.nextLayer.data('customtransition2d') ) && ls.ct ) ? 'new' : 'old';
4990
4991					if( !ls.g.nextLayer.data('transitiontype') ){
4992						ls.transitionType( ls.g.nextLayer );
4993					}
4994
4995					if( ls.g.nextLayer.data('transitiontype') === 'new' ){
4996						tType = 'new';
4997					}
4998
4999					if( ls.o.slideTransition ){
5000						tType = 'forced';
5001					}
5002
5003					if( ls.o.animateFirstSlide && !ls.g.firstSlideAnimated ){
5004
5005						// BUGFIX v3.5 there is no need to animate 'current' layer if the following conditions are true
5006						//			   this fixes the sublayer animation direction bug
5007
5008						if( ls.g.layersNum == 1 ){
5009							var curDelay = 0;
5010
5011							// IMPROVEMENT v4.1.0 Calling cbAnimStop(); function if only one layer is in the slider
5012
5013							ls.o.cbAnimStop(ls.g);
5014
5015						}else{
5016							var nextLayerTimeShift = parseInt(ls.g.nextLayer.data('timeshift')) ? parseInt(ls.g.nextLayer.data('timeshift')) : 0;
5017							var d = tType == 'new' ? 0 : curDuration;
5018							ls.g.t5 = setTimeout(function(){
5019								curLayerCallback();
5020							}, d + Math.abs(nextLayerTimeShift) );
5021						}
5022
5023						// curDelay must be 0!
5024
5025						ls.g.totalDuration = true;
5026
5027						// Animating SUBLAYERS of the first layer
5028
5029						if( ls.o.startInViewport === true ){
5030
5031							startInViewport();
5032						}else{
5033
5034							ls.g.firstSlideAnimated = true;
5035							nextSubLayers();
5036						}
5037
5038						// Displaying the first layer (immediately)
5039
5040						ls.g.nextLayer.css({
5041							width : ls.g.sliderWidth(),
5042							height : ls.g.sliderHeight()
5043						});
5044
5045						if( !ls.g.ie78 ){
5046							ls.g.nextLayer.find('.ls-bg').css({
5047								display : 'none'
5048							}).fadeIn(ls.o.sliderFadeInDuration);
5049						}
5050
5051						ls.g.isLoading = false;
5052					}else{
5053
5054						switch(tType){
5055
5056							// Old transitions (sliding layers)
5057
5058							case 'old':
5059
5060								ls.g.totalDuration = false;
5061
5062								// BUGFIX v4.5.0 Removing elements from ls-lt-container is necessary
5063
5064								if( ls.g.ltContainer ){
5065									ls.g.ltContainer.empty();
5066								}
5067
5068								// Animating CURRENT LAYER and its SUBLAYERS
5069
5070								curLayer();
5071								curSubLayers();
5072
5073								// Animating NEXT LAYER and its SUBLAYERS
5074
5075								nextLayer();
5076								nextSubLayers();
5077							break;
5078
5079							// NEW FEATURE v4.0 2D & 3D Layer Transitions
5080
5081							case 'new':
5082
5083								if( typeof LSCustomTransition != 'undefined' ){
5084									selectCustomTransition();
5085								}else{
5086									selectTransition();
5087								}
5088							break;
5089
5090							case 'forced':
5091								slideTransition( ls.o.slideTransition.type, ls.o.slideTransition.obj );
5092							break;
5093						}
5094					}
5095		};
5096
5097		ls.transitionType = function( el ){
5098
5099			var ttype =  el.data('ls') ||
5100								( 	!el.data('ls') &&
5101									!el.data('slidedelay') &&
5102									!el.data('slidedirection') &&
5103									!el.data('slideoutdirection') &&
5104									!el.data('delayin') &&
5105									!el.data('delayout') &&
5106									!el.data('durationin') &&
5107									!el.data('durationout') &&
5108									!el.data('showuntil') &&
5109									!el.data('easingin') &&
5110									!el.data('easingout') &&
5111									!el.data('scalein') &&
5112									!el.data('scaleout') &&
5113									!el.data('rotatein') &&
5114									!el.data('rotateout')
5115								) ? 'new' : 'old';
5116			el.data('transitiontype', ttype);
5117		};
5118
5119		ls.sublayerShowUntil = function( sublayer ){
5120
5121			if( !sublayer.data('transitiontype') ){
5122				ls.transitionType( sublayer );
5123			}
5124
5125			// BUGFIX v5.1.0 Removing ls-videohack class before starting transition
5126
5127			sublayer.removeClass('ls-videohack');
5128
5129			var prevOrNext = ls.g.curLayer;
5130
5131			if( ls.g.prevNext != 'prev' && ls.g.nextLayer ){
5132				prevOrNext = ls.g.nextLayer;
5133			}
5134
5135			var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection;
5136
5137			// Setting the direction of sliding
5138
5139			var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection];
5140
5141			var curSubSlideDir = sublayer.data('slidedirection') ? sublayer.data('slidedirection') : slideDirection;
5142			var lml, lmt;
5143
5144			switch(curSubSlideDir){
5145				case 'left':
5146					lml = -ls.g.sliderWidth();
5147					lmt = 0;
5148					break;
5149				case 'right':
5150					lml = ls.g.sliderWidth();
5151					lmt = 0;
5152					break;
5153				case 'top':
5154					lmt = -ls.g.sliderHeight();
5155					lml = 0;
5156					break;
5157				case 'bottom':
5158					lmt = ls.g.sliderHeight();
5159					lml = 0;
5160					break;
5161				case 'fade':
5162					lmt = 0;
5163					lml = 0;
5164					break;
5165			}
5166
5167			// NEW FEATURE v1.6 added slideoutdirection to sublayers
5168			// NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
5169
5170			if( sublayer.data('transitiontype') === 'new' ){
5171				var curSubSlideOutDir = 'new';
5172			}else{
5173				var curSubSlideOutDir = sublayer.data('slideoutdirection') ? sublayer.data('slideoutdirection') : false;
5174			}
5175
5176			var curSubSplit = sublayer.data('splitout') ? sublayer.data('splitout') : ls.lt.splitOut;
5177			var curSubShift = sublayer.data('shiftout') ? sublayer.data('shiftout') : ls.lt.shiftOut;
5178
5179			switch(curSubSlideOutDir){
5180				case 'left':
5181					lml = ls.g.sliderWidth();
5182					lmt = 0;
5183					break;
5184				case 'right':
5185					lml = -ls.g.sliderWidth();
5186					lmt = 0;
5187					break;
5188				case 'top':
5189					lmt = ls.g.sliderHeight();
5190					lml = 0;
5191					break;
5192				case 'bottom':
5193					lmt = -ls.g.sliderHeight();
5194					lml = 0;
5195					break;
5196				case 'fade':
5197					lmt = 0;
5198					lml = 0;
5199					break;
5200				case 'new':
5201					var xout = sublayer.data('offsetxout');
5202					if( xout ){
5203						var cycle = xout.trim().split(/[,\s]+/);
5204						$.each(cycle, function(i, xout) {
5205							if( xout === 'left' ){
5206								cycle[i] = ls.g.sliderWidth();
5207							}else if( xout === 'right' ){
5208								cycle[i] = -ls.g.sliderWidth();
5209							}else{
5210								cycle[i] = xout.indexOf('%') < 0 ? parseInt(xout) * ls.g.ratio : parseFloat(xout) / 100 * sublayer.outerWidth();
5211							}
5212						});
5213						lml = curSubSplit && cycle.length > 1 ? cycle : cycle[0];
5214					}else{
5215						lml = ls.lt.offsetXOut;
5216					}
5217					var yout = sublayer.data('offsetyout');
5218					if( yout ){
5219						var cycle = yout.trim().split(/[,\s]+/);
5220						$.each(cycle, function(i, yout) {
5221							if( yout === 'top' ){
5222								cycle[i] = ls.g.sliderHeight();
5223							}else if( yout === 'bottom' ){
5224								cycle[i] = -ls.g.sliderHeight();
5225							}else{
5226								cycle[i] = yout.indexOf('%') < 0 ? parseInt(yout) * ls.g.ratio : parseFloat(yout) / 100 * sublayer.outerHeight();
5227							}
5228						});
5229						lmt = curSubSplit && cycle.length > 1 ? cycle : cycle[0];
5230					}else{
5231						lmt = ls.lt.offsetYOut;
5232					}
5233					break;
5234			}
5235
5236			// NEW FEATURE v4.5.0 Rotating & Scaling sublayers
5237			// BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
5238			// NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
5239
5240			var curSubRotate, curSubRotateX, curSubRotateY, curSubScale, curSubSkewX, curSubSkewY, curSubScaleX, curSubScaleY, curSubClip;
5241
5242			curSubRotate = sublayer.data('rotateout') ? sublayer.data('rotateout') : ls.lt.rotateOut;
5243			curSubRotateX = sublayer.data('rotatexout') ? sublayer.data('rotatexout') : ls.lt.rotateXOut;
5244			curSubRotateY = sublayer.data('rotateyout') ? sublayer.data('rotateyout') : ls.lt.rotateYOut;
5245			curSubScale = sublayer.data('scaleout') ? sublayer.data('scaleout') : ls.lt.scaleOut;
5246			curSubSkewX = sublayer.data('skewxout') ? sublayer.data('skewxout') : ls.lt.skewXOut;
5247			curSubSkewY = sublayer.data('skewyout') ? sublayer.data('skewyout') : ls.lt.skewYOut;
5248			if( curSubScale === 1 ){
5249				curSubScaleX = sublayer.data('scalexout') ? sublayer.data('scalexout') : ls.lt.scaleXOut;
5250				curSubScaleY = sublayer.data('scaleyout') ? sublayer.data('scaleyout') : ls.lt.scaleYOut;
5251			}else{
5252				curSubScaleX = curSubScaleY = curSubScale;
5253			}
5254			curSubClip = sublayer.data('clipout') ? sublayer.data('clipout') : ls.lt.clipOut;
5255
5256			var too = sublayer.data('transformoriginout') ? sublayer.data('transformoriginout').split(' ') : ls.lt.transformOriginOut;
5257
5258			for(var t =0;t<too.length;t++){
5259				if( too[t].indexOf('%') === -1 && too[t].indexOf('left') !== -1 && too[t].indexOf('right') !== -1 && too[t].indexOf('top') !== -1 && too[t].indexOf('bottom') !== -1 ){
5260					too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px';
5261				}
5262			}
5263			var curSubTransformOrigin = too.join(' ');
5264			var curSubPerspective = sublayer.data('perspectiveout') ? sublayer.data('perspectiveout') : ls.lt.perspectiveOut;
5265
5266			// IMPROVEMENT v4.0 Distance (P.level): -1
5267
5268			var endLeft = parseInt( sublayer.css('left') );
5269			var endTop = parseInt( sublayer.css('top') );
5270
5271			var curSubPLevel = parseInt( sublayer.attr('class').split('ls-l')[1] );
5272
5273			var wh = sublayer.outerWidth() > sublayer.outerHeight() ? sublayer.outerWidth() : sublayer.outerHeight();
5274			var modX = parseInt( curSubRotate ) === 0 ? sublayer.outerWidth() : wh;
5275			var modY = parseInt( curSubRotate ) === 0 ? sublayer.outerHeight() : wh;
5276
5277			if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetxout') === 'left' || sublayer.data('offsetxout') === 'right' ) ){
5278				if( lml < 0 ){
5279					lml = ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100;
5280				}else if( lml > 0 ){
5281					lml = -(endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100);
5282				}
5283			}
5284
5285			if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetyout') === 'top' || sublayer.data('offsetyout') === 'bottom' ) ){
5286				if( lmt < 0 ){
5287					lmt = ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100;
5288				}else if( lmt > 0 ){
5289					lmt = - (endTop + ( curSubScaleY / 2 + .5 ) * modY + 100);
5290				}
5291			}
5292
5293			if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){
5294				var curSubPar = 1;
5295			}else{
5296				var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut;
5297				var curSubPar = curSubPLevel * curSubParMod;
5298				lml *= -curSubPar;
5299				lmt *= -curSubPar;
5300			}
5301
5302//			var curSubDelay = parseInt( sublayer.data('showuntil') );
5303
5304			if( sublayer.data('transitiontype') === 'new' ){
5305				var duO = ls.lt.durationOut;
5306				var eO = ls.lt.easingOut;
5307			}else{
5308				var duO = ls.o.durationOut;
5309				var eO = ls.o.easingOut;
5310			}
5311
5312			var curSubTime = sublayer.data('durationout') ? parseInt(sublayer.data('durationout')) : duO;
5313
5314			// BUGFIX v5.2.0 duration cannot be 0
5315
5316			if( curSubTime === 0 ){ curSubTime = 1 }
5317			var curSubEasing = sublayer.data('easingout') ? sublayer.data('easingout') : eO;
5318
5319			var css = {
5320				transformPerspective : curSubPerspective,
5321				transformOrigin : curSubTransformOrigin
5322			};
5323
5324			var transition = {
5325				x : lml,
5326				y : lmt,
5327				rotation : curSubRotate,
5328				rotationX : curSubRotateX,
5329				rotationY : curSubRotateY,
5330				skewX : curSubSkewX,
5331				skewY : curSubSkewY,
5332				scaleX : curSubScaleX,
5333				scaleY : curSubScaleY,
5334				ease : curSubEasing,
5335				onComplete : function(){
5336					sublayer.data('status', 'outend');
5337					sublayer.css({visibility: 'hidden', clip: ''});
5338				}
5339			};
5340
5341			if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir == 'fade' ) || ( sublayer.data('fadeout') !== 'false' && sublayer.data('transitiontype') === 'new' ) ){
5342				transition.opacity = 0;
5343			}
5344
5345			if (curSubClip) {
5346				var ow = sublayer.outerWidth(), oh = sublayer.outerHeight();
5347				css.clip = 'rect(0 '+ow+' '+oh+' 0)';
5348				transition.clip = gsRect(curSubClip, ow, oh);
5349			}
5350
5351			var hover = sublayer.removeClass('ls-mover').data('hover');
5352			if (hover) {
5353				hover.kill();
5354				var t = sublayer[0]._gsTransform;
5355				if (t.rotation || t.rotationX || t.rotationY || t.scaleX != 1 || t.scaleY != 1) {
5356					transition.origin = css.transformOrigin;
5357					delete css.transformOrigin;
5358				}
5359			}
5360
5361			sublayer.data('status', 'out');
5362
5363			var splitOut = sublayer.is('img, div') ? [] : curSubSplit.split('_');
5364			if (splitOut[0]) {
5365				var text = sublayer.data('split'),
5366						nodes = text[ splitOut[0] ];
5367				if (splitOut[1] == 'desc') {
5368					nodes = nodes.slice(0).reverse();
5369				} else if (splitOut[1] == 'rand') {
5370					nodes = nodes.slice(0).sort(function() {return 0.5 - Math.random()});
5371				}
5372				TweenLite.set(nodes, css);
5373				var tl = new TimelineLite({paused: true, onComplete: transition.onComplete});
5374				delete transition.onComplete;
5375
5376				transition.cycle = {};
5377				if (transition.x.length) {
5378					transition.cycle.x = transition.x;
5379					delete transition.x;
5380				}
5381				if (transition.y.length) {
5382					transition.cycle.y = transition.y;
5383					delete transition.y;
5384				}
5385
5386				tl.staggerTo(nodes, curSubTime/1000, transition, curSubShift/1000);
5387				tl.play();
5388			}
5389			else {
5390				TweenLite.set(sublayer[0], css);
5391				TweenLite.to(sublayer[0], curSubTime/1000, transition);
5392			}
5393		};
5394
5395		// scroll-to/down feature
5396		var $win = $(window);
5397		var lsScrollUpdate = function() { $win.scrollTop(this.target.y) };
5398		var lsScrollTo = function(scrollTo) {
5399			var scrollMax = document.body.scrollHeight - $win.height();
5400			TweenLite.to({ y: $win.scrollTop() }, 0.5, {
5401				y: scrollTo > scrollMax ? scrollMax : scrollTo,
5402				onUpdate: lsScrollUpdate
5403			});
5404		};
5405
5406		ls.$el.on('click', 'a[target=ls-scroll-to]', function(e) {
5407			e.preventDefault();
5408			var href = $(this).attr('href');
5409			if (href.match(/^#[-\w]+$/)) {
5410				var $el = $(href +', a[name='+ href.slice(1) +']');
5411				$el.length && lsScrollTo($el.offset().top);
5412			}
5413		}).on('click', '.ls-scroll-down, .ls-mouse', function(e) {
5414			e.preventDefault();
5415			lsScrollTo(ls.$el.offset().top + ls.$el.outerHeight());
5416		});
5417
5418		// initializing
5419		ls.load();
5420	};
5421
5422	var lsConvertTransition = function( t, e, type, undef ){
5423
5424		if( typeof e === 'undefined' ){
5425			var e = 'easeInOutQuart';
5426		}
5427		var tt = {};
5428
5429		if( t.rotate !== undef ){
5430			tt.rotation = t.rotate;
5431		}
5432		if( t.rotateY !== undef ){
5433			tt.rotationY = t.rotateY;
5434		}
5435		if( t.rotateX !== undef ){
5436			tt.rotationX = t.rotateX;
5437		}
5438		if( type === 'after' ){
5439			tt.scaleX = tt.scaleY = tt.scaleZ = 1;
5440		}else if( t.scale3d !== undef ){
5441			tt.scaleX = tt.scaleY = tt.scaleZ = t.scale3d;
5442		}
5443
5444		if( t.delay ){
5445			tt.delay = type === 'after' ? t.delay/1000 : t.delay;
5446		}
5447
5448		tt.ease = e;
5449
5450		return tt;
5451	};
5452
5453	// Support3D checks the CSS3 3D capability of the browser (based on the idea of Modernizr.js)
5454
5455	var lsSupport3D = function( el ) {
5456
5457		var testEl = $('<div>'),
5458			s3d1 = false,
5459			s3d2 = false,
5460			properties = ['perspective', 'OPerspective', 'msPerspective', 'MozPerspective', 'WebkitPerspective'];
5461			transform = ['transformStyle','OTransformStyle','msTransformStyle','MozTransformStyle','WebkitTransformStyle'];
5462
5463		for (var i = properties.length - 1; i >= 0; i--){
5464			s3d1 = s3d1 ? s3d1 : testEl[0].style[properties[i]] != undefined;
5465		};
5466
5467		// preserve 3D test
5468
5469		for (var i = transform.length - 1; i >= 0; i--){
5470			testEl.css( 'transform-style', 'preserve-3d' );
5471			s3d2 = s3d2 ? s3d2 : testEl[0].style[transform[i]] == 'preserve-3d';
5472		};
5473
5474		// If browser has perspective capability and it is webkit, we must check it with this solution because Chrome can give false positive result if GPU acceleration is disabled
5475
5476        if (s3d1 && testEl[0].style[properties[4]] != undefined){
5477			testEl.attr('id','ls-test3d').appendTo( el );
5478            s3d1 = testEl[0].offsetHeight === 3 && testEl[0].offsetLeft === 9;
5479			testEl.remove();
5480        }
5481
5482        return (s3d1 && s3d2);
5483	};
5484
5485	// Order array function
5486
5487	var lsOrderArray = function(x,y,dir) {
5488		var i = [];
5489		if(dir=='forward'){
5490			for( var a=0; a<x;a++){
5491				for( var b=0; b<y; b++){
5492					i.push(a+b*x);
5493				}
5494			}
5495		}else{
5496			for( var a=x-1; a>-1;a--){
5497				for( var b=y-1; b>-1; b--){
5498					i.push(a+b*x);
5499				}
5500			}
5501		}
5502		return i;
5503	};
5504
5505	// CountProp counts the properties in an object
5506
5507	var lsCountProp = function(obj) {
5508	    var count = 0;
5509
5510	    for(var prop in obj) {
5511	        if(obj.hasOwnProperty(prop)){
5512	            ++count;
5513			}
5514	    }
5515	    return count;
5516	};
5517
5518	// We need the browser function (removed from jQuery 1.9)
5519
5520	var lsBrowser = function(){
5521
5522		uaMatch = function( ua ) {
5523			ua = ua.toLowerCase();
5524
5525			var match = /(edge)([\/\w.]+)/.exec( ua ) ||
5526       /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
5527				/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
5528				/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
5529				/(msie) ([\w.]+)/.exec( ua ) ||
5530				ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
5531				[];
5532
5533			return {
5534				browser: match[ 1 ] || "",
5535				version: match[ 2 ] || "0"
5536			};
5537		};
5538
5539		var matched = uaMatch( navigator.userAgent ), browser = {};
5540
5541		if ( matched.browser ) {
5542			browser[ matched.browser ] = true;
5543			browser.version = matched.version;
5544		}
5545
5546		if ( browser.chrome ) {
5547			browser.webkit = true;
5548		} else if ( browser.webkit ) {
5549			browser.safari = true;
5550		}
5551
5552		return browser;
5553	};
5554
5555	var lsPrefixes = function(obj, method){
5556
5557		var pfx = ['webkit', 'khtml', 'moz', 'ms', 'o', ''];
5558		var p = 0, m, t;
5559		while (p < pfx.length && !obj[m]) {
5560			m = method;
5561			if (pfx[p] == '') {
5562				m = m.substr(0,1).toLowerCase() + m.substr(1);
5563			}
5564			m = pfx[p] + m;
5565			t = typeof obj[m];
5566			if (t != 'undefined') {
5567				pfx = [pfx[p]];
5568				return (t == 'function' ? obj[m]() : obj[m]);
5569			}
5570			p++;
5571		}
5572	};
5573
5574	// Global parameters (Do not change these settings!)
5575
5576	layerSlider.global = {
5577
5578		version				: '5.x',
5579
5580		isMobile			: function(){
5581								if( navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i) ){
5582									return true;
5583								}else{
5584									return false;
5585								}
5586							},
5587		isHideOn3D			: function(el){
5588								if( el.css('padding-bottom') == 'auto' || el.css('padding-bottom') == 'none' || el.css('padding-bottom') == 0 || el.css('padding-bottom') == '0px' ){
5589									return true;
5590								}else{
5591									return false;
5592								}
5593							},
5594
5595		ie78				: lsBrowser().msie && lsBrowser().version < 9 || lsBrowser().edge ? true : false,
5596		originalAutoStart	: false,
5597		paused				: false,
5598		pausedByVideo		: false,
5599		autoSlideshow		: false,
5600		isAnimating			: false,
5601		layersNum			: null,
5602		prevNext			: 'next',
5603		slideTimer			: null,
5604		sliderWidth			: null,
5605		sliderHeight		: null,
5606		numYouTubeCurslide	: 0,
5607		slideDirections		: {
5608								prev : {
5609									left	: 'right',
5610									right	: 'left',
5611									top		: 'bottom',
5612									bottom	: 'top'
5613								},
5614								next : {
5615									left	: 'left',
5616									right	: 'right',
5617									top		: 'top',
5618									bottom	: 'bottom'
5619								}
5620							},
5621
5622		// Default delay time, fadeout and fadein durations of videoPreview images
5623
5624		v					: {
5625								d	: 500,
5626								fo	: 750,
5627								fi	: 500
5628							}
5629	};
5630
5631	// Layer Transition Defaults
5632
5633	layerSlider.layerTransitions = {
5634
5635		offsetXIn			: 80,
5636		offsetYIn			: 0,
5637		durationIn			: 1000,
5638		delayIn				: 0,
5639		easingIn			: 'easeInOutQuint',
5640		fadeIn				: true,
5641		rotateIn			: 0,
5642		rotateXIn			: 0,
5643		rotateYIn			: 0,
5644		scaleIn				: 1,
5645		scaleXIn			: 1,
5646		scaleYIn			: 1,
5647		skewXIn				: 0,
5648		skewYIn				: 0,
5649		transformOriginIn	: ['50%','50%','0'],
5650		perspectiveIn 		: 500,
5651		splitIn				: '',
5652		shiftIn				: 50,
5653		clipIn				: '',
5654
5655		offsetXOut			: -80,
5656		offsetYOut			: 0,
5657		durationOut			: 400,
5658		showUntil			: 0,
5659		easingOut			: 'easeInOutQuint',
5660		fadeOut				: true,
5661		rotateOut			: 0,
5662		rotateXOut			: 0,
5663		rotateYOut			: 0,
5664		scaleOut			: 1,
5665		scaleXOut			: 1,
5666		scaleYOut			: 1,
5667		skewXOut			: 0,
5668		skewYOut			: 0,
5669		transformOriginOut	: ['50%','50%','0'],
5670		perspectiveOut 		: 500,
5671		splitOut			: '',
5672		shiftOut			: 50,
5673		clipOut				: ''
5674	};
5675
5676	layerSlider.slideTransitions = {
5677
5678		slideDelay			: 4000							// Time before the next slide will be loading.
5679	};
5680
5681	// Global settings (can be modified)
5682
5683	layerSlider.options = {
5684
5685		// Layout
5686
5687		responsive			: true,
5688		responsiveUnder		: 0,
5689		layersContainer		: 0,
5690		fullPage			: false,
5691		appendTo			: '',						// NEW FEATURE 5.5.0
5692
5693		// Slideshow
5694
5695		autoStart			: true,
5696		startInViewport		: true,						// NEW FEATURE v5.2.0
5697		pauseOnHover		: true,
5698		firstSlide			: 1,
5699		animateFirstSlide	: true,
5700		sliderFadeInDuration: 350,						// NEW FEATURE v5.2.0
5701		loops				: 0,
5702		forceLoopNum		: true,
5703		twoWaySlideshow		: false,
5704		randomSlideshow		: false,
5705
5706		// Appearance
5707
5708		skin				: 'v5',
5709		skinsPath			: '/layerslider/skins/',
5710		globalBGColor		: 'transparent',
5711		globalBGImage		: false,
5712		globalBGPosition: '0 0',
5713		globalBGSize: 'auto',
5714		globalBGRepeat: 'no-repeat',
5715		globalBGBehaviour: 'scroll',
5716
5717
5718		// Navigation Area
5719
5720		navPrevNext			: true,
5721		navStartStop		: true,
5722		navButtons			: true,
5723		keybNav				: true,
5724		touchNav			: true,
5725		hoverPrevNext		: true,
5726		hoverBottomNav		: false,
5727		showBarTimer		: false,
5728		showCircleTimer		: true,
5729
5730		// Thumbnail navigation
5731
5732		thumbnailNavigation	: 'hover',
5733		tnContainerWidth	: '60%',
5734		tnWidth				: 100,
5735		tnHeight			: 60,
5736		tnActiveOpacity		: 35,
5737		tnInactiveOpacity	: 100,
5738
5739		// Parallax
5740
5741		parallaxType: 'mouse',
5742		slideParallax: 0,
5743		parallaxOrigin: 'top',
5744		parallaxScrollDuration: 0,
5745		parallaxScrollOnMobile: false,
5746
5747		// Videos
5748
5749		autoPlayVideos		: true,
5750		autoPauseSlideshow	: 'auto',
5751		youtubePreview		: 'maxresdefault.jpg',
5752
5753		// Preload
5754
5755		imgPreload			: true,
5756		lazyLoad 			: true,
5757
5758		// YourLogo
5759
5760		yourLogo			: false,
5761		yourLogoStyle		: 'left: -10px; top: -10px;',
5762		yourLogoLink		: false,
5763		yourLogoTarget		: '_self',
5764
5765		// Optimize for IE7 and IE8
5766
5767		optimizeForMobile	: true,
5768		optimizeForIE78		: true,
5769
5770		// NEW FEATURES 5.2.0 Mobile features
5771
5772		hideOnMobile		: false,
5773		hideUnder			: 0,
5774		hideOver			: 1000000,
5775
5776		staticImage			: '', // will be available in 6.0.0
5777
5778		// API functions
5779
5780		cbInit				: function(element){},
5781		cbStart				: function(data){},
5782		cbStop				: function(data){},
5783		cbPause				: function(data){},
5784		cbAnimStart			: function(data){},
5785		cbAnimStop			: function(data){},
5786		cbPrev				: function(data){},
5787		cbNext				: function(data){},
5788
5789		// !!! IMPORTANT !!! The following properties are deprecated from version 5.0.0 DO NOT USE THEM.
5790		// The slider will recognize these properties in the init code or if you add these properties into the style attribute of the layer
5791		// but we recommend you to use to new html5 data attribute (data-ls) with the new properties
5792
5793		slideDelay			: 4000,
5794		slideDirection		: 'right',
5795		parallaxIn			: .45,
5796		parallaxOut			: .45,
5797		durationIn			: 1000,
5798		durationOut			: 1000,
5799		easingIn			: 'easeInOutQuint',
5800		easingOut			: 'easeInOutQuint',
5801		delayIn				: 0,
5802		delayOut			: 0
5803	};
5804})(window.jq183||jQuery);
5805
5806jQuery(function($) {
5807	$(function() {
5808
5809		var $a = $('a[target=ls-gallery]:first, .ls-imagelightbox:first');
5810		if ($a.length) {
5811			var path = $a.closest('.ls-container').data('LayerSlider').o.skinsPath.replace(/skins\/$/, '');
5812			var ver = $('script[src*=kreatura]').attr('src').match(/(\.min|)\.js\?v=([.0-9]*)$/);
5813			$('<link type="text/css" rel="stylesheet">')
5814				.appendTo(document.head)
5815				.attr('href', path+'css/lightgallery'+ver[1]+'.css?v='+ver[2]);
5816			$('<script>').load(function() {
5817				// init ls-gallery after lightgallery script loaded
5818				$('.ls-container').each(function() {
5819					var $ls = $(this);
5820					var $a = $ls.find('a[target=ls-gallery], .ls-imagelightbox');
5821					if ($a.length) {
5822						var sliderEl = [], slideEl = {};
5823						var startIndex = -$ls.find('.ls-lt-container').length;
5824
5825						$a.each(function() {
5826							var $this = $(this);
5827							var href = $this.attr('href') || $this.parent('a').attr('href');
5828							if (!href || href == '#') {
5829								$this.data('ls-gallery-index', sliderEl.length);
5830								sliderEl.push({
5831									src: $this.siblings('.ls-bg').data('src'),
5832									subHtml: this.title
5833								});
5834							} else {
5835								var i = startIndex + $this.closest('.ls-slide').index();
5836								slideEl[i] || (slideEl[i] = []);
5837								$this.data('ls-gallery-index', slideEl[i].length);
5838								slideEl[i].push({
5839									iframe: !href.match(/youtube|vimeo/i) && !href.match(/\.(jpe?g|gif|png|tiff|bmp)$/i),
5840									src: href,
5841									subHtml: this.title
5842								});
5843							}
5844							this.title = '';
5845						});
5846
5847						if (sliderEl.length) {
5848							$ls.lightGallery({ autoOpen: false, counter: false, download: false, dynamic: true, dynamicEl: sliderEl });
5849						}
5850						var i, $slide = $ls.find('.ls-slide');
5851						for (i in slideEl) {
5852							if (slideEl[i].length) {
5853								$slide.eq(i).lightGallery({ autoOpen: false, counter: false, download: false, iframeMaxWidth: '90%', dynamic: true, dynamicEl: slideEl[i] });
5854							}
5855						}
5856					}
5857				});
5858
5859				$(document.body).on('click', 'a[target=ls-gallery], .ls-imagelightbox', function(e) { // open LightGallery
5860					e.preventDefault();
5861					var $this = $(this);
5862					var href = $this.attr('href') || $this.parent('a').attr('href');
5863					var $lg = $this.closest(!href || href == '#' ? '.ls-container' : '.ls-slide');
5864					$lg.data('lightGallery').s.index = $this.data('ls-gallery-index');
5865					$lg.lightGallery();
5866				}).on('onBeforeOpen.lg', function(e) { // pause slider
5867					var $ls = $(e.target).closest('.ls-container'), ls = $ls.data('LayerSlider');
5868					ls.g.isLoading = true; // prevent left & right cursor
5869					if (ls.g.autoSlideshow) {
5870						$ls.data('ls-stopped', true);
5871						$ls.layerSlider('stop');
5872					}
5873				}).on('onCloseAfter.lg', function(e) { // resume slider
5874					var $ls = $(e.target).closest('.ls-container'), ls = $ls.data('LayerSlider');
5875					ls.g.isLoading = false;
5876					if ($ls.data('ls-stopped')) {
5877						$ls.removeData('ls-stopped');
5878						$ls.layerSlider('start');
5879					}
5880				});
5881
5882			}).appendTo(document.head)
5883				.attr('src', path+'js/lightgallery'+ver[1]+'.js?v='+ver[2]);
5884		}
5885
5886	});
5887});

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.