PageSourceSearch

https://www.tunisienumerique.com/wp-content/themes/tunisienumerique/js/scripts.js?ver=6.7.9

js tunisienumerique.com collected 2026-10-02 05:00:46 UTC 149,015 bytes, 3,874 lines download raw bytes

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