PageSourceSearch

https://www.partymixtv.ro/wp-content/themes/flex-mag/js/scripts.js?ver=6.1.7

js partymixtv.ro collected 2026-10-07 20:03:21 UTC 151,018 bytes, 3,907 lines download raw bytes

1jQuery(document).ready(function($) {
2"use strict";
3
4  	// Sticky Navigation
5
6  	$(window).load(function(){
7	var aboveHeight = $('#head-main-top').outerHeight();
8	    $(window).scroll(function(){
9	    	if ($(window).scrollTop() > aboveHeight){
10	    		$('#main-nav-wrap').addClass('fixed').css('top','0');
11	    		$('.nav-logo-fade').addClass('nav-logo-show');
12	    		$('.nav-logo-out').addClass('nav-logo-out-fade');
13	    		$('.nav-logo-in').addClass('nav-logo-in-fade');
14	    		$('.nav-left-wrap').addClass('nav-left-width');
15	    		$('#wallpaper').addClass('wall-fixed');
16	    		$('.col-tabs-wrap').addClass('fixed-col').css('top','50px');
17	    		$('#body-main-wrap').addClass('tabs-top-marg');
18	    		$('#body-main-wrap').addClass('body-top-pad');
19	    		$('.fly-to-top').addClass('to-top-trans');
20	    	} else {
21	    		$('#main-nav-wrap').removeClass('fixed');
22	    		$('.nav-logo-fade').removeClass('nav-logo-show');
23	    		$('.nav-logo-out').removeClass('nav-logo-out-fade');
24	    		$('.nav-logo-in').removeClass('nav-logo-in-fade');
25	    		$('.nav-left-wrap').removeClass('nav-left-width');
26	    		$('#wallpaper').removeClass('wall-fixed');
27	    		$('.col-tabs-wrap').removeClass('fixed-col').css('top','0');
28	    		$('#body-main-wrap').removeClass('tabs-top-marg');
29	    		$('#body-main-wrap').removeClass('body-top-pad');
30	    		$('.fly-to-top').removeClass('to-top-trans');
31	    	}
32		});
33	});
34
35
36  	// Fly-Out Navigation
37
38	$(".fly-but-wrap").on('click', function(){
39		$("#fly-wrap").toggleClass("fly-menu");
40  		$("#head-main-top").toggleClass("fly-content");
41  		$("#wallpaper").toggleClass("fly-content");
42  		$(".col-tabs-wrap").toggleClass("fly-content");
43  		$("#main-nav-wrap").toggleClass("main-nav-over");
44  		$("#soc-nav-wrap").toggleClass("fly-content");
45  		$("#body-main-wrap").toggleClass("fly-content");
46  		$(".fly-but-wrap").toggleClass("fly-open");
47  		$(".fly-fade").toggleClass("fly-fade-trans");
48	});
49
50	// Back to Top Button
51    	var duration = 500;
52    	$('.back-to-top').on('click', function(event) {
53          event.preventDefault();
54          $('html, body').animate({scrollTop: 0}, duration);
55          return false;
56    	});
57
58 	// Search Toggle
59 	$(".nav-search-but").on('click', function(){
60 	  $(".search-fly-wrap").slideToggle();
61  	});
62
63	// Columns Toggle
64
65	$('#site-wrap').each(function() {
66		$(this).find("ul.col-tabs li.feat-col-tab").addClass("active").show(); //Activate first tab
67	});
68
69	$("ul.col-tabs li").on('click', function(e) {
70		$(this).parents('#site-wrap').find("ul.col-tabs li").removeClass("active"); //Remove any "active" class
71		$(this).addClass("active"); //Add "active" class to selected tab
72		$(this).parents('#site-wrap').find(".tab-col-cont").hide(); //Hide all tab content
73
74		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
75		$(this).parents('#site-wrap').find(activeTab).fadeIn(); //Fade in the active ID content
76
77        $('html, body').animate({scrollTop: 0}, duration);
78        return false;
79
80		e.preventDefault();
81	});
82
83	$("ul.col-tabs li a").on('click', function(e) {
84		e.preventDefault();
85	})
86
87	$(".non-feat-tab").on('click', function(e) {
88		$("#feat-top-wrap").hide();
89		$("#feat-wide-wrap").hide();
90	});
91
92	$(".feat-col-tab").on('click', function(e) {
93		$("#feat-top-wrap").fadeIn();
94		$("#feat-wide-wrap").fadeIn();
95	});
96
97});
98
99
100	// Scoreboard
101
102(function( window, $, undefined ) {
103
104	$.fn.touchwipe 				= function(settings) {
105
106		var config = {
107			min_move_x: 20,
108			min_move_y: 20,
109			wipeLeft: function() { },
110			wipeRight: function() { },
111			wipeUp: function() { },
112			wipeDown: function() { },
113			preventDefaultEvents: true
114		};
115
116		if (settings) $.extend(config, settings);
117
118		this.each(function() {
119			var startX;
120			var startY;
121			var isMoving = false;
122
123			function cancelTouch() {
124				this.removeEventListener('touchmove', onTouchMove);
125				startX = null;
126				isMoving = false;
127			}
128
129			function onTouchMove(e) {
130				if(config.preventDefaultEvents) {
131					e.preventDefault();
132				}
133				if(isMoving) {
134					var x = e.touches[0].pageX;
135					var y = e.touches[0].pageY;
136					var dx = startX - x;
137					var dy = startY - y;
138					if(Math.abs(dx) >= config.min_move_x) {
139						cancelTouch();
140						if(dx > 0) {
141							config.wipeLeft();
142						}
143						else {
144							config.wipeRight();
145						}
146					}
147					else if(Math.abs(dy) >= config.min_move_y) {
148						cancelTouch();
149						if(dy > 0) {
150							config.wipeDown();
151						}
152						else {
153							config.wipeUp();
154						}
155					}
156				}
157			}
158
159			function onTouchStart(e)
160			{
161				if (e.touches.length == 1) {
162					startX = e.touches[0].pageX;
163					startY = e.touches[0].pageY;
164					isMoving = true;
165					this.addEventListener('touchmove', onTouchMove, false);
166				}
167			}
168			if ('ontouchstart' in document.documentElement) {
169				this.addEventListener('touchstart', onTouchStart, false);
170			}
171		});
172
173		return this;
174	};
175
176	$.elastislide 				= function( options, element ) {
177		this.$el	= $( element );
178		this._init( options );
179	};
180
181	$.elastislide.defaults 		= {
182		speed		: 450,	// animation speed
183		easing		: '',	// animation easing effect
184		imageW		: 190,	// the images width
185		margin		: 0,	// image margin right
186		border		: 0,	// image border
187		minItems	: 1,	// the minimum number of items to show.
188							// when we resize the window, this will make sure minItems are always shown
189							// (unless of course minItems is higher than the total number of elements)
190		current		: 0,	// index of the current item
191							// when we resize the window, the carousel will make sure this item is visible
192		onClick		: function() { return false; } // click item callback
193    };
194
195	$.elastislide.prototype 	= {
196		_init 				: function( options ) {
197
198			this.options 		= $.extend( true, {}, $.elastislide.defaults, options );
199
200			// <ul>
201			this.$slider		= this.$el.find('ul');
202
203			// <li>
204			this.$items			= this.$slider.children('li');
205
206			// total number of elements / images
207			this.itemsCount		= this.$items.length;
208
209			// cache the <ul>'s parent, since we will eventually need to recalculate its width on window resize
210			this.$esCarousel	= this.$slider.parent();
211
212			// validate options
213			this._validateOptions();
214
215			// set sizes and initialize some vars...
216			this._configure();
217
218			// add navigation buttons
219			this._addControls();
220
221			// initialize the events
222			this._initEvents();
223
224			// show the <ul>
225			this.$slider.show();
226
227			// slide to current's position
228			this._slideToCurrent( false );
229
230		},
231		_validateOptions	: function() {
232
233			if( this.options.speed < 0 )
234				this.options.speed = 450;
235			if( this.options.margin < 0 )
236				this.options.margin = 4;
237			if( this.options.border < 0 )
238				this.options.border = 1;
239			if( this.options.minItems < 1 || this.options.minItems > this.itemsCount )
240				this.options.minItems = 1;
241			if( this.options.current > this.itemsCount - 1 )
242				this.options.current = 0;
243
244		},
245		_configure			: function() {
246
247			// current item's index
248			this.current		= this.options.current;
249
250			// the ul's parent's (div.es-carousel) width is the "visible" width
251			this.visibleWidth	= this.$esCarousel.width();
252
253			// test to see if we need to initially resize the items
254			if( this.visibleWidth < this.options.minItems * ( this.options.imageW + 2 * this.options.border ) + ( this.options.minItems - 1 ) * this.options.margin ) {
255				this._setDim( ( this.visibleWidth - ( this.options.minItems - 1 ) * this.options.margin ) / this.options.minItems );
256				this._setCurrentValues();
257				// how many items fit with the current width
258				this.fitCount	= this.options.minItems;
259			}
260			else {
261				this._setDim();
262				this._setCurrentValues();
263			}
264
265			// set the <ul> width
266			this.$slider.css({
267				width	: this.sliderW
268			});
269
270		},
271		_setDim				: function( elW ) {
272
273			// <li> style
274			this.$items.css({
275				marginRight	: this.options.margin,
276				width		: ( elW ) ? elW : this.options.imageW + 2 * this.options.border
277			}).children('a').css({ // <a> style
278				borderWidth		: this.options.border
279			});
280
281		},
282		_setCurrentValues	: function() {
283
284			// the total space occupied by one item
285			this.itemW			= this.$items.outerWidth(true);
286
287			// total width of the slider / <ul>
288			// this will eventually change on window resize
289			this.sliderW		= this.itemW * this.itemsCount;
290
291			// the ul parent's (div.es-carousel) width is the "visible" width
292			this.visibleWidth	= this.$esCarousel.width();
293
294			// how many items fit with the current width
295			this.fitCount		= Math.floor( this.visibleWidth / this.itemW );
296
297		},
298		_addControls		: function() {
299
300			this.$navNext	= $('<span class="es-nav-next"><a>&gt;</a></span>');
301			this.$navPrev	= $('<span class="es-nav-prev"><a>&lt;</a></span>');
302			$('<div class="es-nav"/>')
303			.append( this.$navPrev )
304			.append( this.$navNext )
305			.appendTo( this.$el );
306
307			//this._toggleControls();
308
309		},
310		_toggleControls		: function( dir, status ) {
311
312			// show / hide navigation buttons
313			if( dir && status ) {
314				if( status === 1 )
315					( dir === 'right' ) ? this.$navNext.show() : this.$navPrev.show();
316				else
317					( dir === 'right' ) ? this.$navNext.hide() : this.$navPrev.hide();
318			}
319			else if( this.current === this.itemsCount - 1 || this.fitCount >= this.itemsCount )
320					this.$navNext.hide();
321
322		},
323		_initEvents			: function() {
324
325			var instance	= this;
326
327			// window resize
328			$(window).bind('resize.elastislide', function( event ) {
329
330				// set values again
331				instance._setCurrentValues();
332
333				// need to resize items
334				if( instance.visibleWidth < instance.options.minItems * ( instance.options.imageW + 2 * instance.options.border ) + ( instance.options.minItems - 1 ) * instance.options.margin ) {
335					instance._setDim( ( instance.visibleWidth - ( instance.options.minItems - 1 ) * instance.options.margin ) / instance.options.minItems );
336					instance._setCurrentValues();
337					instance.fitCount	= instance.options.minItems;
338				}
339				else{
340					instance._setDim();
341					instance._setCurrentValues();
342				}
343
344				instance.$slider.css({
345					width	: instance.sliderW + 10 // TODO: +10px seems to solve a firefox "bug" :S
346				});
347
348				// slide to the current element
349				clearTimeout( instance.resetTimeout );
350				instance.resetTimeout	= setTimeout(function() {
351					instance._slideToCurrent();
352				}, 200);
353
354			});
355
356			// navigation buttons events
357			this.$navNext.bind('click.elastislide', function( event ) {
358				instance._slide('right');
359			});
360
361			this.$navPrev.bind('click.elastislide', function( event ) {
362				instance._slide('left');
363			});
364
365			// item click event
366			this.$items.bind('click.elastislide', function( event ) {
367				instance.options.onClick( $(this) );
368				//return false;
369			});
370
371			// touch events
372			instance.$slider.touchwipe({
373				wipeLeft			: function() {
374					instance._slide('right');
375				},
376				wipeRight			: function() {
377					instance._slide('left');
378				}
379			});
380
381		},
382		_slide				: function( dir, val, anim, callback ) {
383
384			// if animating return
385			if( this.$slider.is(':animated') )
386				return false;
387
388			// current margin left
389			var ml		= parseFloat( this.$slider.css('margin-left') );
390
391			// val is just passed when we want an exact value for the margin left (used in the _slideToCurrent function)
392			if( val === undefined ) {
393
394				// how much to slide?
395				var amount	= this.fitCount * this.itemW, val;
396
397				if( amount < 0 ) return false;
398
399				// make sure not to leave a space between the last item / first item and the end / beggining of the slider available width
400				if( dir === 'right' && this.sliderW - ( Math.abs( ml ) + amount ) < this.visibleWidth ) {
401					amount	= this.sliderW - ( Math.abs( ml ) + this.visibleWidth ) - this.options.margin; // decrease the margin left
402					// show / hide navigation buttons
403					this._toggleControls( 'right', -1 );
404					this._toggleControls( 'left', 1 );
405				}
406				else if( dir === 'left' && Math.abs( ml ) - amount < 0 ) {
407					amount	= Math.abs( ml );
408					// show / hide navigation buttons
409					this._toggleControls( 'left', -1 );
410					this._toggleControls( 'right', 1 );
411				}
412				else {
413					var fml; // future margin left
414					( dir === 'right' )
415						? fml = Math.abs( ml ) + this.options.margin + Math.abs( amount )
416						: fml = Math.abs( ml ) - this.options.margin - Math.abs( amount );
417
418					// show / hide navigation buttons
419					if( fml > 0 )
420						this._toggleControls( 'left', 1 );
421					else
422						this._toggleControls( 'left', -1 );
423
424					if( fml < this.sliderW - this.visibleWidth )
425						this._toggleControls( 'right', 1 );
426					else
427						this._toggleControls( 'right', -1 );
428
429				}
430
431				( dir === 'right' ) ? val = '-=' + amount : val = '+=' + amount
432
433			}
434			else {
435				var fml		= Math.abs( val ); // future margin left
436
437				if( Math.max( this.sliderW, this.visibleWidth ) - fml < this.visibleWidth ) {
438					val	= - ( Math.max( this.sliderW, this.visibleWidth ) - this.visibleWidth );
439					if( val !== 0 )
440						val += this.options.margin;	// decrease the margin left if not on the first position
441
442					// show / hide navigation buttons
443					this._toggleControls( 'right', -1 );
444					fml	= Math.abs( val );
445				}
446
447				// show / hide navigation buttons
448				if( fml > 0 )
449					this._toggleControls( 'left', 1 );
450				else
451					this._toggleControls( 'left', -1 );
452
453				if( Math.max( this.sliderW, this.visibleWidth ) - this.visibleWidth > fml + this.options.margin )
454					this._toggleControls( 'right', 1 );
455				else
456					this._toggleControls( 'right', -1 );
457
458			}
459
460			$.fn.applyStyle = ( anim === undefined ) ? $.fn.animate : $.fn.css;
461
462			var sliderCSS	= { marginLeft : val };
463
464			var instance	= this;
465
466			this.$slider.applyStyle( sliderCSS, $.extend( true, [], { duration : this.options.speed, easing : this.options.easing, complete : function() {
467				if( callback ) callback.call();
468			} } ) );
469
470		},
471		_slideToCurrent		: function( anim ) {
472
473			// how much to slide?
474			var amount	= this.current * this.itemW;
475			this._slide('', -amount, anim );
476
477		},
478		add					: function( $newelems, callback ) {
479
480			// adds new items to the carousel
481			this.$items 		= this.$items.add( $newelems );
482			this.itemsCount		= this.$items.length;
483			this._setDim();
484			this._setCurrentValues();
485			this.$slider.css({
486				width	: this.sliderW
487			});
488			this._slideToCurrent();
489
490			if ( callback ) callback.call( $newelems );
491
492		},
493		destroy				: function( callback ) {
494			this._destroy( callback );
495		},
496		_destroy 			: function( callback ) {
497			this.$el.unbind('.elastislide').removeData('elastislide');
498			$(window).unbind('.elastislide');
499			if ( callback ) callback.call();
500		}
501	};
502
503	var logError 				= function( message ) {
504		if ( this.console ) {
505			console.error( message );
506		}
507	};
508
509	$.fn.elastislide 				= function( options ) {
510		if ( typeof options === 'string' ) {
511			var args = Array.prototype.slice.call( arguments, 1 );
512
513			this.each(function() {
514				var instance = $.data( this, 'elastislide' );
515				if ( !instance ) {
516					logError( "cannot call methods on elastislide prior to initialization; " +
517					"attempted to call method '" + options + "'" );
518					return;
519				}
520				if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
521					logError( "no such method '" + options + "' for elastislide instance" );
522					return;
523				}
524				instance[ options ].apply( instance, args );
525			});
526		}
527		else {
528			this.each(function() {
529				var instance = $.data( this, 'elastislide' );
530				if ( !instance ) {
531					$.data( this, 'elastislide', new $.elastislide( options, this ) );
532				}
533			});
534		}
535		return this;
536	};
537
538})( window, jQuery );
539
540	// Nicescroll
541
542(function(jQuery){
543
544  // globals
545  var domfocus = false;
546  var mousefocus = false;
547  var zoomactive = false;
548  var tabindexcounter = 5000;
549  var ascrailcounter = 2000;
550  var globalmaxzindex = 0;
551
552  var $ = jQuery;  // sandbox
553
554  // http://stackoverflow.com/questions/2161159/get-script-path
555  function getScriptPath() {
556    var scripts=document.getElementsByTagName('script');
557    var path=scripts[scripts.length-1].src.split('?')[0];
558    return (path.split('/').length>0) ? path.split('/').slice(0,-1).join('/')+'/' : '';
559  }
560  var scriptpath = getScriptPath();
561
562  var vendors = ['ms','moz','webkit','o'];
563
564  var setAnimationFrame = window.requestAnimationFrame||false;
565  var clearAnimationFrame = window.cancelAnimationFrame||false;
566
567  if (!setAnimationFrame) {
568    for(var vx in vendors) {
569      var v = vendors[vx];
570      if (!setAnimationFrame) setAnimationFrame = window[v+'RequestAnimationFrame'];
571      if (!clearAnimationFrame) clearAnimationFrame = window[v+'CancelAnimationFrame']||window[v+'CancelRequestAnimationFrame'];
572    }
573  }
574
575  var clsMutationObserver = window.MutationObserver || window.WebKitMutationObserver || false;
576
577  var _globaloptions = {
578      zindex:"auto",
579      cursoropacitymin:0,
580      cursoropacitymax:1,
581      cursorcolor:"#424242",
582      cursorwidth:"5px",
583      cursorborder:"1px solid #fff",
584      cursorborderradius:"5px",
585      scrollspeed:60,
586      mousescrollstep:8*3,
587      touchbehavior:false,
588      hwacceleration:true,
589      usetransition:true,
590      boxzoom:false,
591      dblclickzoom:true,
592      gesturezoom:true,
593      grabcursorenabled:true,
594      autohidemode:true,
595      background:"",
596      iframeautoresize:true,
597      cursorminheight:32,
598      preservenativescrolling:true,
599      railoffset:false,
600      bouncescroll:true,
601      spacebarenabled:true,
602      railpadding:{top:0,right:0,left:0,bottom:0},
603      disableoutline:true,
604      horizrailenabled:true,
605      railalign:"right",
606      railvalign:"bottom",
607      enabletranslate3d:true,
608      enablemousewheel:true,
609      enablekeyboard:true,
610      smoothscroll:true,
611      sensitiverail:true,
612      enablemouselockapi:true,
613//      cursormaxheight:false,
614      cursorfixedheight:false,
615      directionlockdeadzone:6,
616      hidecursordelay:400,
617      nativeparentscrolling:true,
618      enablescrollonselection:true,
619      overflowx:true,
620      overflowy:true,
621      cursordragspeed:0.3,
622      rtlmode:false,
623      cursordragontouch:false,
624      oneaxismousemode:"auto"
625  }
626
627  var browserdetected = false;
628
629  var getBrowserDetection = function() {
630
631    if (browserdetected) return browserdetected;
632
633    var domtest = document.createElement('DIV');
634
635    var d = {};
636
637		d.haspointerlock = "pointerLockElement" in document || "mozPointerLockElement" in document || "webkitPointerLockElement" in document;
638
639    d.isopera = ("opera" in window);
640    d.isopera12 = (d.isopera&&("getUserMedia" in navigator));
641    d.isoperamini = (Object.prototype.toString.call(window.operamini) === "[object OperaMini]");
642
643    d.isie = (("all" in document) && ("attachEvent" in domtest) && !d.isopera);
644    d.isieold = (d.isie && !("msInterpolationMode" in domtest.style));  // IE6 and older
645    d.isie7 = d.isie&&!d.isieold&&(!("documentMode" in document)||(document.documentMode==7));
646    d.isie8 = d.isie&&("documentMode" in document)&&(document.documentMode==8);
647    d.isie9 = d.isie&&("performance" in window)&&(document.documentMode>=9);
648    d.isie10 = d.isie&&("performance" in window)&&(document.documentMode>=10);
649
650    d.isie9mobile = /iemobile.9/i.test(navigator.userAgent);  //wp 7.1 mango
651    if (d.isie9mobile) d.isie9 = false;
652    d.isie7mobile = (!d.isie9mobile&&d.isie7) && /iemobile/i.test(navigator.userAgent);  //wp 7.0
653
654    d.ismozilla = ("MozAppearance" in domtest.style);
655
656    d.iswebkit = ("WebkitAppearance" in domtest.style);
657
658    d.ischrome = ("chrome" in window);
659		d.ischrome22 = (d.ischrome&&d.haspointerlock);
660    d.ischrome26 = (d.ischrome&&("transition" in domtest.style));  // issue with transform detection (maintain prefix)
661
662    d.cantouch = ("ontouchstart" in document.documentElement)||("ontouchstart" in window);  // detection for Chrome Touch Emulation
663    d.hasmstouch = (window.navigator.msPointerEnabled||false);  // IE10+ pointer events
664
665    d.ismac = /^mac$/i.test(navigator.platform);
666
667    d.isios = (d.cantouch && /iphone|ipad|ipod/i.test(navigator.platform));
668    d.isios4 = ((d.isios)&&!("seal" in Object));
669
670    d.isandroid = (/android/i.test(navigator.userAgent));
671
672    d.trstyle = false;
673    d.hastransform = false;
674    d.hastranslate3d = false;
675    d.transitionstyle = false;
676    d.hastransition = false;
677    d.transitionend = false;
678
679    var check = ['transform','msTransform','webkitTransform','MozTransform','OTransform'];
680    for(var a=0;a<check.length;a++){
681      if (typeof domtest.style[check[a]] != "undefined") {
682        d.trstyle = check[a];
683        break;
684      }
685    }
686    d.hastransform = (d.trstyle != false);
687    if (d.hastransform) {
688      domtest.style[d.trstyle] = "translate3d(1px,2px,3px)";
689      d.hastranslate3d = /translate3d/.test(domtest.style[d.trstyle]);
690    }
691
692    d.transitionstyle = false;
693    d.prefixstyle = '';
694    d.transitionend = false;
695    var check = ['transition','webkitTransition','MozTransition','OTransition','OTransition','msTransition','KhtmlTransition'];
696    var prefix = ['','-webkit-','-moz-','-o-','-o','-ms-','-khtml-'];
697    var evs = ['transitionend','webkitTransitionEnd','transitionend','otransitionend','oTransitionEnd','msTransitionEnd','KhtmlTransitionEnd'];
698    for(var a=0;a<check.length;a++) {
699      if (check[a] in domtest.style) {
700        d.transitionstyle = check[a];
701        d.prefixstyle = prefix[a];
702        d.transitionend = evs[a];
703        break;
704      }
705    }
706    if (d.ischrome26) {  // use always prefix
707      d.prefixstyle = prefix[1];
708    }
709
710    d.hastransition = (d.transitionstyle);
711
712    function detectCursorGrab() {
713      var lst = ['-moz-grab','-webkit-grab','grab'];
714      if ((d.ischrome&&!d.ischrome22)||d.isie) lst=[];  // force setting for IE returns false positive and chrome cursor bug
715      for(var a=0;a<lst.length;a++) {
716        var p = lst[a];
717        domtest.style['cursor']=p;
718        if (domtest.style['cursor']==p) return p;
719      }
720      return 'url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize';  // thank you google for custom cursor!
721    }
722    d.cursorgrabvalue = detectCursorGrab();
723
724    d.hasmousecapture = ("setCapture" in domtest);
725
726    d.hasMutationObserver = (clsMutationObserver !== false);
727
728    domtest = null;  //memory released
729
730    browserdetected = d;
731
732    return d;
733  }
734
735  var NiceScrollClass = function(myopt,me) {
736
737    var self = this;
738
739    this.version = '3.5.0 BETA5';
740    this.name = 'nicescroll';
741
742    this.me = me;
743
744    this.opt = {
745      doc:$("body"),
746      win:false
747    };
748
749    $.extend(this.opt,_globaloptions);
750
751// Options for internal use
752    this.opt.snapbackspeed = 80;
753
754    if (myopt||false) {
755      for(var a in self.opt) {
756        if (typeof myopt[a] != "undefined") self.opt[a] = myopt[a];
757      }
758    }
759
760    this.doc = self.opt.doc;
761    this.iddoc = (this.doc&&this.doc[0])?this.doc[0].id||'':'';
762    this.ispage = /BODY|HTML/.test((self.opt.win)?self.opt.win[0].nodeName:this.doc[0].nodeName);
763    this.haswrapper = (self.opt.win!==false);
764    this.win = self.opt.win||(this.ispage?$(window):this.doc);
765    this.docscroll = (this.ispage&&!this.haswrapper)?$(window):this.win;
766    this.body = $("body");
767    this.viewport = false;
768
769    this.isfixed = false;
770
771    this.iframe = false;
772    this.isiframe = ((this.doc[0].nodeName == 'IFRAME') && (this.win[0].nodeName == 'IFRAME'));
773
774    this.istextarea = (this.win[0].nodeName == 'TEXTAREA');
775
776    this.forcescreen = false; //force to use screen position on events
777
778    this.canshowonmouseevent = (self.opt.autohidemode!="scroll");
779
780// Events jump table
781    this.onmousedown = false;
782    this.onmouseup = false;
783    this.onmousemove = false;
784    this.onmousewheel = false;
785    this.onkeypress = false;
786    this.ongesturezoom = false;
787    this.onclick = false;
788
789// Nicescroll custom events
790    this.onscrollstart = false;
791    this.onscrollend = false;
792    this.onscrollcancel = false;
793
794    this.onzoomin = false;
795    this.onzoomout = false;
796
797// Let's start!
798    this.view = false;
799    this.page = false;
800
801    this.scroll = {x:0,y:0};
802    this.scrollratio = {x:0,y:0};
803    this.cursorheight = 20;
804    this.scrollvaluemax = 0;
805
806    this.checkrtlmode = false;
807
808    this.scrollrunning = false;
809
810    this.scrollmom = false;
811
812    this.observer = false;
813    this.observerremover = false;  // observer on parent for remove detection
814
815    do {
816      this.id = "ascrail"+(ascrailcounter++);
817    } while (document.getElementById(this.id));
818
819    this.rail = false;
820    this.cursor = false;
821    this.cursorfreezed = false;
822    this.selectiondrag = false;
823
824    this.zoom = false;
825    this.zoomactive = false;
826
827    this.hasfocus = false;
828    this.hasmousefocus = false;
829
830    this.visibility = true;
831    this.locked = false;
832    this.hidden = false; // rails always hidden
833    this.cursoractive = true; // user can interact with cursors
834
835    this.overflowx = self.opt.overflowx;
836    this.overflowy = self.opt.overflowy;
837
838    this.nativescrollingarea = false;
839    this.checkarea = 0;
840
841    this.events = [];  // event list for unbind
842
843    this.saved = {};
844
845    this.delaylist = {};
846    this.synclist = {};
847
848    this.lastdeltax = 0;
849    this.lastdeltay = 0;
850
851    this.detected = getBrowserDetection();
852
853    var cap = $.extend({},this.detected);
854
855    this.canhwscroll = (cap.hastransform&&self.opt.hwacceleration);
856    this.ishwscroll = (this.canhwscroll&&self.haswrapper);
857
858    this.istouchcapable = false;  // desktop devices with touch screen support
859
860//## Check Chrome desktop with touch support
861    if (cap.cantouch&&cap.ischrome&&!cap.isios&&!cap.isandroid) {
862      this.istouchcapable = true;
863      cap.cantouch = false;  // parse normal desktop events
864    }
865
866//## Firefox 18 nightly build (desktop) false positive (or desktop with touch support)
867    if (cap.cantouch&&cap.ismozilla&&!cap.isios&&!cap.isandroid) {
868      this.istouchcapable = true;
869      cap.cantouch = false;  // parse normal desktop events
870    }
871
872//## disable MouseLock API on user request
873
874    if (!self.opt.enablemouselockapi) {
875      cap.hasmousecapture = false;
876      cap.haspointerlock = false;
877    }
878
879    this.delayed = function(name,fn,tm,lazy) {
880      var dd = self.delaylist[name];
881      var nw = (new Date()).getTime();
882      if (!lazy&&dd&&dd.tt) return false;
883      if (dd&&dd.tt) clearTimeout(dd.tt);
884      if (dd&&dd.last+tm>nw&&!dd.tt) {
885        self.delaylist[name] = {
886          last:nw+tm,
887          tt:setTimeout(function(){self.delaylist[name].tt=0;fn.call();},tm)
888        }
889      }
890      else if (!dd||!dd.tt) {
891        self.delaylist[name] = {
892          last:nw,
893          tt:0
894        }
895        setTimeout(function(){fn.call();},0);
896      }
897    };
898
899    this.debounced = function(name,fn,tm) {
900      var dd = self.delaylist[name];
901      var nw = (new Date()).getTime();
902      self.delaylist[name] = fn;
903      if (!dd) {
904        setTimeout(function(){var fn=self.delaylist[name];self.delaylist[name]=false;fn.call();},tm);
905      }
906    }
907
908    this.synched = function(name,fn) {
909
910      function requestSync() {
911        if (self.onsync) return;
912        setAnimationFrame(function(){
913          self.onsync = false;
914          for(name in self.synclist){
915            var fn = self.synclist[name];
916            if (fn) fn.call(self);
917            self.synclist[name] = false;
918          }
919        });
920        self.onsync = true;
921      };
922
923      self.synclist[name] = fn;
924      requestSync();
925      return name;
926    };
927
928    this.unsynched = function(name) {
929      if (self.synclist[name]) self.synclist[name] = false;
930    }
931
932    this.css = function(el,pars) {  // save & set
933      for(var n in pars) {
934        self.saved.css.push([el,n,el.css(n)]);
935        el.css(n,pars[n]);
936      }
937    };
938
939    this.scrollTop = function(val) {
940      return (typeof val == "undefined") ? self.getScrollTop() : self.setScrollTop(val);
941    };
942
943    this.scrollLeft = function(val) {
944      return (typeof val == "undefined") ? self.getScrollLeft() : self.setScrollLeft(val);
945    };
946
947// derived by by Dan Pupius www.pupius.net
948    BezierClass = function(st,ed,spd,p1,p2,p3,p4) {
949      this.st = st;
950      this.ed = ed;
951      this.spd = spd;
952
953      this.p1 = p1||0;
954      this.p2 = p2||1;
955      this.p3 = p3||0;
956      this.p4 = p4||1;
957
958      this.ts = (new Date()).getTime();
959      this.df = this.ed-this.st;
960    };
961    BezierClass.prototype = {
962      B2:function(t){ return 3*t*t*(1-t) },
963      B3:function(t){ return 3*t*(1-t)*(1-t) },
964      B4:function(t){ return (1-t)*(1-t)*(1-t) },
965      getNow:function(){
966        var nw = (new Date()).getTime();
967        var pc = 1-((nw-this.ts)/this.spd);
968        var bz = this.B2(pc) + this.B3(pc) + this.B4(pc);
969        return (pc<0) ? this.ed : this.st+Math.round(this.df*bz);
970      },
971      update:function(ed,spd){
972        this.st = this.getNow();
973        this.ed = ed;
974        this.spd = spd;
975        this.ts = (new Date()).getTime();
976        this.df = this.ed-this.st;
977        return this;
978      }
979    };
980
981    if (this.ishwscroll) {
982    // hw accelerated scroll
983      this.doc.translate = {x:0,y:0,tx:"0px",ty:"0px"};
984
985      //this one can help to enable hw accel on ios6 http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/
986      if (cap.hastranslate3d&&cap.isios) this.doc.css("-webkit-backface-visibility","hidden");  // prevent flickering http://stackoverflow.com/questions/3461441/
987
988      //derived from http://stackoverflow.com/questions/11236090/
989      function getMatrixValues() {
990        var tr = self.doc.css(cap.trstyle);
991        if (tr&&(tr.substr(0,6)=="matrix")) {
992          return tr.replace(/^.*\((.*)\)$/g, "$1").replace(/px/g,'').split(/, +/);
993        }
994        return false;
995      }
996
997      this.getScrollTop = function(last) {
998        if (!last) {
999          var mtx = getMatrixValues();
1000          if (mtx) return (mtx.length==16) ? -mtx[13] : -mtx[5];  //matrix3d 16 on IE10
1001          if (self.timerscroll&&self.timerscroll.bz) return self.timerscroll.bz.getNow();
1002        }
1003        return self.doc.translate.y;
1004      };
1005
1006      this.getScrollLeft = function(last) {
1007        if (!last) {
1008          var mtx = getMatrixValues();
1009          if (mtx) return (mtx.length==16) ? -mtx[12] : -mtx[4];  //matrix3d 16 on IE10
1010          if (self.timerscroll&&self.timerscroll.bh) return self.timerscroll.bh.getNow();
1011        }
1012        return self.doc.translate.x;
1013      };
1014
1015      if (document.createEvent) {
1016        this.notifyScrollEvent = function(el) {
1017          var e = document.createEvent("UIEvents");
1018          e.initUIEvent("scroll", false, true, window, 1);
1019          el.dispatchEvent(e);
1020        };
1021      }
1022      else if (document.fireEvent) {
1023        this.notifyScrollEvent = function(el) {
1024          var e = document.createEventObject();
1025          el.fireEvent("onscroll");
1026          e.cancelBubble = true;
1027        };
1028      }
1029      else {
1030        this.notifyScrollEvent = function(el,add) {}; //NOPE
1031      }
1032
1033      if (cap.hastranslate3d&&self.opt.enabletranslate3d) {
1034        this.setScrollTop = function(val,silent) {
1035          self.doc.translate.y = val;
1036          self.doc.translate.ty = (val*-1)+"px";
1037          self.doc.css(cap.trstyle,"translate3d("+self.doc.translate.tx+","+self.doc.translate.ty+",0px)");
1038          if (!silent) self.notifyScrollEvent(self.win[0]);
1039        };
1040        this.setScrollLeft = function(val,silent) {
1041          self.doc.translate.x = val;
1042          self.doc.translate.tx = (val*-1)+"px";
1043          self.doc.css(cap.trstyle,"translate3d("+self.doc.translate.tx+","+self.doc.translate.ty+",0px)");
1044          if (!silent) self.notifyScrollEvent(self.win[0]);
1045        };
1046      } else {
1047        this.setScrollTop = function(val,silent) {
1048          self.doc.translate.y = val;
1049          self.doc.translate.ty = (val*-1)+"px";
1050          self.doc.css(cap.trstyle,"translate("+self.doc.translate.tx+","+self.doc.translate.ty+")");
1051          if (!silent) self.notifyScrollEvent(self.win[0]);
1052        };
1053        this.setScrollLeft = function(val,silent) {
1054          self.doc.translate.x = val;
1055          self.doc.translate.tx = (val*-1)+"px";
1056          self.doc.css(cap.trstyle,"translate("+self.doc.translate.tx+","+self.doc.translate.ty+")");
1057          if (!silent) self.notifyScrollEvent(self.win[0]);
1058        };
1059      }
1060    } else {
1061    // native scroll
1062      this.getScrollTop = function() {
1063        return self.docscroll.scrollTop();
1064      };
1065      this.setScrollTop = function(val) {
1066        return self.docscroll.scrollTop(val);
1067      };
1068      this.getScrollLeft = function() {
1069        return self.docscroll.scrollLeft();
1070      };
1071      this.setScrollLeft = function(val) {
1072        return self.docscroll.scrollLeft(val);
1073      };
1074    }
1075
1076    this.getTarget = function(e) {
1077      if (!e) return false;
1078      if (e.target) return e.target;
1079      if (e.srcElement) return e.srcElement;
1080      return false;
1081    };
1082
1083    this.hasParent = function(e,id) {
1084      if (!e) return false;
1085      var el = e.target||e.srcElement||e||false;
1086      while (el && el.id != id) {
1087        el = el.parentNode||false;
1088      }
1089      return (el!==false);
1090    };
1091
1092    function getZIndex() {
1093      var dom = self.win;
1094      if ("zIndex" in dom) return dom.zIndex();  // use jQuery UI method when available
1095      while (dom.length>0) {
1096        if (dom[0].nodeType==9) return false;
1097        var zi = dom.css('zIndex');
1098        if (!isNaN(zi)&&zi!=0) return parseInt(zi);
1099        dom = dom.parent();
1100      }
1101      return false;
1102    };
1103
1104//inspired by http://forum.jquery.com/topic/width-includes-border-width-when-set-to-thin-medium-thick-in-ie
1105    var _convertBorderWidth = {"thin":1,"medium":3,"thick":5};
1106    function getWidthToPixel(dom,prop,chkheight) {
1107      var wd = dom.css(prop);
1108      var px = parseFloat(wd);
1109      if (isNaN(px)) {
1110        px = _convertBorderWidth[wd]||0;
1111        var brd = (px==3) ? ((chkheight)?(self.win.outerHeight() - self.win.innerHeight()):(self.win.outerWidth() - self.win.innerWidth())) : 1; //DON'T TRUST CSS
1112        if (self.isie8&&px) px+=1;
1113        return (brd) ? px : 0;
1114      }
1115      return px;
1116    };
1117
1118    this.getOffset = function() {
1119      if (self.isfixed) return {top:parseFloat(self.win.css('top')),left:parseFloat(self.win.css('left'))};
1120      if (!self.viewport) return self.win.offset();
1121      var ww = self.win.offset();
1122      var vp = self.viewport.offset();
1123      return {top:ww.top-vp.top+self.viewport.scrollTop(),left:ww.left-vp.left+self.viewport.scrollLeft()};
1124    };
1125
1126    this.updateScrollBar = function(len) {
1127      if (self.ishwscroll) {
1128        self.rail.css({height:self.win.innerHeight()});
1129        if (self.railh) self.railh.css({width:self.win.innerWidth()});
1130      } else {
1131        var wpos = self.getOffset();
1132        var pos = {top:wpos.top,left:wpos.left};
1133        pos.top+= getWidthToPixel(self.win,'border-top-width',true);
1134        var brd = (self.win.outerWidth() - self.win.innerWidth())/2;
1135        pos.left+= (self.rail.align) ? self.win.outerWidth() - getWidthToPixel(self.win,'border-right-width') - self.rail.width : getWidthToPixel(self.win,'border-left-width');
1136
1137        var off = self.opt.railoffset;
1138        if (off) {
1139          if (off.top) pos.top+=off.top;
1140          if (self.rail.align&&off.left) pos.left+=off.left;
1141        }
1142
1143				if (!self.locked) self.rail.css({top:pos.top,left:pos.left,height:(len)?len.h:self.win.innerHeight()});
1144
1145				if (self.zoom) {
1146				  self.zoom.css({top:pos.top+1,left:(self.rail.align==1) ? pos.left-20 : pos.left+self.rail.width+4});
1147			  }
1148
1149				if (self.railh&&!self.locked) {
1150					var pos = {top:wpos.top,left:wpos.left};
1151					var y = (self.railh.align) ? pos.top + getWidthToPixel(self.win,'border-top-width',true) + self.win.innerHeight() - self.railh.height : pos.top + getWidthToPixel(self.win,'border-top-width',true);
1152					var x = pos.left + getWidthToPixel(self.win,'border-left-width');
1153					self.railh.css({top:y,left:x,width:self.railh.width});
1154				}
1155
1156
1157      }
1158    };
1159
1160    this.doRailClick = function(e,dbl,hr) {
1161
1162      var fn,pg,cur,pos;
1163
1164//      if (self.rail.drag&&self.rail.drag.pt!=1) return;
1165      if (self.locked) return;
1166//      if (self.rail.drag) return;
1167
1168//      self.cancelScroll();
1169
1170      self.cancelEvent(e);
1171
1172      if (dbl) {
1173        fn = (hr) ? self.doScrollLeft : self.doScrollTop;
1174        cur = (hr) ? ((e.pageX - self.railh.offset().left - (self.cursorwidth/2)) * self.scrollratio.x) : ((e.pageY - self.rail.offset().top - (self.cursorheight/2)) * self.scrollratio.y);
1175        fn(cur);
1176      } else {
1177//        console.log(e.pageY);
1178        fn = (hr) ? self.doScrollLeftBy : self.doScrollBy;
1179        cur = (hr) ? self.scroll.x : self.scroll.y;
1180        pos = (hr) ? e.pageX - self.railh.offset().left : e.pageY - self.rail.offset().top;
1181        pg = (hr) ? self.view.w : self.view.h;
1182        (cur>=pos) ? fn(pg) : fn(-pg);
1183      }
1184
1185    }
1186
1187    self.hasanimationframe = (setAnimationFrame);
1188    self.hascancelanimationframe = (clearAnimationFrame);
1189
1190    if (!self.hasanimationframe) {
1191      setAnimationFrame=function(fn){return setTimeout(fn,15-Math.floor((+new Date)/1000)%16)}; // 1000/60)};
1192      clearAnimationFrame=clearInterval;
1193    }
1194    else if (!self.hascancelanimationframe) clearAnimationFrame=function(){self.cancelAnimationFrame=true};
1195
1196    this.init = function() {
1197
1198      self.saved.css = [];
1199
1200      if (cap.isie7mobile) return true; // SORRY, DO NOT WORK!
1201      if (cap.isoperamini) return true; // SORRY, DO NOT WORK!
1202
1203      if (cap.hasmstouch) self.css((self.ispage)?$("html"):self.win,{'-ms-touch-action':'none'});
1204
1205      self.zindex = "auto";
1206      if (!self.ispage&&self.opt.zindex=="auto") {
1207        self.zindex = getZIndex()||"auto";
1208      } else {
1209        self.zindex = self.opt.zindex;
1210      }
1211
1212      if (!self.ispage&&self.zindex!="auto") {
1213        if (self.zindex>globalmaxzindex) globalmaxzindex=self.zindex;
1214      }
1215
1216      if (self.isie&&self.zindex==0&&self.opt.zindex=="auto") {  // fix IE auto == 0
1217        self.zindex="auto";
1218      }
1219
1220/*
1221      self.ispage = true;
1222      self.haswrapper = true;
1223//      self.win = $(window);
1224      self.docscroll = $("body");
1225//      self.doc = $("body");
1226*/
1227
1228      if (!self.ispage || (!cap.cantouch && !cap.isieold && !cap.isie9mobile)) {
1229
1230        var cont = self.docscroll;
1231        if (self.ispage) cont = (self.haswrapper)?self.win:self.doc;
1232
1233        if (!cap.isie9mobile) self.css(cont,{'overflow-y':'hidden'});
1234
1235        if (self.ispage&&cap.isie7) {
1236          if (self.doc[0].nodeName=='BODY') self.css($("html"),{'overflow-y':'hidden'});  //IE7 double scrollbar issue
1237          else if (self.doc[0].nodeName=='HTML') self.css($("body"),{'overflow-y':'hidden'});  //IE7 double scrollbar issue
1238        }
1239
1240        if (cap.isios&&!self.ispage&&!self.haswrapper) self.css($("body"),{"-webkit-overflow-scrolling":"touch"});  //force hw acceleration
1241
1242        var cursor = $(document.createElement('div'));
1243        cursor.css({
1244          position:"relative",top:0,"float":"right",width:self.opt.cursorwidth,height:"0px",
1245          'background-color':self.opt.cursorcolor,
1246          border:self.opt.cursorborder,
1247          'background-clip':'padding-box',
1248          '-webkit-border-radius':self.opt.cursorborderradius,
1249          '-moz-border-radius':self.opt.cursorborderradius,
1250          'border-radius':self.opt.cursorborderradius
1251        });
1252
1253        cursor.hborder = parseFloat(cursor.outerHeight() - cursor.innerHeight());
1254        self.cursor = cursor;
1255
1256        var rail = $(document.createElement('div'));
1257        rail.attr('id',self.id);
1258        rail.addClass('nicescroll-rails');
1259
1260        var v,a,kp = ["left","right"];  //"top","bottom"
1261        for(var n in kp) {
1262          a=kp[n];
1263          v = self.opt.railpadding[a];
1264          (v) ? rail.css("padding-"+a,v+"px") : self.opt.railpadding[a] = 0;
1265        }
1266
1267        rail.append(cursor);
1268
1269        rail.width = Math.max(parseFloat(self.opt.cursorwidth),cursor.outerWidth()) + self.opt.railpadding['left'] + self.opt.railpadding['right'];
1270        rail.css({width:rail.width+"px",'zIndex':self.zindex,"background":self.opt.background,cursor:"default"});
1271
1272        rail.visibility = true;
1273        rail.scrollable = true;
1274
1275        rail.align = (self.opt.railalign=="left") ? 0 : 1;
1276
1277        self.rail = rail;
1278
1279        self.rail.drag = false;
1280
1281        var zoom = false;
1282        if (self.opt.boxzoom&&!self.ispage&&!cap.isieold) {
1283          zoom = document.createElement('div');
1284          self.bind(zoom,"click",self.doZoom);
1285          self.zoom = $(zoom);
1286          self.zoom.css({"cursor":"pointer",'z-index':self.zindex,'backgroundImage':'url('+scriptpath+'zoomico.png)','height':18,'width':18,'backgroundPosition':'0px 0px'});
1287          if (self.opt.dblclickzoom) self.bind(self.win,"dblclick",self.doZoom);
1288          if (cap.cantouch&&self.opt.gesturezoom) {
1289            self.ongesturezoom = function(e) {
1290              if (e.scale>1.5) self.doZoomIn(e);
1291              if (e.scale<0.8) self.doZoomOut(e);
1292              return self.cancelEvent(e);
1293            };
1294            self.bind(self.win,"gestureend",self.ongesturezoom);
1295          }
1296        }
1297
1298// init HORIZ
1299
1300        self.railh = false;
1301
1302        if (self.opt.horizrailenabled) {
1303
1304          self.css(cont,{'overflow-x':'hidden'});
1305
1306          var cursor = $(document.createElement('div'));
1307          cursor.css({
1308            position:"relative",top:0,height:self.opt.cursorwidth,width:"0px",
1309            'background-color':self.opt.cursorcolor,
1310            border:self.opt.cursorborder,
1311            'background-clip':'padding-box',
1312            '-webkit-border-radius':self.opt.cursorborderradius,
1313            '-moz-border-radius':self.opt.cursorborderradius,
1314            'border-radius':self.opt.cursorborderradius
1315          });
1316
1317          cursor.wborder = parseFloat(cursor.outerWidth() - cursor.innerWidth());
1318          self.cursorh = cursor;
1319
1320          var railh = $(document.createElement('div'));
1321          railh.attr('id',self.id+'-hr');
1322          railh.addClass('nicescroll-rails');
1323          railh.height = Math.max(parseFloat(self.opt.cursorwidth),cursor.outerHeight());
1324          railh.css({height:railh.height+"px",'zIndex':self.zindex,"background":self.opt.background});
1325
1326          railh.append(cursor);
1327
1328          railh.visibility = true;
1329          railh.scrollable = true;
1330
1331          railh.align = (self.opt.railvalign=="top") ? 0 : 1;
1332
1333          self.railh = railh;
1334
1335          self.railh.drag = false;
1336
1337        }
1338
1339//
1340
1341        if (self.ispage) {
1342          rail.css({position:"fixed",top:"0px",height:"100%"});
1343          (rail.align) ? rail.css({right:"0px"}) : rail.css({left:"0px"});
1344          self.body.append(rail);
1345          if (self.railh) {
1346            railh.css({position:"fixed",left:"0px",width:"100%"});
1347            (railh.align) ? railh.css({bottom:"0px"}) : railh.css({top:"0px"});
1348            self.body.append(railh);
1349          }
1350        } else {
1351          if (self.ishwscroll) {
1352            if (self.win.css('position')=='static') self.css(self.win,{'position':'relative'});
1353            var bd = (self.win[0].nodeName == 'HTML') ? self.body : self.win;
1354            if (self.zoom) {
1355              self.zoom.css({position:"absolute",top:1,right:0,"margin-right":rail.width+4});
1356              bd.append(self.zoom);
1357            }
1358            rail.css({position:"absolute",top:0});
1359            (rail.align) ? rail.css({right:0}) : rail.css({left:0});
1360            bd.append(rail);
1361            if (railh) {
1362              railh.css({position:"absolute",left:0,bottom:0});
1363              (railh.align) ? railh.css({bottom:0}) : railh.css({top:0});
1364              bd.append(railh);
1365            }
1366          } else {
1367            self.isfixed = (self.win.css("position")=="fixed");
1368            var rlpos = (self.isfixed) ? "fixed" : "absolute";
1369
1370            if (!self.isfixed) self.viewport = self.getViewport(self.win[0]);
1371            if (self.viewport) {
1372              self.body = self.viewport;
1373              if ((/relative|absolute/.test(self.viewport.css("position")))==false) self.css(self.viewport,{"position":"relative"});
1374            }
1375
1376            rail.css({position:rlpos});
1377            if (self.zoom) self.zoom.css({position:rlpos});
1378            self.updateScrollBar();
1379            self.body.append(rail);
1380            if (self.zoom) self.body.append(self.zoom);
1381            if (self.railh) {
1382              railh.css({position:rlpos});
1383              self.body.append(railh);
1384            }
1385          }
1386
1387          if (cap.isios) self.css(self.win,{'-webkit-tap-highlight-color':'rgba(0,0,0,0)','-webkit-touch-callout':'none'});  // prevent grey layer on click
1388
1389					if (cap.isie&&self.opt.disableoutline) self.win.attr("hideFocus","true");  // IE, prevent dotted rectangle on focused div
1390					if (cap.iswebkit&&self.opt.disableoutline) self.win.css({"outline":"none"});
1391//          if (cap.isopera&&self.opt.disableoutline) self.win.css({"outline":"0"});  // Opera to test [TODO]
1392
1393        }
1394
1395        if (self.opt.autohidemode===false) {
1396          self.autohidedom = false;
1397          self.rail.css({opacity:self.opt.cursoropacitymax});
1398          if (self.railh) self.railh.css({opacity:self.opt.cursoropacitymax});
1399        }
1400        else if (self.opt.autohidemode===true) {
1401          self.autohidedom = $().add(self.rail);
1402          if (cap.isie8) self.autohidedom=self.autohidedom.add(self.cursor);
1403          if (self.railh) self.autohidedom=self.autohidedom.add(self.railh);
1404          if (self.railh&&cap.isie8) self.autohidedom=self.autohidedom.add(self.cursorh);
1405        }
1406        else if (self.opt.autohidemode=="scroll") {
1407          self.autohidedom = $().add(self.rail);
1408          if (self.railh) self.autohidedom=self.autohidedom.add(self.railh);
1409        }
1410        else if (self.opt.autohidemode=="cursor") {
1411          self.autohidedom = $().add(self.cursor);
1412          if (self.railh) self.autohidedom=self.autohidedom.add(self.cursorh);
1413        }
1414        else if (self.opt.autohidemode=="hidden") {
1415          self.autohidedom = false;
1416          self.hide();
1417          self.locked = false;
1418        }
1419
1420        if (cap.isie9mobile) {
1421
1422          self.scrollmom = new ScrollMomentumClass2D(self);
1423
1424          /*
1425          var trace = function(msg) {
1426            var db = $("#debug");
1427            if (isNaN(msg)&&(typeof msg != "string")) {
1428              var x = [];
1429              for(var a in msg) {
1430                x.push(a+":"+msg[a]);
1431              }
1432              msg ="{"+x.join(",")+"}";
1433            }
1434            if (db.children().length>0) {
1435              db.children().eq(0).before("<div>"+msg+"</div>");
1436            } else {
1437              db.append("<div>"+msg+"</div>");
1438            }
1439          }
1440          window.onerror = function(msg,url,ln) {
1441            trace("ERR: "+msg+" at "+ln);
1442          }
1443*/
1444
1445          self.onmangotouch = function(e) {
1446            var py = self.getScrollTop();
1447            var px = self.getScrollLeft();
1448
1449            if ((py == self.scrollmom.lastscrolly)&&(px == self.scrollmom.lastscrollx)) return true;
1450//            $("#debug").html('DRAG:'+py);
1451
1452            var dfy = py-self.mangotouch.sy;
1453            var dfx = px-self.mangotouch.sx;
1454            var df = Math.round(Math.sqrt(Math.pow(dfx,2)+Math.pow(dfy,2)));
1455            if (df==0) return;
1456
1457            var dry = (dfy<0)?-1:1;
1458            var drx = (dfx<0)?-1:1;
1459
1460            var tm = +new Date();
1461            if (self.mangotouch.lazy) clearTimeout(self.mangotouch.lazy);
1462
1463            if (((tm-self.mangotouch.tm)>80)||(self.mangotouch.dry!=dry)||(self.mangotouch.drx!=drx)) {
1464//              trace('RESET+'+(tm-self.mangotouch.tm));
1465              self.scrollmom.stop();
1466              self.scrollmom.reset(px,py);
1467              self.mangotouch.sy = py;
1468              self.mangotouch.ly = py;
1469              self.mangotouch.sx = px;
1470              self.mangotouch.lx = px;
1471              self.mangotouch.dry = dry;
1472              self.mangotouch.drx = drx;
1473              self.mangotouch.tm = tm;
1474            } else {
1475
1476              self.scrollmom.stop();
1477              self.scrollmom.update(self.mangotouch.sx-dfx,self.mangotouch.sy-dfy);
1478              var gap = tm - self.mangotouch.tm;
1479              self.mangotouch.tm = tm;
1480
1481//              trace('MOVE:'+df+" - "+gap);
1482
1483              var ds = Math.max(Math.abs(self.mangotouch.ly-py),Math.abs(self.mangotouch.lx-px));
1484              self.mangotouch.ly = py;
1485              self.mangotouch.lx = px;
1486
1487              if (ds>2) {
1488                self.mangotouch.lazy = setTimeout(function(){
1489//                  trace('END:'+ds+'+'+gap);
1490                  self.mangotouch.lazy = false;
1491                  self.mangotouch.dry = 0;
1492                  self.mangotouch.drx = 0;
1493                  self.mangotouch.tm = 0;
1494                  self.scrollmom.doMomentum(30);
1495                },100);
1496              }
1497            }
1498          }
1499
1500          var top = self.getScrollTop();
1501          var lef = self.getScrollLeft();
1502          self.mangotouch = {sy:top,ly:top,dry:0,sx:lef,lx:lef,drx:0,lazy:false,tm:0};
1503
1504          self.bind(self.docscroll,"scroll",self.onmangotouch);
1505
1506        } else {
1507
1508          if (cap.cantouch||self.istouchcapable||self.opt.touchbehavior||cap.hasmstouch) {
1509
1510            self.scrollmom = new ScrollMomentumClass2D(self);
1511
1512            self.ontouchstart = function(e) {
1513              if (e.pointerType&&e.pointerType!=2) return false;
1514
1515              if (!self.locked) {
1516
1517                if (cap.hasmstouch) {
1518                  var tg = (e.target) ? e.target : false;
1519                  while (tg) {
1520                    var nc = $(tg).getNiceScroll();
1521                    if ((nc.length>0)&&(nc[0].me == self.me)) break;
1522                    if (nc.length>0) return false;
1523                    if ((tg.nodeName=='DIV')&&(tg.id==self.id)) break;
1524                    tg = (tg.parentNode) ? tg.parentNode : false;
1525                  }
1526                }
1527
1528                self.cancelScroll();
1529
1530                var tg = self.getTarget(e);
1531
1532                if (tg) {
1533                  var skp = (/INPUT/i.test(tg.nodeName))&&(/range/i.test(tg.type));
1534                  if (skp) return self.stopPropagation(e);
1535                }
1536
1537                if (!("clientX" in e) && ("changedTouches" in e)) {
1538                  e.clientX = e.changedTouches[0].clientX;
1539                  e.clientY = e.changedTouches[0].clientY;
1540                }
1541
1542                if (self.forcescreen) {
1543                  var le = e;
1544                  var e = {"original":(e.original)?e.original:e};
1545                  e.clientX = le.screenX;
1546                  e.clientY = le.screenY;
1547                }
1548
1549                self.rail.drag = {x:e.clientX,y:e.clientY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop(),sl:self.getScrollLeft(),pt:2,dl:false};
1550
1551                if (self.ispage||!self.opt.directionlockdeadzone) {
1552                  self.rail.drag.dl = "f";
1553                } else {
1554
1555                  var view = {
1556                    w:$(window).width(),
1557                    h:$(window).height()
1558                  };
1559
1560                  var page = {
1561                    w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),
1562                    h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)
1563                  }
1564
1565                  var maxh = Math.max(0,page.h - view.h);
1566                  var maxw = Math.max(0,page.w - view.w);
1567
1568                  if (!self.rail.scrollable&&self.railh.scrollable) self.rail.drag.ck = (maxh>0) ? "v" : false;
1569                  else if (self.rail.scrollable&&!self.railh.scrollable) self.rail.drag.ck = (maxw>0) ? "h" : false;
1570                  else self.rail.drag.ck = false;
1571                  if (!self.rail.drag.ck) self.rail.drag.dl = "f";
1572                }
1573
1574                if (self.opt.touchbehavior&&self.isiframe&&cap.isie) {
1575                  var wp = self.win.position();
1576                  self.rail.drag.x+=wp.left;
1577                  self.rail.drag.y+=wp.top;
1578                }
1579
1580                self.hasmoving = false;
1581                self.lastmouseup = false;
1582                self.scrollmom.reset(e.clientX,e.clientY);
1583                if (!cap.cantouch&&!this.istouchcapable&&!cap.hasmstouch) {
1584
1585                  var ip = (tg)?/INPUT|SELECT|TEXTAREA/i.test(tg.nodeName):false;
1586                  if (!ip) {
1587                    if (!self.ispage&&cap.hasmousecapture) tg.setCapture();
1588//                  return self.cancelEvent(e);
1589                    return (self.opt.touchbehavior) ? self.cancelEvent(e) : self.stopPropagation(e);
1590                  }
1591                  if (/SUBMIT|CANCEL|BUTTON/i.test($(tg).attr('type'))) {
1592                    pc = {"tg":tg,"click":false};
1593                    self.preventclick = pc;
1594                  }
1595
1596                }
1597              }
1598
1599            };
1600
1601            self.ontouchend = function(e) {
1602              if (e.pointerType&&e.pointerType!=2) return false;
1603              if (self.rail.drag&&(self.rail.drag.pt==2)) {
1604                self.scrollmom.doMomentum();
1605                self.rail.drag = false;
1606                if (self.hasmoving) {
1607                  self.hasmoving = false;
1608                  self.lastmouseup = true;
1609                  self.hideCursor();
1610                  if (cap.hasmousecapture) document.releaseCapture();
1611                  if (!cap.cantouch) return self.cancelEvent(e);
1612                }
1613              }
1614
1615            };
1616
1617            var moveneedoffset = (self.opt.touchbehavior&&self.isiframe&&!cap.hasmousecapture);
1618
1619            self.ontouchmove = function(e,byiframe) {
1620
1621              if (e.pointerType&&e.pointerType!=2) return false;
1622
1623              if (self.rail.drag&&(self.rail.drag.pt==2)) {
1624                if (cap.cantouch&&(typeof e.original == "undefined")) return true;  // prevent ios "ghost" events by clickable elements
1625
1626                self.hasmoving = true;
1627
1628                if (self.preventclick&&!self.preventclick.click) {
1629                  self.preventclick.click = self.preventclick.tg.onclick||false;
1630                  self.preventclick.tg.onclick = self.onpreventclick;
1631                }
1632
1633                var ev = $.extend({"original":e},e);
1634                e = ev;
1635
1636                if (("changedTouches" in e)) {
1637                  e.clientX = e.changedTouches[0].clientX;
1638                  e.clientY = e.changedTouches[0].clientY;
1639                }
1640
1641                if (self.forcescreen) {
1642                  var le = e;
1643                  var e = {"original":(e.original)?e.original:e};
1644                  e.clientX = le.screenX;
1645                  e.clientY = le.screenY;
1646                }
1647
1648                var ofx = ofy = 0;
1649
1650                if (moveneedoffset&&!byiframe) {
1651                  var wp = self.win.position();
1652                  ofx=-wp.left;
1653                  ofy=-wp.top;
1654                }
1655
1656                var fy = e.clientY + ofy;
1657                var my = (fy-self.rail.drag.y);
1658                var fx = e.clientX + ofx;
1659                var mx = (fx-self.rail.drag.x);
1660
1661                var ny = self.rail.drag.st-my;
1662
1663                if (self.ishwscroll&&self.opt.bouncescroll) {
1664                  if (ny<0) {
1665                    ny = Math.round(ny/2);
1666//                    fy = 0;
1667                  }
1668                  else if (ny>self.page.maxh) {
1669                    ny = self.page.maxh+Math.round((ny-self.page.maxh)/2);
1670//                    fy = 0;
1671                  }
1672                } else {
1673                  if (ny<0) {ny=0;fy=0}
1674                  if (ny>self.page.maxh) {ny=self.page.maxh;fy=0}
1675                }
1676
1677                if (self.railh&&self.railh.scrollable) {
1678                  var nx = self.rail.drag.sl-mx;
1679
1680                  if (self.ishwscroll&&self.opt.bouncescroll) {
1681                    if (nx<0) {
1682                      nx = Math.round(nx/2);
1683//                      fx = 0;
1684                    }
1685                    else if (nx>self.page.maxw) {
1686                      nx = self.page.maxw+Math.round((nx-self.page.maxw)/2);
1687//                      fx = 0;
1688                    }
1689                  } else {
1690                    if (nx<0) {nx=0;fx=0}
1691                    if (nx>self.page.maxw) {nx=self.page.maxw;fx=0}
1692                  }
1693
1694                }
1695
1696                var grabbed = false;
1697                if (self.rail.drag.dl) {
1698                  grabbed = true;
1699                  if (self.rail.drag.dl=="v") nx = self.rail.drag.sl;
1700                  else if (self.rail.drag.dl=="h") ny = self.rail.drag.st;
1701                } else {
1702                  var ay = Math.abs(my);
1703                  var ax = Math.abs(mx);
1704                  var dz = self.opt.directionlockdeadzone;
1705                  if (self.rail.drag.ck=="v") {
1706                    if (ay>dz&&(ax<=(ay*0.3))) {
1707                      self.rail.drag = false;
1708                      return true;
1709                    }
1710                    else if (ax>dz) {
1711                      self.rail.drag.dl="f";
1712                      $("body").scrollTop($("body").scrollTop());  // stop iOS native scrolling (when active javascript has blocked)
1713                    }
1714                  }
1715                  else if (self.rail.drag.ck=="h") {
1716                    if (ax>dz&&(ay<=(ax*0.3))) {
1717                      self.rail.drag = false;
1718                      return true;
1719                    }
1720                    else if (ay>dz) {
1721                      self.rail.drag.dl="f";
1722                      $("body").scrollLeft($("body").scrollLeft());  // stop iOS native scrolling (when active javascript has blocked)
1723                    }
1724                  }
1725                }
1726
1727                self.synched("touchmove",function(){
1728                  if (self.rail.drag&&(self.rail.drag.pt==2)) {
1729                    if (self.prepareTransition) self.prepareTransition(0);
1730                    if (self.rail.scrollable) self.setScrollTop(ny);
1731                    self.scrollmom.update(fx,fy);
1732                    if (self.railh&&self.railh.scrollable) {
1733                      self.setScrollLeft(nx);
1734                      self.showCursor(ny,nx);
1735                    } else {
1736                      self.showCursor(ny);
1737                    }
1738                    if (cap.isie10) document.selection.clear();
1739                  }
1740                });
1741
1742                if (cap.ischrome&&self.istouchcapable) grabbed=false;  //chrome touch emulation doesn't like!
1743                if (grabbed) return self.cancelEvent(e);
1744              }
1745
1746            };
1747
1748          }
1749
1750          self.onmousedown = function(e,hronly) {
1751            if (self.rail.drag&&self.rail.drag.pt!=1) return;
1752            if (self.locked) return self.cancelEvent(e);
1753            self.cancelScroll();
1754            self.rail.drag = {x:e.clientX,y:e.clientY,sx:self.scroll.x,sy:self.scroll.y,pt:1,hr:(!!hronly)};
1755            var tg = self.getTarget(e);
1756            if (!self.ispage&&cap.hasmousecapture) tg.setCapture();
1757            if (self.isiframe&&!cap.hasmousecapture) {
1758              self.saved["csspointerevents"] = self.doc.css("pointer-events");
1759              self.css(self.doc,{"pointer-events":"none"});
1760            }
1761            return self.cancelEvent(e);
1762          };
1763
1764          self.onmouseup = function(e) {
1765            if (self.rail.drag) {
1766              if (cap.hasmousecapture) document.releaseCapture();
1767              if (self.isiframe&&!cap.hasmousecapture) self.doc.css("pointer-events",self.saved["csspointerevents"]);
1768              if(self.rail.drag.pt!=1)return;
1769              self.rail.drag = false;
1770              //if (!self.rail.active) self.hideCursor();
1771              return self.cancelEvent(e);
1772            }
1773          };
1774
1775          self.onmousemove = function(e) {
1776            if (self.rail.drag) {
1777              if(self.rail.drag.pt!=1)return;
1778
1779              if (cap.ischrome&&e.which==0) return self.onmouseup(e);
1780
1781              self.cursorfreezed = true;
1782
1783              if (self.rail.drag.hr) {
1784                self.scroll.x = self.rail.drag.sx + (e.clientX-self.rail.drag.x);
1785                if (self.scroll.x<0) self.scroll.x=0;
1786                var mw = self.scrollvaluemaxw;
1787                if (self.scroll.x>mw) self.scroll.x=mw;
1788              } else {
1789                self.scroll.y = self.rail.drag.sy + (e.clientY-self.rail.drag.y);
1790                if (self.scroll.y<0) self.scroll.y=0;
1791                var my = self.scrollvaluemax;
1792                if (self.scroll.y>my) self.scroll.y=my;
1793              }
1794
1795              self.synched('mousemove',function(){
1796                if (self.rail.drag&&(self.rail.drag.pt==1)) {
1797                  self.showCursor();
1798                  if (self.rail.drag.hr) self.doScrollLeft(Math.round(self.scroll.x*self.scrollratio.x),self.opt.cursordragspeed);
1799                  else self.doScrollTop(Math.round(self.scroll.y*self.scrollratio.y),self.opt.cursordragspeed);
1800                }
1801              });
1802
1803              return self.cancelEvent(e);
1804            }
1805/*
1806            else {
1807              self.checkarea = true;
1808            }
1809*/
1810          };
1811
1812          if (cap.cantouch||self.opt.touchbehavior) {
1813
1814            self.onpreventclick = function(e) {
1815              if (self.preventclick) {
1816                self.preventclick.tg.onclick = self.preventclick.click;
1817                self.preventclick = false;
1818                return self.cancelEvent(e);
1819              }
1820            }
1821
1822//            self.onmousedown = self.ontouchstart;
1823//            self.onmouseup = self.ontouchend;
1824//            self.onmousemove = self.ontouchmove;
1825
1826            self.bind(self.win,"mousedown",self.ontouchstart);  // control content dragging
1827
1828            self.onclick = (cap.isios) ? false : function(e) {
1829              if (self.lastmouseup) {
1830                self.lastmouseup = false;
1831                return self.cancelEvent(e);
1832              } else {
1833                return true;
1834              }
1835            };
1836
1837            if (self.opt.grabcursorenabled&&cap.cursorgrabvalue) {
1838              self.css((self.ispage)?self.doc:self.win,{'cursor':cap.cursorgrabvalue});
1839              self.css(self.rail,{'cursor':cap.cursorgrabvalue});
1840            }
1841
1842          } else {
1843
1844            function checkSelectionScroll(e) {
1845              if (!self.selectiondrag) return;
1846
1847              if (e) {
1848                var ww = self.win.outerHeight();
1849                var df = (e.pageY - self.selectiondrag.top);
1850                if (df>0&&df<ww) df=0;
1851                if (df>=ww) df-=ww;
1852                self.selectiondrag.df = df;
1853              }
1854              if (self.selectiondrag.df==0) return;
1855
1856              var rt = -Math.floor(self.selectiondrag.df/6)*2;
1857//              self.doScrollTop(self.getScrollTop(true)+rt);
1858              self.doScrollBy(rt);
1859
1860              self.debounced("doselectionscroll",function(){checkSelectionScroll()},50);
1861            }
1862
1863            if ("getSelection" in document) {  // A grade - Major browsers
1864              self.hasTextSelected = function() {
1865                return (document.getSelection().rangeCount>0);
1866              }
1867            }
1868            else if ("selection" in document) {  //IE9-
1869              self.hasTextSelected = function() {
1870                return (document.selection.type != "None");
1871              }
1872            }
1873            else {
1874              self.hasTextSelected = function() {  // no support
1875                return false;
1876              }
1877            }
1878
1879            self.onselectionstart = function(e) {
1880              if (self.ispage) return;
1881              self.selectiondrag = self.win.offset();
1882            }
1883            self.onselectionend = function(e) {
1884              self.selectiondrag = false;
1885            }
1886            self.onselectiondrag = function(e) {
1887              if (!self.selectiondrag) return;
1888              if (self.hasTextSelected()) self.debounced("selectionscroll",function(){checkSelectionScroll(e)},250);
1889            }
1890
1891
1892          }
1893
1894          if (cap.hasmstouch) {
1895            self.css(self.rail,{'-ms-touch-action':'none'});
1896            self.css(self.cursor,{'-ms-touch-action':'none'});
1897
1898            self.bind(self.win,"MSPointerDown",self.ontouchstart);
1899            self.bind(document,"MSPointerUp",self.ontouchend);
1900            self.bind(document,"MSPointerMove",self.ontouchmove);
1901            self.bind(self.cursor,"MSGestureHold",function(e){e.preventDefault()});
1902            self.bind(self.cursor,"contextmenu",function(e){e.preventDefault()});
1903          }
1904
1905          if (this.istouchcapable) {  //desktop with screen touch enabled
1906            self.bind(self.win,"touchstart",self.ontouchstart);
1907            self.bind(document,"touchend",self.ontouchend);
1908            self.bind(document,"touchcancel",self.ontouchend);
1909            self.bind(document,"touchmove",self.ontouchmove);
1910          }
1911
1912          self.bind(self.cursor,"mousedown",self.onmousedown);
1913          self.bind(self.cursor,"mouseup",self.onmouseup);
1914
1915          if (self.railh) {
1916            self.bind(self.cursorh,"mousedown",function(e){self.onmousedown(e,true)});
1917            self.bind(self.cursorh,"mouseup",function(e){
1918              if (self.rail.drag&&self.rail.drag.pt==2) return;
1919              self.rail.drag = false;
1920              self.hasmoving = false;
1921              self.hideCursor();
1922              if (cap.hasmousecapture) document.releaseCapture();
1923              return self.cancelEvent(e);
1924            });
1925          }
1926
1927          if (self.opt.cursordragontouch||!cap.cantouch&&!self.opt.touchbehavior) {
1928
1929            self.rail.css({"cursor":"default"});
1930            self.railh&&self.railh.css({"cursor":"default"});
1931
1932            self.jqbind(self.rail,"mouseenter",function() {
1933              if (self.canshowonmouseevent) self.showCursor();
1934              self.rail.active = true;
1935            });
1936            self.jqbind(self.rail,"mouseleave",function() {
1937              self.rail.active = false;
1938              if (!self.rail.drag) self.hideCursor();
1939            });
1940
1941            if (self.opt.sensitiverail) {
1942              self.bind(self.rail,"click",function(e){self.doRailClick(e,false,false)});
1943              self.bind(self.rail,"dblclick",function(e){self.doRailClick(e,true,false)});
1944              self.bind(self.cursor,"click",function(e){self.cancelEvent(e)});
1945              self.bind(self.cursor,"dblclick",function(e){self.cancelEvent(e)});
1946            }
1947
1948            if (self.railh) {
1949              self.jqbind(self.railh,"mouseenter",function() {
1950                if (self.canshowonmouseevent) self.showCursor();
1951                self.rail.active = true;
1952              });
1953              self.jqbind(self.railh,"mouseleave",function() {
1954                self.rail.active = false;
1955                if (!self.rail.drag) self.hideCursor();
1956              });
1957
1958              if (self.opt.sensitiverail) {
1959                self.bind(self.railh, "click", function(e){self.doRailClick(e,false,true)});
1960                self.bind(self.railh, "dblclick", function(e){self.doRailClick(e, true, true) });
1961                self.bind(self.cursorh, "click", function (e) { self.cancelEvent(e) });
1962                self.bind(self.cursorh, "dblclick", function (e) { self.cancelEvent(e) });
1963              }
1964
1965            }
1966
1967          }
1968
1969          if (!cap.cantouch&&!self.opt.touchbehavior) {
1970
1971            self.bind((cap.hasmousecapture)?self.win:document,"mouseup",self.onmouseup);
1972            self.bind(document,"mousemove",self.onmousemove);
1973            if (self.onclick) self.bind(document,"click",self.onclick);
1974
1975            if (!self.ispage&&self.opt.enablescrollonselection) {
1976              self.bind(self.win[0],"mousedown",self.onselectionstart);
1977              self.bind(document,"mouseup",self.onselectionend);
1978              self.bind(self.cursor,"mouseup",self.onselectionend);
1979              if (self.cursorh) self.bind(self.cursorh,"mouseup",self.onselectionend);
1980              self.bind(document,"mousemove",self.onselectiondrag);
1981            }
1982
1983						if (self.zoom) {
1984							self.jqbind(self.zoom,"mouseenter",function() {
1985								if (self.canshowonmouseevent) self.showCursor();
1986								self.rail.active = true;
1987							});
1988							self.jqbind(self.zoom,"mouseleave",function() {
1989								self.rail.active = false;
1990								if (!self.rail.drag) self.hideCursor();
1991							});
1992						}
1993
1994          } else {
1995
1996            self.bind((cap.hasmousecapture)?self.win:document,"mouseup",self.ontouchend);
1997            self.bind(document,"mousemove",self.ontouchmove);
1998            if (self.onclick) self.bind(document,"click",self.onclick);
1999
2000            if (self.opt.cursordragontouch) {
2001              self.bind(self.cursor,"mousedown",self.onmousedown);
2002              self.bind(self.cursor,"mousemove",self.onmousemove);
2003              self.cursorh&&self.bind(self.cursorh,"mousedown",self.onmousedown);
2004              self.cursorh&&self.bind(self.cursorh,"mousemove",self.onmousemove);
2005            }
2006
2007          }
2008
2009					if (self.opt.enablemousewheel) {
2010						if (!self.isiframe) self.bind((cap.isie&&self.ispage) ? document : self.win /*self.docscroll*/ ,"mousewheel",self.onmousewheel);
2011						self.bind(self.rail,"mousewheel",self.onmousewheel);
2012						if (self.railh) self.bind(self.railh,"mousewheel",self.onmousewheelhr);
2013					}
2014
2015          if (!self.ispage&&!cap.cantouch&&!(/HTML|BODY/.test(self.win[0].nodeName))) {
2016            if (!self.win.attr("tabindex")) self.win.attr({"tabindex":tabindexcounter++});
2017
2018            self.jqbind(self.win,"focus",function(e) {
2019              domfocus = (self.getTarget(e)).id||true;
2020              self.hasfocus = true;
2021              if (self.canshowonmouseevent) self.noticeCursor();
2022            });
2023            self.jqbind(self.win,"blur",function(e) {
2024              domfocus = false;
2025              self.hasfocus = false;
2026            });
2027
2028            self.jqbind(self.win,"mouseenter",function(e) {
2029              mousefocus = (self.getTarget(e)).id||true;
2030              self.hasmousefocus = true;
2031              if (self.canshowonmouseevent) self.noticeCursor();
2032            });
2033            self.jqbind(self.win,"mouseleave",function() {
2034              mousefocus = false;
2035              self.hasmousefocus = false;
2036            });
2037
2038          };
2039
2040        }  // !ie9mobile
2041
2042        //Thanks to http://www.quirksmode.org !!
2043        self.onkeypress = function(e) {
2044          if (self.locked&&self.page.maxh==0) return true;
2045
2046          e = (e) ? e : window.e;
2047          var tg = self.getTarget(e);
2048          if (tg&&/INPUT|TEXTAREA|SELECT|OPTION/.test(tg.nodeName)) {
2049            var tp = tg.getAttribute('type')||tg.type||false;
2050            if ((!tp)||!(/submit|button|cancel/i.tp)) return true;
2051          }
2052
2053          if (self.hasfocus||(self.hasmousefocus&&!domfocus)||(self.ispage&&!domfocus&&!mousefocus)) {
2054            var key = e.keyCode;
2055
2056            if (self.locked&&key!=27) return self.cancelEvent(e);
2057
2058            var ctrl = e.ctrlKey||false;
2059            var shift = e.shiftKey || false;
2060
2061            var ret = false;
2062            switch (key) {
2063              case 38:
2064              case 63233: //safari
2065                self.doScrollBy(24*3);
2066                ret = true;
2067                break;
2068              case 40:
2069              case 63235: //safari
2070                self.doScrollBy(-24*3);
2071                ret = true;
2072                break;
2073              case 37:
2074              case 63232: //safari
2075                if (self.railh) {
2076                  (ctrl) ? self.doScrollLeft(0) : self.doScrollLeftBy(24*3);
2077                  ret = true;
2078                }
2079                break;
2080              case 39:
2081              case 63234: //safari
2082                if (self.railh) {
2083                  (ctrl) ? self.doScrollLeft(self.page.maxw) : self.doScrollLeftBy(-24*3);
2084                  ret = true;
2085                }
2086                break;
2087              case 33:
2088              case 63276: // safari
2089                self.doScrollBy(self.view.h);
2090                ret = true;
2091                break;
2092              case 34:
2093              case 63277: // safari
2094                self.doScrollBy(-self.view.h);
2095                ret = true;
2096                break;
2097              case 36:
2098              case 63273: // safari
2099                (self.railh&&ctrl) ? self.doScrollPos(0,0) : self.doScrollTo(0);
2100                ret = true;
2101                break;
2102              case 35:
2103              case 63275: // safari
2104                (self.railh&&ctrl) ? self.doScrollPos(self.page.maxw,self.page.maxh) : self.doScrollTo(self.page.maxh);
2105                ret = true;
2106                break;
2107              case 32:
2108                if (self.opt.spacebarenabled) {
2109                  (shift) ? self.doScrollBy(self.view.h) : self.doScrollBy(-self.view.h);
2110                  ret = true;
2111                }
2112                break;
2113              case 27: // ESC
2114                if (self.zoomactive) {
2115                  self.doZoom();
2116                  ret = true;
2117                }
2118                break;
2119            }
2120            if (ret) return self.cancelEvent(e);
2121          }
2122        };
2123
2124        if (self.opt.enablekeyboard) self.bind(document,(cap.isopera&&!cap.isopera12)?"keypress":"keydown",self.onkeypress);
2125
2126        self.bind(window,'resize',self.lazyResize);
2127        self.bind(window,'orientationchange',self.lazyResize);
2128
2129        self.bind(window,"load",self.lazyResize);
2130
2131        if (cap.ischrome&&!self.ispage&&!self.haswrapper) { //chrome void scrollbar bug - it persists in version 26
2132          var tmp=self.win.attr("style");
2133					var ww = parseFloat(self.win.css("width"))+1;
2134          self.win.css('width',ww);
2135          self.synched("chromefix",function(){self.win.attr("style",tmp)});
2136        }
2137
2138
2139// Trying a cross-browser implementation - good luck!
2140
2141        self.onAttributeChange = function(e) {
2142          self.lazyResize(250);
2143        }
2144
2145        if (!self.ispage&&!self.haswrapper) {
2146          // redesigned MutationObserver for Chrome18+/Firefox14+/iOS6+ with support for: remove div, add/remove content
2147          if (clsMutationObserver !== false) {
2148            self.observer = new clsMutationObserver(function(mutations) {
2149              mutations.forEach(self.onAttributeChange);
2150            });
2151            self.observer.observe(self.win[0],{childList: true, characterData: false, attributes: true, subtree: false});
2152
2153            self.observerremover = new clsMutationObserver(function(mutations) {
2154               mutations.forEach(function(mo){
2155                 if (mo.removedNodes.length>0) {
2156                   for (var dd in mo.removedNodes) {
2157                     if (mo.removedNodes[dd]==self.win[0]) return self.remove();
2158                   }
2159                 }
2160               });
2161            });
2162            self.observerremover.observe(self.win[0].parentNode,{childList: true, characterData: false, attributes: false, subtree: false});
2163
2164          } else {
2165            self.bind(self.win,(cap.isie&&!cap.isie9)?"propertychange":"DOMAttrModified",self.onAttributeChange);
2166            if (cap.isie9) self.win[0].attachEvent("onpropertychange",self.onAttributeChange); //IE9 DOMAttrModified bug
2167            self.bind(self.win,"DOMNodeRemoved",function(e){
2168              if (e.target==self.win[0]) self.remove();
2169            });
2170          }
2171        }
2172
2173//
2174
2175        if (!self.ispage&&self.opt.boxzoom) self.bind(window,"resize",self.resizeZoom);
2176        if (self.istextarea) self.bind(self.win,"mouseup",self.lazyResize);
2177
2178        self.checkrtlmode = true;
2179        self.lazyResize(30);
2180
2181      }
2182
2183      if (this.doc[0].nodeName == 'IFRAME') {
2184        function oniframeload(e) {
2185          self.iframexd = false;
2186          try {
2187            var doc = 'contentDocument' in this ? this.contentDocument : this.contentWindow.document;
2188            var a = doc.domain;
2189          } catch(e){self.iframexd = true;doc=false};
2190
2191          if (self.iframexd) {
2192            if ("console" in window) console.log('NiceScroll error: policy restriced iframe');
2193            return true;  //cross-domain - I can't manage this
2194          }
2195
2196          self.forcescreen = true;
2197
2198          if (self.isiframe) {
2199            self.iframe = {
2200              "doc":$(doc),
2201              "html":self.doc.contents().find('html')[0],
2202              "body":self.doc.contents().find('body')[0]
2203            };
2204            self.getContentSize = function(){
2205              return {
2206                w:Math.max(self.iframe.html.scrollWidth,self.iframe.body.scrollWidth),
2207                h:Math.max(self.iframe.html.scrollHeight,self.iframe.body.scrollHeight)
2208              }
2209            }
2210            self.docscroll = $(self.iframe.body);//$(this.contentWindow);
2211          }
2212
2213          if (!cap.isios&&self.opt.iframeautoresize&&!self.isiframe) {
2214            self.win.scrollTop(0); // reset position
2215            self.doc.height("");  //reset height to fix browser bug
2216            var hh=Math.max(doc.getElementsByTagName('html')[0].scrollHeight,doc.body.scrollHeight);
2217            self.doc.height(hh);
2218          }
2219          self.lazyResize(30);
2220
2221          if (cap.isie7) self.css($(self.iframe.html),{'overflow-y':'hidden'});
2222          //self.css($(doc.body),{'overflow-y':'hidden'});
2223          self.css($(self.iframe.body),{'overflow-y':'hidden'});
2224
2225          if (cap.isios&&self.haswrapper) {
2226            self.css($(doc.body),{'-webkit-transform':'translate3d(0,0,0)'});  // avoid iFrame content clipping - thanks to http://blog.derraab.com/2012/04/02/avoid-iframe-content-clipping-with-css-transform-on-ios/
2227
2228            console.log(1);
2229
2230          }
2231
2232          if ('contentWindow' in this) {
2233            self.bind(this.contentWindow,"scroll",self.onscroll);  //IE8 & minor
2234          } else {
2235            self.bind(doc,"scroll",self.onscroll);
2236          }
2237
2238          if (self.opt.enablemousewheel) {
2239            self.bind(doc,"mousewheel",self.onmousewheel);
2240          }
2241
2242          if (self.opt.enablekeyboard) self.bind(doc,(cap.isopera)?"keypress":"keydown",self.onkeypress);
2243
2244          if (cap.cantouch||self.opt.touchbehavior) {
2245            self.bind(doc,"mousedown",self.ontouchstart);
2246            self.bind(doc,"mousemove",function(e){self.ontouchmove(e,true)});
2247            if (self.opt.grabcursorenabled&&cap.cursorgrabvalue) self.css($(doc.body),{'cursor':cap.cursorgrabvalue});
2248          }
2249
2250          self.bind(doc,"mouseup",self.ontouchend);
2251
2252          if (self.zoom) {
2253            if (self.opt.dblclickzoom) self.bind(doc,'dblclick',self.doZoom);
2254            if (self.ongesturezoom) self.bind(doc,"gestureend",self.ongesturezoom);
2255          }
2256        };
2257
2258        if (this.doc[0].readyState&&this.doc[0].readyState=="complete"){
2259          setTimeout(function(){oniframeload.call(self.doc[0],false)},500);
2260        }
2261        self.bind(this.doc,"load",oniframeload);
2262
2263      }
2264
2265    };
2266
2267    this.showCursor = function(py,px) {
2268      if (self.cursortimeout) {
2269        clearTimeout(self.cursortimeout);
2270        self.cursortimeout = 0;
2271      }
2272      if (!self.rail) return;
2273      if (self.autohidedom) {
2274        self.autohidedom.stop().css({opacity:self.opt.cursoropacitymax});
2275        self.cursoractive = true;
2276      }
2277
2278      if (!self.rail.drag||self.rail.drag.pt!=1) {
2279        if ((typeof py != "undefined")&&(py!==false)) {
2280          self.scroll.y = Math.round(py * 1/self.scrollratio.y);
2281        }
2282        if (typeof px != "undefined") {
2283          self.scroll.x = Math.round(px * 1/self.scrollratio.x);
2284        }
2285      }
2286
2287      self.cursor.css({height:self.cursorheight,top:self.scroll.y});
2288      if (self.cursorh) {
2289        (!self.rail.align&&self.rail.visibility) ? self.cursorh.css({width:self.cursorwidth,left:self.scroll.x+self.rail.width}) : self.cursorh.css({width:self.cursorwidth,left:self.scroll.x});
2290        self.cursoractive = true;
2291      }
2292
2293      if (self.zoom) self.zoom.stop().css({opacity:self.opt.cursoropacitymax});
2294    };
2295
2296    this.hideCursor = function(tm) {
2297      if (self.cursortimeout) return;
2298      if (!self.rail) return;
2299      if (!self.autohidedom) return;
2300      self.cursortimeout = setTimeout(function() {
2301         if (!self.rail.active||!self.showonmouseevent) {
2302           self.autohidedom.stop().animate({opacity:self.opt.cursoropacitymin});
2303           if (self.zoom) self.zoom.stop().animate({opacity:self.opt.cursoropacitymin});
2304           self.cursoractive = false;
2305         }
2306         self.cursortimeout = 0;
2307      },tm||self.opt.hidecursordelay);
2308    };
2309
2310    this.noticeCursor = function(tm,py,px) {
2311      self.showCursor(py,px);
2312      if (!self.rail.active) self.hideCursor(tm);
2313    };
2314
2315    this.getContentSize =
2316      (self.ispage) ?
2317        function(){
2318          return {
2319            w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),
2320            h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)
2321          }
2322        }
2323      : (self.haswrapper) ?
2324        function(){
2325          return {
2326            w:self.doc.outerWidth()+parseInt(self.win.css('paddingLeft'))+parseInt(self.win.css('paddingRight')),
2327            h:self.doc.outerHeight()+parseInt(self.win.css('paddingTop'))+parseInt(self.win.css('paddingBottom'))
2328          }
2329        }
2330      : function() {
2331        return {
2332          w:self.docscroll[0].scrollWidth,
2333          h:self.docscroll[0].scrollHeight
2334        }
2335      };
2336
2337    this.onResize = function(e,page) {
2338
2339	  if (!self.win) return false;
2340
2341      if (!self.haswrapper&&!self.ispage) {
2342        if (self.win.css('display')=='none') {
2343          if (self.visibility) self.hideRail().hideRailHr();
2344          return false;
2345        } else {
2346          if (!self.hidden&&!self.visibility) self.showRail().showRailHr();
2347        }
2348      }
2349
2350      var premaxh = self.page.maxh;
2351      var premaxw = self.page.maxw;
2352
2353      var preview = {h:self.view.h,w:self.view.w};
2354
2355      self.view = {
2356        w:(self.ispage) ? self.win.width() : parseInt(self.win[0].clientWidth),
2357        h:(self.ispage) ? self.win.height() : parseInt(self.win[0].clientHeight)
2358      };
2359
2360      self.page = (page) ? page : self.getContentSize();
2361
2362      self.page.maxh = Math.max(0,self.page.h - self.view.h);
2363      self.page.maxw = Math.max(0,self.page.w - self.view.w);
2364
2365      if ((self.page.maxh==premaxh)&&(self.page.maxw==premaxw)&&(self.view.w==preview.w)) {
2366        // test position
2367        if (!self.ispage) {
2368          var pos = self.win.offset();
2369          if (self.lastposition) {
2370            var lst = self.lastposition;
2371            if ((lst.top==pos.top)&&(lst.left==pos.left)) return self; //nothing to do
2372          }
2373          self.lastposition = pos;
2374        } else {
2375          return self; //nothing to do
2376        }
2377      }
2378
2379      if (self.page.maxh==0) {
2380        self.hideRail();
2381        self.scrollvaluemax = 0;
2382        self.scroll.y = 0;
2383        self.scrollratio.y = 0;
2384        self.cursorheight = 0;
2385        self.setScrollTop(0);
2386        self.rail.scrollable = false;
2387      } else {
2388        self.rail.scrollable = true;
2389      }
2390
2391      if (self.page.maxw==0) {
2392        self.hideRailHr();
2393        self.scrollvaluemaxw = 0;
2394        self.scroll.x = 0;
2395        self.scrollratio.x = 0;
2396        self.cursorwidth = 0;
2397        self.setScrollLeft(0);
2398        self.railh.scrollable = false;
2399      } else {
2400        self.railh.scrollable = true;
2401      }
2402
2403      self.locked = (self.page.maxh==0)&&(self.page.maxw==0);
2404      if (self.locked) {
2405				if (!self.ispage) self.updateScrollBar(self.view);
2406			  return false;
2407		  }
2408
2409      if (!self.hidden&&!self.visibility) {
2410        self.showRail().showRailHr();
2411      }
2412      else if (!self.hidden&&!self.railh.visibility) self.showRailHr();
2413
2414      if (self.istextarea&&self.win.css('resize')&&self.win.css('resize')!='none') self.view.h-=20;
2415
2416      self.cursorheight = Math.min(self.view.h,Math.round(self.view.h * (self.view.h / self.page.h)));
2417      self.cursorheight = (self.opt.cursorfixedheight) ? self.opt.cursorfixedheight : Math.max(self.opt.cursorminheight,self.cursorheight);
2418
2419      self.cursorwidth = Math.min(self.view.w,Math.round(self.view.w * (self.view.w / self.page.w)));
2420      self.cursorwidth = (self.opt.cursorfixedheight) ? self.opt.cursorfixedheight : Math.max(self.opt.cursorminheight,self.cursorwidth);
2421
2422      self.scrollvaluemax = self.view.h-self.cursorheight-self.cursor.hborder;
2423
2424      if (self.railh) {
2425        self.railh.width = (self.page.maxh>0) ? (self.view.w-self.rail.width) : self.view.w;
2426        self.scrollvaluemaxw = self.railh.width-self.cursorwidth-self.cursorh.wborder;
2427      }
2428
2429      if (self.checkrtlmode&&self.railh) {
2430        self.checkrtlmode = false;
2431        if (self.opt.rtlmode&&self.scroll.x==0) self.setScrollLeft(self.page.maxw);
2432      }
2433
2434      if (!self.ispage) self.updateScrollBar(self.view);
2435
2436      self.scrollratio = {
2437        x:(self.page.maxw/self.scrollvaluemaxw),
2438        y:(self.page.maxh/self.scrollvaluemax)
2439      };
2440
2441      var sy = self.getScrollTop();
2442      if (sy>self.page.maxh) {
2443        self.doScrollTop(self.page.maxh);
2444      } else {
2445        self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
2446        self.scroll.x = Math.round(self.getScrollLeft() * (1/self.scrollratio.x));
2447        if (self.cursoractive) self.noticeCursor();
2448      }
2449
2450      if (self.scroll.y&&(self.getScrollTop()==0)) self.doScrollTo(Math.floor(self.scroll.y*self.scrollratio.y));
2451
2452      return self;
2453    };
2454
2455    this.resize = self.onResize;
2456
2457    this.lazyResize = function(tm) {   // event debounce
2458      tm = (isNaN(tm)) ? 30 : tm;
2459      self.delayed('resize',self.resize,tm);
2460      return self;
2461    }
2462
2463// modified by MDN https://developer.mozilla.org/en-US/docs/DOM/Mozilla_event_reference/wheel
2464    function _modernWheelEvent(dom,name,fn,bubble) {
2465      self._bind(dom,name,function(e){
2466        var  e = (e) ? e : window.event;
2467        var event = {
2468          original: e,
2469          target: e.target || e.srcElement,
2470          type: "wheel",
2471          deltaMode: e.type == "MozMousePixelScroll" ? 0 : 1,
2472          deltaX: 0,
2473          deltaZ: 0,
2474          preventDefault: function() {
2475            e.preventDefault ? e.preventDefault() : e.returnValue = false;
2476            return false;
2477          },
2478          stopImmediatePropagation: function() {
2479            (e.stopImmediatePropagation) ? e.stopImmediatePropagation() : e.cancelBubble = true;
2480          }
2481        };
2482
2483        if (name=="mousewheel") {
2484          event.deltaY = - 1/40 * e.wheelDelta;
2485          e.wheelDeltaX && (event.deltaX = - 1/40 * e.wheelDeltaX);
2486        } else {
2487          event.deltaY = e.detail;
2488        }
2489
2490        return fn.call(dom,event);
2491      },bubble);
2492    };
2493
2494    this._bind = function(el,name,fn,bubble) {  // primitive bind
2495      self.events.push({e:el,n:name,f:fn,b:bubble,q:false});
2496      if (el.addEventListener) {
2497        el.addEventListener(name,fn,bubble||false);
2498      }
2499      else if (el.attachEvent) {
2500        el.attachEvent("on"+name,fn);
2501      }
2502      else {
2503        el["on"+name] = fn;
2504      }
2505    };
2506
2507    this.jqbind = function(dom,name,fn) {  // use jquery bind for non-native events (mouseenter/mouseleave)
2508      self.events.push({e:dom,n:name,f:fn,q:true});
2509      $(dom).bind(name,fn);
2510    }
2511
2512    this.bind = function(dom,name,fn,bubble) {  // touch-oriented & fixing jquery bind
2513      var el = ("jquery" in dom) ? dom[0] : dom;
2514
2515      if (name=='mousewheel') {
2516        if ("onwheel" in self.win) {
2517          self._bind(el,"wheel",fn,bubble||false);
2518        } else {
2519          var wname = (typeof document.onmousewheel != "undefined") ? "mousewheel" : "DOMMouseScroll";  // older IE/Firefox
2520          _modernWheelEvent(el,wname,fn,bubble||false);
2521          if (wname=="DOMMouseScroll") _modernWheelEvent(el,"MozMousePixelScroll",fn,bubble||false);  // Firefox legacy
2522        }
2523      }
2524      else if (el.addEventListener) {
2525        if (cap.cantouch && /mouseup|mousedown|mousemove/.test(name)) {  // touch device support
2526          var tt=(name=='mousedown')?'touchstart':(name=='mouseup')?'touchend':'touchmove';
2527          self._bind(el,tt,function(e){
2528            if (e.touches) {
2529              if (e.touches.length<2) {var ev=(e.touches.length)?e.touches[0]:e;ev.original=e;fn.call(this,ev);}
2530            }
2531            else if (e.changedTouches) {var ev=e.changedTouches[0];ev.original=e;fn.call(this,ev);}  //blackberry
2532          },bubble||false);
2533        }
2534        self._bind(el,name,fn,bubble||false);
2535        if (cap.cantouch && name=="mouseup") self._bind(el,"touchcancel",fn,bubble||false);
2536      }
2537      else {
2538        self._bind(el,name,function(e) {
2539          e = e||window.event||false;
2540          if (e) {
2541            if (e.srcElement) e.target=e.srcElement;
2542          }
2543          if (!("pageY" in e)) {
2544            e.pageX = e.clientX + document.documentElement.scrollLeft;
2545            e.pageY = e.clientY + document.documentElement.scrollTop;
2546          }
2547          return ((fn.call(el,e)===false)||bubble===false) ? self.cancelEvent(e) : true;
2548        });
2549      }
2550    };
2551
2552    this._unbind = function(el,name,fn,bub) {  // primitive unbind
2553      if (el.removeEventListener) {
2554        el.removeEventListener(name,fn,bub);
2555      }
2556      else if (el.detachEvent) {
2557        el.detachEvent('on'+name,fn);
2558      } else {
2559        el['on'+name] = false;
2560      }
2561    };
2562
2563    this.unbindAll = function() {
2564      for(var a=0;a<self.events.length;a++) {
2565        var r = self.events[a];
2566        (r.q) ? r.e.unbind(r.n,r.f) : self._unbind(r.e,r.n,r.f,r.b);
2567      }
2568    };
2569
2570    // Thanks to http://www.switchonthecode.com !!
2571    this.cancelEvent = function(e) {
2572      var e = (e.original) ? e.original : (e) ? e : window.event||false;
2573      if (!e) return false;
2574      if(e.preventDefault) e.preventDefault();
2575      if(e.stopPropagation) e.stopPropagation();
2576      if(e.preventManipulation) e.preventManipulation();  //IE10
2577      e.cancelBubble = true;
2578      e.cancel = true;
2579      e.returnValue = false;
2580      return false;
2581    };
2582
2583    this.stopPropagation = function(e) {
2584      var e = (e.original) ? e.original : (e) ? e : window.event||false;
2585      if (!e) return false;
2586      if (e.stopPropagation) return e.stopPropagation();
2587      if (e.cancelBubble) e.cancelBubble=true;
2588      return false;
2589    }
2590
2591    this.showRail = function() {
2592      if ((self.page.maxh!=0)&&(self.ispage||self.win.css('display')!='none')) {
2593        self.visibility = true;
2594        self.rail.visibility = true;
2595        self.rail.css('display','block');
2596      }
2597      return self;
2598    };
2599
2600    this.showRailHr = function() {
2601      if (!self.railh) return self;
2602      if ((self.page.maxw!=0)&&(self.ispage||self.win.css('display')!='none')) {
2603        self.railh.visibility = true;
2604        self.railh.css('display','block');
2605      }
2606      return self;
2607    };
2608
2609    this.hideRail = function() {
2610      self.visibility = false;
2611      self.rail.visibility = false;
2612      self.rail.css('display','none');
2613      return self;
2614    };
2615
2616    this.hideRailHr = function() {
2617      if (!self.railh) return self;
2618      self.railh.visibility = false;
2619      self.railh.css('display','none');
2620      return self;
2621    };
2622
2623    this.show = function() {
2624      self.hidden = false;
2625      self.locked = false;
2626      return self.showRail().showRailHr();
2627    };
2628
2629    this.hide = function() {
2630      self.hidden = true;
2631      self.locked = true;
2632      return self.hideRail().hideRailHr();
2633    };
2634
2635    this.toggle = function() {
2636      return (self.hidden) ? self.show() : self.hide();
2637    };
2638
2639    this.remove = function() {
2640      self.stop();
2641      if (self.cursortimeout) clearTimeout(self.cursortimeout);
2642      self.doZoomOut();
2643      self.unbindAll();
2644
2645      if (cap.isie9) self.win[0].detachEvent("onpropertychange",self.onAttributeChange); //IE9 DOMAttrModified bug
2646
2647      if (self.observer !== false) self.observer.disconnect();
2648      if (self.observerremover !== false) self.observerremover.disconnect();
2649
2650      self.events = null;
2651
2652      if (self.cursor) {
2653        self.cursor.remove();
2654      }
2655      if (self.cursorh) {
2656        self.cursorh.remove();
2657      }
2658      if (self.rail) {
2659        self.rail.remove();
2660      }
2661      if (self.railh) {
2662        self.railh.remove();
2663      }
2664      if (self.zoom) {
2665        self.zoom.remove();
2666      }
2667      for(var a=0;a<self.saved.css.length;a++) {
2668        var d=self.saved.css[a];
2669        d[0].css(d[1],(typeof d[2]=="undefined") ? '' : d[2]);
2670      }
2671      self.saved = false;
2672      self.me.data('__nicescroll',''); //erase all traces
2673
2674      // memory leak fixed by GianlucaGuarini - thanks a lot!
2675      // remove the current nicescroll from the $.nicescroll array & normalize array
2676      var lst = $.nicescroll;
2677      lst.each(function(i){
2678        if (!this) return;
2679        if(this.id === self.id) {
2680          delete lst[i];
2681          for(var b=++i;b<lst.length;b++,i++) lst[i]=lst[b];
2682          lst.length--;
2683          if (lst.length) delete lst[lst.length];
2684        }
2685      });
2686
2687      for (var i in self) {
2688        self[i] = null;
2689        delete self[i];
2690      }
2691
2692      self = null;
2693
2694    };
2695
2696    this.scrollstart = function(fn) {
2697      this.onscrollstart = fn;
2698      return self;
2699    }
2700    this.scrollend = function(fn) {
2701      this.onscrollend = fn;
2702      return self;
2703    }
2704    this.scrollcancel = function(fn) {
2705      this.onscrollcancel = fn;
2706      return self;
2707    }
2708
2709    this.zoomin = function(fn) {
2710      this.onzoomin = fn;
2711      return self;
2712    }
2713    this.zoomout = function(fn) {
2714      this.onzoomout = fn;
2715      return self;
2716    }
2717
2718    this.isScrollable = function(e) {
2719      var dom = (e.target) ? e.target : e;
2720      if (dom.nodeName == 'OPTION') return true;
2721      while (dom&&(dom.nodeType==1)&&!(/BODY|HTML/.test(dom.nodeName))) {
2722        var dd = $(dom);
2723        var ov = dd.css('overflowY')||dd.css('overflowX')||dd.css('overflow')||'';
2724        if (/scroll|auto/.test(ov)) return (dom.clientHeight!=dom.scrollHeight);
2725        dom = (dom.parentNode) ? dom.parentNode : false;
2726      }
2727      return false;
2728    };
2729
2730    this.getViewport = function(me) {
2731      var dom = (me&&me.parentNode) ? me.parentNode : false;
2732      while (dom&&(dom.nodeType==1)&&!(/BODY|HTML/.test(dom.nodeName))) {
2733        var dd = $(dom);
2734        var ov = dd.css('overflowY')||dd.css('overflowX')||dd.css('overflow')||'';
2735        if ((/scroll|auto/.test(ov))&&(dom.clientHeight!=dom.scrollHeight)) return dd;
2736        if (dd.getNiceScroll().length>0) return dd;
2737        dom = (dom.parentNode) ? dom.parentNode : false;
2738      }
2739      return false;
2740    };
2741
2742    function execScrollWheel(e,hr,chkscroll) {
2743      var px,py;
2744      var rt = 1;
2745
2746      if (e.deltaMode==0) {  // PIXEL
2747        px = -Math.floor(e.deltaX*(self.opt.mousescrollstep/(18*3)));
2748        py = -Math.floor(e.deltaY*(self.opt.mousescrollstep/(18*3)));
2749      }
2750      else if (e.deltaMode==1) {  // LINE
2751        px = -Math.floor(e.deltaX*self.opt.mousescrollstep);
2752        py = -Math.floor(e.deltaY*self.opt.mousescrollstep);
2753      }
2754
2755      if (hr&&self.opt.oneaxismousemode&&(px==0)&&py) {  // classic vertical-only mousewheel + browser with x/y support
2756        px = py;
2757        py = 0;
2758      }
2759
2760      if (px) {
2761        if (self.scrollmom) {self.scrollmom.stop()}
2762        self.lastdeltax+=px;
2763        self.debounced("mousewheelx",function(){var dt=self.lastdeltax;self.lastdeltax=0;if(!self.rail.drag){self.doScrollLeftBy(dt)}},120);
2764      }
2765      if (py) {
2766        if (self.opt.nativeparentscrolling&&chkscroll&&!self.ispage&&!self.zoomactive) {
2767          if (py<0) {
2768            if (self.getScrollTop()>=self.page.maxh) return true;
2769          } else {
2770            if (self.getScrollTop()<=0) return true;
2771          }
2772        }
2773        if (self.scrollmom) {self.scrollmom.stop()}
2774        self.lastdeltay+=py;
2775        self.debounced("mousewheely",function(){var dt=self.lastdeltay;self.lastdeltay=0;if(!self.rail.drag){self.doScrollBy(dt)}},120);
2776      }
2777
2778      e.stopImmediatePropagation();
2779      return e.preventDefault();
2780//      return self.cancelEvent(e);
2781    };
2782
2783    this.onmousewheel = function(e) {
2784      if (self.locked) {
2785        self.debounced("checkunlock",self.resize,250);
2786        return true;
2787      }
2788      if (self.rail.drag) return self.cancelEvent(e);
2789
2790      if (self.opt.oneaxismousemode=="auto"&&e.deltaX!=0) self.opt.oneaxismousemode = false;  // check two-axis mouse support (not very elegant)
2791
2792      if (self.opt.oneaxismousemode&&e.deltaX==0) {
2793        if (!self.rail.scrollable) {
2794          if (self.railh&&self.railh.scrollable) {
2795            return self.onmousewheelhr(e);
2796          } else {
2797            return true;
2798          }
2799        }
2800      }
2801
2802      var nw = +(new Date());
2803      var chk = false;
2804      if (self.opt.preservenativescrolling&&((self.checkarea+600)<nw)) {
2805//        self.checkarea = false;
2806        self.nativescrollingarea = self.isScrollable(e);
2807        chk = true;
2808      }
2809      self.checkarea = nw;
2810      if (self.nativescrollingarea) return true; // this isn't my business
2811//      if (self.locked) return self.cancelEvent(e);
2812      var ret = execScrollWheel(e,false,chk);
2813      if (ret) self.checkarea = 0;
2814      return ret;
2815    };
2816
2817    this.onmousewheelhr = function(e) {
2818      if (self.locked||!self.railh.scrollable) return true;
2819      if (self.rail.drag) return self.cancelEvent(e);
2820
2821      var nw = +(new Date());
2822      var chk = false;
2823      if (self.opt.preservenativescrolling&&((self.checkarea+600)<nw)) {
2824//        self.checkarea = false;
2825        self.nativescrollingarea = self.isScrollable(e);
2826        chk = true;
2827      }
2828      self.checkarea = nw;
2829      if (self.nativescrollingarea) return true; // this isn't my business
2830      if (self.locked) return self.cancelEvent(e);
2831
2832      return execScrollWheel(e,true,chk);
2833    };
2834
2835    this.stop = function() {
2836      self.cancelScroll();
2837      if (self.scrollmon) self.scrollmon.stop();
2838      self.cursorfreezed = false;
2839      self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
2840      self.noticeCursor();
2841      return self;
2842    };
2843
2844    this.getTransitionSpeed = function(dif) {
2845      var sp = Math.round(self.opt.scrollspeed*10);
2846      var ex = Math.min(sp,Math.round((dif / 20) * self.opt.scrollspeed));
2847      return (ex>
284720) ? ex : 0;
2848    }
2849
2850    if (!self.opt.smoothscroll) {
2851      this.doScrollLeft = function(x,spd) {  //direct
2852        var y = self.getScrollTop();
2853        self.doScrollPos(x,y,spd);
2854      }
2855      this.doScrollTop = function(y,spd) {   //direct
2856        var x = self.getScrollLeft();
2857        self.doScrollPos(x,y,spd);
2858      }
2859      this.doScrollPos = function(x,y,spd) {  //direct
2860        var nx = (x>self.page.maxw) ? self.page.maxw : x;
2861        if (nx<0) nx=0;
2862        var ny = (y>self.page.maxh) ? self.page.maxh : y;
2863        if (ny<0) ny=0;
2864        self.synched('scroll',function(){
2865          self.setScrollTop(ny);
2866          self.setScrollLeft(nx);
2867        });
2868      }
2869      this.cancelScroll = function() {}; // direct
2870    }
2871    else if (self.ishwscroll&&cap.hastransition&&self.opt.usetransition) {
2872      this.prepareTransition = function(dif,istime) {
2873        var ex = (istime) ? ((dif>20)?dif:0) : self.getTransitionSpeed(dif);
2874        var trans = (ex) ? cap.prefixstyle+'transform '+ex+'ms ease-out' : '';
2875        if (!self.lasttransitionstyle||self.lasttransitionstyle!=trans) {
2876          self.lasttransitionstyle = trans;
2877          self.doc.css(cap.transitionstyle,trans);
2878        }
2879        return ex;
2880      };
2881
2882      this.doScrollLeft = function(x,spd) {  //trans
2883        var y = (self.scrollrunning) ? self.newscrolly : self.getScrollTop();
2884        self.doScrollPos(x,y,spd);
2885      }
2886
2887      this.doScrollTop = function(y,spd) {   //trans
2888        var x = (self.scrollrunning) ? self.newscrollx : self.getScrollLeft();
2889        self.doScrollPos(x,y,spd);
2890      }
2891
2892      this.doScrollPos = function(x,y,spd) {  //trans
2893
2894        var py = self.getScrollTop();
2895        var px = self.getScrollLeft();
2896
2897        if (((self.newscrolly-py)*(y-py)<0)||((self.newscrollx-px)*(x-px)<0)) self.cancelScroll();  //inverted movement detection
2898
2899        if (self.opt.bouncescroll==false) {
2900          if (y<0) y=0;
2901          else if (y>self.page.maxh) y=self.page.maxh;
2902          if (x<0) x=0;
2903          else if (x>self.page.maxw) x=self.page.maxw;
2904        }
2905
2906        if (self.scrollrunning&&x==self.newscrollx&&y==self.newscrolly) return false;
2907
2908        self.newscrolly = y;
2909        self.newscrollx = x;
2910
2911        self.newscrollspeed = spd||false;
2912
2913        if (self.timer) return false;
2914
2915        self.timer = setTimeout(function(){
2916
2917          var top = self.getScrollTop();
2918          var lft = self.getScrollLeft();
2919
2920          var dst = {};
2921          dst.x = x-lft;
2922          dst.y = y-top;
2923          dst.px = lft;
2924          dst.py = top;
2925
2926          var dd = Math.round(Math.sqrt(Math.pow(dst.x,2)+Math.pow(dst.y,2)));
2927
2928//          var df = (self.newscrollspeed) ? self.newscrollspeed : dd;
2929
2930          var ms = (self.newscrollspeed && self.newscrollspeed>1) ? self.newscrollspeed : self.getTransitionSpeed(dd);
2931          if (self.newscrollspeed&&self.newscrollspeed<=1) ms*=self.newscrollspeed;
2932
2933          self.prepareTransition(ms,true);
2934
2935          if (self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
2936
2937          if (ms>0) {
2938
2939            if (!self.scrollrunning&&self.onscrollstart) {
2940              var info = {"type":"scrollstart","current":{"x":lft,"y":top},"request":{"x":x,"y":y},"end":{"x":self.newscrollx,"y":self.newscrolly},"speed":ms};
2941              self.onscrollstart.call(self,info);
2942            }
2943
2944            if (cap.transitionend) {
2945              if (!self.scrollendtrapped) {
2946                self.scrollendtrapped = true;
2947                self.bind(self.doc,cap.transitionend,self.onScrollEnd,false); //I have got to do something usefull!!
2948              }
2949            } else {
2950              if (self.scrollendtrapped) clearTimeout(self.scrollendtrapped);
2951              self.scrollendtrapped = setTimeout(self.onScrollEnd,ms);  // simulate transitionend event
2952            }
2953
2954            var py = top;
2955            var px = lft;
2956            self.timerscroll = {
2957              bz: new BezierClass(py,self.newscrolly,ms,0,0,0.58,1),
2958              bh: new BezierClass(px,self.newscrollx,ms,0,0,0.58,1)
2959            };
2960            if (!self.cursorfreezed) self.timerscroll.tm=setInterval(function(){self.showCursor(self.getScrollTop(),self.getScrollLeft())},60);
2961
2962          }
2963
2964          self.synched("doScroll-set",function(){
2965            self.timer = 0;
2966            if (self.scrollendtrapped) self.scrollrunning = true;
2967            self.setScrollTop(self.newscrolly);
2968            self.setScrollLeft(self.newscrollx);
2969            if (!self.scrollendtrapped) self.onScrollEnd();
2970          });
2971
2972
2973        },50);
2974
2975      };
2976
2977      this.cancelScroll = function() {
2978        if (!self.scrollendtrapped) return true;
2979        var py = self.getScrollTop();
2980        var px = self.getScrollLeft();
2981        self.scrollrunning = false;
2982        if (!cap.transitionend) clearTimeout(cap.transitionend);
2983        self.scrollendtrapped = false;
2984        self._unbind(self.doc,cap.transitionend,self.onScrollEnd);
2985        self.prepareTransition(0);
2986        self.setScrollTop(py); // fire event onscroll
2987        if (self.railh) self.setScrollLeft(px);
2988        if (self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
2989        self.timerscroll = false;
2990
2991        self.cursorfreezed = false;
2992
2993        //self.noticeCursor(false,py,px);
2994        self.showCursor(py,px);
2995        return self;
2996      };
2997      this.onScrollEnd = function() {
2998        if (self.scrollendtrapped) self._unbind(self.doc,cap.transitionend,self.onScrollEnd);
2999        self.scrollendtrapped = false;
3000        self.prepareTransition(0);
3001        if (self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
3002        self.timerscroll = false;
3003        var py = self.getScrollTop();
3004        var px = self.getScrollLeft();
3005        self.setScrollTop(py);  // fire event onscroll
3006        if (self.railh) self.setScrollLeft(px);  // fire event onscroll left
3007
3008        self.noticeCursor(false,py,px);
3009
3010        self.cursorfreezed = false;
3011
3012        if (py<0) py=0
3013        else if (py>self.page.maxh) py=self.page.maxh;
3014        if (px<0) px=0
3015        else if (px>self.page.maxw) px=self.page.maxw;
3016        if((py!=self.newscrolly)||(px!=self.newscrollx)) return self.doScrollPos(px,py,self.opt.snapbackspeed);
3017
3018        if (self.onscrollend&&self.scrollrunning) {
3019          var info = {"type":"scrollend","current":{"x":px,"y":py},"end":{"x":self.newscrollx,"y":self.newscrolly}};
3020          self.onscrollend.call(self,info);
3021        }
3022        self.scrollrunning = false;
3023
3024      };
3025
3026    } else {
3027
3028      this.doScrollLeft = function(x,spd) {  //no-trans
3029        var y = (self.scrollrunning) ? self.newscrolly : self.getScrollTop();
3030        self.doScrollPos(x,y,spd);
3031      }
3032
3033      this.doScrollTop = function(y,spd) {  //no-trans
3034        var x = (self.scrollrunning) ? self.newscrollx : self.getScrollLeft();
3035        self.doScrollPos(x,y,spd);
3036      }
3037
3038      this.doScrollPos = function(x,y,spd) {  //no-trans
3039        var y = ((typeof y == "undefined")||(y===false)) ? self.getScrollTop(true) : y;
3040
3041        if  ((self.timer)&&(self.newscrolly==y)&&(self.newscrollx==x)) return true;
3042
3043        if (self.timer) clearAnimationFrame(self.timer);
3044        self.timer = 0;
3045
3046        var py = self.getScrollTop();
3047        var px = self.getScrollLeft();
3048
3049        if (((self.newscrolly-py)*(y-py)<0)||((self.newscrollx-px)*(x-px)<0)) self.cancelScroll();  //inverted movement detection
3050
3051        self.newscrolly = y;
3052        self.newscrollx = x;
3053
3054        if (!self.bouncescroll||!self.rail.visibility) {
3055          if (self.newscrolly<0) {
3056            self.newscrolly = 0;
3057          }
3058          else if (self.newscrolly>self.page.maxh) {
3059            self.newscrolly = self.page.maxh;
3060          }
3061        }
3062        if (!self.bouncescroll||!self.railh.visibility) {
3063          if (self.newscrollx<0) {
3064            self.newscrollx = 0;
3065          }
3066          else if (self.newscrollx>self.page.maxw) {
3067            self.newscrollx = self.page.maxw;
3068          }
3069        }
3070
3071        self.dst = {};
3072        self.dst.x = x-px;
3073        self.dst.y = y-py;
3074        self.dst.px = px;
3075        self.dst.py = py;
3076
3077        var dst = Math.round(Math.sqrt(Math.pow(self.dst.x,2)+Math.pow(self.dst.y,2)));
3078
3079        self.dst.ax = self.dst.x / dst;
3080        self.dst.ay = self.dst.y / dst;
3081
3082        var pa = 0;
3083        var pe = dst;
3084
3085        if (self.dst.x==0) {
3086          pa = py;
3087          pe = y;
3088          self.dst.ay = 1;
3089          self.dst.py = 0;
3090        } else if (self.dst.y==0) {
3091          pa = px;
3092          pe = x;
3093          self.dst.ax = 1;
3094          self.dst.px = 0;
3095        }
3096
3097        var ms = self.getTransitionSpeed(dst);
3098        if (spd&&spd<=1) ms*=spd;
3099        if (ms>0) {
3100          self.bzscroll = (self.bzscroll) ? self.bzscroll.update(pe,ms) : new BezierClass(pa,pe,ms,0,1,0,1);
3101        } else {
3102          self.bzscroll = false;
3103        }
3104
3105        if (self.timer) return;
3106
3107        if ((py==self.page.maxh&&y>=self.page.maxh)||(px==self.page.maxw&&x>=self.page.maxw)) self.checkContentSize();
3108
3109        var sync = 1;
3110
3111        function scrolling() {
3112          if (self.cancelAnimationFrame) return true;
3113
3114          self.scrollrunning = true;
3115
3116          sync = 1-sync;
3117          if (sync) return (self.timer = setAnimationFrame(scrolling)||1);
3118
3119          var done = 0;
3120
3121          var sc = sy = self.getScrollTop();
3122          if (self.dst.ay) {
3123            sc = (self.bzscroll) ? self.dst.py + (self.bzscroll.getNow()
3123*self.dst.ay) : self.newscrolly;
3124            var dr=sc-sy;
3125            if ((dr<0&&sc<self.newscrolly)||(dr>0&&sc>self.newscrolly)) sc = self.newscrolly;
3126            self.setScrollTop(sc);
3127            if (sc == self.newscrolly) done=1;
3128          } else {
3129            done=1;
3130          }
3131
3132          var scx = sx = self.getScrollLeft();
3133          if (self.dst.ax) {
3134            scx = (self.bzscroll) ? self.dst.px + (self.bzscroll.getNow()*self.dst.ax) : self.newscrollx;
3135            var dr=scx-sx;
3136            if ((dr<0&&scx<self.newscrollx)||(dr>0&&scx>self.newscrollx)) scx = self.newscrollx;
3137            self.setScrollLeft(scx);
3138            if (scx == self.newscrollx) done+=1;
3139          } else {
3140            done+=1;
3141          }
3142
3143          if (done==2) {
3144            self.timer = 0;
3145            self.cursorfreezed = false;
3146            self.bzscroll = false;
3147            self.scrollrunning = false;
3148            if (sc<0) sc=0;
3149            else if (sc>self.page.maxh) sc=self.page.maxh;
3150            if (scx<0) scx=0;
3151            else if (scx>self.page.maxw) scx=self.page.maxw;
3152            if ((scx!=self.newscrollx)||(sc!=self.newscrolly)) self.doScrollPos(scx,sc);
3153            else {
3154              if (self.onscrollend) {
3155                var info = {"type":"scrollend","current":{"x":sx,"y":sy},"end":{"x":self.newscrollx,"y":self.newscrolly}};
3156                self.onscrollend.call(self,info);
3157              }
3158            }
3159          } else {
3160            self.timer = setAnimationFrame(scrolling)||1;
3161          }
3162        };
3163        self.cancelAnimationFrame=false;
3164        self.timer = 1;
3165
3166        if (self.onscrollstart&&!self.scrollrunning) {
3167          var info = {"type":"scrollstart","current":{"x":px,"y":py},"request":{"x":x,"y":y},"end":{"x":self.newscrollx,"y":self.newscrolly},"speed":ms};
3168          self.onscrollstart.call(self,info);
3169        }
3170
3171        scrolling();
3172
3173        if ((py==self.page.maxh&&y>=py)||(px==self.page.maxw&&x>=px)) self.checkContentSize();
3174
3175        self.noticeCursor();
3176      };
3177
3178      this.cancelScroll = function() {
3179        if (self.timer) clearAnimationFrame(self.timer);
3180        self.timer = 0;
3181        self.bzscroll = false;
3182        self.scrollrunning = false;
3183        return self;
3184      };
3185
3186    }
3187
3188    this.doScrollBy = function(stp,relative) {
3189      var ny = 0;
3190      if (relative) {
3191        ny = Math.floor((self.scroll.y-stp)*self.scrollratio.y)
3192      } else {
3193        var sy = (self.timer) ? self.newscrolly : self.getScrollTop(true);
3194        ny = sy-stp;
3195      }
3196      if (self.bouncescroll) {
3197        var haf = Math.round(self.view.h/2);
3198        if (ny<-haf) ny=-haf
3199        else if (ny>(self.page.maxh+haf)) ny = (self.page.maxh+haf);
3200      }
3201      self.cursorfreezed = false;
3202
3203      py = self.getScrollTop(true);
3204      if (ny<0&&py<=0) return self.noticeCursor();
3205      else if (ny>self.page.maxh&&py>=self.page.maxh) {
3206        self.checkContentSize();
3207        return self.noticeCursor();
3208      }
3209
3210      self.doScrollTop(ny);
3211    };
3212
3213    this.doScrollLeftBy = function(stp,relative) {
3214      var nx = 0;
3215      if (relative) {
3216        nx = Math.floor((self.scroll.x-stp)*self.scrollratio.x)
3217      } else {
3218        var sx = (self.timer) ? self.newscrollx : self.getScrollLeft(true);
3219        nx = sx-stp;
3220      }
3221      if (self.bouncescroll) {
3222        var haf = Math.round(self.view.w/2);
3223        if (nx<-haf) nx=-haf
3224        else if (nx>(self.page.maxw+haf)) nx = (self.page.maxw+haf);
3225      }
3226      self.cursorfreezed = false;
3227
3228      px = self.getScrollLeft(true);
3229      if (nx<0&&px<=0) return self.noticeCursor();
3230      else if (nx>self.page.maxw&&px>=self.page.maxw) return self.noticeCursor();
3231
3232      self.doScrollLeft(nx);
3233    };
3234
3235    this.doScrollTo = function(pos,relative) {
3236      var ny = (relative) ? Math.round(pos*self.scrollratio.y) : pos;
3237      if (ny<0) ny=0
3238      else if (ny>self.page.maxh) ny = self.page.maxh;
3239      self.cursorfreezed = false;
3240      self.doScrollTop(pos);
3241    };
3242
3243    this.checkContentSize = function() {
3244      var pg = self.getContentSize();
3245      if ((pg.h!=self.page.h)||(pg.w!=self.page.w)) self.resize(false,pg);
3246    };
3247
3248    self.onscroll = function(e) {
3249      if (self.rail.drag) return;
3250      if (!self.cursorfreezed) {
3251        self.synched('scroll',function(){
3252          self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
3253          if (self.railh) self.scroll.x = Math.round(self.getScrollLeft() * (1/self.scrollratio.x));
3254          self.noticeCursor();
3255        });
3256      }
3257    };
3258    self.bind(self.docscroll,"scroll",self.onscroll);
3259
3260    this.doZoomIn = function(e) {
3261      if (self.zoomactive) return;
3262      self.zoomactive = true;
3263
3264      self.zoomrestore = {
3265        style:{}
3266      };
3267      var lst = ['position','top','left','zIndex','backgroundColor','marginTop','marginBottom','marginLeft','marginRight'];
3268      var win = self.win[0].style;
3269      for(var a in lst) {
3270        var pp = lst[a];
3271        self.zoomrestore.style[pp] = (typeof win[pp] != "undefined") ? win[pp] : '';
3272      }
3273
3274      self.zoomrestore.style.width = self.win.css('width');
3275      self.zoomrestore.style.height = self.win.css('height');
3276
3277      self.zoomrestore.padding = {
3278        w:self.win.outerWidth()-self.win.width(),
3279        h:self.win.outerHeight()-self.win.height()
3280      };
3281
3282      if (cap.isios4) {
3283        self.zoomrestore.scrollTop = $(window).scrollTop();
3284        $(window).scrollTop(0);
3285      }
3286
3287      self.win.css({
3288        "position":(cap.isios4)?"absolute":"fixed",
3289        "top":0,
3290        "left":0,
3291        "z-index":globalmaxzindex+100,
3292        "margin":"0px"
3293      });
3294      var bkg = self.win.css("backgroundColor");
3295      if (bkg==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(bkg)) self.win.css("backgroundColor","#fff");
3296      self.rail.css({"z-index":globalmaxzindex+101});
3297      self.zoom.css({"z-index":globalmaxzindex+102});
3298      self.zoom.css('backgroundPosition','0px -18px');
3299      self.resizeZoom();
3300
3301      if (self.onzoomin) self.onzoomin.call(self);
3302
3303      return self.cancelEvent(e);
3304    };
3305
3306    this.doZoomOut = function(e) {
3307      if (!self.zoomactive) return;
3308      self.zoomactive = false;
3309
3310      self.win.css("margin","");
3311      self.win.css(self.zoomrestore.style);
3312
3313      if (cap.isios4) {
3314        $(window).scrollTop(self.zoomrestore.scrollTop);
3315      }
3316
3317      self.rail.css({"z-index":self.zindex});
3318      self.zoom.css({"z-index":self.zindex});
3319      self.zoomrestore = false;
3320      self.zoom.css('backgroundPosition','0px 0px');
3321      self.onResize();
3322
3323      if (self.onzoomout) self.onzoomout.call(self);
3324
3325      return self.cancelEvent(e);
3326    };
3327
3328    this.doZoom = function(e) {
3329      return (self.zoomactive) ? self.doZoomOut(e) : self.doZoomIn(e);
3330    };
3331
3332    this.resizeZoom = function() {
3333      if (!self.zoomactive) return;
3334
3335      var py = self.getScrollTop(); //preserve scrolling position
3336      self.win.css({
3337        width:$(window).width()-self.zoomrestore.padding.w+"px",
3338        height:$(window).height()-self.zoomrestore.padding.h+"px"
3339      });
3340      self.onResize();
3341
3342      self.setScrollTop(Math.min(self.page.maxh,py));
3343    };
3344
3345    this.init();
3346
3347    $.nicescroll.push(this);
3348
3349  };
3350
3351// Inspired by the work of Kin Blas
3352// http://webpro.host.adobe.com/people/jblas/momentum/includes/jquery.momentum.0.7.js
3353
3354
3355  var ScrollMomentumClass2D = function(nc) {
3356    var self = this;
3357    this.nc = nc;
3358
3359    this.lastx = 0;
3360    this.lasty = 0;
3361    this.speedx = 0;
3362    this.speedy = 0;
3363    this.lasttime = 0;
3364    this.steptime = 0;
3365    this.snapx = false;
3366    this.snapy = false;
3367    this.demulx = 0;
3368    this.demuly = 0;
3369
3370    this.lastscrollx = -1;
3371    this.lastscrolly = -1;
3372
3373    this.chkx = 0;
3374    this.chky = 0;
3375
3376    this.timer = 0;
3377
3378    this.time = function() {
3379      return +new Date();//beautifull hack
3380    };
3381
3382    this.reset = function(px,py) {
3383      self.stop();
3384      var now = self.time();
3385      self.steptime = 0;
3386      self.lasttime = now;
3387      self.speedx = 0;
3388      self.speedy = 0;
3389      self.lastx = px;
3390      self.lasty = py;
3391      self.lastscrollx = -1;
3392      self.lastscrolly = -1;
3393    };
3394
3395    this.update = function(px,py) {
3396      var now = self.time();
3397      self.steptime = now - self.lasttime;
3398      self.lasttime = now;
3399      var dy = py - self.lasty;
3400      var dx = px - self.lastx;
3401      var sy = self.nc.getScrollTop();
3402      var sx = self.nc.getScrollLeft();
3403      var newy = sy + dy;
3404      var newx = sx + dx;
3405      self.snapx = (newx<0)||(newx>self.nc.page.maxw);
3406      self.snapy = (newy<0)||(newy>self.nc.page.maxh);
3407      self.speedx = dx;
3408      self.speedy = dy;
3409      self.lastx = px;
3410      self.lasty = py;
3411    };
3412
3413    this.stop = function() {
3414      self.nc.unsynched("domomentum2d");
3415      if (self.timer) clearTimeout(self.timer);
3416      self.timer = 0;
3417      self.lastscrollx = -1;
3418      self.lastscrolly = -1;
3419    };
3420
3421    this.doSnapy = function(nx,ny) {
3422      var snap = false;
3423
3424      if (ny<0) {
3425        ny=0;
3426        snap=true;
3427      }
3428      else if (ny>self.nc.page.maxh) {
3429        ny=self.nc.page.maxh;
3430        snap=true;
3431      }
3432
3433      if (nx<0) {
3434        nx=0;
3435        snap=true;
3436      }
3437      else if (nx>self.nc.page.maxw) {
3438        nx=self.nc.page.maxw;
3439        snap=true;
3440      }
3441
3442      if (snap) self.nc.doScrollPos(nx,ny,self.nc.opt.snapbackspeed);
3443    };
3444
3445    this.doMomentum = function(gp) {
3446      var t = self.time();
3447      var l = (gp) ? t+gp : self.lasttime;
3448
3449      var sl = self.nc.getScrollLeft();
3450      var st = self.nc.getScrollTop();
3451
3452      var pageh = self.nc.page.maxh;
3453      var pagew = self.nc.page.maxw;
3454
3455      self.speedx = (pagew>0) ? Math.min(60,self.speedx) : 0;
3456      self.speedy = (pageh>0) ? Math.min(60,self.speedy) : 0;
3457
3458      var chk = l && (t - l) <= 60;
3459
3460      if ((st<0)||(st>pageh)||(sl<0)||(sl>
3460pagew)) chk = false;
3461
3462      var sy = (self.speedy && chk) ? self.speedy : false;
3463      var sx = (self.speedx && chk) ? self.speedx : false;
3464
3465      if (sy||sx) {
3466        var tm = Math.max(16,self.steptime); //timeout granularity
3467
3468        if (tm>50) {  // do smooth
3469          var xm = tm/50;
3470          self.speedx*=xm;
3471          self.speedy*=xm;
3472          tm = 50;
3473        }
3474
3475        self.demulxy = 0;
3476
3477        self.lastscrollx = self.nc.getScrollLeft();
3478        self.chkx = self.lastscrollx;
3479        self.lastscrolly = self.nc.getScrollTop();
3480        self.chky = self.lastscrolly;
3481
3482        var nx = self.lastscrollx;
3483        var ny = self.lastscrolly;
3484
3485        var onscroll = function(){
3486          var df = ((self.time()-t)>600) ? 0.04 : 0.02;
3487
3488          if (self.speedx) {
3489            nx = Math.floor(self.lastscrollx - (self.speedx*(1-self.demulxy)));
3490            self.lastscrollx = nx;
3491            if ((nx<0)||(nx>pagew)) df=0.10;
3492          }
3493
3494          if (self.speedy) {
3495            ny = Math.floor(self.lastscrolly - (self.speedy*(1-self.demulxy)));
3496            self.lastscrolly = ny;
3497            if ((ny<0)||(ny>pageh)) df=0.10;
3498          }
3499
3500          self.demulxy = Math.min(1,self.demulxy+df);
3501
3502          self.nc.synched("domomentum2d",function(){
3503
3504            if (self.speedx) {
3505              var scx = self.nc.getScrollLeft();
3506              if (scx!=self.chkx) self.stop();
3507              self.chkx=nx;
3508              self.nc.setScrollLeft(nx);
3509            }
3510
3511            if (self.speedy) {
3512              var scy = self.nc.getScrollTop();
3513              if (scy!=self.chky) self.stop();
3514              self.chky=ny;
3515              self.nc.setScrollTop(ny);
3516            }
3517
3518            if(!self.timer) {
3519              self.nc.hideCursor();
3520              self.doSnapy(nx,ny);
3521            }
3522
3523          });
3524
3525          if (self.demulxy<1) {
3526            self.timer = setTimeout(onscroll,tm);
3527          } else {
3528            self.stop();
3529            self.nc.hideCursor();
3530            self.doSnapy(nx,ny);
3531          }
3532        };
3533
3534        onscroll();
3535
3536      } else {
3537        self.doSnapy(self.nc.getScrollLeft(),self.nc.getScrollTop());
3538      }
3539
3540    }
3541
3542  };
3543
3544
3545// override jQuery scrollTop
3546
3547  var _scrollTop = jQuery.fn.scrollTop; // preserve original function
3548
3549  jQuery.cssHooks["pageYOffset"] = {
3550    get: function(elem,computed,extra) {
3551      var nice = $.data(elem,'__nicescroll')||false;
3552      return (nice&&nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(elem);
3553    },
3554    set: function(elem,value) {
3555      var nice = $.data(elem,'__nicescroll')||false;
3556      (nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)) : _scrollTop.call(elem,value);
3557      return this;
3558    }
3559  };
3560
3561/*
3562  $.fx.step["scrollTop"] = function(fx){
3563    $.cssHooks["scrollTop"].set( fx.elem, fx.now + fx.unit );
3564  };
3565*/
3566
3567  jQuery.fn.scrollTop = function(value) {
3568    if (typeof value == "undefined") {
3569      var nice = (this[0]) ? $.data(this[0],'__nicescroll')||false : false;
3570      return (nice&&nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(this);
3571    } else {
3572      return this.each(function() {
3573        var nice = $.data(this,'__nicescroll')||false;
3574        (nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)) : _scrollTop.call($(this),value);
3575      });
3576    }
3577  }
3578
3579// override jQuery scrollLeft
3580
3581  var _scrollLeft = jQuery.fn.scrollLeft; // preserve original function
3582
3583  $.cssHooks.pageXOffset = {
3584    get: function(elem,computed,extra) {
3585      var nice = $.data(elem,'__nicescroll')||false;
3586      return (nice&&nice.ishwscroll) ? nice.getScrollLeft() : _scrollLeft.call(elem);
3587    },
3588    set: function(elem,value) {
3589      var nice = $.data(elem,'__nicescroll')||false;
3590      (nice&&nice.ishwscroll) ? nice.setScrollLeft(parseInt(value)) : _scrollLeft.call(elem,value);
3591      return this;
3592    }
3593  };
3594
3595/*
3596  $.fx.step["scrollLeft"] = function(fx){
3597    $.cssHooks["scrollLeft"].set( fx.elem, fx.now + fx.unit );
3598  };
3599*/
3600
3601  jQuery.fn.scrollLeft = function(value) {
3602    if (typeof value == "undefined") {
3603      var nice = (this[0]) ? $.data(this[0],'__nicescroll')||false : false;
3604      return (nice&&nice.ishwscroll) ? nice.getScrollLeft() : _scrollLeft.call(this);
3605    } else {
3606      return this.each(function() {
3607        var nice = $.data(this,'__nicescroll')||false;
3608        (nice&&nice.ishwscroll) ? nice.setScrollLeft(parseInt(value)) : _scrollLeft.call($(this),value);
3609      });
3610    }
3611  }
3612
3613  var NiceScrollArray = function(doms) {
3614    var self = this;
3615    this.length = 0;
3616    this.name = "nicescrollarray";
3617
3618    this.each = function(fn) {
3619      for(var a=0,i=0;a<self.length;a++) fn.call(self[a],i++);
3620      return self;
3621    };
3622
3623    this.push = function(nice) {
3624      self[self.length]=nice;
3625      self.length++;
3626    };
3627
3628    this.eq = function(idx) {
3629      return self[idx];
3630    };
3631
3632    if (doms) {
3633      for(a=0;a<doms.length;a++) {
3634        var nice = $.data(doms[a],'__nicescroll')||false;
3635        if (nice) {
3636          this[this.length]=nice;
3637          this.length++;
3638        }
3639      };
3640    }
3641
3642    return this;
3643  };
3644
3645  function mplex(el,lst,fn) {
3646    for(var a=0;a<lst.length;a++) fn(el,lst[a]);
3647  };
3648  mplex(
3649    NiceScrollArray.prototype,
3650    ['show','hide','toggle','onResize','resize','remove','stop','doScrollPos'],
3651    function(e,n) {
3652      e[n] = function(){
3653        var args = arguments;
3654        return this.each(function(){
3655          this[n].apply(this,args);
3656        });
3657      };
3658    }
3659  );
3660
3661  jQuery.fn.getNiceScroll = function(index) {
3662    if (typeof index == "undefined") {
3663      return new NiceScrollArray(this);
3664    } else {
3665      var nice = this[index]&&$.data(this[index],'__nicescroll')||false;
3666      return nice;
3667    }
3668  };
3669
3670  jQuery.extend(jQuery.expr[':'], {
3671    nicescroll: function(a) {
3672      return ($.data(a,'__nicescroll'))?true:false;
3673    }
3674  });
3675
3676  $.fn.niceScroll = function(wrapper,opt) {
3677    if (typeof opt=="undefined") {
3678      if ((typeof wrapper=="object")&&!("jquery" in wrapper)) {
3679        opt = wrapper;
3680        wrapper = false;
3681      }
3682    }
3683    var ret = new NiceScrollArray();
3684    if (typeof opt=="undefined") opt = {};
3685
3686    if (wrapper||false) {
3687      opt.doc = $(wrapper);
3688      opt.win = $(this);
3689    }
3690    var docundef = !("doc" in opt);
3691    if (!docundef&&!("win" in opt)) opt.win = $(this);
3692
3693    this.each(function() {
3694      var nice = $(this).data('__nicescroll')||false;
3695      if (!nice) {
3696        opt.doc = (docundef) ? $(this) : opt.doc;
3697        nice = new NiceScrollClass(opt,$(this));
3698        $(this).data('__nicescroll',nice);
3699      }
3700      ret.push(nice);
3701    });
3702    return (ret.length==1) ? ret[0] : ret;
3703  };
3704
3705  window.NiceScroll = {
3706    getjQuery:function(){return jQuery}
3707  };
3708
3709  if (!$.nicescroll) {
3710   $.nicescroll = new NiceScrollArray();
3711   $.nicescroll.options = _globaloptions;
3712  }
3713
3714})( jQuery );
3715
3716
3717	// Retina
3718
3719/*!
3720 * Retina.js v1.3.0
3721 *
3722 * Copyright 2014 Imulus, LLC
3723 * Released under the MIT license
3724 *
3725 * Retina.js is an open source script that makes it easy to serve
3726 * high-resolution images to devices with retina displays.
3727 */
3728
3729(function() {
3730    var root = (typeof exports === 'undefined' ? window : exports);
3731    var config = {
3732        // An option to choose a suffix for 2x images
3733        retinaImageSuffix : '@2x',
3734
3735        // Ensure Content-Type is an image before trying to load @2x image
3736        // https://github.com/imulus/retinajs/pull/45)
3737        check_mime_type: true,
3738
3739        // Resize high-resolution images to original image's pixel dimensions
3740        // https://github.com/imulus/retinajs/issues/8
3741        force_original_dimensions: true
3742    };
3743
3744    function Retina() {}
3745
3746    root.Retina = Retina;
3747
3748    Retina.configure = function(options) {
3749        if (options === null) {
3750            options = {};
3751        }
3752
3753        for (var prop in options) {
3754            if (options.hasOwnProperty(prop)) {
3755                config[prop] = options[prop];
3756            }
3757        }
3758    };
3759
3760    Retina.init = function(context) {
3761        if (context === null) {
3762            context = root;
3763        }
3764
3765        var existing_onload = context.onload || function(){};
3766
3767        context.onload = function() {
3768            var images = document.getElementsByTagName('img'), retinaImages = [], i, image;
3769            for (i = 0; i < images.length; i += 1) {
3770                image = images[i];
3771                if (!!!image.getAttributeNode('data-no-retina')) {
3772                    retinaImages.push(new RetinaImage(image));
3773                }
3774            }
3775            existing_onload();
3776        };
3777    };
3778
3779    Retina.isRetina = function(){
3780        var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)';
3781
3782        if (root.devicePixelRatio > 1) {
3783            return true;
3784        }
3785
3786        if (root.matchMedia && root.matchMedia(mediaQuery).matches) {
3787            return true;
3788        }
3789
3790        return false;
3791    };
3792
3793
3794    var regexMatch = /\.\w+$/;
3795    function suffixReplace (match) {
3796        return config.retinaImageSuffix + match;
3797    }
3798
3799    function RetinaImagePath(path, at_2x_path) {
3800        this.path = path || '';
3801        if (typeof at_2x_path !== 'undefined' && at_2x_path !== null) {
3802            this.at_2x_path = at_2x_path;
3803            this.perform_check = false;
3804        } else {
3805            if (undefined !== document.createElement) {
3806                var locationObject = document.createElement('a');
3807                locationObject.href = this.path;
3808                locationObject.pathname = locationObject.pathname.replace(regexMatch, suffixReplace);
3809                this.at_2x_path = locationObject.href;
3810            } else {
3811                var parts = this.path.split('?');
3812                parts[0] = parts[0].replace(regexMatch, suffixReplace);
3813                this.at_2x_path = parts.join('?');
3814            }
3815            this.perform_check = true;
3816        }
3817    }
3818
3819    root.RetinaImagePath = RetinaImagePath;
3820
3821    RetinaImagePath.confirmed_paths = [];
3822
3823    RetinaImagePath.prototype.is_external = function() {
3824        return !!(this.path.match(/^https?\:/i) && !this.path.match('//' + document.domain) );
3825    };
3826
3827    RetinaImagePath.prototype.check_2x_variant = function(callback) {
3828        var http, that = this;
3829        if (this.is_external()) {
3830            return callback(false);
3831        } else if (!this.perform_check && typeof this.at_2x_path !== 'undefined' && this.at_2x_path !== null) {
3832            return callback(true);
3833        } else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
3834            return callback(true);
3835        } else {
3836            http = new XMLHttpRequest();
3837            http.open('HEAD', this.at_2x_path);
3838            http.onreadystatechange = function() {
3839                if (http.readyState !== 4) {
3840                    return callback(false);
3841                }
3842
3843                if (http.status >= 200 && http.status <= 399) {
3844                    if (config.check_mime_type) {
3845                        var type = http.getResponseHeader('Content-Type');
3846                        if (type === null || !type.match(/^image/i)) {
3847                            return callback(false);
3848                        }
3849                    }
3850
3851                    RetinaImagePath.confirmed_paths.push(that.at_2x_path);
3852                    return callback(true);
3853                } else {
3854                    return callback(false);
3855                }
3856            };
3857            http.send();
3858        }
3859    };
3860
3861
3862    function RetinaImage(el) {
3863        this.el = el;
3864        this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
3865        var that = this;
3866        this.path.check_2x_variant(function(hasVariant) {
3867            if (hasVariant) {
3868                that.swap();
3869            }
3870        });
3871    }
3872
3873    root.RetinaImage = RetinaImage;
3874
3875    RetinaImage.prototype.swap = function(path) {
3876        if (typeof path === 'undefined') {
3877            path = this.path.at_2x_path;
3878        }
3879
3880        var that = this;
3881        function load() {
3882            if (! that.el.complete) {
3883                setTimeout(load, 5);
3884            } else {
3885                if (config.force_original_dimensions) {
3886                    that.el.setAttribute('width', that.el.offsetWidth);
3887                    that.el.setAttribute('height', that.el.offsetHeight);
3888                }
3889
3890                that.el.setAttribute('src', path);
3891            }
3892        }
3893        load();
3894    };
3895
3896
3897    if (Retina.isRetina()) {
3898        Retina.init(root);
3899    }
3900})();
3901
3902
3903/*
3904 * jQuery FlexSlider v2.5.0
3905 * Copyright 2012 WooThemes
3906 * Contributing Author: Tyler Smith
3907 */!function($){$.flexslider=function(e,t){var a=$(e);a.vars=$.extend({},$.flexslider.defaults,t);var n=a.vars.namespace,i=window.navigator&&window.navigator.msPointerEnabled&&window.MSGesture,s=("ontouchstart"in window||i||window.DocumentTouch&&document instanceof DocumentTouch)&&a.vars.touch,r="click touchend MSPointerUp keyup",o="",l,c="vertical"===a.vars.direction,d=a.vars.reverse,u=a.vars.itemWidth>0,v="fade"===a.vars.animation,p=""!==a.vars.asNavFor,m={},f=!0;$.data(e,"flexslider",a),m={init:function(){a.animating=!1,a.currentSlide=parseInt(a.vars.startAt?a.vars.startAt:0,10),isNaN(a.currentSlide)&&(a.currentSlide=0),a.animatingTo=a.currentSlide,a.atEnd=0===a.currentSlide||a.currentSlide===a.last,a.containerSelector=a.vars.selector.substr(0,a.vars.selector.search(" ")),a.slides=$(a.vars.selector,a),a.container=$(a.containerSelector,a),a.count=a.slides.length,a.syncExists=$(a.vars.sync).length>0,"slide"===a.vars.animation&&(a.vars.animation="swing"),a.prop=c?"top":"marginLeft",a.args={},a.manualPause=!1,a.stopped=!1,a.started=!1,a.startTimeout=null,a.transitions=!a.vars.video&&!v&&a.vars.useCSS&&function(){var e=document.createElement("div"),t=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var n in t)if(void 0!==e.style[t[n]])return a.pfx=t[n].replace("Perspective","").toLowerCase(),a.prop="-"+a.pfx+"-transform",!0;return!1}(),a.ensureAnimationEnd="",""!==a.vars.controlsContainer&&(a.controlsContainer=$(a.vars.controlsContainer).length>0&&$(a.vars.controlsContainer)),""!==a.vars.manualControls&&(a.manualControls=$(a.vars.manualControls).length>0&&$(a.vars.manualControls)),""!==a.vars.customDirectionNav&&(a.customDirectionNav=2===$(a.vars.customDirectionNav).length&&$(a.vars.customDirectionNav)),a.vars.randomize&&(a.slides.sort(function(){return Math.round(Math.random())-.5}),a.container.empty().append(a.slides)),a.doMath(),a.setup("init"),a.vars.c
3907ontrolNav&&m.controlNav.setup(),a.vars.directionNav&&m.directionNav.setup(),a.vars.keyboard&&(1===$(a.containerSelector).length||a.vars.multipleKeyboard)&&$(document).bind("keyup",function(e){var t=e.keyCode;if(!a.animating&&(39===t||37===t)){var n=39===t?a.getTarget("next"):37===t?a.getTarget("prev"):!1;a.flexAnimate(n,a.vars.pauseOnAction)}}),a.vars.mousewheel&&a.bind("mousewheel",function(e,t,n,i){e.preventDefault();var s=a.getTarget(0>t?"next":"prev");a.flexAnimate(s,a.vars.pauseOnAction)}),a.vars.pausePlay&&m.pausePlay.setup(),a.vars.slideshow&&a.vars.pauseInvisible&&m.pauseInvisible.init(),a.vars.slideshow&&(a.vars.pauseOnHover&&a.hover(function(){a.manualPlay||a.manualPause||a.pause()},function(){a.manualPause||a.manualPlay||a.stopped||a.play()}),a.vars.pauseInvisible&&m.pauseInvisible.isHidden()||(a.vars.initDelay>0?a.startTimeout=setTimeout(a.play,a.vars.initDelay):a.play())),p&&m.asNav.setup(),s&&a.vars.touch&&m.touch(),(!v||v&&a.vars.smoothHeight)&&$(window).bind("resize orientationchange focus",m.resize),a.find("img").attr("draggable","false"),setTimeout(function(){a.vars.start(a)},200)},asNav:{setup:function(){a.asNav=!0,a.animatingTo=Math.floor(a.currentSlide/a.move),a.currentItem=a.currentSlide,a.slides.removeClass(n+"active-slide").eq(a.currentItem).addClass(n+"active-slide"),i?(e._slider=a,a.slides.each(function(){var e=this;e._gesture=new MSGesture,e._gesture.target=e,e.addEventListener("MSPointerDown",function(e){e.preventDefault(),e.currentTarget._gesture&&e.currentTarget._gesture.addPointer(e.pointerId)},!1),e.addEventListener("MSGestureTap",function(e){e.preventDefault();var t=$(this),n=t.index();$(a.vars.asNavFor).data("flexslider").animating||t.hasClass("active")||(a.direction=a.currentItem<n?"next":"prev",a.flexAnimate(n,a.vars.pauseOnAction,!1,!0,!0))})})):a.slides.on(r,function(e){e.preventDefault();var t=$(this),i=t.index(),s=t.offset().left-$(a).scrollLeft();0>=s&&t.hasClass(n+"active-slide")?a.flexAnimate(a.getTarget("prev"),!0):$(a.vars.asNavFor).data("flexslider").animating||t.hasClass(n+"active-slide")||(a.direction=a.currentItem<i?"next":"prev",a.flexAnimate(i,a.vars.pauseOnAction,!1,!0,!0))})}},controlNav:{setup:function(){a.manualControls?m.controlNav.setupManual():m.controlNav.setupPaging()},setupPaging:function(){var e="thumbnails"===a.vars.controlNav?"control-thumbs":"control-paging",t=1,i,s;if(a.controlNavScaffold=$('<ol class="'+n+"control-nav "+n+e+'"></ol>'),a.pagingCount>1)for(var l=0;l<a.pagingCount;l++){if(s=a.slides.eq(l),i="thumbnails"===a.vars.controlNav?'<img src="'+s.attr("data-thumb")+'"/>':"<a>"+t+"</a>","thumbnails"===a.vars.controlNav&&!0===a.vars.thumbCaptions){var c=s.attr("data-thumbcaption");""!==c&&void 0!==c&&(i+='<span class="'+n+'caption">'+c+"</span>")}a.controlNavScaffold.append("<li>"+i+"</li>"),t++}a.controlsContainer?$(a.controlsContainer).append(a.controlNavScaffold):a.append(a.controlNavScaffold),m.controlNav.set(),m.controlNav.active(),a.controlNavScaffold.delegate("a, img",r,function(e){if(e.preventDefault(),""===o||o===e.type){var t=$(this),i=a.controlNav.index(t);t.hasClass(n+"active")||(a.direction=i>a.currentSlide?"next":"prev",a.flexAnimate(i,a.vars.pauseOnAction))}""===o&&(o=e.type),m.setToClearWatchedEvent()})},setupManual:function(){a.controlNav=a.manualControls,m.controlNav.active(),a.controlNav.bind(r,function(e){if(e.preventDefault(),""===o||o===e.type){var t=$(this),i=a.controlNav.index(t);t.hasClass(n+"active")||(a.direction=i>a.currentSlide?"next":"prev",a.flexAnimate(i,a.vars.pauseOnAction))}""===o&&(o=e.type),m.setToClearWatchedEvent()})},set:function(){var e="thumbnails"===a.vars.controlNav?"img":"a";a.controlNav=$("."+n+"control-nav li "+e,a.controlsContainer?a.controlsContainer:a)},active:function(){a.controlNav.removeClass(n+"active").eq(a.animatingTo).addClass(n+"active")},update:function(e,t){a.pagingCount>1&&"add"===e?a.controlNavScaffold.append($("<li><a>"+a.count+"</a></li>")):1===a.pagingCount?a.controlNavScaffold.find("li").remove():a.controlNav.eq(t).closest("li").remove(),m.controlNav.set(),a.pagingCount>1&&a.pagingCount!==a.controlNav.length?a.update(t,e):m.controlNav.active()}}
3907,directionNav:{setup:function(){var e=$('<ul class="'+n+'direction-nav"><li class="'+n+'nav-prev"><a class="'+n+'prev" href="#">'+a.vars.prevText+'</a></li><li class="'+n+'nav-next"><a class="'+n+'next" href="#">'+a.vars.nextText+"</a></li></ul>");a.customDirectionNav?a.directionNav=a.customDirectionNav:a.controlsContainer?($(a.controlsContainer).append(e),a.directionNav=$("."+n+"direction-nav li a",a.controlsContainer)):(a.append(e),a.directionNav=$("."+n+"direction-nav li a",a)),m.directionNav.update(),a.directionNav.bind(r,function(e){e.preventDefault();var t;(""===o||o===e.type)&&(t=a.getTarget($(this).hasClass(n+"next")?"next":"prev"),a.flexAnimate(t,a.vars.pauseOnAction)),""===o&&(o=e.type),m.setToClearWatchedEvent()})},update:function(){var e=n+"disabled";1===a.pagingCount?a.directionNav.addClass(e).attr("tabindex","-1"):a.vars.animationLoop?a.directionNav.removeClass(e).removeAttr("tabindex"):0===a.animatingTo?a.directionNav.removeClass(e).filter("."+n+"prev").addClass(e).attr("tabindex","-1"):a.animatingTo===a.last?a.directionNav.removeClass(e).filter("."+n+"next").addClass(e).attr("tabindex","-1"):a.directionNav.removeClass(e).removeAttr("tabindex")}}
3907,pausePlay:{setup:function(){var e=$('<div class="'+n+'pauseplay"><a></a></div>');a.controlsContainer?(a.controlsContainer.append(e),a.pausePlay=$("."+n+"pauseplay a",a.controlsContainer)):(a.append(e),a.pausePlay=$("."+n+"pauseplay a",a)),m.pausePlay.update(a.vars.slideshow?n+"pause":n+"play"),a.pausePlay.bind(r,function(e){e.preventDefault(),(""===o||o===e.type)&&($(this).hasClass(n+"pause")?(a.manualPause=!0,a.manualPlay=!1,a.pause()):(a.manualPause=!1,a.manualPlay=!0,a.play())),""===o&&(o=e.type),m.setToClearWatchedEvent()})},update:function(e){"play"===e?a.pausePlay.removeClass(n+"pause").addClass(n+"play").html(a.vars.playText):a.pausePlay.removeClass(n+"play").addClass(n+"pause").html(a.vars.pauseText)}},touch:function(){function t(t){t.stopPropagation(),a.animating?t.preventDefault():(a.pause(),e._gesture.addPointer(t.pointerId),w=0,p=c?a.h:a.w,f=Number(new Date),l=u&&d&&a.animatingTo===a.last?0:u&&d?a.limit-(a.itemW+a.vars.itemMargin)*a.move*a.animatingTo:u&&a.currentSlide===a.last?a.limit:u?(a.itemW+a.vars.itemMargin)*a.move*a.currentSlide:d?(a.last-a.currentSlide+a.cloneOffset)*p:(a.currentSlide+a.cloneOffset)*p)}function n(t){t.stopPropagation();var a=t.target._slider;if(a){var n=-t.translationX,i=-t.translationY;return w+=c?i:n,m=w,y=c?Math.abs(w)<Math.abs(-n):Math.abs(w)<Math.abs(-i),t.detail===t.MSGESTURE_FLAG_INERTIA?void setImmediate(function(){e._gesture.stop()}):void((!y||Number(new Date)-f>500)&&(t.preventDefault(),!v&&a.transitions&&(a.vars.animationLoop||(m=w/(0===a.currentSlide&&0>w||a.currentSlide===a.last&&w>0?Math.abs(w)/p+2:1)),a.setProps(l+m,"setTouch"))))}}function s(e){e.stopPropagation();var t=e.target._slider;if(t){if(t.animatingTo===t.currentSlide&&!y&&null!==m){var a=d?-m:m,n=t.getTarget(a>0?"next":"prev");t.canAdvance(n)&&(Number(new Date)-f<550&&Math.abs(a)>50||Math.abs(a)>p/2)?t.flexAnimate(n,t.vars.pauseOnAction):v||t.flexAnimate(t.currentSlide,t.vars.pauseOnAction,!0)}r=null,o=null,m=null,l=null,w=0}}var r,o,l,p,m,f,g,h,S,y=!1,x=0,b=0,w=0;i?(e.style.msTouchAction="none",e._gesture=new MSGesture,e._gesture.target=e,e.addEventListener("MSPointerDown",t,!1),e._slider=a,e.addEventListener("MSGestureChange",n,!1),e.addEventListener("MSGestureEnd",s,!1)):(g=function(t){a.animating?t.preventDefault():(window.navigator.msPointerEnabled||1===t.touches.length)&&(a.pause(),p=c?a.h:a.w,f=Number(new Date),x=t.touches[0].pageX,b=t.touches[0].pageY,l=u&&d&&a.animatingTo===a.last?0:u&&d?a.limit-(a.itemW+a.vars.itemMargin)*a.move*a.animatingTo:u&&a.currentSlide===a.last?a.limit:u?(a.itemW+a.vars.itemMargin)*a.move*a.currentSlide:d?(a.last-a.currentSlide+a.cloneOffset)*p:(a.currentSlide+a.cloneOffset)*p,r=c?b:x,o=c?x:b,e.addEventListener("touchmove",h,!1),e.addEventListener("touchend",S,!1))},h=function(e){x=e.touches[0].pageX,b=e.touches[0].pageY,m=c?r-b:r-x,y=c?Math.abs(m)<Math.abs(x-o):Math.abs(m)<Math.abs(b-o);var t=500;(!y||Number(new Date)-f>t)&&(e.preventDefault(),!v&&a.transitions&&(a.vars.animationLoop||(m/=0===a.currentSlide&&0>m||a.currentSlide===a.last&&m>0?Math.abs(m)/p+2:1),a.setProps(l+m,"setTouch")))},S=function(t){if(e.removeEventListener("touchmove",h,!1),a.animatingTo===a.currentSlide&&!y&&null!==m){var n=d?-m:m,i=a.getTarget(n>0?"next":"prev");a.canAdvance(i)&&(Number(new Date)-f<550&&Math.abs(n)>50||Math.abs(n)>p/2)?a.flexAnimate(i,a.vars.pauseOnAction):v||a.flexAnimate(a.currentSlide,a.vars.pauseOnAction,!0)}e.removeEventListener("touchend",S,!1),r=null,o=null,m=null,l=null},e.addEventListener("touchstart",g,!1))},resize:function(){!a.animating&&a.is(":visible")&&(u||a.doMath(),v?m.smoothHeight():u?(a.slides.width(a.computedW),a.update(a.pagingCount),a.setProps()):c?(a.viewport.height(a.h),a.setProps(a.h,"setTotal")):(a.vars.smoothHeight&&m.smoothHeight(),a.newSlides.width(a.computedW),a.setProps(a.computedW,"setTotal")))},smoothHeight:function(e){if(!c||v){var t=v?a:a.viewport;e?t.animate({height:a.slides.eq(a.animatingTo).height()},e):t.height(a.slides.eq(a.animatingTo).height())}},sync:function(e){var t=$(a.vars.sync).data("flexslider"),n=a.animatingTo;switch(e){case"animate":t.flexAnimate(n,a.vars.pauseOnAction,!1,!0);break;case"play":t.playing||t.asNav||t.play();break;case"pause":t.pause()}},uniqueID:function(e){return e.filter("[id]").add(e.find("[id]")).each(function(){var e=$
vendor: 10,368 bytes, line 3907
3907(this);e.attr("id",e.attr("id")+"_clone")}),e},pauseInvisible:{visProp:null,init:function(){var e=m.pauseInvisible.getHiddenProp();if(e){var t=e.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(t,function(){m.pauseInvisible.isHidden()?a.startTimeout?clearTimeout(a.startTimeout):a.pause():a.started?a.play():a.vars.initDelay>0?setTimeout(a.play,a.vars.initDelay):a.play()})}},isHidden:function(){var e=m.pauseInvisible.getHiddenProp();return e?document[e]:!1},getHiddenProp:function(){var e=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var t=0;t<e.length;t++)if(e[t]+"Hidden"in document)return e[t]+"Hidden";return null}},setToClearWatchedEvent:function(){clearTimeout(l),l=setTimeout(function(){o=""},3e3)}},a.flexAnimate=function(e,t,i,r,o){if(a.vars.animationLoop||e===a.currentSlide||(a.direction=e>a.currentSlide?"next":"prev"),p&&1===a.pagingCount&&(a.direction=a.currentItem<e?"next":"prev"),!a.animating&&(a.canAdvance(e,o)||i)&&a.is(":visible")){if(p&&r){var l=$(a.vars.asNavFor).data("flexslider");if(a.atEnd=0===e||e===a.count-1,l.flexAnimate(e,!0,!1,!0,o),a.direction=a.currentItem<e?"next":"prev",l.direction=a.direction,Math.ceil((e+1)/a.visible)-1===a.currentSlide||0===e)return a.currentItem=e,a.slides.removeClass(n+"active-slide").eq(e).addClass(n+"active-slide"),!1;a.currentItem=e,a.slides.removeClass(n+"active-slide").eq(e).addClass(n+"active-slide"),e=Math.floor(e/a.visible)}if(a.animating=!0,a.animatingTo=e,t&&a.pause(),a.vars.before(a),a.syncExists&&!o&&m.sync("animate"),a.vars.controlNav&&m.controlNav.active(),u||a.slides.removeClass(n+"active-slide").eq(e).addClass(n+"active-slide"),a.atEnd=0===e||e===a.last,a.vars.directionNav&&m.directionNav.update(),e===a.last&&(a.vars.end(a),a.vars.animationLoop||a.pause()),v)s?(a.slides.eq(a.currentSlide).css({opacity:0,zIndex:1}),a.slides.eq(e).css({opacity:1,zIndex:2}),a.wrapup(f)):(a.slides.eq(a.currentSlide).css({zIndex:1}).animate({opacity:0},a.vars.animationSpeed,a.vars.easing),a.slides.eq(e).css({zIndex:2}).animate({opacity:1},a.vars.animationSpeed,a.vars.easing,a.wrapup));else{var f=c?a.slides.filter(":first").height():a.computedW,g,h,S;u?(g=a.vars.itemMargin,S=(a.itemW+g)*a.move*a.animatingTo,h=S>a.limit&&1!==a.visible?a.limit:S):h=0===a.currentSlide&&e===a.count-1&&a.vars.animationLoop&&"next"!==a.direction?d?(a.count+a.cloneOffset)*f:0:a.currentSlide===a.last&&0===e&&a.vars.animationLoop&&"prev"!==a.direction?d?0:(a.count+1)*f:d?(a.count-1-e+a.cloneOffset)*f:(e+a.cloneOffset)*f,a.setProps(h,"",a.vars.animationSpeed),a.transitions?(a.vars.animationLoop&&a.atEnd||(a.animating=!1,a.currentSlide=a.animatingTo),a.container.unbind("webkitTransitionEnd transitionend"),a.container.bind("webkitTransitionEnd transitionend",function(){clearTimeout(a.ensureAnimationEnd),a.wrapup(f)}),clearTimeout(a.ensureAnimationEnd),a.ensureAnimationEnd=setTimeout(function(){a.wrapup(f)},a.vars.animationSpeed+100)):a.container.animate(a.args,a.vars.animationSpeed,a.vars.easing,function(){a.wrapup(f)})}a.vars.smoothHeight&&m.smoothHeight(a.vars.animationSpeed)}},a.wrapup=function(e){v||u||(0===a.currentSlide&&a.animatingTo===a.last&&a.vars.animationLoop?a.setProps(e,"jumpEnd"):a.currentSlide===a.last&&0===a.animatingTo&&a.vars.animationLoop&&a.setProps(e,"jumpStart")),a.animating=!1,a.currentSlide=a.animatingTo,a.vars.after(a)},a.animateSlides=function(){!a.animating&&f&&a.flexAnimate(a.getTarget("next"))},a.pause=function(){clearInterval(a.animatedSlides),a.animatedSlides=null,a.playing=!1,a.vars.pausePlay&&m.pausePlay.update("play"),a.syncExists&&m.sync("pause")},a.play=function(){a.playing&&clearInterval(a.animatedSlides),a.animatedSlides=a.animatedSlides||setInterval(a.animateSlides,a.vars.slideshowSpeed),a.started=a.playing=!0,a.vars.pausePlay&&m.pausePlay.update("pause"),a.syncExists&&m.sync("play")},a.stop=function(){a.pause(),a.stopped=!0},a.canAdvance=function(e,t){var n=p?a.pagingCount-1:a.last;return t?!0:p&&a.currentItem===a.count-1&&0===e&&"prev"===a.direction?!0:p&&0===a.currentItem&&e===a.pagingCount-1&&"next"!==a.direction?!1:e!==a.currentSlide||p?a.vars.animationLoop?!0:a.atEnd&&0===a.currentSlide&&e===n&&"next"!==a.direction?!1:a.atEnd&&a.currentSlide===n&&0===e&&"next"===a.direction?!1:!0:!1},a.getTarget=function(e){return a.direction=e,"next"===e?a.currentSlide===a.last?0:a.currentSlide+1:0===a.currentSlide?a.last:a.currentSlide-1},a.setProps=function(e,t,n){var i=function(){var n=e?e:(a.itemW+a.vars.itemMargin)*a.move*a.animatingTo,i=function(){if(u)return"setTouch"===t?e:d&&a.animatingTo===a.last?0:d?a.limit-(a.itemW+a.vars.itemMargin)*a.move*a.animatingTo:a.animatingTo===a.last?a.limit:n;switch(t){case"setTotal":return d?(a.count-1-a.currentSlide+a.cloneOffset)*e:(a.currentSlide+a.cloneOffset)*e;case"setTouch":return d?e:e;case"jumpEnd":return d?e:a.count*e;case"jumpStart":return d?a.count*e:e;default:return e}}();return-1*i+"px"}();a.transitions&&(i=c?"translate3d(0,"+i+",0)":"translate3d("+i+",0,0)",n=void 0!==n?n/1e3+"s":"0s",a.container.css("-"+a.pfx+"-transition-duration",n),a.container.css("transition-duration",n)),a.args[a.prop]=i,(a.transitions||void 0===n)&&a.container.css(a.args),a.container.css("transform",i)},a.setup=function(e){if(v)a.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"}),"init"===e&&(s?a.slides.css({opacity:0,display:"block",webkitTransition:"opacity "+a.vars.animationSpeed/1e3+"s ease",zIndex:1}).eq(a.currentSlide).css({opacity:1,zIndex:2}):0==a.vars.fadeFirstSlide?a.slides.css({opacity:0,display:"block",zIndex:1}).eq(a.currentSlide).css({zIndex:2}).css({opacity:1}):a.slides.css({opacity:0,display:"block",zIndex:1}).eq(a.currentSlide).css({zIndex:2}).animate({opacity:1},a.vars.animationSpeed,a.vars.easing)),a.vars.smoothHeight&&m.smoothHeight();else{var t,i;"init"===e&&(a.viewport=$('<div class="'+n+'viewport"></div>').css({overflow:"hidden",position:"relative"}).appendTo(a).append(a.container),a.cloneCount=0,a.cloneOffset=0,d&&(i=$.makeArray(a.slides).reverse(),a.slides=$(i),a.container.empty().append(a.slides))),a.vars.animationLoop&&!u&&(a.cloneCount=2,a.cloneOffset=1,"init"!==e&&a.container.find(".clone").remove(),a.container.append(m.uniqueID(a.slides.first().clone().addClass("clone")).attr("aria-hidden","true")).prepend(m.uniqueID(a.slides.last().clone().addClass("clone")).attr("aria-hidden","true"))),a.newSlides=$(a.vars.selector,a),t=d?a.count-1-a.currentSlide+a.cloneOffset:a.currentSlide+a.cloneOffset,c&&!u?(a.container.height(200*(a.count+a.cloneCount)+"%").css("position","absolute").width("100%"),setTimeout(function(){a.newSlides.css({display:"block"}),a.doMath(),a.viewport.height(a.h),a.setProps(t*a.h,"init")},"init"===e?100:0)):(a.container.width(200*(a.count+a.cloneCount)+"%"),a.setProps(t*a.computedW,"init"),setTimeout(function(){a.doMath(),a.newSlides.css({width:a.computedW,"float":"left",display:"block"}),a.vars.smoothHeight&&m.smoothHeight()},"init"===e?100:0))}u||a.slides.removeClass(n+"active-slide").eq(a.currentSlide).addClass(n+"active-slide"),a.vars.init(a)},a.doMath=function(){var e=a.slides.first(),t=a.vars.itemMargin,n=a.vars.minItems,i=a.vars.maxItems;a.w=void 0===a.viewport?a.width():a.viewport.width(),a.h=e.height(),a.boxPadding=e.outerWidth()-e.width(),u?(a.itemT=a.vars.itemWidth+t,a.minW=n?n*a.itemT:a.w,a.maxW=i?i*a.itemT-t:a.w,a.itemW=a.minW>a.w?(a.w-t*(n-1))/n:a.maxW<a.w?(a.w-t*(i-1))/i:a.vars.itemWidth>a.w?a.w:a.vars.itemWidth,a.visible=Math.floor(a.w/a.itemW),a.move=a.vars.move>0&&a.vars.move<a.visible?a.vars.move:a.visible,a.pagingCount=Math.ceil((a.count-a.visible)/a.move+1),a.last=a.pagingCount-1,a.limit=1===a.pagingCount?0:a.vars.itemWidth>a.w?a.itemW*(a.count-1)+t*(a.count-1):(a.itemW+t)*a.count-a.w-t):(a.itemW=a.w,a.pagingCount=a.count,a.last=a.count-1),a.computedW=a.itemW-a.boxPadding},a.update=function(e,t){a.doMath(),u||(e<a.currentSlide?a.currentSlide+=1:e<=a.currentSlide&&0!==e&&(a.currentSlide-=1),a.animatingTo=a.currentSlide),a.vars.controlNav&&!a.manualControls&&("add"===t&&!u||a.pagingCount>a.controlNav.length?m.controlNav.update("add"):("remove"===t&&!u||a.pagingCount<a.controlNav.length)&&(u&&a.currentSlide>a.last&&(a.currentSlide-=1,a.animatingTo-=1),m.controlNav.update("remove",a.last))),a.vars.directionNav&&m.directionNav.update()},a.addSlide=function(e,t){var n=$(e);a.count+=1,a.last=a.count-1,c&&d?void 0!==t?a.slides.eq(a.count-t).after(n):a.container.prepend(n):void 0!==t?a.slides.eq(t).before(n):a.container.append(n),a.update(t,"add"),a.slides=$(a.vars.selector+":not(.clone)",a),a.setup(),a.vars.added(a)},a.removeSlide=function(e){var t=isNaN(e)?a.slides.index($(e)):e;a.count-=1,a.last=a.count-1,isNaN(e)?$(e,a.slides).remove():c&&d?a.slides.eq(a.last).remove():a.slides.eq(e).remove(),a.doMath(),a.update(t,"remove"),a.slides=$(a.vars.selector+":not(.clone)",a),a.setup(),a.vars.removed(a)},m.init()},$(window).blur(function(e){focused=!1}).focus(function(e){focused=!0}),$.flexslider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:!1,animationLoop:!0,smoothHeight:!1,startAt:0,slideshow:!0,slideshowSpeed:7e3,animationSpeed:600,initDelay:0,randomize:!1,fadeFirstSlide:!0,thumbCaptions:!1,pauseOnAction:!0,pauseOnHover:!1,pauseInvisible:!0,useCSS:!0,touch:!0,video:!1,controlNav:!0,directionNav:!0,prevText:"Previous",nextText:"Next",keyboard:!0,multipleKeyboard:!1,mousewheel:!1,pausePlay:!1,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",customDirectionNav:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:1,maxItems:0,move:0,allowOneSlide:!0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){},init:function(){}},$.fn.flexslider=function(e){if(void 0===e&&(e={}),"object"==typeof e)return this.each(function(){var t=$(this),a=e.selector?e.selector:".slides > li",n=t.find(a);1===n.length&&e.allowOneSlide===!0||0===n.length?(n.fadeIn(400),e.start&&e.start(t)):void 0===t.data("flexslider")&&new $.flexslider(this,e)});var t=$(this).data("flexslider");switch(e){case"play":t.play();break;case"pause":t.pause();break;case"stop":t.stop();break;case"next":t.flexAnimate(t.getTarget("next"),!0);break;case"prev":case"previous":t.flexAnimate(t.getTarget("prev"),!0);break;default:"number"==typeof e&&t.flexAnimate(e,!0)}}}(jQuery);

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.