PageSourceSearch

https://www.ticketmarket.lt/assets/js/main_dev.js

js ticketmarket.lt collected 2026-10-02 06:58:38 UTC 315,722 bytes, 6,860 lines download raw bytes

1/* Lithuanian (UTF-8) initialisation for the jQuery UI date picker plugin. */
2/* @author Arturas Paleicikas <[email protected]> */
3function nl2br(str, is_xhtml) {
4  var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>'; // Adjust comment to avoid issue on phpjs.org display
5
6  return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
7}
8
9(function( factory ) {
10	if ( typeof define === "function" && define.amd ) {
11
12		// AMD. Register as an anonymous module.
13		define([ "../datepicker" ], factory );
14	} else {
15
16		// Browser globals
17		factory( jQuery.datepicker );
18	}
19}(function( datepicker ) {
20
21datepicker.regional['lt'] = {
22	closeText: 'Uždaryti',
23	prevText: '&#x3C;Atgal',
24	nextText: 'Pirmyn&#x3E;',
25	currentText: 'Å iandien',
26	monthNames: ['Sausis','Vasaris','Kovas','Balandis','Gegužė','Birželis',
27	'Liepa','Rugpjūtis','Rugsėjis','Spalis','Lapkritis','Gruodis'],
28	monthNamesShort: ['Sau','Vas','Kov','Bal','Geg','Bir',
29	'Lie','Rugp','Rugs','Spa','Lap','Gru'],
30	dayNames: ['sekmadienis','pirmadienis','antradienis','trečiadienis','ketvirtadienis','penktadienis','šeštadienis'],
31	dayNamesShort: ['sek','pir','ant','tre','ket','pen','šeš'],
32	dayNamesMin: ['Se','Pr','An','Tr','Ke','Pe','Å e'],
33	weekHeader: 'SAV',
34	dateFormat: 'yy-mm-dd',
35	firstDay: 1,
36	isRTL: false,
37	showMonthAfterYear: true,
38	yearSuffix: ''};
39// datepicker.setDefaults(datepicker.regional['lt']);
40
41return datepicker.regional['lt'];
42
43}));
44
45
46/**
47 * Owl carousel
48 * @version 2.0.0
49 * @author Bartosz Wojciechowski
50 * @license The MIT License (MIT)
51 * @todo Lazy Load Icon
52 * @todo prevent animationend bubling
53 * @todo itemsScaleUp
54 * @todo Test Zepto
55 * @todo stagePadding calculate wrong active classes
56 */
57;(function($, window, document, undefined) {
58
59	var drag, state, e;
60
61	/**
62	 * Template for status information about drag and touch events.
63	 * @private
64	 */
65	drag = {
66		start: 0,
67		startX: 0,
68		startY: 0,
69		current: 0,
70		currentX: 0,
71		currentY: 0,
72		offsetX: 0,
73		offsetY: 0,
74		distance: null,
75		startTime: 0,
76		endTime: 0,
77		updatedX: 0,
78		targetEl: null
79	};
80
81	/**
82	 * Template for some status informations.
83	 * @private
84	 */
85	state = {
86		isTouch: false,
87		isScrolling: false,
88		isSwiping: false,
89		direction: false,
90		inMotion: false
91	};
92
93	/**
94	 * Event functions references.
95	 * @private
96	 */
97	e = {
98		_onDragStart: null,
99		_onDragMove: null,
100		_onDragEnd: null,
101		_transitionEnd: null,
102		_resizer: null,
103		_responsiveCall: null,
104		_goToLoop: null,
105		_checkVisibile: null
106	};
107
108	/**
109	 * Creates a carousel.
110	 * @class The Owl Carousel.
111	 * @public
112	 * @param {HTMLElement|jQuery} element - The element to create the carousel for.
113	 * @param {Object} [options] - The options
114	 */
115	function Owl(element, options) {
116
117		/**
118		 * Current settings for the carousel.
119		 * @public
120		 */
121		this.settings = null;
122
123		/**
124		 * Current options set by the caller including defaults.
125		 * @public
126		 */
127		this.options = $.extend({}, Owl.Defaults, options);
128
129		/**
130		 * Plugin element.
131		 * @public
132		 */
133		this.$element = $(element);
134
135		/**
136		 * Caches informations about drag and touch events.
137		 */
138		this.drag = $.extend({}, drag);
139
140		/**
141		 * Caches some status informations.
142		 * @protected
143		 */
144		this.state = $.extend({}, state);
145
146		/**
147		 * @protected
148		 * @todo Must be documented
149		 */
150		this.e = $.extend({}, e);
151
152		/**
153		 * References to the running plugins of this carousel.
154		 * @protected
155		 */
156		this._plugins = {};
157
158		/**
159		 * Currently suppressed events to prevent them from beeing retriggered.
160		 * @protected
161		 */
162		this._supress = {};
163
164		/**
165		 * Absolute current position.
166		 * @protected
167		 */
168		this._current = null;
169
170		/**
171		 * Animation speed in milliseconds.
172		 * @protected
173		 */
174		this._speed = null;
175
176		/**
177		 * Coordinates of all items in pixel.
178		 * @todo The name of this member is missleading.
179		 * @protected
180		 */
181		this._coordinates = [];
182
183		/**
184		 * Current breakpoint.
185		 * @todo Real media queries would be nice.
186		 * @protected
187		 */
188		this._breakpoint = null;
189
190		/**
191		 * Current width of the plugin element.
192		 */
193		this._width = null;
194
195		/**
196		 * All real items.
197		 * @protected
198		 */
199		this._items = [];
200
201		/**
202		 * All cloned items.
203		 * @protected
204		 */
205		this._clones = [];
206
207		/**
208		 * Merge values of all items.
209		 * @todo Maybe this could be part of a plugin.
210		 * @protected
211		 */
212		this._mergers = [];
213
214		/**
215		 * Invalidated parts within the update process.
216		 * @protected
217		 */
218		this._invalidated = {};
219
220		/**
221		 * Ordered list of workers for the update process.
222		 * @protected
223		 */
224		this._pipe = [];
225
226		$.each(Owl.Plugins, $.proxy(function(key, plugin) {
227			this._plugins[key[0].toLowerCase() + key.slice(1)]
228				= new plugin(this);
229		}, this));
230
231		$.each(Owl.Pipe, $.proxy(function(priority, worker) {
232			this._pipe.push({
233				'filter': worker.filter,
234				'run': $.proxy(worker.run, this)
235			});
236		}, this));
237
238		this.setup();
239		this.initialize();
240	}
241
242	/**
243	 * Default options for the carousel.
244	 * @public
245	 */
246	Owl.Defaults = {
247		items: 3,
248		loop: false,
249		center: false,
250
251		mouseDrag: true,
252		touchDrag: true,
253		pullDrag: true,
254		freeDrag: false,
255
256		margin: 0,
257		stagePadding: 0,
258
259		merge: false,
260		mergeFit: true,
261		autoWidth: false,
262
263		startPosition: 0,
264		rtl: false,
265
266		smartSpeed: 250,
267		fluidSpeed: false,
268		dragEndSpeed: false,
269
270		responsive: {},
271		responsiveRefreshRate: 200,
272		responsiveBaseElement: window,
273		responsiveClass: false,
274
275		fallbackEasing: 'swing',
276
277		info: false,
278
279		nestedItemSelector: false,
280		itemElement: 'div',
281		stageElement: 'div',
282
283		// Classes and Names
284		themeClass: 'owl-theme',
285		baseClass: 'owl-carousel',
286		itemClass: 'owl-item',
287		centerClass: 'center',
288		activeClass: 'active'
289	};
290
291	/**
292	 * Enumeration for width.
293	 * @public
294	 * @readonly
295	 * @enum {String}
296	 */
297	Owl.Width = {
298		Default: 'default',
299		Inner: 'inner',
300		Outer: 'outer'
301	};
302
303	/**
304	 * Contains all registered plugins.
305	 * @public
306	 */
307	Owl.Plugins = {};
308
309	/**
310	 * Update pipe.
311	 */
312	Owl.Pipe = [ {
313		filter: [ 'width', 'items', 'settings' ],
314		run: function(cache) {
315			cache.current = this._items && this._items[this.relative(this._current)];
316		}
317	}, {
318		filter: [ 'items', 'settings' ],
319		run: function() {
320			var cached = this._clones,
321				clones = this.$stage.children('.cloned');
322
323			if (clones.length !== cached.length || (!this.settings.loop && cached.length > 0)) {
324				this.$stage.children('.cloned').remove();
325				this._clones = [];
326			}
327		}
328	}, {
329		filter: [ 'items', 'settings' ],
330		run: function() {
331			var i, n,
332				clones = this._clones,
333				items = this._items,
334				delta = this.settings.loop ? clones.length - Math.max(this.settings.items * 2, 4) : 0;
335
336			for (i = 0, n = Math.abs(delta / 2); i < n; i++) {
337				if (delta > 0) {
338					this.$stage.children().eq(items.length + clones.length - 1).remove();
339					clones.pop();
340					this.$stage.children().eq(0).remove();
341					clones.pop();
342				} else {
343					clones.push(clones.length / 2);
344					this.$stage.append(items[clones[clones.length - 1]].clone().addClass('cloned'));
345					clones.push(items.length - 1 - (clones.length - 1) / 2);
346					this.$stage.prepend(items[clones[clones.length - 1]].clone().addClass('cloned'));
347				}
348			}
349		}
350	}, {
351		filter: [ 'width', 'items', 'settings' ],
352		run: function() {
353			var rtl = (this.settings.rtl ? 1 : -1),
354				width = (this.width() / this.settings.items).toFixed(3),
355				coordinate = 0, merge, i, n;
356
357			this._coordinates = [];
358			for (i = 0, n = this._clones.length + this._items.length; i < n; i++) {
359				merge = this._mergers[this.relative(i)];
360				merge = (this.settings.mergeFit && Math.min(merge, this.settings.items)) || merge;
361				coordinate += (this.settings.autoWidth ? this._items[this.relative(i)].width() + this.settings.margin : width * merge) * rtl;
362
363				this._coordinates.push(coordinate);
364			}
365		}
366	}, {
367		filter: [ 'width', 'items', 'settings' ],
368		run: function() {
369			var i, n, width = (this.width() / this.settings.items).toFixed(3), css = {
370				'width': Math.abs(this._coordinates[this._coordinates.length - 1]) + this.settings.stagePadding * 2,
371				'padding-left': this.settings.stagePadding || '',
372				'padding-right': this.settings.stagePadding || ''
373			};
374
375			this.$stage.css(css);
376
377			css = { 'width': this.settings.autoWidth ? 'auto' : width - this.settings.margin };
378			css[this.settings.rtl ? 'margin-left' : 'margin-right'] = this.settings.margin;
379
380			if (!this.settings.autoWidth && $.grep(this._mergers, function(v) { return v > 1 }).length > 0) {
381				for (i = 0, n = this._coordinates.length; i < n; i++) {
382					css.width = Math.abs(this._coordinates[i]) - Math.abs(this._coordinates[i - 1] || 0) - this.settings.margin;
383					this.$stage.children().eq(i).css(css);
384				}
385			} else {
386				this.$stage.children().css(css);
387			}
388		}
389	}, {
390		filter: [ 'width', 'items', 'settings' ],
391		run: function(cache) {
392			cache.current && this.reset(this.$stage.children().index(cache.current));
393		}
394	}, {
395		filter: [ 'position' ],
396		run: function() {
397			this.animate(this.coordinates(this._current));
398		}
399	}, {
400		filter: [ 'width', 'position', 'items', 'settings' ],
401		run: function() {
402			var rtl = this.settings.rtl ? 1 : -1,
403				padding = this.settings.stagePadding * 2,
404				begin = this.coordinates(this.current()) + padding,
405				end = begin + this.width() * rtl,
406				inner, outer, matches = [], i, n;
407
408			for (i = 0, n = this._coordinates.length; i < n; i++) {
409				inner = this._coordinates[i - 1] || 0;
410				outer = Math.abs(this._coordinates[i]) + padding * rtl;
411
412				if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end)))
413					|| (this.op(outer, '<', begin) && this.op(outer, '>', end))) {
414					matches.push(i);
415				}
416			}
417
418			this.$stage.children('.' + this.settings.activeClass).removeClass(this.settings.activeClass);
419			this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass(this.settings.activeClass);
420
421			if (this.settings.center) {
422				this.$stage.children('.' + this.settings.centerClass).removeClass(this.settings.centerClass);
423				this.$stage.children().eq(this.current()).addClass(this.settings.centerClass);
424			}
425		}
426	} ];
427
428	/**
429	 * Initializes the carousel.
430	 * @protected
431	 */
432	Owl.prototype.initialize = function() {
433		this.trigger('initialize');
434
435		this.$element
436			.addClass(this.settings.baseClass)
437			.addClass(this.settings.themeClass)
438			.toggleClass('owl-rtl', this.settings.rtl);
439
440		// check support
441		this.browserSupport();
442
443		if (this.settings.autoWidth && this.state.imagesLoaded !== true) {
444			var imgs, nestedSelector, width;
445			imgs = this.$element.find('img');
446			nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined;
447			width = this.$element.children(nestedSelector).width();
448
449			if (imgs.length && width <= 0) {
450				this.preloadAutoWidthImages(imgs);
451				return false;
452			}
453		}
454
455		this.$element.addClass('owl-loading');
456
457		// create stage
458		this.$stage = $('<' + this.settings.stageElement + ' class="owl-stage"/>')
459			.wrap('<div class="owl-stage-outer">');
460
461		// append stage
462		this.$element.append(this.$stage.parent());
463
464		// append content
465		this.replace(this.$element.children().not(this.$stage.parent()));
466
467		// set view width
468		this._width = this.$element.width();
469
470		// update view
471		this.refresh();
472
473		this.$element.removeClass('owl-loading').addClass('owl-loaded');
474
475		// attach generic events
476		this.eventsCall();
477
478		// attach generic events
479		this.internalEvents();
480
481		// attach custom control events
482		this.addTriggerableEvents();
483
484		this.trigger('initialized');
485	};
486
487	/**
488	 * Setups the current settings.
489	 * @todo Remove responsive classes. Why should adaptive designs be brought into IE8?
490	 * @todo Support for media queries by using `matchMedia` would be nice.
491	 * @public
492	 */
493	Owl.prototype.setup = function() {
494		var viewport = this.viewport(),
495			overwrites = this.options.responsive,
496			match = -1,
497			settings = null;
498
499		if (!overwrites) {
500			settings = $.extend({}, this.options);
501		} else {
502			$.each(overwrites, function(breakpoint) {
503				if (breakpoint <= viewport && breakpoint > match) {
504					match = Number(breakpoint);
505				}
506			});
507
508			settings = $.extend({}, this.options, overwrites[match]);
509			delete settings.responsive;
510
511			// responsive class
512			if (settings.responsiveClass) {
513				this.$element.attr('class', function(i, c) {
514					return c.replace(/\b owl-responsive-\S+/g, '');
515				}).addClass('owl-responsive-' + match);
516			}
517		}
518
519		if (this.settings === null || this._breakpoint !== match) {
520			this.trigger('change', { property: { name: 'settings', value: settings } });
521			this._breakpoint = match;
522			this.settings = settings;
523			this.invalidate('settings');
524			this.trigger('changed', { property: { name: 'settings', value: this.settings } });
525		}
526	};
527
528	/**
529	 * Updates option logic if necessery.
530	 * @protected
531	 */
532	Owl.prototype.optionsLogic = function() {
533		// Toggle Center class
534		this.$element.toggleClass('owl-center', this.settings.center);
535
536		// if items number is less than in body
537		if (this.settings.loop && this._items.length < this.settings.items) {
538			this.settings.loop = false;
539		}
540
541		if (this.settings.autoWidth) {
542			this.settings.stagePadding = false;
543			this.settings.merge = false;
544		}
545	};
546
547	/**
548	 * Prepares an item before add.
549	 * @todo Rename event parameter `content` to `item`.
550	 * @protected
551	 * @returns {jQuery|HTMLElement} - The item container.
552	 */
553	Owl.prototype.prepare = function(item) {
554		var event = this.trigger('prepare', { content: item });
555
556		if (!event.data) {
557			event.data = $('<' + this.settings.itemElement + '/>')
558				.addClass(this.settings.itemClass).append(item)
559		}
560
561		this.trigger('prepared', { content: event.data });
562
563		return event.data;
564	};
565
566	/**
567	 * Updates the view.
568	 * @public
569	 */
570	Owl.prototype.update = function() {
571		var i = 0,
572			n = this._pipe.length,
573			filter = $.proxy(function(p) { return this[p] }, this._invalidated),
574			cache = {};
575
576		while (i < n) {
577			if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) {
578				this._pipe[i].run(cache);
579			}
580			i++;
581		}
582
583		this._invalidated = {};
584	};
585
586	/**
587	 * Gets the width of the view.
588	 * @public
589	 * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return.
590	 * @returns {Number} - The width of the view in pixel.
591	 */
592	Owl.prototype.width = function(dimension) {
593		dimension = dimension || Owl.Width.Default;
594		switch (dimension) {
595			case Owl.Width.Inner:
596			case Owl.Width.Outer:
597				return this._width;
598			default:
599				return this._width - this.settings.stagePadding * 2 + this.settings.margin;
600		}
601	};
602
603	/**
604	 * Refreshes the carousel primarily for adaptive purposes.
605	 * @public
606	 */
607	Owl.prototype.refresh = function() {
608		if (this._items.length === 0) {
609			return false;
610		}
611
612		var start = new Date().getTime();
613
614		this.trigger('refresh');
615
616		this.setup();
617
618		this.optionsLogic();
619
620		// hide and show methods helps here to set a proper widths,
621		// this prevents scrollbar to be calculated in stage width
622		this.$stage.addClass('owl-refresh');
623
624		this.update();
625
626		this.$stage.removeClass('owl-refresh');
627
628		this.state.orientation = window.orientation;
629
630		this.watchVisibility();
631
632		this.trigger('refreshed');
633	};
634
635	/**
636	 * Save internal event references and add event based functions.
637	 * @protected
638	 */
639	Owl.prototype.eventsCall = function() {
640		// Save events references
641		this.e._onDragStart = $.proxy(function(e) {
642			this.onDragStart(e);
643		}, this);
644		this.e._onDragMove = $.proxy(function(e) {
645			this.onDragMove(e);
646		}, this);
647		this.e._onDragEnd = $.proxy(function(e) {
648			this.onDragEnd(e);
649		}, this);
650		this.e._onResize = $.proxy(function(e) {
651			this.onResize(e);
652		}, this);
653		this.e._transitionEnd = $.proxy(function(e) {
654			this.transitionEnd(e);
655		}, this);
656		this.e._preventClick = $.proxy(function(e) {
657			this.preventClick(e);
658		}, this);
659	};
660
661	/**
662	 * Checks window `resize` event.
663	 * @protected
664	 */
665	Owl.prototype.onThrottledResize = function() {
666		window.clearTimeout(this.resizeTimer);
667		this.resizeTimer = window.setTimeout(this.e._onResize, this.settings.responsiveRefreshRate);
668	};
669
670	/**
671	 * Checks window `resize` event.
672	 * @protected
673	 */
674	Owl.prototype.onResize = function() {
675		if (!this._items.length) {
676			return false;
677		}
678
679		if (this._width === this.$element.width()) {
680			return false;
681		}
682
683		if (this.trigger('resize').isDefaultPrevented()) {
684			return false;
685		}
686
687		this._width = this.$element.width();
688
689		this.invalidate('width');
690
691		this.refresh();
692
693		this.trigger('resized');
694	};
695
696	/**
697	 * Checks for touch/mouse drag event type and add run event handlers.
698	 * @protected
699	 */
700	Owl.prototype.eventsRouter = function(event) {
701		var type = event.type;
702
703		if (type === "mousedown" || type === "touchstart") {
704			this.onDragStart(event);
705		} else if (type === "mousemove" || type === "touchmove") {
706			this.onDragMove(event);
707		} else if (type === "mouseup" || type === "touchend") {
708			this.onDragEnd(event);
709		} else if (type === "touchcancel") {
710			this.onDragEnd(event);
711		}
712	};
713
714	/**
715	 * Checks for touch/mouse drag options and add necessery event handlers.
716	 * @protected
717	 */
718	Owl.prototype.internalEvents = function() {
719		var isTouch = isTouchSupport(),
720			isTouchIE = isTouchSupportIE();
721
722		if (this.settings.mouseDrag){
723			this.$stage.on('mousedown', $.proxy(function(event) { this.eventsRouter(event) }, this));
724			this.$stage.on('dragstart', function() { return false });
725			this.$stage.get(0).onselectstart = function() { return false };
726		} else {
727			this.$element.addClass('owl-text-select-on');
728		}
729
730		if (this.settings.touchDrag && !isTouchIE){
731			this.$stage.on('touchstart touchcancel', $.proxy(function(event) { this.eventsRouter(event) }, this));
732		}
733
734		// catch transitionEnd event
735		if (this.transitionEndVendor) {
736			this.on(this.$stage.get(0), this.transitionEndVendor, this.e._transitionEnd, false);
737		}
738
739		// responsive
740		if (this.settings.responsive !== false) {
741			this.on(window, 'resize', $.proxy(this.onThrottledResize, this));
742		}
743	};
744
745	/**
746	 * Handles touchstart/mousedown event.
747	 * @protected
748	 * @param {Event} event - The event arguments.
749	 */
750	Owl.prototype.onDragStart = function(event) {
751		var ev, isTouchEvent, pageX, pageY, animatedPos;
752
753		ev = event.originalEvent || event || window.event;
754
755		// prevent right click
756		if (ev.which === 3 || this.state.isTouch) {
757			return false;
758		}
759
760		if (ev.type === 'mousedown') {
761			this.$stage.addClass('owl-grab');
762		}
763
764		this.trigger('drag');
765		this.drag.startTime = new Date().getTime();
766		this.speed(0);
767		this.state.isTouch = true;
768		this.state.isScrolling = false;
769		this.state.isSwiping = false;
770		this.drag.distance = 0;
771
772		pageX = getTouches(ev).x;
773		pageY = getTouches(ev).y;
774
775		// get stage position left
776		this.drag.offsetX = this.$stage.position().left;
777		this.drag.offsetY = this.$stage.position().top;
778
779		if (this.settings.rtl) {
780			this.drag.offsetX = this.$stage.position().left + this.$stage.width() - this.width()
781				+ this.settings.margin;
782		}
783
784		// catch position // ie to fix
785		if (this.state.inMotion && this.support3d) {
786			animatedPos = this.getTransformProperty();
787			this.drag.offsetX = animatedPos;
788			this.animate(animatedPos);
789			this.state.inMotion = true;
790		} else if (this.state.inMotion && !this.support3d) {
791			this.state.inMotion = false;
792			return false;
793		}
794
795		this.drag.startX = pageX - this.drag.offsetX;
796		this.drag.startY = pageY - this.drag.offsetY;
797
798		this.drag.start = pageX - this.drag.startX;
799		this.drag.targetEl = ev.target || ev.srcElement;
800		this.drag.updatedX = this.drag.start;
801
802		// to do/check
803		// prevent links and images dragging;
804		if (this.drag.targetEl.tagName === "IMG" || this.drag.targetEl.tagName === "A") {
805			this.drag.targetEl.draggable = false;
806		}
807
808		$(document).on('mousemove.owl.dragEvents mouseup.owl.dragEvents touchmove.owl.dragEvents touchend.owl.dragEvents', $.proxy(function(event) {this.eventsRouter(event)},this));
809	};
810
811	/**
812	 * Handles the touchmove/mousemove events.
813	 * @todo Simplify
814	 * @protected
815	 * @param {Event} event - The event arguments.
816	 */
817	Owl.prototype.onDragMove = function(event) {
818		var ev, isTouchEvent, pageX, pageY, minValue, maxValue, pull;
819
820		if (!this.state.isTouch) {
821			return;
822		}
823
824		if (this.state.isScrolling) {
825			return;
826		}
827
828		ev = event.originalEvent || event || window.event;
829
830		pageX = getTouches(ev).x;
831		pageY = getTouches(ev).y;
832
833		// Drag Direction
834		this.drag.currentX = pageX - this.drag.startX;
835		this.drag.currentY = pageY - this.drag.startY;
836		this.drag.distance = this.drag.currentX - this.drag.offsetX;
837
838		// Check move direction
839		if (this.drag.distance < 0) {
840			this.state.direction = this.settings.rtl ? 'right' : 'left';
841		} else if (this.drag.distance > 0) {
842			this.state.direction = this.settings.rtl ? 'left' : 'right';
843		}
844		// Loop
845		if (this.settings.loop) {
846			if (this.op(this.drag.currentX, '>', this.coordinates(this.minimum())) && this.state.direction === 'right') {
847				this.drag.currentX -= (this.settings.center && this.coordinates(0)) - this.coordinates(this._items.length);
848			} else if (this.op(this.drag.currentX, '<', this.coordinates(this.maximum())) && this.state.direction === 'left') {
849				this.drag.currentX += (this.settings.center && this.coordinates(0)) - this.coordinates(this._items.length);
850			}
851		} else {
852			// pull
853			minValue = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum());
854			maxValue = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum());
855			pull = this.settings.pullDrag ? this.drag.distance / 5 : 0;
856			this.drag.currentX = Math.max(Math.min(this.drag.currentX, minValue + pull), maxValue + pull);
857		}
858
859		// Lock browser if swiping horizontal
860
861		if ((this.drag.distance > 8 || this.drag.distance < -8)) {
862			if (ev.preventDefault !== undefined) {
863				ev.preventDefault();
864			} else {
865				ev.returnValue = false;
866			}
867			this.state.isSwiping = true;
868		}
869
870		this.drag.updatedX = this.drag.currentX;
871
872		// Lock Owl if scrolling
873		if ((this.drag.currentY > 16 || this.drag.currentY < -16) && this.state.isSwiping === false) {
874			this.state.isScrolling = true;
875			this.drag.updatedX = this.drag.start;
876		}
877
878		this.animate(this.drag.updatedX);
879	};
880
881	/**
882	 * Handles the touchend/mouseup events.
883	 * @protected
884	 */
885	Owl.prototype.onDragEnd = function(event) {
886		var compareTimes, distanceAbs, closest;
887
888		if (!this.state.isTouch) {
889			return;
890		}
891
892		if (event.type === 'mouseup') {
893			this.$stage.removeClass('owl-grab');
894		}
895
896		this.trigger('dragged');
897
898		// prevent links and images dragging;
899		this.drag.targetEl.removeAttribute("draggable");
900
901		// remove drag event listeners
902
903		this.state.isTouch = false;
904		this.state.isScrolling = false;
905		this.state.isSwiping = false;
906
907		// to check
908		if (this.drag.distance === 0 && this.state.inMotion !== true) {
909			this.state.inMotion = false;
910			return false;
911		}
912
913		// prevent clicks while scrolling
914
915		this.drag.endTime = new Date().getTime();
916		compareTimes = this.drag.endTime - this.drag.startTime;
917		distanceAbs = Math.abs(this.drag.distance);
918
919		// to test
920		if (distanceAbs > 3 || compareTimes > 300) {
921			this.removeClick(this.drag.targetEl);
922		}
923
924		closest = this.closest(this.drag.updatedX);
925
926		this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed);
927		this.current(closest);
928		this.invalidate('position');
929		this.update();
930
931		// if pullDrag is off then fire transitionEnd event manually when stick
932		// to border
933		if (!this.settings.pullDrag && this.drag.updatedX === this.coordinates(closest)) {
934			this.transitionEnd();
935		}
936
937		this.drag.distance = 0;
938
939		$(document).off('.owl.dragEvents');
940	};
941
942	/**
943	 * Attaches `preventClick` to disable link while swipping.
944	 * @protected
945	 * @param {HTMLElement} [target] - The target of the `click` event.
946	 */
947	Owl.prototype.removeClick = function(target) {
948		this.drag.targetEl = target;
949		$(target).on('click.preventClick', this.e._preventClick);
950		// to make sure click is removed:
951		window.setTimeout(function() {
952			$(target).off('click.preventClick');
953		}, 300);
954	};
955
956	/**
957	 * Suppresses click event.
958	 * @protected
959	 * @param {Event} ev - The event arguments.
960	 */
961	Owl.prototype.preventClick = function(ev) {
962		if (ev.preventDefault) {
963			ev.preventDefault();
964		} else {
965			ev.returnValue = false;
966		}
967		if (ev.stopPropagation) {
968			ev.stopPropagation();
969		}
970		$(ev.target).off('click.preventClick');
971	};
972
973	/**
974	 * Catches stage position while animate (only CSS3).
975	 * @protected
976	 * @returns
977	 */
978	Owl.prototype.getTransformProperty = function() {
979		var transform, matrix3d;
980
981		transform = window.getComputedStyle(this.$stage.get(0), null).getPropertyValue(this.vendorName + 'transform');
982		// var transform = this.$stage.css(this.vendorName + 'transform')
983		transform = transform.replace(/matrix(3d)?\(|\)/g, '').split(',');
984		matrix3d = transform.length === 16;
985
986		return matrix3d !== true ? transform[4] : transform[12];
987	};
988
989	/**
990	 * Gets absolute position of the closest item for a coordinate.
991	 * @todo Setting `freeDrag` makes `closest` not reusable. See #165.
992	 * @protected
993	 * @param {Number} coordinate - The coordinate in pixel.
994	 * @return {Number} - The absolute position of the closest item.
995	 */
996	Owl.prototype.closest = function(coordinate) {
997		var position = -1, pull = 30, width = this.width(), coordinates = this.coordinates();
998
999		if (!this.settings.freeDrag) {
1000			// check closest item
1001			$.each(coordinates, $.proxy(function(index, value) {
1002				if (coordinate > value - pull && coordinate < value + pull) {
1003					position = index;
1004				} else if (this.op(coordinate, '<', value)
1005					&& this.op(coordinate, '>', coordinates[index + 1] || value - width)) {
1006					position = this.state.direction === 'left' ? index + 1 : index;
1007				}
1008				return position === -1;
1009			}, this));
1010		}
1011
1012		if (!this.settings.loop) {
1013			// non loop boundries
1014			if (this.op(coordinate, '>', coordinates[this.minimum()])) {
1015				position = coordinate = this.minimum();
1016			} else if (this.op(coordinate, '<', coordinates[this.maximum()])) {
1017				position = coordinate = this.maximum();
1018			}
1019		}
1020
1021		return position;
1022	};
1023
1024	/**
1025	 * Animates the stage.
1026	 * @public
1027	 * @param {Number} coordinate - The coordinate in pixels.
1028	 */
1029	Owl.prototype.animate = function(coordinate) {
1030		this.trigger('translate');
1031		this.state.inMotion = this.speed() > 0;
1032
1033		if (this.support3d) {
1034			this.$stage.css({
1035				transform: 'translate3d(' + coordinate + 'px' + ',0px, 0px)',
1036				transition: (this.speed() / 1000) + 's'
1037			});
1038		} else if (this.state.isTouch) {
1039			this.$stage.css({
1040				left: coordinate + 'px'
1041			});
1042		} else {
1043			this.$stage.animate({
1044				left: coordinate
1045			}, this.speed() / 1000, this.settings.fallbackEasing, $.proxy(function() {
1046				if (this.state.inMotion) {
1047					this.transitionEnd();
1048				}
1049			}, this));
1050		}
1051	};
1052
1053	/**
1054	 * Sets the absolute position of the current item.
1055	 * @public
1056	 * @param {Number} [position] - The new absolute position or nothing to leave it unchanged.
1057	 * @returns {Number} - The absolute position of the current item.
1058	 */
1059	Owl.prototype.current = function(position) {
1060		if (position === undefined) {
1061			return this._current;
1062		}
1063
1064		if (this._items.length === 0) {
1065			return undefined;
1066		}
1067
1068		position = this.normalize(position);
1069
1070		if (this._current !== position) {
1071			var event = this.trigger('change', { property: { name: 'position', value: position } });
1072
1073			if (event.data !== undefined) {
1074				position = this.normalize(event.data);
1075			}
1076
1077			this._current = position;
1078
1079			this.invalidate('position');
1080
1081			this.trigger('changed', { property: { name: 'position', value: this._current } });
1082		}
1083
1084		return this._current;
1085	};
1086
1087	/**
1088	 * Invalidates the given part of the update routine.
1089	 * @param {String}
1089 part - The part to invalidate.
1090	 */
1091	Owl.prototype.invalidate = function(part) {
1092		this._invalidated[part] = true;
1093	}
1094
1095	/**
1096	 * Resets the absolute position of the current item.
1097	 * @public
1098	 * @param {Number} position - The absolute position of the new item.
1099	 */
1100	Owl.prototype.reset = function(position) {
1101		position = this.normalize(position);
1102
1103		if (position === undefined) {
1104			return;
1105		}
1106
1107		this._speed = 0;
1108		this._current = position;
1109
1110		this.suppress([ 'translate', 'translated' ]);
1111
1112		this.animate(this.coordinates(position));
1113
1114		this.release([ 'translate', 'translated' ]);
1115	};
1116
1117	/**
1118	 * Normalizes an absolute or a relative position for an item.
1119	 * @public
1120	 * @param {Number} position - The absolute or relative position to normalize.
1121	 * @param {Boolean} [relative=false] - Whether the given position is relative or not.
1122	 * @returns {Number} - The normalized position.
1123	 */
1124	Owl.prototype.normalize = function(position, relative) {
1125		var n = (relative ? this._items.length : this._items.length + this._clones.length);
1126
1127		if (!$.isNumeric(position) || n < 1) {
1128			return undefined;
1129		}
1130
1131		if (this._clones.length) {
1132			position = ((position % n) + n) % n;
1133		} else {
1134			position = Math.max(this.minimum(relative), Math.min(this.maximum(relative), position));
1135		}
1136
1137		return position;
1138	};
1139
1140	/**
1141	 * Converts an absolute position for an item into a relative position.
1142	 * @public
1143	 * @param {Number} position - The absolute position to convert.
1144	 * @returns {Number} - The converted position.
1145	 */
1146	Owl.prototype.relative = function(position) {
1147		position = this.normalize(position);
1148		position = position - this._clones.length / 2;
1149		return this.normalize(position, true);
1150	};
1151
1152	/**
1153	 * Gets the maximum position for an item.
1154	 * @public
1155	 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1156	 * @returns {Number}
1157	 */
1158	Owl.prototype.maximum = function(relative) {
1159		var maximum, width, i = 0, coordinate,
1160			settings = this.settings;
1161
1162		if (relative) {
1163			return this._items.length - 1;
1164		}
1165
1166		if (!settings.loop && settings.center) {
1167			maximum = this._items.length - 1;
1168		} else if (!settings.loop && !settings.center) {
1169			maximum = this._items.length - settings.items;
1170		} else if (settings.loop || settings.center) {
1171			maximum = this._items.length + settings.items;
1172		} else if (settings.autoWidth || settings.merge) {
1173			revert = settings.rtl ? 1 : -1;
1174			width = this.$stage.width() - this.$element.width();
1175			while (coordinate = this.coordinates(i)) {
1176				if (coordinate * revert >= width) {
1177					break;
1178				}
1179				maximum = ++i;
1180			}
1181		} else {
1182			throw 'Can not detect maximum absolute position.'
1183		}
1184
1185		return maximum;
1186	};
1187
1188	/**
1189	 * Gets the minimum position for an item.
1190	 * @public
1191	 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1192	 * @returns {Number}
1193	 */
1194	Owl.prototype.minimum = function(relative) {
1195		if (relative) {
1196			return 0;
1197		}
1198
1199		return this._clones.length / 2;
1200	};
1201
1202	/**
1203	 * Gets an item at the specified relative position.
1204	 * @public
1205	 * @param {Number} [position] - The relative position of the item.
1206	 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1207	 */
1208	Owl.prototype.items = function(position) {
1209		if (position === undefined) {
1210			return this._items.slice();
1211		}
1212
1213		position = this.normalize(position, true);
1214		return this._items[position];
1215	};
1216
1217	/**
1218	 * Gets an item at the specified relative position.
1219	 * @public
1220	 * @param {Number} [position] - The relative position of the item.
1221	 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1222	 */
1223	Owl.prototype.mergers = function(position) {
1224		if (position === undefined) {
1225			return this._mergers.slice();
1226		}
1227
1228		position = this.normalize(position, true);
1229		return this._mergers[position];
1230	};
1231
1232	/**
1233	 * Gets the absolute positions of clones for an item.
1234	 * @public
1235	 * @param {Number} [position] - The relative position of the item.
1236	 * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given.
1237	 */
1238	Owl.prototype.clones = function(position) {
1239		var odd = this._clones.length / 2,
1240			even = odd + this._items.length,
1241			map = function(index) { return index % 2 === 0 ? even + index / 2 : odd 
1241- (index + 1) / 2 };
1242
1243		if (position === undefined) {
1244			return $.map(this._clones, function(v, i) { return map(i) });
1245		}
1246
1247		return $.map(this._clones, function(v, i) { return v === position ? map(i) : null });
1248	};
1249
1250	/**
1251	 * Sets the current animation speed.
1252	 * @public
1253	 * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged.
1254	 * @returns {Number} - The current animation speed in milliseconds.
1255	 */
1256	Owl.prototype.speed = function(speed) {
1257		if (speed !== undefined) {
1258			this._speed = speed;
1259		}
1260
1261		return this._speed;
1262	};
1263
1264	/**
1265	 * Gets the coordinate of an item.
1266	 * @todo The name of this method is missleanding.
1267	 * @public
1268	 * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`.
1269	 * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates.
1270	 */
1271	Owl.prototype.coordinates = function(position) {
1272		var coordinate = null;
1273
1274		if (position === undefined) {
1275			return $.map(this._coordinates, $.proxy(function(coordinate, index) {
1276				return this.coordinates(index);
1277			}, this));
1278		}
1279
1280		if (this.settings.center) {
1281			coordinate = this._coordinates[position];
1282			coordinate += (this.width() - coordinate + (this._coordinates[position - 1] || 0)) / 2 * (this.settings.rtl ? -1 : 1);
1283		} else {
1284			coordinate = this._coordinates[position - 1] || 0;
1285		}
1286
1287		return coordinate;
1288	};
1289
1290	/**
1291	 * Calculates the speed for a translation.
1292	 * @protected
1293	 * @param {Number} from - The absolute position of the start item.
1294	 * @param {Number} to - The absolute position of the target item.
1295	 * @param {Number} [factor=undefined] - The time factor in milliseconds.
1296	 * @returns {Number} - The time in milliseconds for the translation.
1297	 */
1298	Owl.prototype.duration = function(from, to, factor) {
1299		return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed));
1300	};
1301
1302	/**
1303	 * Slides to the specified item.
1304	 * @public
1305	 * @param {Number} position - The position of the item.
1306	 * @param {Number} [speed] - The time in milliseconds for the transition.
1307	 */
1308	Owl.prototype.to = function(position, speed) {
1309		if (this.settings.loop) {
1310			var distance = position - this.relative(this.current()),
1311				revert = this.current(),
1312				before = this.current(),
1313				after = this.current() + distance,
1314				direction = before - after < 0 ? true : false,
1315				items = this._clones.length + this._items.length;
1316
1317			if (after < this.settings.items && direction === false) {
1318				revert = before + this._items.length;
1319				this.reset(revert);
1320			} else if (after >= items - this.settings.items && direction === true) {
1321				revert = before - this._items.length;
1322				this.reset(revert);
1323			}
1324			window.clearTimeout(this.e._goToLoop);
1325			this.e._goToLoop = window.setTimeout($.proxy(function() {
1326				this.speed(this.duration(this.current(), revert + distance, speed));
1327				this.current(revert + distance);
1328				this.update();
1329			}, this), 30);
1330		} else {
1331			this.speed(this.duration(this.current(), position, speed));
1332			this.current(position);
1333			this.update();
1334		}
1335	};
1336
1337	/**
1338	 * Slides to the next item.
1339	 * @public
1340	 * @param {Number} [speed] - The time in milliseconds for the transition.
1341	 */
1342	Owl.prototype.next = function(speed) {
1343		speed = speed || false;
1344		this.to(this.relative(this.current()) + 1, speed);
1345	};
1346
1347	/**
1348	 * Slides to the previous item.
1349	 * @public
1350	 * @param {Number} [speed] - The time in milliseconds for the transition.
1351	 */
1352	Owl.prototype.prev = function(speed) {
1353		speed = speed || false;
1354		this.to(this.relative(this.current()) - 1, speed);
1355	};
1356
1357	/**
1358	 * Handles the end of an animation.
1359	 * @protected
1360	 * @param {Event} event - The event arguments.
1361	 */
1362	Owl.prototype.transitionEnd = function(event) {
1363
1364		// if css2 animation then event object is undefined
1365		if (event !== undefined) {
1366			event.stopPropagation();
1367
1368			// Catch only owl-stage transitionEnd event
1369			if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) {
1370				return false;
1371			}
1372		}
1373
1374		this.state.inMotion = false;
1375		this.trigger('translated');
1376	};
1377
1378	/**
1379	 * Gets viewport width.
1380	 * @protected
1381	 * @return {Number} - The width in pixel.
1382	 */
1383	Owl.prototype.viewport = function() {
1384		var width;
1385		if (this.options.responsiveBaseElement !== window) {
1386			width = $(this.options.responsiveBaseElement).width();
1387		} else if (window.innerWidth) {
1388			width = window.innerWidth;
1389		} else if (document.documentElement && document.documentElement.clientWidth) {
1390			width = document.documentElement.clientWidth;
1391		} else {
1392			throw 'Can not detect viewport width.';
1393		}
1394		return width;
1395	};
1396
1397	/**
1398	 * Replaces the current content.
1399	 * @public
1400	 * @param {HTMLElement|jQuery|String} content - The new content.
1401	 */
1402	Owl.prototype.replace = function(content) {
1403		this.$stage.empty();
1404		this._items = [];
1405
1406		if (content) {
1407			content = (content instanceof jQuery) ? content : $(content);
1408		}
1409
1410		if (this.settings.nestedItemSelector) {
1411			content = content.find('.' + this.settings.nestedItemSelector);
1412		}
1413
1414		content.filter(function() {
1415			return this.nodeType === 1;
1416		}).each($.proxy(function(index, item) {
1417			item = this.prepare(item);
1418			this.$stage.append(item);
1419			this._items.push(item);
1420			this._mergers.push(item.find('[data-merge]').andSelf('[data-merge]').attr('data-merge') * 1 || 1);
1421		}, this));
1422
1423		this.reset($.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0);
1424
1425		this.invalidate('items');
1426	};
1427
1428	/**
1429	 * Adds an item.
1430	 * @todo Use `item` instead of `content` for the event arguments.
1431	 * @public
1432	 * @param {HTMLElement|jQuery|String} content - The item content to add.
1433	 * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end.
1434	 */
1435	Owl.prototype.add = function(content, position) {
1436		position = position === undefined ? this._items.length : this.normalize(position, true);
1437
1438		this.trigger('add', { content: content, position: position });
1439
1440		if (this._items.length === 0 || position === this._items.length) {
1441			this.$stage.append(content);
1442			this._items.push(content);
1443			this._mergers.push(content.find('[data-merge]').andSelf('[data-merge]').attr('data-merge') * 1 || 1);
1444		} else {
1445			this._items[position].before(content);
1446			this._items.splice(position, 0, content);
1447			this._mergers.splice(position, 0, content.find('[data-merge]').andSelf('[data-merge]').attr('data-merge') * 1 || 1);
1448		}
1449
1450		this.invalidate('items');
1451
1452		this.trigger('added', { content: content, position: position });
1453	};
1454
1455	/**
1456	 * Removes an item by its position.
1457	 * @todo Use `item` instead of `content` for the event arguments.
1458	 * @public
1459	 * @param {Number} position - The relative position of the item to remove.
1460	 */
1461	Owl.prototype.remove = function(position) {
1462		position = this.normalize(position, true);
1463
1464		if (position === undefined) {
1465			return;
1466		}
1467
1468		this.trigger('del', { content: this._items[position], position: position });
1469
1470		this._items[position].remove();
1471		this._items.splice(position, 1);
1472		this._mergers.splice(position, 1);
1473
1474		this.invalidate('items');
1475
1476		this.trigger('deled', { content: null, position: position });
1477	};
1478
1479	/**
1480	 * Adds triggerable events.
1481	 * @protected
1482	 */
1483	Owl.prototype.addTriggerableEvents = function() {
1484		var handler = $.proxy(function(callback, event) {
1485			return $.proxy(function(e) {
1486				if (e.relatedTarget !== this) {
1487					this.suppress([ event ]);
1488					callback.apply(this, [].slice.call(arguments, 1));
1489					this.release([ event ]);
1490				}
1491			}, this);
1492		}, this);
1493
1494		$.each({
1495			'next': this.next,
1496			'prev': this.prev,
1497			'to': this.to,
1498			'destroy': this.destroy,
1499			'refresh': this.refresh,
1500			'replace': this.replace,
1501			'add': this.add,
1502			'del': this.remove
1503		}, $.proxy(function(event, callback) {
1504			this.$element.on(event + '.owl.carousel', handler(callback, event + '.owl.carousel'));
1505		}, this));
1506
1507	};
1508
1509	/**
1510	 * Watches the visibility of the carousel element.
1511	 * @protected
1512	 */
1513	Owl.prototype.watchVisibility = function() {
1514
1515		// test on zepto
1516		if (!isElVisible(this.$element.get(0))) {
1517			this.$element.addClass('owl-hidden');
1518			window.clearInterval(this.e._checkVisibile);
1519			this.e._checkVisibile = window.setInterval($.proxy(checkVisible, this), 500);
1520		}
1521
1522		function isElVisible(el) {
1523			return el.offsetWidth > 0 && el.offsetHeight > 0;
1524		}
1525
1526		function checkVisible() {
1527			if (isElVisible(this.$element.get(0))) {
1528				this.$element.removeClass('owl-hidden');
1529				this.refresh();
1530				window.clearInterval(this.e._checkVisibile);
1531			}
1532		}
1533	};
1534
1535	/**
1536	 * Preloads images with auto width.
1537	 * @protected
1538	 * @todo Still to test
1539	 */
1540	Owl.prototype.preloadAutoWidthImages = function(imgs) {
1541		var loaded, that, $el, img;
1542
1543		loaded = 0;
1544		that = this;
1545		imgs.each(function(i, el) {
1546			$el = $(el);
1547			img = new Image();
1548
1549			img.onload = function() {
1550				loaded++;
1551				$el.attr('src', img.src);
1552				$el.css('opacity', 1);
1553				if (loaded >= imgs.length) {
1554					that.state.imagesLoaded = true;
1555					that.initialize();
1556				}
1557			};
1558
1559			img.src = $el.attr('src') || $el.attr('data-src') || $el.attr('data-src-retina');
1560		});
1561	};
1562
1563	/**
1564	 * Destroys the carousel.
1565	 * @public
1566	 */
1567	Owl.prototype.destroy = function() {
1568
1569		if (this.$element.hasClass(this.settings.themeClass)) {
1570			this.$element.removeClass(this.settings.themeClass);
1571		}
1572
1573		if (this.settings.responsive !== false) {
1574			$(window).off('resize.owl.carousel');
1575		}
1576
1577		if (this.transitionEndVendor) {
1578			this.off(this.$stage.get(0), this.transitionEndVendor, this.e._transitionEnd);
1579		}
1580
1581		for ( var i in this._plugins) {
1582			this._plugins[i].destroy();
1583		}
1584
1585		if (this.settings.mouseDrag || this.settings.touchDrag) {
1586			this.$stage.off('mousedown touchstart touchcancel');
1587			$(document).off('.owl.dragEvents');
1588			this.$stage.get(0).onselectstart = function() {};
1589			this.$stage.off('dragstart', function() { return false });
1590		}
1591
1592		// remove event handlers in the ".owl.carousel" namespace
1593		this.$element.off('.owl');
1594
1595		this.$stage.children('.cloned').remove();
1596		this.e = null;
1597		this.$element.removeData('owlCarousel');
1598
1599		this.$stage.children().contents().unwrap();
1600		this.$stage.children().unwrap();
1601		this.$stage.unwrap();
1602	};
1603
1604	/**
1605	 * Operators to calculate right-to-left and left-to-right.
1606	 * @protected
1607	 * @param {Number} [a] - The left side operand.
1608	 * @param {String} [o] - The operator.
1609	 * @param {Number} [b] - The right side operand.
1610	 */
1611	Owl.prototype.op = function(a, o, b) {
1612		var rtl = this.settings.rtl;
1613		switch (o) {
1614			case '<':
1615				return rtl ? a > b : a < b;
1616			case '>':
1617				return rtl ? a < b : a > b;
1618			case '>=':
1619				return rtl ? a <= b : a >= b;
1620			case '<=':
1621				return rtl ? a >= b : a <= b;
1622			default:
1623				break;
1624		}
1625	};
1626
1627	/**
1628	 * Attaches to an internal event.
1629	 * @protected
1630	 * @param {HTMLElement} element - The event source.
1631	 * @param {String} event - The event name.
1632	 * @param {Function} listener - The event handler to attach.
1633	 * @param {Boolean} capture - Wether the event should be handled at the capturing p
1633hase or not.
1634	 */
1635	Owl.prototype.on = function(element, event, listener, capture) {
1636		if (element.addEventListener) {
1637			element.addEventListener(event, listener, capture);
1638		} else if (element.attachEvent) {
1639			element.attachEvent('on' + event, listener);
1640		}
1641	};
1642
1643	/**
1644	 * Detaches from an internal event.
1645	 * @protected
1646	 * @param {HTMLElement} element - The event source.
1647	 * @param {String} event - The event name.
1648	 * @param {Function} listener - The attached event handler to detach.
1649	 * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not.
1650	 */
1651	Owl.prototype.off = function(element, event, listener, capture) {
1652		if (element.removeEventListener) {
1653			element.removeEventListener(event, listener, capture);
1654		} else if (element.detachEvent) {
1655			element.detachEvent('on' + event, listener);
1656		}
1657	};
1658
1659	/**
1660	 * Triggers an public event.
1661	 * @protected
1662	 * @param {String} name - The event name.
1663	 * @param {*} [data=null] - The event data.
1664	 * @param {String} [namespace=.owl.carousel] - The event namespace.
1665	 * @returns {Event} - The event arguments.
1666	 */
1667	Owl.prototype.trigger = function(name, data, namespace) {
1668		var status = {
1669			item: { count: this._items.length, index: this.current() }
1670		}, handler = $.camelCase(
1671			$.grep([ 'on', name, namespace ], function(v) { return v })
1672				.join('-').toLowerCase()
1673		), event = $.Event(
1674			[ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(),
1675			$.extend({ relatedTarget: this }, status, data)
1676		);
1677
1678		if (!this._supress[name]) {
1679			$.each(this._plugins, function(name, plugin) {
1680				if (plugin.onTrigger) {
1681					plugin.onTrigger(event);
1682				}
1683			});
1684
1685			this.$element.trigger(event);
1686
1687			if (this.settings && typeof this.settings[handler] === 'function') {
1688				this.settings[handler].apply(this, event);
1689			}
1690		}
1691
1692		return event;
1693	};
1694
1695	/**
1696	 * Suppresses events.
1697	 * @protected
1698	 * @param {Array.<String>} events - The events to suppress.
1699	 */
1700	Owl.prototype.suppress = function(events) {
1701		$.each(events, $.proxy(function(index, event) {
1702			this._supress[event] = true;
1703		}, this));
1704	}
1705
1706	/**
1707	 * Releases suppressed events.
1708	 * @protected
1709	 * @param {Array.<String>} events - The events to release.
1710	 */
1711	Owl.prototype.release = function(events) {
1712		$.each(events, $.proxy(function(index, event) {
1713			delete this._supress[event];
1714		}, this));
1715	}
1716
1717	/**
1718	 * Checks the availability of some browser features.
1719	 * @protected
1720	 */
1721	Owl.prototype.browserSupport = function() {
1722		this.support3d = isPerspective();
1723
1724		if (this.support3d) {
1725			this.transformVendor = isTransform();
1726
1727			// take transitionend event name by detecting transition
1728			var endVendors = [ 'transitionend', 'webkitTransitionEnd', 'transitionend', 'oTransitionEnd' ];
1729			this.transitionEndVendor = endVendors[isTransition()];
1730
1731			// take vendor name from transform name
1732			this.vendorName = this.transformVendor.replace(/Transform/i, '');
1733			this.vendorName = this.vendorName !== '' ? '-' + this.vendorName.toLowerCase() + '-' : '';
1734		}
1735
1736		this.state.orientation = window.orientation;
1737	};
1738
1739	/**
1740	 * Get touch/drag coordinats.
1741	 * @private
1742	 * @param {event} - mousedown/touchstart event
1743	 * @returns {object} - Contains X and Y of current mouse/touch position
1744	 */
1745
1746	function getTouches(event) {
1747		if (event.touches !== undefined) {
1748			return {
1749				x: event.touches[0].pageX,
1750				y: event.touches[0].pageY
1751			};
1752		}
1753
1754		if (event.touches === undefined) {
1755			if (event.pageX !== undefined) {
1756				return {
1757					x: event.pageX,
1758					y: event.pageY
1759				};
1760			}
1761
1762		if (event.pageX === undefined) {
1763			return {
1764					x: event.clientX,
1765					y: event.clientY
1766				};
1767			}
1768		}
1769	}
1770
1771	/**
1772	 * Checks for CSS support.
1773	 * @private
1774	 * @param {Array} array - The CSS properties to check for.
1775	 * @returns {Array} - Contains the supported CSS property name and its index or `false`.
1776	 */
1777	function isStyleSupported(array) {
1778		var p, s, fake = document.createElement('div'), list = array;
1779		for (p in list) {
1780			s = list[p];
1781			if (typeof fake.style[s] !== 'undefined') {
1782				fake = null;
1783				return [ s, p ];
1784			}
1785		}
1786		return [ false ];
1787	}
1788
1789	/**
1790	 * Checks for CSS transition support.
1791	 * @private
1792	 * @todo Realy bad design
1793	 * @returns {Number}
1794	 */
1795	function isTransition() {
1796		return isStyleSupported([ 'transition', 'WebkitTransition', 'MozTransition', 'OTransition' ])[1];
1797	}
1798
1799	/**
1800	 * Checks for CSS transform support.
1801	 * @private
1802	 * @returns {String} The supported property name or false.
1803	 */
1804	function isTransform() {
1805		return isStyleSupported([ 'transform', 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform' ])[0];
1806	}
1807
1808	/**
1809	 * Checks for CSS perspective support.
1810	 * @private
1811	 * @returns {String} The supported property name or false.
1812	 */
1813	function isPerspective() {
1814		return isStyleSupported([ 'perspective', 'webkitPerspective', 'MozPerspective', 'OPerspective', 'MsPerspective' ])[0];
1815	}
1816
1817	/**
1818	 * Checks wether touch is supported or not.
1819	 * @private
1820	 * @returns {Boolean}
1821	 */
1822	function isTouchSupport() {
1823		return 'ontouchstart' in window || !!(navigator.msMaxTouchPoints);
1824	}
1825
1826	/**
1827	 * Checks wether touch is supported or not for IE.
1828	 * @private
1829	 * @returns {Boolean}
1830	 */
1831	function isTouchSupportIE() {
1832		return window.navigator.msPointerEnabled;
1833	}
1834
1835	/**
1836	 * The jQuery Plugin for the Owl Carousel
1837	 * @public
1838	 */
1839	$.fn.owlCarousel = function(options) {
1840		return this.each(function() {
1841			if (!$(this).data('owlCarousel')) {
1842				$(this).data('owlCarousel', new Owl(this, options));
1843			}
1844		});
1845	};
1846
1847	/**
1848	 * The constructor for the jQuery Plugin
1849	 * @public
1850	 */
1851	$.fn.owlCarousel.Constructor = Owl;
1852
1853})(window.Zepto || window.jQuery, window, document);
1854
1855/**
1856 * Lazy Plugin
1857 * @version 2.0.0
1858 * @author Bartosz Wojciechowski
1859 * @license The MIT License (MIT)
1860 */
1861;(function($, window, document, undefined) {
1862
1863	/**
1864	 * Creates the lazy plugin.
1865	 * @class The Lazy Plugin
1866	 * @param {Owl} carousel - The Owl Carousel
1867	 */
1868	var Lazy = function(carousel) {
1869
1870		/**
1871		 * Reference to the core.
1872		 * @protected
1873		 * @type {Owl}
1874		 */
1875		this._core = carousel;
1876
1877		/**
1878		 * Already loaded items.
1879		 * @protected
1880		 * @type {Array.<jQuery>}
1881		 */
1882		this._loaded = [];
1883
1884		/**
1885		 * Event handlers.
1886		 * @protected
1887		 * @type {Object}
1888		 */
1889		this._handlers = {
1890			'initialized.owl.carousel change.owl.carousel': $.proxy(function(e) {
1891				if (!e.namespace) {
1892					return;
1893				}
1894
1895				if (!this._core.settings || !this._core.settings.lazyLoad) {
1896					return;
1897				}
1898
1899				if ((e.property && e.property.name == 'position') || e.type == 'initialized') {
1900					var settings = this._core.settings,
1901						n = (settings.center && Math.ceil(settings.items / 2) || settings.items),
1902						i = ((settings.center && n * -1) || 0),
1903						position = ((e.property && e.property.value) || this._core.current()) + i,
1904						clones = this._core.clones().length,
1905						load = $.proxy(function(i, v) { this.load(v) }, this);
1906
1907					while (i++ < n) {
1908						this.load(clones / 2 + this._core.relative(position));
1909						clones && $.each(this._core.clones(this._core.relative(position++)), load);
1910					}
1911				}
1912			}, this)
1913		};
1914
1915		// set the default options
1916		this._core.options = $.extend({}, Lazy.Defaults, this._core.options);
1917
1918		// register event handler
1919		this._core.$element.on(this._handlers);
1920	}
1921
1922	/**
1923	 * Default options.
1924	 * @public
1925	 */
1926	Lazy.Defaults = {
1927		lazyLoad: false
1928	}
1929
1930	/**
1931	 * Loads all resources of an item at the specified position.
1932	 * @param {Number} position - The absolute position of the item.
1933	 * @protected
1934	 */
1935	Lazy.prototype.load = function(position) {
1936		var $item = this._core.$stage.children().eq(position),
1937			$elements = $item && $item.find('.owl-lazy');
1938
1939		if (!$elements || $.inArray($item.get(0), this._loaded) > -1) {
1940			return;
1941		}
1942
1943		$elements.each($.proxy(function(index, element) {
1944			var $element = $(element), image,
1945				url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src');
1946
1947			this._core.trigger('load', { element: $element, url: url }, 'lazy');
1948
1949			if ($element.is('img')) {
1950				$element.one('load.owl.lazy', $.proxy(function() {
1951					$element.css('opacity', 1);
1952					this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1953				}, this)).attr('src', url);
1954			} else {
1955				image = new Image();
1956				image.onload = $.proxy(function() {
1957					$element.css({
1958						'background-image': 'url(' + url + ')',
1959						'opacity': '1'
1960					});
1961					this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1962				}, this);
1963				image.src = url;
1964			}
1965		}, this));
1966
1967		this._loaded.push($item.get(0));
1968	}
1969
1970	/**
1971	 * Destroys the plugin.
1972	 * @public
1973	 */
1974	Lazy.prototype.destroy = function() {
1975		var handler, property;
1976
1977		for (handler in this.handlers) {
1978			this._core.$element.off(handler, this.handlers[handler]);
1979		}
1980		for (property in Object.getOwnPropertyNames(this)) {
1981			typeof this[property] != 'function' && (this[property] = null);
1982		}
1983	}
1984
1985	$.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy;
1986
1987})(window.Zepto || window.jQuery, window, document);
1988
1989/**
1990 * AutoHeight Plugin
1991 * @version 2.0.0
1992 * @author Bartosz Wojciechowski
1993 * @license The MIT License (MIT)
1994 */
1995;(function($, window, document, undefined) {
1996
1997	/**
1998	 * Creates the auto height plugin.
1999	 * @class The Auto Height Plugin
2000	 * @param {Owl} carousel - The Owl Carousel
2001	 */
2002	var AutoHeight = function(carousel) {
2003		/**
2004		 * Reference to the core.
2005		 * @protected
2006		 * @type {Owl}
2007		 */
2008		this._core = carousel;
2009
2010		/**
2011		 * All event handlers.
2012		 * @protected
2013		 * @type {Object}
2014		 */
2015		this._handlers = {
2016			'initialized.owl.carousel': $.proxy(function() {
2017				if (this._core.settings.autoHeight) {
2018					this.update();
2019				}
2020			}, this),
2021			'changed.owl.carousel': $.proxy(function(e) {
2022				if (this._core.settings.autoHeight && e.property.name == 'position'){
2023					this.update();
2024				}
2025			}, this),
2026			'loaded.owl.lazy': $.proxy(function(e) {
2027				if (this._core.settings.autoHeight && e.element.closest('.' + this._core.settings.itemClass)
2028					=== this._core.$stage.children().eq(this._core.current())) {
2029					this.update();
2030				}
2031			}, this)
2032		};
2033
2034		// set default options
2035		this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options);
2036
2037		// register event handlers
2038		this._core.$element.on(this._handlers);
2039	};
2040
2041	/**
2042	 * Default options.
2043	 * @public
2044	 */
2045	AutoHeight.Defaults = {
2046		autoHeight: false,
2047		autoHeightClass: 'owl-height'
2048	};
2049
2050	/**
2051	 * Updates the view.
2052	 */
2053	AutoHeight.prototype.update = function() {
2054		this._core.$stage.parent()
2055			.height(this._core.$stage.children().eq(this._core.current()).height())
2056			.addClass(this._core.settings.autoHeightClass);
2057	};
2058
2059	AutoHeight.prototype.destroy = function() {
2060		var handler, property;
2061
2062		for (handler in this._handlers) {
2063			this._core.$element.off(handler, this._handlers[handler]);
2064		}
2065		for (property in Object.getOwnPropertyNames(this)) {
2066			typeof this[property] != 'function' && (this[property] = null);
2067		}
2068	};
2069
2070	$.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight;
2071
2072})(window.Zepto || window.jQuery, window, document);
2073
2074/**
2075 * Video Plugin
2076 * @version 2.0.0
2077 * @author Bartosz Wojciechowski
2078 * @license The MIT License (MIT)
2079 */
2080;(function($, window, document, undefined) {
2081
2082	/**
2083	 * Creates the video plugin.
2084	 * @class The Video Plugin
2085	 * @param {Owl} carousel - The Owl Carousel
2086	 */
2087	var Video = function(carousel) {
2088		/**
2089		 * Reference to the core.
2090		 * @protected
2091		 * @type {Owl}
2092		 */
2093		this._core = carousel;
2094
2095		/**
2096		 * Cache all video URLs.
2097		 * @protected
2098		 * @type {Object}
2099		 */
2100		this._videos = {};
2101
2102		/**
2103		 * Current playing item.
2104		 * @protected
2105		 * @type {jQuery}
2106		 */
2107		this._playing = null;
2108
2109		/**
2110		 * Whether this is in fullscreen or not.
2111		 * @protected
2112		 * @type {Boolean}
2113		 */
2114		this._fullscreen = false;
2115
2116		/**
2117		 * All event handlers.
2118		 * @protected
2119		 * @type {Object}
2120		 */
2121		this._handlers = {
2122			'resize.owl.carousel': $.proxy(function(e) {
2123				if (this._core.settings.video && !this.isInFullScreen()) {
2124					e.preventDefault();
2125				}
2126			}, this),
2127			'refresh.owl.carousel changed.owl.carousel': $.proxy(function(e) {
2128				if (this._playing) {
2129					this.stop();
2130				}
2131			}, this),
2132			'prepared.owl.carousel': $.proxy(function(e) {
2133				var $element = $(e.content).find('.owl-video');
2134				if ($element.length) {
2135					$element.css('display', 'none');
2136					this.fetch($element, $(e.content));
2137				}
2138			}, this)
2139		};
2140
2141		// set default options
2142		this._core.options = $.extend({}, Video.Defaults, this._core.options);
2143
2144		// register event handlers
2145		this._core.$element.on(this._handlers);
2146
2147		this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) {
2148			this.play(e);
2149		}, this));
2150	};
2151
2152	/**
2153	 * Default options.
2154	 * @public
2155	 */
2156	Video.Defaults = {
2157		video: false,
2158		videoHeight: false,
2159		videoWidth: false
2160	};
2161
2162	/**
2163	 * Gets the video ID and the type (YouTube/Vimeo only).
2164	 * @protected
2165	 * @param {jQuery} target - The target containing the video data.
2166	 * @param {jQuery} item - The item containing the video.
2167	 */
2168	Video.prototype.fetch = function(target, item) {
2169
2170		var type = target.attr('data-vimeo-id') ? 'vimeo' : 'youtube',
2171			id = target.attr('data-vimeo-id') || target.attr('data-youtube-id'),
2172			width = target.attr('data-width') || this._core.settings.videoWidth,
2173			height = target.attr('data-height') || this._core.settings.videoHeight,
2174			url = target.attr('href');
2175
2176		if (url) {
2177			id = url.match(/(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/);
2178
2179			if (id[3].indexOf('youtu') > -1) {
2180				type = 'youtube';
2181			} else if (id[3].indexOf('vimeo') > -1) {
2182				type = 'vimeo';
2183			} else {
2184				throw new Error('Video URL not supported.');
2185			}
2186			id = id[6];
2187		} else {
2188			throw new Error('Missing video URL.');
2189		}
2190
2191		this._videos[url] = {
2192			type: type,
2193			id: id,
2194			width: width,
2195			height: height
2196		};
2197
2198		item.attr('data-video', url);
2199
2200		this.thumbnail(target, this._videos[url]);
2201	};
2202
2203	/**
2204	 * Creates video thumbnail.
2205	 * @protected
2206	 * @param {jQuery} target - The target containing the video data.
2207	 * @param {Object} info - The video info object.
2208	 * @see `fetch`
2209	 */
2210	Video.prototype.thumbnail = function(target, video) {
2211
2212		var tnLink,
2213			icon,
2214			path,
2215			dimensions = video.width && video.height ? 'style="width:' + video.width + 'px;height:' + video.height + 'px;"' : '',
2216			customTn = target.find('img'),
2217			srcType = 'src',
2218			lazyClass = '',
2219			settings = this._core.settings,
2220			create = function(path) {
2221				icon = '<div class="owl-video-play-icon"></div>';
2222
2223				if (settings.lazyLoad) {
2224					tnLink = '<div class="owl-video-tn ' + lazyClass + '" ' + srcType + '="' + path + '"></div>';
2225				} else {
2226					tnLink = '<div class="owl-video-tn" style="opacity:1;background-image:url(' + path + ')"></div>';
2227				}
2228				target.after(tnLink);
2229				target.after(icon);
2230			};
2231
2232		// wrap video content into owl-video-wrapper div
2233		target.wrap('<div class="owl-video-wrapper"' + dimensions + '></div>');
2234
2235		if (this._core.settings.lazyLoad) {
2236			srcType = 'data-src';
2237			lazyClass = 'owl-lazy';
2238		}
2239
2240		// custom thumbnail
2241		if (customTn.length) {
2242			create(customTn.attr(srcType));
2243			customTn.remove();
2244			return false;
2245		}
2246
2247		if (video.type === 'youtube') {
2248			path = "http://img.youtube.com/vi/" + video.id + "/hqdefault.jpg";
2249			create(path);
2250		} else if (video.type === 'vimeo') {
2251			$.ajax({
2252				type: 'GET',
2253				url: 'http://vimeo.com/api/v2/video/' + video.id + '.json',
2254				jsonp: 'callback',
2255				dataType: 'jsonp',
2256				success: function(data) {
2257					path = data[0].thumbnail_large;
2258					create(path);
2259				}
2260			});
2261		}
2262	};
2263
2264	/**
2265	 * Stops the current video.
2266	 * @public
2267	 */
2268	Video.prototype.stop = function() {
2269		this._core.trigger('stop', null, 'video');
2270		this._playing.find('.owl-video-frame').remove();
2271		this._playing.removeClass('owl-video-playing');
2272		this._playing = null;
2273	};
2274
2275	/**
2276	 * Starts the current video.
2277	 * @public
2278	 * @param {Event} ev - The event arguments.
2279	 */
2280	Video.prototype.play = function(ev) {
2281		this._core.trigger('play', null, 'video');
2282
2283		if (this._playing) {
2284			this.stop();
2285		}
2286
2287		var target = $(ev.target || ev.srcElement),
2288			item = target.closest('.' + this._core.settings.itemClass),
2289			video = this._videos[item.attr('data-video')],
2290			width = video.width || '100%',
2291			height = video.height || this._core.$stage.height(),
2292			html, wrap;
2293
2294		if (video.type === 'youtube') {
2295			html = '<iframe width="' + width + '" height="' + height + '" src="http://www.youtube.com/embed/'
2296				+ video.id + '?autoplay=1&v=' + video.id + '" frameborder="0" allowfullscreen></iframe>';
2297		} else if (video.type === 'vimeo') {
2298			html = '<iframe src="http://player.vimeo.com/video/' + video.id + '?autoplay=1" width="' + width
2299				+ '" height="' + height
2300				+ '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
2301		}
2302
2303		item.addClass('owl-video-playing');
2304		this._playing = item;
2305
2306		wrap = $('<div style="height:' + height + 'px; width:' + width + 'px" class="owl-video-frame">'
2307			+ html + '</div>');
2308		target.after(wrap);
2309	};
2310
2311	/**
2312	 * Checks whether an video is currently in full screen mode or not.
2313	 * @todo Bad style because looks like a readonly method but changes members.
2314	 * @protected
2315	 * @returns {Boolean}
2316	 */
2317	Video.prototype.isInFullScreen = function() {
2318
2319		// if Vimeo Fullscreen mode
2320		var element = document.fullscreenElement || document.mozFullScreenElement
2321			|| document.webkitFullscreenElement;
2322
2323		if (element && $(element).parent().hasClass('owl-video-frame')) {
2324			this._core.speed(0);
2325			this._fullscreen = true;
2326		}
2327
2328		if (element && this._fullscreen && this._playing) {
2329			return false;
2330		}
2331
2332		// comming back from fullscreen
2333		if (this._fullscreen) {
2334			this._fullscreen = false;
2335			return false;
2336		}
2337
2338		// check full screen mode and window orientation
2339		if (this._playing) {
2340			if (this._core.state.orientation !== window.orientation) {
2341				this._core.state.orientation = window.orientation;
2342				return false;
2343			}
2344		}
2345
2346		return true;
2347	};
2348
2349	/**
2350	 * Destroys the plugin.
2351	 */
2352	Video.prototype.destroy = function() {
2353		var handler, property;
2354
2355		this._core.$element.off('click.owl.video');
2356
2357		for (handler in this._handlers) {
2358			this._core.$element.off(handler, this._handlers[handler]);
2359		}
2360		for (property in Object.getOwnPropertyNames(this)) {
2361			typeof this[property] != 'function' && (this[property] = null);
2362		}
2363	};
2364
2365	$.fn.owlCarousel.Constructor.Plugins.Video = Video;
2366
2367})(window.Zepto || window.jQuery, window, document);
2368
2369/**
2370 * Animate Plugin
2371 * @version 2.0.0
2372 * @author Bartosz Wojciechowski
2373 * @license The MIT License (MIT)
2374 */
2375;(function($, window, document, undefined) {
2376
2377	/**
2378	 * Creates the animate plugin.
2379	 * @class The Navigation Plugin
2380	 * @param {Owl} scope - The Owl Carousel
2381	 */
2382	var Animate = function(scope) {
2383		this.core = scope;
2384		this.core.options = $.extend({}, Animate.Defaults, this.core.options);
2385		this.swapping = true;
2386		this.previous = undefined;
2387		this.next = undefined;
2388
2389		this.handlers = {
2390			'change.owl.carousel': $.proxy(function(e) {
2391				if (e.property.name == 'position') {
2392					this.previous = this.core.current();
2393					this.next = e.property.value;
2394				}
2395			}, this),
2396			'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) {
2397				this.swapping = e.type == 'translated';
2398			}, this),
2399			'translate.owl.carousel': $.proxy(function(e) {
2400				if (this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) {
2401					this.swap();
2402				}
2403			}, this)
2404		};
2405
2406		this.core.$element.on(this.handlers);
2407	};
2408
2409	/**
2410	 * Default options.
2411	 * @public
2412	 */
2413	Animate.Defaults = {
2414		animateOut: false,
2415		animateIn: false
2416	};
2417
2418	/**
2419	 * Toggles the animation classes whenever an translations starts.
2420	 * @protected
2421	 * @returns {Boolean|undefined}
2422	 */
2423	Animate.prototype.swap = function() {
2424
2425		if (this.core.settings.items !== 1 || !this.core.support3d) {
2426			return;
2427		}
2428
2429		this.core.speed(0);
2430
2431		var left,
2432			clear = $.proxy(this.clear, this),
2433			previous = this.core.$stage.children().eq(this.previous),
2434			next = this.core.$stage.children().eq(this.next),
2435			incoming = this.core.settings.animateIn,
2436			outgoing = this.core.settings.animateOut;
2437
2438		if (this.core.current() === this.previous) {
2439			return;
2440		}
2441
2442		if (outgoing) {
2443			left = this.core.coordinates(this.previous) - this.core.coordinates(this.next);
2444			previous.css( { 'left': left + 'px' } )
2445				.addClass('animated owl-animated-out')
2446				.addClass(outgoing)
2447				.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', clear);
2448		}
2449
2450		if (incoming) {
2451			next.addClass('animated owl-animated-in')
2452				.addClass(incoming)
2453				.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', clear);
2454		}
2455	};
2456
2457	Animate.prototype.clear = function(e) {
2458		$(e.target).css( { 'left': '' } )
2459			.removeClass('animated owl-animated-out owl-animated-in')
2460			.removeClass(this.core.settings.animateIn)
2461			.removeClass(this.core.settings.animateOut);
2462		this.core.transitionEnd();
2463	}
2464
2465	/**
2466	 * Destroys the plugin.
2467	 * @public
2468	 */
2469	Animate.prototype.destroy = function() {
2470		var handler, property;
2471
2472		for (handler in this.handlers) {
2473			this.core.$element.off(handler, this.handlers[handler]);
2474		}
2475		for (property in Object.getOwnPropertyNames(this)) {
2476			typeof this[property] != 'function' && (this[property] = null);
2477		}
2478	};
2479
2480	$.fn.owlCarousel.Constructor.Plugins.Animate = Animate;
2481
2482})(window.Zepto || window.jQuery, window, document);
2483
2484/**
2485 * Autoplay Plugin
2486 * @version 2.0.0
2487 * @author Bartosz Wojciechowski
2488 * @license The MIT License (MIT)
2489 */
2490;(function($, window, document, undefined) {
2491
2492	/**
2493	 * Creates the autoplay plugin.
2494	 * @class The Autoplay Plugin
2495	 * @param {Owl} scope - The Owl Carousel
2496	 */
2497	var Autoplay = function(scope) {
2498		this.core = scope;
2499		this.core.options = $.extend({}, Autoplay.Defaults, this.core.options);
2500
2501		this.handlers = {
2502			'translated.owl.carousel refreshed.owl.carousel': $.proxy(function() {
2503				this.autoplay();
2504			}, this),
2505			'play.owl.autoplay': $.proxy(function(e, t, s) {
2506				this.play(t, s);
2507			}, this),
2508			'stop.owl.autoplay': $.proxy(function() {
2509				this.stop();
2510			}, this),
2511			'mouseover.owl.autoplay': $.proxy(function() {
2512				if (this.core.settings.autoplayHoverPause) {
2513					this.pause();
2514				}
2515			}, this),
2516			'mouseleave.owl.autoplay': $.proxy(function() {
2517				if (this.core.settings.autoplayHoverPause) {
2518					this.autoplay();
2519				}
2520			}, this)
2521		};
2522
2523		this.core.$element.on(this.handlers);
2524	};
2525
2526	/**
2527	 * Default options.
2528	 * @public
2529	 */
2530	Autoplay.Defaults = {
2531		autoplay: false,
2532		autoplayTimeout: 5000,
2533		autoplayHoverPause: false,
2534		autoplaySpeed: false
2535	};
2536
2537	/**
2538	 * @protected
2539	 * @todo Must be documented.
2540	 */
2541	Autoplay.prototype.autoplay = function() {
2542		if (this.core.settings.autoplay && !this.core.state.videoPlay) {
2543			window.clearInterval(this.interval);
2544
2545			this.interval = window.setInterval($.proxy(function() {
2546				this.play();
2547			}, this), this.core.settings.autoplayTimeout);
2548		} else {
2549			window.clearInterval(this.interval);
2550		}
2551	};
2552
2553	/**
2554	 * Starts the autoplay.
2555	 * @public
2556	 * @param {Number} [timeout] - ...
2557	 * @param {Number} [speed] - ...
2558	 * @returns {Boolean|undefined} - ...
2559	 * @todo Must be documented.
2560	 */
2561	Autoplay.prototype.play = function(timeout, speed) {
2562		// if tab is inactive - doesnt work in <IE10
2563		if (document.hidden === true) {
2564			return;
2565		}
2566
2567		if (this.core.state.isTouch || this.core.state.isScrolling
2568			|| this.core.state.isSwiping || this.core.state.inMotion) {
2569			return;
2570		}
2571
2572		if (this.core.settings.autoplay === false) {
2573			window.clearInterval(this.interval);
2574			return;
2575		}
2576
2577		this.core.next(this.core.settings.autoplaySpeed);
2578	};
2579
2580	/**
2581	 * Stops the autoplay.
2582	 * @public
2583	 */
2584	Autoplay.prototype.stop = function() {
2585		window.clearInterval(this.interval);
2586	};
2587
2588	/**
2589	 * Pauses the autoplay.
2590	 * @public
2591	 */
2592	Autoplay.prototype.pause = function() {
2593		window.clearInterval(this.interval);
2594	};
2595
2596	/**
2597	 * Destroys the plugin.
2598	 */
2599	Autoplay.prototype.destroy = function() {
2600		var handler, property;
2601
2602		window.clearInterval(this.interval);
2603
2604		for (handler in this.handlers) {
2605			this.core.$element.off(handler, this.handlers[handler]);
2606		}
2607		for (property in Object.getOwnPropertyNames(this)) {
2608			typeof this[property] != 'function' && (this[property] = null);
2609		}
2610	};
2611
2612	$.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay;
2613
2614})(window.Zepto || window.jQuery, window, document);
2615
2616/**
2617 * Navigation Plugin
2618 * @version 2.0.0
2619 * @author Artus Kolanowski
2620 * @license The MIT License (MIT)
2621 */
2622;(function($, window, document, undefined) {
2623	'use strict';
2624
2625	/**
2626	 * Creates the navigation plugin.
2627	 * @class The Navigation Plugin
2628	 * @param {Owl} carousel - The Owl Carousel.
2629	 */
2630	var Navigation = function(carousel) {
2631		/**
2632		 * Reference to the core.
2633		 * @protected
2634		 * @type {Owl}
2635		 */
2636		this._core = carousel;
2637
2638		/**
2639		 * Indicates whether the plugin is initialized or not.
2640		 * @protected
2641		 * @type {Boolean}
2642		 */
2643		this._initialized = false;
2644
2645		/**
2646		 * The current paging indexes.
2647		 * @protected
2648		 * @type {Array}
2649		 */
2650		this._pages = [];
2651
2652		/**
2653		 * All DOM elements of the user interface.
2654		 * @protected
2655		 * @type {Object}
2656		 */
2657		this._controls = {};
2658
2659		/**
2660		 * Markup for an indicator.
2661		 * @protected
2662		 * @type {Array.<String>}
2663		 */
2664		this._templates = [];
2665
2666		/**
2667		 * The carousel element.
2668		 * @type {jQuery}
2669		 */
2670		this.$element = this._core.$element;
2671
2672		/**
2673		 * Overridden methods of the carousel.
2674		 * @protected
2675		 * @type {Object}
2676		 */
2677		this._overrides = {
2678			next: this._core.next,
2679			prev: this._core.prev,
2680			to: this._core.to
2681		};
2682
2683		/**
2684		 * All event handlers.
2685		 * @protected
2686		 * @type {Object}
2687		 */
2688		this._handlers = {
2689			'prepared.owl.carousel': $.proxy(function(e) {
2690				if (this._core.settings.dotsData) {
2691					this._templates.push($(e.content).find('[data-dot]').andSelf('[data-dot]').attr('data-dot'));
2692				}
2693			}, this),
2694			'add.owl.carousel': $.proxy(function(e) {
2695				if (this._core.settings.dotsData) {
2696					this._templates.splice(e.position, 0, $(e.content).find('[data-dot]').andSelf('[data-dot]').attr('data-dot'));
2697				}
2698			}, this),
2699			'remove.owl.carousel prepared.owl.carousel': $.proxy(function(e) {
2700				if (this._core.settings.dotsData) {
2701					this._templates.splice(e.position, 1);
2702				}
2703			}, this),
2704			'change.owl.carousel': $.proxy(function(e) {
2705				if (e.property.name == 'position') {
2706					if (!this._core.state.revert && !this._core.settings.loop && this._core.settings.navRewind) {
2707						var current = this._core.current(),
2708							maximum = this._core.maximum(),
2709							minimum = this._core.minimum();
2710						e.data = e.property.value > maximum
2711							? current >= maximum ? minimum : maximum
2712							: e.property.value < minimum ? maximum : e.property.value;
2713					}
2714				}
2715			}, this),
2716			'changed.owl.carousel': $.proxy(function(e) {
2717				if (e.property.name == 'position') {
2718					this.draw();
2719				}
2720			}, this),
2721			'refreshed.owl.carousel': $.proxy(function() {
2722				if (!this._initialized) {
2723					this.initialize();
2724					this._initialized = true;
2725				}
2726				this._core.trigger('refresh', null, 'navigation');
2727				this.update();
2728				this.draw();
2729				this._core.trigger('refreshed', null, 'navigation');
2730			}, this)
2731		};
2732
2733		// set default options
2734		this._core.options = $.extend({}, Navigation.Defaults, this._core.options);
2735
2736		// register event handlers
2737		this.$element.on(this._handlers);
2738	}
2739
2740	/**
2741	 * Default options.
2742	 * @public
2743	 * @todo Rename `slideBy` to `navBy`
2744	 */
2745	Navigation.Defaults = {
2746		nav: false,
2747		navRewind: true,
2748		navText: [ 'prev', 'next' ],
2749		navSpeed: false,
2750		navElement: 'div',
2751		navContainer: false,
2752		navContainerClass: 'owl-nav',
2753		navClass: [ 'owl-prev', 'owl-next' ],
2754		slideBy: 1,
2755		dotClass: 'owl-dot',
2756		dotsClass: 'owl-dots',
2757		dots: true,
2758		dotsEach: false,
2759		dotData: false,
2760		dotsSpeed: false,
2761		dotsContainer: false,
2762		controlsClass: 'owl-controls'
2763	}
2764
2765	/**
2766	 * Initializes the layout of the plugin and extends the carousel.
2767	 * @protected
2768	 */
2769	Navigation.prototype.initialize = function() {
2770		var $container, override,
2771			options = this._core.settings;
2772
2773		// create the indicator template
2774		if (!options.dotsData) {
2775			this._templates = [ $('<div>')
2776				.addClass(options.dotClass)
2777				.append($('<span>'))
2778				.prop('outerHTML') ];
2779		}
2780
2781		// create controls container if needed
2782		if (!options.navContainer || !options.dotsContainer) {
2783			this._controls.$container = $('<div>')
2784				.addClass(options.controlsClass)
2785				.appendTo(this.$element);
2786		}
2787
2788		// create DOM structure for absolute navigation
2789		this._controls.$indicators = options.dotsContainer ? $(options.dotsContainer)
2790			: $('<div>').hide().addClass(options.dotsClass).appendTo(this._controls.$container);
2791
2792		this._controls.$indicators.on('click', 'div', $.proxy(function(e) {
2793			var index = $(e.target).parent().is(this._controls.$indicators)
2794				? $(e.target).index() : $(e.target).parent().index();
2795
2796			e.preventDefault();
2797
2798			this.to(index, options.dotsSpeed);
2799		}, this));
2800
2801		// create DOM structure for relative navigation
2802		$container = options.navContainer ? $(options.navContainer)
2803			: $('<div>').addClass(options.navContainerClass).prependTo(this._controls.$container);
2804
2805		this._controls.$next = $('<' + options.navElement + '>');
2806		this._controls.$previous = this._controls.$next.clone();
2807
2808		this._controls.$previous
2809			.addClass(options.navClass[0])
2810			.html(options.navText[0])
2811			.hide()
2812			.prependTo($container)
2813			.on('click', $.proxy(function(e) {
2814				this.prev(options.navSpeed);
2815			}, this));
2816		this._controls.$next
2817			.addClass(options.navClass[1])
2818			.html(options.navText[1])
2819			.hide()
2820			.appendTo($container)
2821			.on('click', $.proxy(function(e) {
2822				this.next(options.navSpeed);
2823			}, this));
2824
2825		// override public methods of the carousel
2826		for (override in this._overrides) {
2827			this._core[override] = $.proxy(this[override], this);
2828		}
2829	}
2830
2831	/**
2832	 * Destroys the plugin.
2833	 * @protected
2834	 */
2835	Navigation.prototype.destroy = function() {
2836		var handler, control, property, override;
2837
2838		for (handler in this._handlers) {
2839			this.$element.off(handler, this._handlers[handler]);
2840		}
2841		for (control in this._controls) {
2842			this._controls[control].remove();
2843		}
2844		for (override in this.overides) {
2845			this._core[override] = this._overrides[override];
2846		}
2847		for (property in Object.getOwnPropertyNames(this)) {
2848			typeof this[property] != 'function' && (this[property] = null);
2849		}
2850	}
2851
2852	/**
2853	 * Updates the internal state.
2854	 * @protected
2855	 */
2856	Navigation.prototype.update = function() {
2857		var i, j, k,
2858			options = this._core.settings,
2859			lower = this._core.clones().length / 2,
2860			upper = lower + this._core.items().length,
2861			size = options.center || options.autoWidth || options.dotData
2862				? 1 : options.dotsEach || options.items;
2863
2864		if (options.slideBy !== 'page') {
2865			options.slideBy = Math.min(options.slideBy, options.items);
2866		}
2867
2868		if (options.dots || options.slideBy == 'page') {
2869			this._pages = [];
2870
2871			for (i = lower, j = 0, k = 0; i < upper; i++) {
2872				if (j >= size || j === 0) {
2873					this._pages.push({
2874						start: i - lower,
2875						end: i - lower + size - 1
2876					});
2877					j = 0, ++k;
2878				}
2879				j += this._core.mergers(this._core.relative(i));
2880			}
2881		}
2882	}
2883
2884	/**
2885	 * Draws the user interface.
2886	 * @todo The option `dotData` wont work.
2887	 * @protected
2888	 */
2889	Navigation.prototype.draw = function() {
2890		var difference, i, html = '',
2891			options = this._core.settings,
2892			$items = this._core.$stage.children(),
2893			index = this._core.relative(this._core.current());
2894
2895		if (options.nav && !options.loop && !options.navRewind) {
2896			this._controls.$previous.toggleClass('disabled', index <= 0);
2897			this._controls.$next.toggleClass('disabled', index >= this._core.maximum());
2898		}
2899
2900		this._controls.$previous.toggle(options.nav);
2901		this._controls.$next.toggle(options.nav);
2902
2903		if (options.dots) {
2904			difference = this._pages.length - this._controls.$indicators.children().length;
2905
2906			if (options.dotData && difference !== 0) {
2907				for (i = 0; i < this._controls.$indicators.children().length; i++) {
2908					html += this._templates[this._core.relative(i)];
2909				}
2910				this._controls.$indicators.html(html);
2911			} else if (difference > 0) {
2912				html = new Array(difference + 1).join(this._templates[0]);
2913				this._controls.$indicators.append(html);
2914			} else if (difference < 0) {
2915				this._controls.$indicators.children().slice(difference).remove();
2916			}
2917
2918			this._controls.$indicators.find('.active').removeClass('active');
2919			this._controls.$indicators.children().eq($.inArray(this.current(), this._pages)).addClass('active');
2920		}
2921
2922		this._controls.$indicators.toggle(options.dots);
2923	}
2924
2925	/**
2926	 * Extends event data.
2927	 * @protected
2928	 * @param {Event} event - The event object which gets thrown.
2929	 */
2930	Navigation.prototype.onTrigger = function(event) {
2931		var settings = this._core.settings;
2932
2933		event.page = {
2934			index: $.inArray(this.current(), this._pages),
2935			count: this._pages.length,
2936			size: settings && (settings.center || settings.autoWidth || settings.dotData
2937				? 1 : settings.dotsEach || settings.items)
2938		};
2939	}
2940
2941	/**
2942	 * Gets the current page position of the carousel.
2943	 * @protected
2944	 * @returns {Number}
2945	 */
2946	Navigation.prototype.current = function() {
2947		var index = this._core.relative(this._core.current());
2948		return $.grep(this._pages, function(o) {
2949			return o.start <= index && o.end >= index;
2950		}).pop();
2951	}
2952
2953	/**
2954	 * Gets the current succesor/predecessor position.
2955	 * @protected
2956	 * @returns {Number}
2957	 */
2958	Navigation.prototype.getPosition = function(successor) {
2959		var position, length,
2960			options = this._core.settings;
2961
2962		if (options.slideBy == 'page') {
2963			position = $.inArray(this.current(), this._pages);
2964			length = this._pages.length;
2965			successor ? ++position : --position;
2966			position = this._pages[((position % length) + length) % length].start;
2967		} else {
2968			position = this._core.relative(this._core.current());
2969			length = this._core.items().length;
2970			successor ? position += options.slideBy : position -= options.slideBy;
2971		}
2972		return position;
2973	}
2974
2975	/**
2976	 * Slides to the next item or page.
2977	 * @public
2978	 * @param {Number} [speed=false] - The time in milliseconds for the transition.
2979	 */
2980	Navigation.prototype.next = function(speed) {
2981		$.proxy(this._overrides.to, this._core)(this.getPosition(true), speed);
2982	}
2983
2984	/**
2985	 * Slides to the previous item or page.
2986	 * @public
2987	 * @param {Number} [speed=false] - The time in milliseconds for the transition.
2988	 */
2989	Navigation.prototype.prev = function(speed) {
2990		$.proxy(this._overrides.to, this._core)(this.getPosition(false), speed);
2991	}
2992
2993	/**
2994	 * Slides to the specified item or page.
2995	 * @public
2996	 * @param {Number} position - The position of the item or page.
2997	 * @param {Number} [speed] - The time in milliseconds for the transition.
2998	 * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not.
2999	 */
3000	Navigation.prototype.to = function(position, speed, standard) {
3001		var length;
3002
3003		if (!standard) {
3004			length = this._pages.length;
3005			$.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed);
3006		} else {
3007			$.proxy(this._overrides.to, this._core)(position, speed);
3008		}
3009	}
3010
3011	$.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation;
3012
3013})(window.Zepto || window.jQuery, window, document);
3014
3015/**
3016 * Hash Plugin
3017 * @version 2.0.0
3018 * @author Artus Kolanowski
3019 * @license The MIT License (MIT)
3020 */
3021;(function($, window, document, undefined) {
3022	'use strict';
3023
3024	/**
3025	 * Creates the hash plugin.
3026	 * @class The Hash Plugin
3027	 * @param {Owl} carousel - The Owl Carousel
3028	 */
3029	var Hash = function(carousel) {
3030		/**
3031		 * Reference to the core.
3032		 * @protected
3033		 * @type {Owl}
3034		 */
3035		this._core = carousel;
3036
3037		/**
3038		 * Hash table for the hashes.
3039		 * @protected
3040		 * @type {Object}
3041		 */
3042		this._hashes = {};
3043
3044		/**
3045		 * The carousel element.
3046		 * @type {jQuery}
3047		 */
3048		this.$element = this._core.$element;
3049
3050		/**
3051		 * All event handlers.
3052		 * @protected
3053		 * @type {Object}
3054		 */
3055		this._handlers = {
3056			'initialized.owl.carousel': $.proxy(function() {
3057				if (this._core.settings.startPosition == 'URLHash') {
3058					$(window).trigger('hashchange.owl.navigation');
3059				}
3060			}, this),
3061			'prepared.owl.carousel': $.proxy(function(e) {
3062				var hash = $(e.content).find('[data-hash]').andSelf('[data-hash]').attr('data-hash');
3063				this._hashes[hash] = e.content;
3064			}, this)
3065		};
3066
3067		// set default options
3068		this._core.options = $.extend({}, Hash.Defaults, this._core.options);
3069
3070		// register the event handlers
3071		this.$element.on(this._handlers);
3072
3073		// register event listener for hash navigation
3074		$(window).on('hashchange.owl.navigation', $.proxy(function() {
3075			var hash = window.location.hash.substring(1),
3076				items = this._core.$stage.children(),
3077				position = this._hashes[hash] && items.index(this._hashes[hash]) || 0;
3078
3079			if (!hash) {
3080				return false;
3081			}
3082
3083			this._core.to(position, false, true);
3084		}, this));
3085	}
3086
3087	/**
3088	 * Default options.
3089	 * @public
3090	 */
3091	Hash.Defaults = {
3092		URLhashListener: false
3093	}
3094
3095	/**
3096	 * Destroys the plugin.
3097	 * @public
3098	 */
3099	Hash.prototype.destroy = function() {
3100		var handler, property;
3101
3102		$(window).off('hashchange.owl.navigation');
3103
3104		for (handler in this._handlers) {
3105			this._core.$element.off(handler, this._handlers[handler]);
3106		}
3107		for (property in Object.getOwnPropertyNames(this)) {
3108			typeof this[property] != 'function' && (this[property] = null);
3109		}
3110	}
3111
3112	$.fn.owlCarousel.Constructor.Plugins.Hash = Hash;
3113
3114})(window.Zepto || window.jQuery, window, document);
3115
3116
3117/**
3118 * Owl carousel @version 2.0.0 filter plugin
3119 * @version 1.0.0
3120 * @author Darius Aleksiupas
3121 */
3122;(function($, window, document, undefined) {
3123
3124    var Filter = function(carousel) {
3125        this._core = carousel;
3126        
3127        this._handlers = {
3128            'initialized.owl.carousel': $.proxy(function() {
3129                if (this._core.settings.filter) {
3130                    this.init();
3131                }
3132            }, this)
3133        };
3134
3135        this._core.options = $.extend({}, Filter.Defaults, this._core.options);
3136        this._core.$element.on(this._handlers);
3137    }
3138
3139    Filter.Defaults = {
3140        filter: false
3141    }
3142
3143    //mehtods:
3144    Filter.prototype.init = function() {
3145        var $filter = this._core.$element.siblings('.carousel-filter');
3146        
3147        if ($filter.length === 0) {return false;}
3148        
3149        var _ = this;
3150        var itemsFilterArray = [];
3151            this._itemsClone = [];
3152
3153        $.each(this._core._items, function () {
3154            _._itemsClone.push(this.clone());
3155
3156            var $el = this.find('[data-filter]');
3157
3158            if ($el.length !==0) {
3159                itemsFilterArray.push($el.data('filter'));
3160            }
3161
3162        });
3163
3164        this._itemsClone.reverse();
3165        itemsFilterArray.reverse();
3166
3167        $filter.find('[data-filter]').on('click', function () {
3168            var f = parseInt(this.dataset.filter);
3169
3170            $.each(_._core._items, function (i, el) {
3171                _._core.$element.trigger('del.owl.carousel', [i]);
3172            });
3173
3174            if (f > 0) {
3175                $.each(itemsFilterArray, function (i, F) {
3176                    if (f === F) {
3177                        _._core.$element.trigger('add.owl.carousel', [_._itemsClone[i], 0]);
3178                    }
3179                });
3180
3181            } else {
3182                $.each(itemsFilterArray, function (i, F) {
3183                    _._core.$element.trigger('add.owl.carousel', [_._itemsClone[i], 0]);
3184                });
3185            }
3186            
3187            _._core.settings.nav = _._core._items.length > _._core.settings.items;
3188
3189            _._core.$element.trigger('refresh.owl.carousel');
3190
3191        });
3192        
3193    }
3194
3195    //destroy:
3196    Filter.prototype.destroy = function(){
3197        var handler, property;
3198
3199        for (handler in this._handlers) {
3200            this._core.$element.off(handler, this._handlers[handler]);
3201        }
3202        for (property in Object.getOwnPropertyNames(this)) {
3203            typeof this[property] != 'function' && (this[property] = null);
3204        }
3205    };
3206
3207    $.fn.owlCarousel.Constructor.Plugins['Filter'] = Filter;
3208
3209})( window.Zepto || window.jQuery, window,  document );
3210
3211
3212/*! nouislider - 8.0.2 - 2015-07-06 13:22:09 */
3213
3214!function(a){if("function"==typeof define&&define.amd)define([],a);else if("object"==typeof exports){var b=require("fs");module.exports=a(),module.exports.css=function(){return b.readFileSync(__dirname+"/nouislider.min.css","utf8")}}else window.noUiSlider=a()}(function(){"use strict";function a(a){return a.filter(function(a){return this[a]?!1:this[a]=!0},{})}function b(a,b){return Math.round(a/b)*b}function c(a){var b=a.getBoundingClientRect(),c=a.ownerDocument,d=c.defaultView||c.parentWindow,e=c.documentElement,f=d.pageXOffset;return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(f=0),{top:b.top+d.pageYOffset-e.clientTop,left:b.left+f-e.clientLeft}}function d(a){return"number"==typeof a&&!isNaN(a)&&isFinite(a)}function e(a){var b=Math.pow(10,7);return Number((Math.round(a*b)/b).toFixed(7))}function f(a,b,c){j(a,b),setTimeout(function(){k(a,b)},c)}function g(a){return Math.max(Math.min(a,100),0)}function h(a){return Array.isArray(a)?a:[a]}function i(a){var b=a.split(".");return b.length>1?b[1].length:0}function j(a,b){a.classList?a.classList.add(b):a.className+=" "+b}function k(a,b){a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp("(^|\\b)"+b.split(" ").join("|")+"(\\b|$)","gi")," ")}function l(a,b){a.classList?a.classList.contains(b):new RegExp("(^| )"+b+"( |$)","gi").test(a.className)}function m(a,b){return 100/(b-a)}function n(a,b){return 100*b/(a[1]-a[0])}function o(a,b){return n(a,a[0]<0?b+Math.abs(a[0]):b-a[0])}function p(a,b){return b*(a[1]-a[0])/100+a[0]}function q(a,b){for(var c=1;a>=b[c];)c+=1;return c}function r(a,b,c){if(c>=a.slice(-1)[0])return 100;var d,e,f,g,h=q(c,a);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],f+o([d,e],c)/m(f,g)}function s(a,b,c){if(c>=100)return a.slice(-1)[0];var d,e,f,g,h=q(c,b);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],p([d,e],(c-f)*m(f,g))}function t(a,c,d,e){if(100===e)return e;var f,g,h=q(e,a);return d?(f=a[h-1],g=a[h],e-f>(g-f)/2?g:f):c[h-1]?a[h-1]+b(e-a[h-1],c[h-1]):e}function u(a,b,c){var e;if("number"==typeof b&&(b=[b]),"[object Array]"!==Object.prototype.toString.call(b))throw new Error("noUiSlider: 'range' contains invalid value.");if(e="min"===a?0:"max"===a?100:parseFloat(a),!d(e)||!d(b[0]))throw new Error("noUiSlider: 'range' value isn't numeric.");c.xPct.push(e),c.xVal.push(b[0]),e?c.xSteps.push(isNaN(b[1])?!1:b[1]):isNaN(b[1])||(c.xSteps[0]=b[1])}function v(a,b,c){return b?void(c.xSteps[a]=n([c.xVal[a],c.xVal[a+1]],b)/m(c.xPct[a],c.xPct[a+1])):!0}function w(a,b,c,d){this.xPct=[],this.xVal=[],this.xSteps=[d||!1],this.xNumSteps=[!1],this.snap=b,this.direction=c;var e,f=[];for(e in a)a.hasOwnProperty(e)&&f.push([a[e],e]);for(f.sort(function(a,b){return a[0]-b[0]}),e=0;e<f.length;e++)u(f[e][1],f[e][0],this);for(this.xNumSteps=this.xSteps.slice(0),e=0;e<this.xNumSteps.length;e++)v(e,this.xNumSteps[e],this)}function x(a,b){if(!d(b))throw new Error("noUiSlider: 'step' is not numeric.");a.singleStep=b}function y(a,b){if("object"!=typeof b||Array.isArray(b))throw new Error("noUiSlider: 'range' is not an object.");if(void 0===b.min||void 0===b.max)throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");a.spectrum=new w(b,a.snap,a.dir,a.singleStep)}function z(a,b){if(b=h(b),!Array.isArray(b)||!b.length||b.length>2)throw new Error("noUiSlider: 'start' option is incorrect.");a.handles=b.length,a.start=b}function A(a,b){if(a.snap=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'snap' option must be a boolean.")}function B(a,b){if(a.animate=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'animate' option must be a boolean.")}function C(a,b){if("lower"===b&&1===a.handles)a.connect=1;else if("upper"===b&&1===a.handles)a.connect=2;else if(b===!0&&2===a.handles)a.connect=3;else{if(b!==!1)throw new Error("noUiSlider: 'connect' option doesn't match handle count.");a.connect=0}}function D(a,b){switch(b){case"horizontal":a.ort=0;break;case"vertical":a.ort=1;break;default:throw new Error("noUiSlider: 'orientation' option is invali
3214d.")}}function E(a,b){if(!d(b))throw new Error("noUiSlider: 'margin' option must be numeric.");if(a.margin=a.spectrum.getMargin(b),!a.margin)throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.")}function F(a,b){if(!d(b))throw new Error("noUiSlider: 'limit' option must be numeric.");if(a.limit=a.spectrum.getMargin(b),!a.limit)throw new Error("noUiSlider: 'limit' option is only supported on linear sliders.")}function G(a,b){switch(b){case"ltr":a.dir=0;break;case"rtl":a.dir=1,a.connect=[0,2,1,3][a.connect];break;default:throw new Error("noUiSlider: 'direction' option was not recognized.")}}function H(a,b){if("string"!=typeof b)throw new Error("noUiSlider: 'behaviour' must be a string containing options.");var c=b.indexOf("tap")>=0,d=b.indexOf("drag")>=0,e=b.indexOf("fixed")>=0,f=b.indexOf("snap")>=0;a.events={tap:c||f,drag:d,fixed:e,snap:f}}function I(a,b){if(a.format=b,"function"==typeof b.to&&"function"==typeof b.from)return!0;throw new Error("noUiSlider: 'format' requires 'to' and 'from' methods.")}function J(a){var b,c={margin:0,limit:0,animate:!0,format:U};b={step:{r:!1,t:x},start:{r:!0,t:z},connect:{r:!0,t:C},direction:{r:!0,t:G},snap:{r:!1,t:A},animate:{r:!1,t:B},range:{r:!0,t:y},orientation:{r:!1,t:D},margin:{r:!1,t:E},limit:{r:!1,t:F},behaviour:{r:!0,t:H},format:{r:!1,t:I}};var d={connect:!1,direction:"ltr",behaviour:"tap",orientation:"horizontal"};return Object.keys(d).forEach(function(b){void 0===a[b]&&(a[b]=d[b])}),Object.keys(b).forEach(function(d){var e=b[d];if(void 0===a[d]){if(e.r)throw new Error("noUiSlider: '"+d+"' is required.");return!0}e.t(c,a[d])}),c.pips=a.pips,c.style=c.ort?"top":"left",c}function K(a,b,c){var d=a+b[0],e=a+b[1];return c?(0>d&&(e+=Math.abs(d)),e>100&&(d-=e-100),[g(d),g(e)]):[d,e]}function L(a){a.preventDefault();var b,c,d=0===a.type.indexOf("touch"),e=0===a.type.indexOf("mouse"),f=0===a.type.indexOf("pointer"),g=a;return 0===a.type.indexOf("MSPointer")&&(f=!0),d&&(b=a.changedTouches[0].pageX,c=a.changedTouches[0].pageY),(e||f)&&(b=a.clientX+window.pageXOffset,c=a.clientY+window.pageYOffset),g.points=[b,c],g.cursor=e||f,g}function M(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=["-lower","-upper"];return a&&e.reverse(),j(d,T[3]),j(d,T[3]+e[b]),j(c,T[2]),c.appendChild(d),c}function N(a,b,c){switch(a){case 1:j(b,T[7]),j(c[0],T[6]);break;case 3:j(c[1],T[6]);case 2:j(c[0],T[7]);case 0:j(b,T[6])}}function O(a,b,c){var d,e=[];for(d=0;a>d;d+=1)e.push(c.appendChild(M(b,d)));return e}function P(a,b,c){j(c,T[0]),j(c,T[8+a]),j(c,T[4+b]);var d=document.createElement("div");return j(d,T[1]),c.appendChild(d),d}function Q(b,d){function e(a,b,c){if("range"===a||"steps"===a)return M.xVal;if("count"===a){var d,e=100/(b-1),f=0;for(b=[];(d=f++*e)<=100;)b.push(d);a="positions"}return"positions"===a?b.map(function(a){return M.fromStepping(c?M.getStep(a):a)}):"values"===a?c?b.map(function(a){return M.fromStepping(M.getStep(M.toStepping(a)))}):b:void 0}function m(b,c,d){var e=M.direction,f={},g=M.xVal[0],h=M.xVal[M.xVal.length-1],i=!1,j=!1,k=0;return M.direction=0,d=a(d.slice().sort(function(a,b){return a-b})),d[0]!==g&&(d.unshift(g),i=!0),d[d.length-1]!==h&&(d.push(h),j=!0),d.forEach(function(a,e){var g,h,l,m,n,o,p,q,r,s,t=a,u=d[e+1];if("steps"===c&&(g=M.xNumSteps[e]),g||(g=u-t),t!==!1&&void 0!==u)for(h=t;u>=h;h+=g){for(m=M.toStepping(h),n=m-k,q=n/b,r=Math.round(q),s=n/r,l=1;r>=l;l+=1)o=k+l*s,f[o.toFixed(5)]=["x",0];p=d.indexOf(h)>-1?1:"steps"===c?2:0,!e&&i&&(p=0),h===u&&j||(f[m.toFixed(5)]=[h,p]),k=m}}),M.direction=e,f}function n(a,b,c){function e(a){return["-normal","-large","-sub"][a]}function f(a,b,c){return'class="'+b+" "+b+"-"+h+" "+b+e(c[1])+'" style="'+d.style+": "+a+'%"'}function g(a,d){M.direction&&(a=100-a),d[1]=d[1]&&b?b(d[0],d[1]):d[1],i.innerHTML+="<div "+f(a,"noUi-marker",d)+"></div>",d[1]&&(i.innerHTML+="<div "+f(a,"noUi-value",d)+">"+c.to(d[0])+"</div>")}var h=["horizontal","vertical"][d.ort],i=document.createElement("div");return j(i,"noUi-pips"),j(i,"noUi-pips-"+h),Object.keys(a).forEach(function(b){g(b,a[b])}),i}function o(a){var b=a.mode,c=a.density||1,d=a.filter||!1,f=a.values||!1,g=a.stepped||!1,h=e(b,f,g),i=m(c,b,h),j=a.format||{to:Math.round};return I.appendChild(n(i,d,j))}function p(){return G["offset"+["Width","Height"][d.ort]]}function q(a,b){void 0!==b&&(b=Math.abs(b-d.dir)),Object.keys(R).forEac
3214h(function(c){var d=c.split(".")[0];a===d&&R[c].forEach(function(a){a(h(B()),b,r(Array.prototype.slice.call(Q)))})})}function r(a){return 1===a.length?a[0]:d.dir?a.reverse():a}function s(a,b,c,e){var f=function(b){return I.hasAttribute("disabled")?!1:l(I,T[14])?!1:(b=L(b),a===S.start&&void 0!==b.buttons&&b.buttons>1?!1:(b.calcPoint=b.points[d.ort],void c(b,e)))},g=[];return a.split(" ").forEach(function(a){b.addEventListener(a,f,!1),g.push([a,f])}),g}function t(a,b){var c,d,e=b.handles||H,f=!1,g=100*(a.calcPoint-b.start)/p(),h=e[0]===H[0]?0:1;if(c=K(g,b.positions,e.length>1),f=y(e[0],c[h],1===e.length),e.length>1){if(f=y(e[1],c[h?0:1],!1)||f)for(d=0;d<b.handles.length;d++)q("slide",d)}else f&&q("slide",h)}function u(a,b){var c=G.getElementsByClassName(T[15]),d=b.handles[0]===H[0]?0:1;c.length&&k(c[0],T[15]),a.cursor&&(document.body.style.cursor="",document.body.removeEventListener("selectstart",document.body.noUiListener));var e=document.documentElement;e.noUiListeners.forEach(function(a){e.removeEventListener(a[0],a[1])}),k(I,T[12]),q("set",d),q("change",d)}function v(a,b){var c=document.documentElement;if(1===b.handles.length&&(j(b.handles[0].children[0],T[15]),b.handles[0].hasAttribute("disabled")))return!1;a.stopPropagation();var d=s(S.move,c,t,{start:a.calcPoint,handles:b.handles,positions:[J[0],J[H.length-1]]}),e=s(S.end,c,u,{handles:b.handles});if(c.noUiListeners=d.concat(e),a.cursor){document.body.style.cursor=getComputedStyle(a.target).cursor,H.length>1&&j(I,T[12]);var f=function(){return!1};document.body.noUiListener=f,document.body.addEventListener("selectstart",f,!1)}}function w(a){var b,e,g=a.calcPoint,h=0;return a.stopPropagation(),H.forEach(function(a){h+=c(a)[d.style]}),b=h/2>g||1===H.length?0:1,g-=c(G)[d.style],e=100*g/p(),d.events.snap||f(I,T[14],300),H[b].hasAttribute("disabled")?!1:(y(H[b],e),q("slide",b),q("set",b),q("change",b),void(d.events.snap&&v(a,{handles:[H[h]]})))}function x(a){var b,c;if(!a.fixed)for(b=0;b<H.length;b+=1)s(S.start,H[b].children[0],v,{handles:[H[b]]});a.tap&&s(S.start,G,w,{handles:H}),a.drag&&(c=[G.getElementsByClassName(T[7])[0]],j(c[0],T[10]),a.fixed&&c.push(H[c[0]===H[
32140]?1:0].children[0]),c.forEach(function(a){s(S.start,a,v,{handles:H})}))}function y(a,b,c){var e=a!==H[0]?1:0,f=J[0]+d.margin,h=J[1]-d.margin,i=J[0]+d.limit,l=J[1]-d.limit;return H.length>1&&(b=e?Math.max(b,f):Math.min(b,h)),c!==!1&&d.limit&&H.length>1&&(b=e?Math.min(b,i):Math.max(b,l)),b=M.getStep(b),b=g(parseFloat(b.toFixed(7))),b===J[e]?!1:(a.style[d.style]=b+"%",a.previousSibling||(k(a,T[17]),b>50&&j(a,T[17])),J[e]=b,Q[e]=M.fromStepping(b),q("update",e),!0)}function z(a,b){var c,e,f;for(d.limit&&(a+=1),c=0;a>c;c+=1)e=c%2,f=b[e],null!==f&&f!==!1&&("number"==typeof f&&(f=String(f)),f=d.format.from(f),(f===!1||isNaN(f)||y(H[e],M.toStepping(f),c===3-d.dir)===!1)&&q("update",e))}function A(a){var b,c,e=h(a);for(d.dir&&d.handles>1&&e.reverse(),d.animate&&-1!==J[0]&&f(I,T[14],300),b=H.length>1?3:1,1===e.length&&(b=1),z(b,e),c=0;c<H.length;c++)q("set",c)}function B(){var a,b=[];for(a=0;a<d.handles;a+=1)b[a]=d.format.to(Q[a]);return r(b)}function C(){T.forEach(function(a){a&&k(I,a)}),I.innerHTML="",delete I.noUiSlider}function D(){var a=J.map(function(a,b){var c=M.getApplicableStep(a),d=i(String(c[2])),e=Q[b],f=100===a?null:c[2],g=Number((e-c[2]).toFixed(d)),h=0===a?null:g>=c[1]?c[2]:c[0]||!1;return[h,f]});return r(a)}function E(a,b){R[a]=R[a]||[],R[a].push(b),"update"===a.split(".")[0]&&H.forEach(function(a,b){q("update",b)})}function F(a){var b=a.split(".")[0],c=a.substring(b.length);Object.keys(R).forEach(function(a){var d=a.split(".")[0],e=a.substring(d.length);b&&b!==d||c&&c!==e||delete R[a]})}var G,H,I=b,J=[-1,-1],M=d.spectrum,Q=[],R={};if(I.noUiSlider)throw new Error("Slider was already initialized.");return G=P(d.dir,d.ort,I),H=O(d.handles,d.dir,G),N(d.connect,I,H),x(d.events),d.pips&&o(d.pips),{destroy:C,steps:D,on:E,off:F,get:B,set:A}}function R(a,b){if(!a.nodeName)throw new Error("noUiSlider.create requires a single element.");var c=J(b,a),d=Q(a,c);d.set(c.start),a.noUiSlider=d}var S=window.navigator.pointerEnabled?{start:"pointerdown",move:"pointermove",end:"pointerup"}:window.navigator.msPointerEnabled?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:{start:"mousedown touchstart",move:"mousemove touchmove",end:"mouseup touchend"},T=["noUi-target","noUi-base","noUi-origin","noUi-handle","noUi-horizontal","noUi-vertical","noUi-background","noUi-connect","noUi-ltr","noUi-rtl","noUi-dragable","","noUi-state-drag","","noUi-state-tap","noUi-active","","noUi-stacking"];w.prototype.getMargin=function(a){return 2===this.xPct.length?n(this.xVal,a):!1},w.prototype.toStepping=function(a){return a=r(this.xVal,this.xPct,a),this.direction&&(a=100-a),a},w.prototype.fromStepping=function(a){return this.direction&&(a=100-a),e(s(this.xVal,this.xPct,a))},w.prototype.getStep=function(a){return this.direction&&(a=100-a),a=t(this.xPct,this.xSteps,this.snap,a),this.direction&&(a=100-a),a},w.prototype.getApplicableStep=function(a){var b=q(a,this.xPct),c=100===a?2:1;return[this.xNumSteps[b-2],this.xVal[b-c],this.xNumSteps[b-c]]},w.prototype.convert=function(a){return this.getStep(this.toStepping(a))};var U={to:function(a){return a.toFixed(2)},from:Number};return{create:R}});
3215
3216
3217// ┌────────────────────────────────────────────────────────────────────┐ \\
3218// │ Raphaël 2.1.4 - JavaScript Vector Library                          │ \\
3219// ├────────────────────────────────────────────────────────────────────┤ \\
3220// │ Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com)    │ \\
3221// │ Copyright © 2008-2012 Sencha Labs (http://sencha.com)              │ \\
3222// ├────────────────────────────────────────────────────────────────────┤ \\
3223// │ Licensed under the MIT (http://raphaeljs.com/license.html) license.│ \\
3224// └────────────────────────────────────────────────────────────────────┘ \\
vendor: 58,936 bytes, line 3225
3225!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Raphael=e():t.Raphael=e()}(window,function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){var i,n;i=[r(2)],void 0===(n=function(t){function e(i){if(e.is(i,"function"))return r?i():t.on("raphael.DOMload",i);if(e.is(i,A))return e._engine.create[c](e,i.splice(0,3+e.is(i[0],T))).add(i);var n=Array.prototype.slice.call(arguments,0);if(e.is(n[n.length-1],"function")){var a=n.pop();return r?a.call(e._engine.create[c](e,n)):t.on("raphael.DOMload",function(){a.call(e._engine.create[c](e,n))})}return e._engine.create[c](e,arguments)}e.version="2.3.0",e.eve=t;var r,i,n=/[, ]+/,a={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},s=/\{(\d+)\}/g,o="hasOwnProperty",l={doc:document,win:window},h={was:Object.prototype[o].call(l.win,"Raphael"),is:l.win.Raphael},u=function(){this.ca=this.customAttributes={}},c="apply",f="concat",p="ontouchstart"in window||window.TouchEvent||window.DocumentTouch&&document instanceof DocumentTouch,d="",g=" ",x=String,v="split",y="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel"[v](g),m={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},b=x.prototype.toLowerCase,_=Math,w=_.max,k=_.min,B=_.abs,C=_.pow,S=_.PI,T="number",A="array",M=Object.prototype.toString,E=(e._ISURL=/^url\(['"]?(.+?)['"]?\)$/i,/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i),N={NaN:1,Infinity:1,"-Infinity":1},L=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,P=_.round,z=parseFloat,F=parseInt,R=x.prototype.toUpperCase,j=e._availableAttrs={"arrow-end":"none","arrow-start":"none",blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/","letter-spacing":0,opacity:1,path:"M0,0",r:0,rx:0,ry:0,src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",transform:"",width:0,x:0,y:0,class:""},I=e._availableAnimAttrs={blur:T,"clip-rect":"csv",cx:T,cy:T,fill:"colour","fill-opacity":T,"font-size":T,height:T,opacity:T,path:"path",r:T,rx:T,ry:T,stroke:"colour","stroke-opacity":T,"stroke-width":T,transform:"transform",width:T,x:T,y:T},D=/[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/,q={hs:1,rg:1},O=/,?([achlmqrstvxz]),?/gi,V=/([achlmrqstvz])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/gi,W=/([rstm])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/gi,Y=/(-?\d*\.?\d*(?:e[\-+]?\d+)?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/gi,G=(e._radial_gradient=/^r(?:\(([^,]+?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*([^\)]+?)\))?/,{}),H=function(t,e){return z(t)-z(e)},X=function(t){return t},U=e._rectPath=function(t,e,r,i,n){return n?[["M",t+n,e],["l",r-2*n,0],["a",n,n,0,0,1,n,n],["l",0,i-2*n],["a",n,n,0,0,1,-n,n],["l",2*n-r,0],["a",n,n,0,0,1,-n,-n],["l",0,2*n-i],["a",n,n,0,0,1,n,-n],["z"]]:[["M",t,e],["l",r,0],["l",0,i],["l",-r,0],["z"]]},$=function(t,e,r,i){return null==i&&(i=r),[["M",t,e],["m",0,-i],["a",r,i,0,1,1,0,2*i],["a",r,i,0,1,1,0,-2*i],["z"]]},Z=e._getPath={path:function(t){return t.attr("path")},circle:function(t){var e=t.attrs;return $(e.cx,e.cy,e.r)},ellipse:function(t){var e=t.attrs;return $(e.cx,e.cy,e.rx,e.ry)},rect:function(t){var e=t.attrs;return U(e.x,e.y,e.width,e.height,e.r)},image:function(t){var e=t.attrs;return U(e.x,e.y,e.width,e.height)},text:function(t){var e=t._getBBox();return U(e.x,e.y,e.width,e.height)},set:function(t){var e=t._getBBox();return U(e.x,e.y,e.width,e.height)}},Q=e.mapPath=function(t,e){if(!e)return t;var r,i,n,a,s,o,l;for(n=0,s=(t=Tt(t)).length;n<s;n++)for(a=1,o=(l=t[n]).length;a<o;a+=2)r=e.x(l[a],l[a+1]),i=e.y(l[a],l[a+1]),l[a]=r,l[a+1]=i;return t};if(e._g=l,e.type=l.win.SVGAngle||l.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML","VML"==e.type){var J,K=l.doc.createElement("div");if(K.innerHTML='<v:shape adj="1"/>',(J=K.firstChild).style.behavior="url(#default#VML)",!J||"object"!=typeof J.adj)return e.type=d;K=null}function tt(t){if("function"==typeof t||Object(t)!==t)return t;var e=new t.constructor;for(var r in t)t[o](r)&&(e[r]=tt(t[r]));return e}e.svg=!(e.vml="VML"==e.type),e._Paper=u,e.fn=i=u.prototype=e.prototype,e._id=0,e.is=function(t,e){return"finite"==(e=b.call(e))?!N[o](+t):"array"==e?t instanceof Array:"null"==e&&null===t||e==typeof t&&null!==t||"object"==e&&t===Object(t)||"array"==e&&Array.isArray&&Array.isArray(t)||M.call(t).slice(8,-1).toLowerCase()==e},e.angle=function(t,r,i,n,a,s){if(null==a){var o=t-i,l=r-n;return o||l?(180+180*_.atan2(-l,-o)/S+360)%360:0}return e.angle(t,r,a,s)-e.angle(i,n,a,s)},e.rad=function(t){return t%360*S/180},e.deg=function(t){return Math.round(180*t/S%360*1e3)/1e3},e.snapTo=function(t,r,i){if(i=e.is(i,"finite")?i:10,e.is(t,A)){for(var n=t.length;n--;)if(B(t[n]-r)<=i)return t[n]}else{var a=r%(t=+t);if(a<i)return r-a;if(a>t-i)return r-a+t}return r};var et,rt;e.createUUID=(et=/[xy]/g,rt=function(t){var e=16*_.random()|0;return("x"==t?e:3&e|8).toString(16)},function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(et,rt).toUpperCase()});e.setWindow=function(r){t("raphael.setWindow",e,l.win,r),l.win=r,l.doc=l.win.document,e._engine.initWin&&e._engine.initWin(l.win)};var it=function(t){if(e.vml){var r,i=/^\s+|\s+$/g;try{var n=new ActiveXObject("htmlfile");n.write("<body>"),n.close(),r=n.body}catch(t){r=createPopup().document.body}var a=r.createTextRange();it=ht(function(t){try{r.style.color=x(t).replace(i,d);var e=a.queryCommandValue("ForeColor");return"#"+("000000"+(e=(255&e)<<16|65280&e|(16711680&e)>>>16).toString(16)).slice(-6)}catch(t){return"none"}})}else{var s=l.doc.createElement("i");s.title="Raphaël Colour Picker",s.style.display="none",l.doc.body.appendChild(s),it=ht(function(t){return s.style.color=t,l.doc.defaultView.getComputedStyle(s,d).getPropertyValue("color")})}return it(t)},nt=function(){return"hsb("+[this.h,this.s,this.b]+")"},at=function(){return"hsl("+[this.h,this.s,this.l]+")"},st=function(){return this.hex},ot=function(t,r,i){if(null==r&&e.is(t,"object")&&"r"in t&&"g"in t&&"b"in t&&(i=t.b,r=t.g,t=t.r),null==r&&e.is(t,"string")){var n=e.getRGB(t);t=n.r,r=n.g,i=n.b}return(t>1||r>1||i>1)&&(t/=255,r/=255,i/=255),[t,r,i]},lt=function(t,r,i,n){var a={r:t*=255,g:r*=255,b:i*=255,hex:e.rgb(t,r,i),toString:st};return e.is(n,"finite")&&(a.opacity=n),a};function ht(t,e,r){return function i(){var n=Array.prototype.slice.call(arguments,0),a=n.join("␀"),s=i.cache=i.cache||{},l=i.count=i.count||[];return s[o](a)?(function(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return t.push(t.splice(r,1)[0])}(l,a),r?r(s[a]):s[a]):(l.length>=1e3&&delete s[l.shift()],l.push(a),s[a]=t[c](e,n),r?r(s[a]):s[a])}}e.color=function(t){var r;return e.is(t,"object")&&"h"in t&&"s"in t&&"b"in t?(r=e.hsb2rgb(t),t.r=r.r,t.g=r.g,t.b=r.b,t.hex=r.hex):e.is(t,"object")&&"h"in t&&"s"in t&&"l"in t?(r=e.hsl2rgb(t),t.r=r.r,t.g=r.g,t.b=r.b,t.hex=r.hex):(e.is(t,"string")&&(t=e.getRGB(t)),e.is(t,"object")&&"r"in t&&"g"in t&&"b"in t?(r=e.rgb2hsl(t),t.h=r.h,t.s=r.s,t.l=r.l,r=e.rgb2hsb(t),t.v=r.b):(t={hex:"none"}).r=t.g=t.b=t.h=t.s=t.v=t.l=-1),t.toString=st,t},e.hsb2rgb=function(t,e,r,i){var n,a,s,o,l;return this.is(t,"object")&&"h"in t&&"s"in t&&"b"in t&&(r=t.b,e=t.s,i=t.o,t=t.h),o=(l=r*e)*(1-B((t=(t*=360)%360/60)%2-1)),n=a=s=r-l,lt(n+=[l,o,0,0,o,l][t=~~t],a+=[o,l,l,o,0,0][t],s+=[0,0,o,l,l,o][t],i)},e.hsl2rgb=function(t,e,r,i){var n,a,s,o,l;return this.is(t,"object")&&"h"in t&&"s"in t&&"l"in t&&(r=t.l,e=t.s,t=t.h),(t>1||e>1||r>1)&&(t/=360,e/=100,r/=100),o=(l=2*e*(r<.5?r:1-r))*(1-B((t=(t*=360)%360/60)%2-1)),n=a=s=r-l/2,lt(n+=[l,o,0,0,o,l][t=~~t],a+=[o,l,l,o,0,0][t],s+=[0,0,o,l,l,o][t],i)},e.rgb2hsb=function(t,e,r){var i,n;return t=(r=ot(t,e,r))[0],e=r[1],r=r[2],{h:((0==(n=(i=w(t,e,r))-k(t,e,r))?null:i==t?(e-r)/n:i==e?(r-t)/n+2:(t-e)/n+4)+360)%6*60/360,s:0==n?0:n/i,b:i,toString:nt}},e.rgb2hsl=function(t,e,r){var i,n,a,s;return t=(r=ot(t,e,r))[0],e=r[1],r=r[2],i=((n=w(t,e,r))+(a=k(t,e,r)))/2,{h:((0==(s=n-a)?null:n==t?(e-r)/s:n==e?(r-t)/s+2:(t-e)/s+4)+360)%6*60/360,s:0==s?0:i<.5?s/(2*i):s/(2-2*i),l:i,toString:at}},e._path2string=function(){return this.join(",").replace(O,"$1")};e._preload=function(t,e){var r=l.doc.createElement("img");r.style.cssText="position:absolute;left:-9999em;top:-9999em",r.onload=function(){e.call(this),this.onload=null,l.doc.body.removeChild(this)},r.onerror=function(){l.doc.body.removeChild(this)},l.doc.body.appendChild(r),r.src=t};function ut(){return this.hex}function ct(t,e){for(var r=[],i=0,n=t.length;n-2*!e>i;i+=2){var a=[{x:+t[i-2],y:+t[i-1]},{x:+t[i],y:+t[i+1]},{x:+t[i+2],y:+t[i+3]},{x:+t[i+4],y:+t[i+5]}];e?i?n-4==i?a[3]={x:+t[0],y:+t[1]}:n-2==i&&(a[2]={x:+t[0],y:+t[1]},a[3]={x:+t[2],y:+t[3]}):a[0]={x:+t[n-2],y:+t[n-1]}:n-4==i?a[3]=a[2]:i||(a[0]={x:+t[i],y:+t[i+1]}),r.push(["C",(-a[0].x+6*a[1].x+a[2].x)/6,(-a[0].y+6*a[1].y+a[2].y)/6,(a[1].x+6*a[2].x-a[3].x)/6,(a[1].y+6*a[2].y-a[3].y)/6,a[2].x,a[2].y])}return r}e.getRGB=ht(function(t){if(!t||(t=x(t)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ut};if("none"==t)return{r:-1,g:-1,b:-1,hex:"none",toString:ut};!q[o](t.toLowerCase().substring(0,2))&&"#"!=t.charAt()&&(t=it(t));var r,i,n,a,s,l,h=t.match(E);return h?(h[2]&&(n=F(h[2].substring(5),16),i=F(h[2].substring(3,5),16),r=F(h[2].substring(1,3),16)),h[3]&&(n=F((s=h[3].charAt(3))+s,16),i=F((s=h[3].charAt(2))+s,16),r=F((s=h[3].charAt(1))+s,16)),h[4]&&(l=h[4][v](D),r=z(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=z(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=z(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),"rgba"==h[1].toLowerCase().slice(0,4)&&(a=z(l[3])),l[3]&&"%"==l[3].slice(-1)&&(a/=100)),h[5]?(l=h[5][v](D),r=z(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=z(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=z(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(r/=360),"hsba"==h[1].toLowerCase().slice(0,4)&&(a=z(l[3])),l[3]&&"%"==l[3].slice(-1)&&(a/=100),e.hsb2rgb(r,i,n,a)):h[6]?(l=h[6][v](D),r=z(l[0]),"%"==l[0].slice(-1)&&(r*=2.55),i=z(l[1]),"%"==l[1].slice(-1)&&(i*=2.55),n=z(l[2]),"%"==l[2].slice(-1)&&(n*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(r/=360),"hsla"==h[1].toLowerCase().slice(0,4)&&(a=z(l[3])),l[3]&&"%"==l[3].slice(-1)&&(a/=100),e.hsl2rgb(r,i,n,a)):((h={r:r,g:i,b:n,toString:ut}).hex="#"+(16777216|n|i<<8|r<<16).toString(16).slice(1),e.is(a,"finite")&&(h.opacity=a),h)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ut}},e),e.hsb=ht(function(t,r,i){return e.hsb2rgb(t,r,i).hex}),e.hsl=ht(function(t,r,i){return e.hsl2rgb(t,r,i).hex}),e.rgb=ht(function(t,e,r){function i(t){return t+.5|0}return"#"+(16777216|i(r)|i(e)<<8|i(t)<<16).toString(16).slice(1)}),e.getColor=function(t){var e=this.getColor.start=this.getColor.start||{h:0,s:1,b:t||.75},r=this.hsb2rgb(e.h,e.s,e.b);return e.h+=.075,e.h>1&&(e.h=0,e.s-=.2,e.s<=0&&(this.getColor.start={h:0,s:1,b:e.b})),r.hex},e.getColor.reset=function(){delete this.start},e.parsePathString=function(t){if(!t)return null;var r=ft(t);if(r.arr)return mt(r.arr);var i={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},n=[];return e.is(t,A)&&e.is(t[0],A)&&(n=mt(t)),n.length||x(t).replace(V,function(t,e,r){var a=[],s=e.toLowerCase();if(r.replace(Y,function(t,e){e&&a.push(+e)}),"m"==s&&a.length>2&&(n.push([e][f](a.splice(0,2))),s="l",e="m"==e?"l":"L"),"r"==s)n.push([e][f](a));else for(;a.length>=i[s]&&(n.push([e][f](a.splice(0,i[s]))),i[s]););}),n.toString=e._path2string,r.arr=mt(n),n},e.parseTransformString=ht(function(t){if(!t)return null;var r=[];return e.is(t,A)&&e.is(t[0],A)&&(r=mt(t)),r.length||x(t).replace(W,function(t,e,i){var n=[];b.call(e);i.replace(Y,function(t,e){e&&n.push(+e)}),r.push([e][f](n))}),r.toString=e._path2string,r},this,function(t){if(!t)return t;for(var e=[],r=0;r<t.length;r++){for(var i=[],n=0;n<t[r].length;n++)i.push(t[r][n]);e.push(i)}return e});var ft=function(t){var e=ft.ps=ft.ps||{};return e[t]?e[t].sleep=100:e[t]={sleep:100},setTimeout(function(){for(var r in e)e[o](r)&&r!=t&&(e[r].sleep--,!e[r].sleep&&delete e[r])}),e[t]};function pt(t,e,r,i,n){return t*(t*(-3*e+9*r-9*i+3*n)+6*e-12*r+6*i)-3*e+3*r}function dt(t,e,r,i,n,a,s,o,l){null==l&&(l=1);for(var h=(l=l>1?1:l<0?0:l)/2,u=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],c=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],f=0,p=0;p<12;p++){var d=h*u[p]+h,g=pt(d,t,r,n,s),x=pt(d,e,i,a,o),v=g*g+x*x;f+=c[p]*_.sqrt(v)}return h*f}function gt(t,e,r,i,n,a,s,o){if(!(w(t,r)<k(n,s)||k(t,r)>w(n,s)||w(e,i)<k(a,o)||k(e,i)>w(a,o))){var l=(t-r)*(a-o)-(e-i)*(n-s);if(l){var h=((t*i-e*r)*(n-s)-(t-r)*(n*o-a*s))/l,u=((t*i-e*r)*(a-o)-(e-i)*(n*o-a*s))/l,c=+h.toFixed(2),f=+u.toFixed(2);if(!(c<+k(t,r).toFixed(2)||c>+w(t,r).toFixed(2)||c<+k(n,s).toFixed(2)||c>+w(n,s).toFixed(2)||f<+k(e,i).toFixed(2)||f>+w(e,i).toFixed(2)||f<+k(a,o).toFixed(2)||f>+w(a,o).toFixed(2)))return{x:h,y:u}}}}function xt(t,r,i){var n=e.bezierBBox(t),a=e.bezierBBox(r);if(!e.isBBoxIntersect(n,a))return i?0:[];for(var s=dt.apply(0,t),o=dt.apply(0,r),l=w(~~(s/5),1),h=w(~~(o/5),1),u=[],c=[],f={},p=i?0:[],d=0;d<l+1;d++){var g=e.findDotsAtSegment.apply(e,t.concat(d/l));u.push({x:g.x,y:g.y,t:d/l})}for(d=0;d<h+1;d++)g=e.findDotsAtSegment.apply(e,r.concat(d/h)),c.push({x:g.x,y:g.y,t:d/h});for(d=0;d<l;d++)for(var x=0;x<h;x++){var v=u[d],y=u[d+1],m=c[x],b=c[x+1],_=B(y.x-v.x)<.001?"y":"x",C=B(b.x-m.x)<.001?"y":"x",S=gt(v.x,v.y,y.x,y.y,m.x,m.y,b.x,b.y);if(S){if(f[S.x.toFixed(4)]==S.y.toFixed(4))continue;f[S.x.toFixed(4)]=S.y.toFixed(4);var T=v.t+B((S[_]-v[_])/(y[_]-v[_]))*(y.t-v.t),A=m.t+B((S[C]-m[C])/(b[C]-m[C]))*(b.t-m.t);T>=0&&T<=1.001&&A>=0&&A<=1.001&&(i?p++:p.push({x:S.x,y:S.y,t1:k(T,1),t2:k(A,1)}))}}return p}function vt(t,r,i){t=e._path2curve(t),r=e._path2curve(r);for(var n,a,s,o,l,h,u,c,f,p,d=i?0:[],g=0,x=t.length;g<x;g++){var v=t[g];if("M"==v[0])n=l=v[1],a=h=v[2];else{"C"==v[0]?(f=[n,a].concat(v.slice(1)),n=f[6],a=f[7]):(f=[n,a,n,a,l,h,l,h],n=l,a=h);for(var y=0,m=r.length;y<m;y++){var b=r[y];if("M"==b[0])s=u=b[1],o=c=b[2];else{"C"==b[0]?(p=[s,o].concat(b.slice(1)),s=p[6],o=p[7]):(p=[s,o,s,o,u,c,u,c],s=u,o=c);var _=xt(f,p,i);if(i)d+=_;else{for(var w=0,k=_.length;w<k;w++)_[w].segment1=g,_[w].segment2=y,_[w].bez1=f,_[w].bez2=p;d=d.concat(_)}}}}}return d}e.findDotsAtSegment=function(t,e,r,i,n,a,s,o,l){var h=1-l,u=C(h,3),c=C(h,2),f=l*l,p=f*l,d=u*t+3*c*l*r+3*h*l*l*n+p*s,g=u*e+3*c*l*i+3*h*l*l*a+p*o,x=t+2*l*(r-t)+f*(n-2*r+t),v=e+2*l*(i-e)+f*(a-2*i+e),y=r+2*l*(n-r)+f*(s-2*n+r),m=i+2*l*(a-i)+f*(o-2*a+i),b=h*t+l*r,w=h*e+l*i,k=h*n+l*s,B=h*a+l*o,T=90-180*_.atan2(x-y,v-m)/S;return(x>y||v<m)&&(T+=180),{x:d,y:g,m:{x:x,y:v},n:{x:y,y:m},start:{x:b,y:w},end:{x:k,y:B},alpha:T}},e.bezierBBox=function(t,r,i,n,a,s,o,l){e.is(t,"array")||(t=[t,r,i,n,a,s,o,l]);var h=St.apply(null,t);return{x:h.min.x,y:h.min.y,x2:h.max.x,y2:h.max.y,width:h.max.x-h.min.x,height:h.max.y-h.min.y}},e.isPointInsideBBox=function(t,e,r){return e>=t.x&&e<=t.x2&&r>=t.y&&r<=t.y2},e.isBBoxIntersect=function(t,r){var i=e.isPointInsideBBox;return i(r,t.x,t.y)||i(r,t.x2,t.y)||i(r,t.x,t.y2)||i(r,t.x2,t.y2)||i(t,r.x,r.y)||i(t,r.x2,r.y)||i(t,r.x,r.y2)||i(t,r.x2,r.y2)||(t.x<r.x2&&t.x>r.x||r.x<t.x2&&r.x>t.x)&&(t.y<r.y2&&t.y>r.y||r.y<t.y2&&r.y>t.y)},e.pathIntersection=function(t,e){return vt(t,e)},e.pathIntersectionNumber=function(t,e){return vt(t,e,1)},e.isPointInsidePath=function(t,r,i){var n=e.pathBBox(t);return e.isPointInsideBBox(n,r,i)&&vt(t,[["M",r,i],["H",n.x2+10]],1)%2==1},e._removedFactory=function(e){return function(){t("raphael.log",null,"Raphaël: you are calling to method “"+e+"” of removed object",e)}};var yt=e.pathBBox=function(t){var e=ft(t);if(e.bbox)return tt(e.bbox);if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0};for(var r,i=0,n=0,a=[],s=[],o=0,l=(t=Tt(t)).length;o<l;o++)if("M"==(r=t[o])[0])i=r[1],n=r[2],a.push(i),s.push(n);else{var h=St(i,n,r[1],r[2],r[3],r[4],r[5],r[6]);a=a[f](h.min.x,h.max.x),s=s[f](h.min.y,h.max.y),i=r[5],n=r[6]}var u=k[c](0,a),p=k[c](0,s),d=w[c](0,a),g=w[c](0,s),x=d-u,v=g-p,y={x:u,y:p,x2:d,y2:g,width:x,height:v,cx:u+x/2,cy:p+v/2};return e.bbox=tt(y),y},mt=function(t){var r=tt(t);return r.toString=e._path2string,r},bt=e._pathToRelative=function(t){var r=ft(t);if(r.rel)return mt(r.rel);e.is(t,A)&&e.is(t&&t[0],A)||(t=e.parsePathString(t));var i=[],n=0,a=0,s=0,o=0,l=0;"M"==t[0][0]&&(s=n=t[0][1],o=a=t[0][2],l++,i.push(["M",n,a]));for(var h=l,u=t.length;h<u;h++){var c=i[h]=[],f=t[h];if(f[0]!=b.call(f[0]))switch(c[0]=b.call(f[0]),c[0]){case"a":c[1]=f[1],c[2]=f[2],c[3]=f[3],c[4]=f[4],c[5]=f[5],c[6]=+(f[6]-n).toFixed(3),c[7]=+(f[7]-a).toFixed(3);break;case"v":c[1]=+(f[1]-a).toFixed(3);break;case"m":s=f[1],o=f[2];default:for(var p=1,d=f.length;p<d;p++)c[p]=+(f[p]-(p%2?n:a)).toFixed(3)}else{c=i[h]=[],"m"==f[0]&&(s=f[1]+n,o=f[2]+a);for(var g=0,x=f.length;g<x;g++)i[h][g]=f[g]}var v=i[h].length;switch(i[h][0]){case"z":n=s,a=o;break;case"h":n+=+i[h][v-1];break;case"v":a+=+i[h][v-1];break;default:n+=+i[h][v-2],a+=+i[h][v-1]}}return i.toString=e._path2string,r.rel=mt(i),i},_t=e._pathToAbsolute=function(t){var r=ft(t);if(r.abs)return mt(r.abs);if(e.is(t,A)&&e.is(t&&t[0],A)||(t=e.parsePathString(t)),!t||!t.length)return[["M",0,0]];var i=[],n=0,a=0,s=0,o=0,l=0;"M"==t[0][0]&&(s=n=+t[0][1],o=a=+t[0][2],l++,i[0]=["M",n,a]);for(var h,u,c=3==t.length&&"M"==t[0][0]&&"R"==t[1][0].toUpperCase()&&"Z"==t[2][0].toUpperCase(),p=l,d=t.length;p<d;p++){if(i.push(h=[]),(u=t[p])[0]!=R.call(u[0]))switch(h[0]=R.call(u[0]),h[0]){case"A":h[1]=u[1],h[2]=u[2],h[3]=u[3],h[4]=u[4],h[5]=u[5],h[6]=+(u[6]+n),h[7]=+(u[7]+a);break;case"V":h[1]=+u[1]+a;break;case"H":h[1]=+u[1]+n;break;case"R":for(var g=[n,a][f](u.slice(1)),x=2,v=g.length;x<v;x++)g[x]=+g[x]+n,g[++x]=+g[x]+a;i.pop(),i=i[f](ct(g,c));break;case"M":s=+u[1]+n,o=+u[2]+a;default:for(x=1,v=u.length;x<v;x++)h[x]=+u[x]+(x%2?n:a)}else if("R"==u[0])g=[n,a][f](u.slice(1)),i.pop(),i=i[f](ct(g,c)),h=["R"][f](u.slice(-2));else for(var y=0,m=u.length;y<m;y++)h[y]=u[y];switch(h[0]){case"Z":n=s,a=o;break;case"H":n=h[1];break;case"V":a=h[1];break;case"M":s=h[h.length-2],o=h[h.length-1];default:n=h[h.length-2],a=h[h.length-1]}}return i.toString=e._path2string,r.abs=mt(i),i},wt=function(t,e,r,i){return[t,e,r,i,r,i]},kt=function(t,e,r,i,n,a){return[1/3*t+2/3*r,1/3*e+2/3*i,1/3*n+2/3*r,1/3*a+2/3*i,n,a]},Bt=function(t,e,r,i,n,a,s,o,l,h){var u,c=120*S/180,p=S/180*(+n||0),d=[],g=ht(function(t,e,r){return{x:t*_.cos(r)-e*_.sin(r),y:t*_.sin(r)+e*_.cos(r)}});if(h)A=h[0],M=h[1],C=h[2],T=h[3];else{t=(u=g(t,e,-p)).x,e=u.y,o=(u=g(o,l,-p)).x,l=u.y;_.cos(S/180*n),_.sin(S/180*n);var x=(t-o)/2,y=(e-l)/2,m=x*x/(r*r)+y*y/(i*i);m>1&&(r*=m=_.sqrt(m),i*=m);var b=r*r,w=i*i,k=(a==s?-1:1)*_.sqrt(B((b*w-b*y*y-w*x*x)/(b*y*y+w*x*x))),C=k*r*y/i+(t+o)/2,T=k*-i*x/r+(e+l)/2,A=_.asin(((e-T)/i).toFixed(9)),M=_.asin(((l-T)/i).toFixed(9));(A=t<C?S-A:A)<0&&(A=2*S+A),(M=o<C?S-M:M)<0&&(M=2*S+M),s&&A>M&&(A-=2*S),!s&&M>A&&(M-=2*S)}var E=M-A;if(B(E)>c){var N=M,L=o,P=l;M=A+c*(s&&M>A?1:-1),o=C+r*_.cos(M),l=T+i*_.sin(M),d=Bt(o,l,r,i,n,0,s,L,P,[M,N,C,T])}E=M-A;var z=_.cos(A),F=_.sin(A),R=_.cos(M),j=_.sin(M),I=_.tan(E/4),D=4/3*r*I,q=4/3*i*I,O=[t,e],V=[t+D*F,e-q*z],W=[o+D*j,l-q*R],Y=[o,l];if(V[0]=2*O[0]-V[0],V[1]=2*O[1]-V[1],h)return[V,W,Y][f](d);for(var G=[],H=0,X=(d=[V,W,Y][f](d).join()[v](",")).length;H<X;H++)G[H]=H%2?g(d[H-1],d[H],p).y:g(d[H],d[H+1],p).x;return G},Ct=function(t,e,r,i,n,a,s,o,l){var h=1-l;return{x:C(h,3)*t+3*C(h,2)*l*r+3*h*l*l*n+C(l,3)*s,y:C(h,3)*e+3*C(h,2)*l*i+3*h*l*l*a+C(l,3)*o}},St=ht(function(t,e,r,i,n,a,s,o){var l,h=n-2*r+t-(s-2*n+r),u=2*(r-t)-2*(n-r),f=t-r,p=(-u+_.sqrt(u*u-4*h*f))/2/h,d=(-u-_.sqrt(u*u-4*h*f))/2/h,g=[e,o],x=[t,s];return B(p)>"1e12"&&(p=.5),B(d)>"1e12"&&(d=.5),p>0&&p<1&&(l=Ct(t,e,r,i,n,a,s,o,p),x.push(l.x),g.push(l.y)),d>0&&d<1&&(l=Ct(t,e,r,i,n,a,s,o,d),x.push(l.x),g.push(l.y)),h=a-2*i+e-(o-2*a+i),f=e-i,p=(-(u=2*(i-e)-2*(a-i))+_.sqrt(u*u-4*h*f))/2/h,d=(-u-_.sqrt(u*u-4*h*f))/2/h,B(p)>"1e12"&&(p=.5),B(d)>"1e12"&&(d=.5),p>0&&p<1&&(l=Ct(t,e,r,i,n,a,s,o,p),x.push(l.x),g.push(l.y)),d>0&&d<1&&(l=Ct(t,e,r,i,n,a,s,o,d),x.push(l.x),g.push(l.y)),{min:{x:k[c](0,x),y:k[c](0,g)},max:{x:w[c](0,x),y:w[c](0,g)}}}),Tt=e._path2curve=ht(function(t,e){var r=!e&&ft(t);if(!e&&r.curve)return mt(r.curve);for(var i=_t(t),n=e&&_t(e),a={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},s={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},o=function(t,e,r){var i,n;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(!(t[0]in{T:1,Q:1})&&(e.qx=e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=["C"][f](Bt[c](0,[e.x,e.y][f](t.slice(1))));break;case"S":"C"==r||"S"==r?(i=2*e.x-e.bx,n=2*e.y-e.by):(i=e.x,n=e.y),t=["C",i,n][f](t.slice(1));break;case"T":"Q"==r||"T"==r?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"][f](kt(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"][f](kt(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"L":t=["C"][f](wt(e.x,e.y,t[1],t[2]));break;case"H":t=["C"][f](wt(e.x,e.y,t[1],e.y));break;case"V":t=["C"][f](wt(e.x,e.y,e.x,t[1]));break;case"Z":t=["C"][f](wt(e.x,e.y,e.X,e.Y))}return t},l=function(t,e){if(t[e].length>7){t[e].shift();for(var r=t[e];r.length;)u[e]="A",n&&(p[e]="A"),t.splice(e++,0,["C"][f](r.splice(0,6)));t.splice(e,1),v=w(i.length,n&&n.length||0)}},h=function(t,e,r,a,s){t&&e&&"M"==t[s][0]&&"M"!=e[s][0]&&(e.splice(s,0,["M",a.x,a.y]),r.bx=0,r.by=0,r.x=t[s][1],r.y=t[s][2],v=w(i.length,n&&n.length||0))},u=[],p=[],d="",g="",x=0,v=w(i.length,n&&n.length||0);x<v;x++){i[x]&&(d=i[x][0]),"C"!=d&&(u[x]=d,x&&(g=u[x-1])),i[x]=o(i[x],a,g),"A"!=u[x]&&"C"==d&&(u[x]="C"),l(i,x),n&&(n[x]&&(d=n[x][0]),"C"!=d&&(p[x]=d,x&&(g=p[x-1])),n[x]=o(n[x],s,g),"A"!=p[x]&&"C"==d&&(p[x]="C"),l(n,x)),h(i,n,a,s,x),h(n,i,s,a,x);var y=i[x],m=n&&n[x],b=y.length,_=n&&m.length;a.x=y[b-2],a.y=y[b-1],a.bx=z(y[b-4])||a.x,a.by=z(y[b-3])||a.y,s.bx=n&&(z(m[_-4])||s.x),s.by=n&&(z(m[_-3])||s.y),s.x=n&&m[_-2],s.y=n&&m[_-1]}return n||(r.curve=mt(i)),n?[i,n]:i},null,mt),At=(e._parseDots=ht(function(t){for(var r=[],i=0,n=t.length;i<n;i++){var a={},s=t[i].match(/^([^:]*):?([\d\.]*)/);if(a.color=e.getRGB(s[1]),a.color.error)return null;a.opacity=a.color.opacity,a.color=a.color.hex,s[2]&&(a.offset=s[2]+"%"),r.push(a)}for(i=1,n=r.length-1;i<n;i++)if(!r[i].offset){for(var o=z(r[i-1].offset||0),l=0,h=i+1;h<n;h++)if(r[h].offset){l=r[h].offset;break}l||(l=100,h=n);for(var u=((l=z(l))-o)/(h-i+1);i<h;i++)o+=u,r[i].offset=o+"%"}return r}),e._tear=function(t,e){t==e.top&&(e.top=t.prev),t==e.bottom&&(e.bottom=t.next),t.next&&(t.next.prev=t.prev),t.prev&&(t.prev.next=t.next)}),Mt=(e._tofront=function(t,e){e.top!==t&&(At(t,e),t.next=null,t.prev=e.top,e.top.next=t,e.top=t)},e._toback=function(t,e){e.bottom!==t&&(At(t,e),t.next=e.bottom,t.prev=null,e.bottom.prev=t,e.bottom=t)},e._insertafter=function(t,e,r){At(t,r),e==r.top&&(r.top=t),e.next&&(e.next.prev=t),t.next=e.next,t.prev=e,e.next=t},e._insertbefore=function(t,e,r){At(t,r),e==r.bottom&&(r.bottom=t),e.prev&&(e.prev.next=t),t.prev=e.prev,e.prev=t,t.next=e},e.toMatrix=function(t,e){var r=yt(t),i={_:{transform:d},getBBox:function(){return r}};return Et(i,e),i.matrix}),Et=(e.transformPath=function(t,e){return Q(t,Mt(t,e))},e._extractTransform=function(t,r){if(null==r)return t._.transform;r=x(r).replace(/\.{3}|\u2026/g,t._.transform||d);var i,n,a=e.parseTransformString(r),s=0,o=1,l=1,h=t._,u=new Pt;if(h.transform=a||[],a)for(var c=0,f=a.length;c<f;c++){var p,g,v,y,m,b=a[c],_=b.length,w=x(b[0]).toLowerCase(),k=b[0]!=w,B=k?u.invert():0;"t"==w&&3==_?k?(p=B.x(0,0),g=B.y(0,0),v=B.x(b[1],b[2]),y=B.y(b[1],b[2]),u.translate(v-p,y-g)):u.translate(b[1],b[2]):"r"==w?2==_?(m=m||t.getBBox(1),u.rotate(b[1],m.x+m.width/2,m.y+m.height/2),s+=b[1]):4==_&&(k?(v=B.x(b[2],b[3]),y=B.y(b[2],b[3]),u.rotate(b[1],v,y)):u.rotate(b[1],b[2],b[3]),s+=b[1]):"s"==w?2==_||3==_?(m=m||t.getBBox(1),u.scale(b[1],b[_-1],m.x+m.width/2,m.y+m.height/2),o*=b[1],l*=b[_-1]):5==_&&(k?(v=B.x(b[3],b[4]),y=B.y(b[3],b[4]),u.scale(b[1],b[2],v,y)):u.scale(b[1],b[2],b[3],b[4]),o*=b[1],l*=b[2]):"m"==w&&7==_&&u.add(b[1],b[2],b[3],b[4],b[5],b[6]),h.dirtyT=1,t.matrix=u}t.matrix=u,h.sx=o,h.sy=l,h.deg=s,h.dx=i=u.e,h.dy=n=u.f,1==o&&1==l&&!s&&h.bbox?(h.bbox.x+=+i,h.bbox.y+=+n):h.dirtyT=1}),Nt=function(t){var e=t[0];switch(e.toLowerCase()){case"t":return[e,0,0];case"m":return[e,1,0,0,1,0,0];case"r":return 4==t.length?[e,0,t[2],t[3]]:[e,0];case"s":return 5==t.length?[e,1,1,t[3],t[4]]:3==t.length?[e,1,1]:[e,1]}},Lt=e._equaliseTransform=function(t,r){r=x(r).replace(/\.{3}|\u2026/g,t),t=e.parseTransformString(t)||[],r=e.parseTransformString(r)||[];for(var i,n,a,s,o=w(t.length,r.length),l=[],h=[],u=0;u<o;u++){if(a=t[u]||Nt(r[u]),s=r[u]||Nt(a),a[0]!=s[0]||"r"==a[0].toLowerCase()&&(a[2]!=s[2]||a[3]!=s[3])||"s"==a[0].toLowerCase()&&(a[3]!=s[3]||a[4]!=s[4]))return;for(l[u]=[],h[u]=[],i=0,n=w(a.length,s.length);i<n;i++)i in a&&(l[u][i]=a[i]),i in s&&(h[u][i]=s[i])}return{from:l,to:h}};function Pt(t,e,r,i,n,a){null!=t?(this.a=+t,this.b=+e,this.c=+r,this.d=+i,this.e=+n,this.f=+a):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0)}e._getContainer=function(t,r,i,n){var a;if(null!=(a=null!=n||e.is(t,"object")?t:l.doc.getElementById(t)))return a.tagName?null==r?{container:a,width:a.style.pixelWidth||a.offsetWidth,height:a.style.pixelHeight||a.offsetHeight}:{container:a,width:r,height:i}:{container:1,x:t,y:r,width:i,height:n}},e.pathToRelative=bt,e._engine={},e.path2curve=Tt,e.matrix=function(t,e,r,i,n,a){return new Pt(t,e,r,i,n,a)},function(t){function r(t){return t[0]*t[0]+t[1]*t[1]}function i(t){var e=_.sqrt(r(t));t[0]&&(t[0]/=e),t[1]&&(t[1]/=e)}t.add=function(t,e,r,i,n,a){var s,o,l,h,u=[[],[],[]],c=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],f=[[t,r,n],[e,i,a],[0,0,1]];for(t&&t instanceof Pt&&(f=[[t.a,t.c,t.e],[t.b,t.d,t.f],[0,0,1]]),s=0;s<3;s++)for(o=0;o<3;o++){for(h=0,l=0;l<3;l++)h+=c[s][l]*f[l][o];u[s][o]=h}this.a=u[0][0],this.b=u[1][0],this.c=u[0][1],this.d=u[1][1],this.e=u[0][2],this.f=u[1][2]},t.invert=function(){var t=this,e=t.a*t.d-t.b*t.c;return new Pt(t.d/e,-t.b/e,-t.c/e,t.a/e,(t.c*t.f-t.d*t.e)/e,(t.b*t.e-t.a*t.f)/e)},t.clone=function(){return new Pt(this.a,this.b,this.c,this.d,this.e,this.f)},t.translate=function(t,e){this.add(1,0,0,1,t,e)},t.scale=function(t,e,r,i){null==e&&(e=t),(r||i)&&this.add(1,0,0,1,r,i),this.add(t,0,0,e,0,0),(r||i)&&this.add(1,0,0,1,-r,-i)},t.rotate=function(t,r,i){t=e.rad(t),r=r||0,i=i||0;var n=+_.cos(t).toFixed(9),a=+_.sin(t).toFixed(9);this.add(n,a,-a,n,r,i),this.add(1,0,0,1,-r,-i)},t.x=function(t,e){return t*this.a+e*this.c+this.e},t.y=function(t,e){return t*this.b+e*this.d+this.f},t.get=function(t){return+this[x.fromCharCode(97+t)].toFixed(4)},t.toString=function(){return e.svg?"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")":[this.get(0),this.get(2),this.get(1),this.get(3),0,0].join()},t.toFilter=function(){return"progid:DXImageTransform.Microsoft.Matrix(M11="+this.get(0)+", M12="+this.get(2)+", M21="+this.get(1)+", M22="+this.get(3)+", Dx="+this.get(4)+", Dy="+this.get(5)+", sizingmethod='auto expand')"},t.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},t.split=function(){var t={};t.dx=this.e,t.dy=this.f;var n=[[this.a,this.c],[this.b,this.d]];t.scalex=_.sqrt(r(n[0])),i(n[0]),t.shear=n[0][0]*n[1][0]+n[0][1]*n[1][1],n[1]=[n[1][0]-n[0][0]*t.shear,n[1][1]-n[0][1]*t.shear],t.scaley=_.sqrt(r(n[1])),i(n[1]),t.shear/=t.scaley;var a=-n[0][1],s=n[1][1];return s<0?(t.rotate=e.deg(_.acos(s)),a<0&&(t.rotate=360-t.rotate)):t.rotate=e.deg(_.asin(a)),t.isSimple=!(+t.shear.toFixed(9)||t.scalex.toFixed(9)!=t.scaley.toFixed(9)&&t.rotate),t.isSuperSimple=!+t.shear.toFixed(9)&&t.scalex.toFixed(9)==t.scaley.toFixed(9)&&!t.rotate,t.noRotation=!+t.shear.toFixed(9)&&!t.rotate,t},t.toTransformString=function(t){var e=t||this[v]();return e.isSimple?(e.scalex=+e.scalex.toFixed(4),e.scaley=+e.scaley.toFixed(4),e.rotate=+e.rotate.toFixed(4),(e.dx||e.dy?"t"+[e.dx,e.dy]:d)+(1!=e.scalex||1!=e.scaley?"s"+[e.scalex,e.scaley,0,0]:d)+(e.rotate?"r"+[e.rotate,0,0]:d)):"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]}}(Pt.prototype);for(var zt=function(){this.returnValue=!1},Ft=function(){return this.originalEvent.preventDefault()},Rt=function(){this.cancelBubble=!0},jt=function(){return this.originalEvent.stopPropagation()},It=function(t){var e=l.doc.documentElement.scrollTop||l.doc.body.scrollTop,r=l.doc.documentElement.scrollLeft||l.doc.body.scrollLeft;return{x:t.clientX+r,y:t.clientY+e}},Dt=l.doc.addEventListener?function(t,e,r,i){var n=function(t){var e=It(t);return r.call(i,t,e.x,e.y)};if(t.addEventListener(e,n,!1),p&&m[e]){var a=function(e){for(var n=It(e),a=e,s=0,o=e.targetTouches&&e.targetTouches.length;s<o;s++)if(e.targetTouches[s].target==t){(e=e.targetTouches[s]).originalEvent=a,e.preventDefault=Ft,e.stopPropagation=jt;break}return r.call(i,e,n.x,n.y)};t.addEventListener(m[e],a,!1)}return function(){return t.removeEventListener(e,n,!1),p&&m[e]&&t.removeEventListener(m[e],a,!1),!0}}:l.doc.attachEvent?function(t,e,r,i){var n=function(t){t=t||l.win.event;var e=l.doc.documentElement.scrollTop||l.doc.body.scrollTop,n=l.doc.documentElement.scrollLeft||l.doc.body.scrollLeft,a=t.clientX+n,s=t.clientY+e;return t.preventDefault=t.preventDefault||zt,t.stopPropagation=t.stopPropagation||Rt,r.call(i,t,a,s)};return t.attachEvent("on"+e,n),function(){return t.detachEvent("on"+e,n),!0}}:void 0,qt=[],Ot=function(e){for(var r,i=e.clientX,n=e.clientY,a=l.doc.documentElement.scrollTop||l.doc.body.scrollTop,s=l.doc.documentElement.scrollLeft||l.doc.body.scrollLeft,o=qt.length;o--;){if(r=qt[o],p&&e.touches){for(var h,u=e.touches.length;u--;)if((h=e.touches[u]).identifier==r.el._drag.id){i=h.clientX,n=h.clientY,(e.originalEvent?e.originalEvent:e).preventDefault();break}}else e.preventDefault();var c,f=r.el.node,d=f.nextSibling,g=f.parentNode,x=f.style.display;l.win.opera&&g.removeChild(f),f.style.display="none",c=r.el.paper.getElementByPoint(i,n),f.style.display=x,l.win.opera&&(d?g.insertBefore(f,d):g.appendChild(f)),c&&t("raphael.drag.over."+r.el.id,r.el,c),i+=s,n+=a,t("raphael.drag.move."+r.el.id,r.move_scope||r.el,i-r.el._drag.x,n-r.el._drag.y,i,n,e)}},Vt=function(r){e.unmousemove(Ot).unmouseup(Vt);for(var i,n=qt.length;n--;)(i=qt[n]).el._drag={},t("raphael.drag.end."+i.el.id,i.end_scope||i.start_scope||i.move_scope||i.el,r);qt=[]},Wt=e.el={},Yt=y.length;Yt--;)!function(t){e[t]=Wt[t]=function(r,i){return e.is(r,"function")&&(this.events=this.events||[],this.events.push({name:t,f:r,unbind:Dt(this.shape||this.node||l.doc,t,r,i||this)})),this},e["un"+t]=Wt["un"+t]=function(r){for(var i=this.events||[],n=i.length;n--;)i[n].name!=t||!e.is(r,"undefined")&&i[n].f!=r||(i[n].unbind(),i.splice(n,1),!i.length&&delete this.events);return this}}(y[Yt]);Wt.data=function(r,i){var n=G[this.id]=G[this.id]||{};if(0==arguments.length)return n;if(1==arguments.length){if(e.is(r,"object")){for(var a in r)r[o](a)&&this.data(a,r[a]);return this}return t("raphael.data.get."+this.id,this,n[r],r),n[r]}return n[r]=i,t("raphael.data.set."+this.id,this,i,r),this},Wt.removeData=function(t){return null==t?delete G[this.id]:G[this.id]&&delete G[this.id][t],this},Wt.getData=function(){return tt(G[this.id]||{})},Wt.hover=function(t,e,r,i){return this.mouseover(t,r).mouseout(e,i||r)},Wt.unhover=function(t,e){return this.unmouseover(t).unmouseout(e)};var Gt=[];Wt.drag=function(r,i,n,a,s,o){function h(h){(h.originalEvent||h).preventDefault();var u=h.clientX,c=h.clientY,f=l.doc.documentElement.scrollTop||l.doc.body.scrollTop,d=l.doc.documentElement.scrollLeft||l.doc.body.scrollLeft;if(this._drag.id=h.identifier,p&&h.touches)for(var g,x=h.touches.length;x--;)if(g=h.touches[x],this._drag.id=g.identifier,g.identifier==this._drag.id){u=g.clientX,c=g.clientY;break}this._drag.x=u+d,this._drag.y=c+f,!qt.length&&e.mousemove(Ot).mouseup(Vt),qt.push({el:this,move_scope:a,start_scope:s,end_scope:o}),i&&t.on("raphael.drag.start."+this.id,i),r&&t.on("raphael.drag.move."+this.id,r),n&&t.on("raphael.drag.end."+this.id,n),t("raphael.drag.start."+this.id,s||a||this,this._drag.x,this._drag.y,h)}return this._drag={},Gt.push({el:this,start:h}),this.mousedown(h),this},Wt.onDragOver=function(e){e?t.on("raphael.drag.over."+this.id,e):t.unbind("raphael.drag.over."+this.id)},Wt.undrag=function(){for(var r=Gt.length;r--;)Gt[r].el==this&&(this.unmousedown(Gt[r].start),Gt.splice(r,1),t.unbind("raphael.drag.*."+this.id));!Gt.length&&e.unmousemove(Ot).unmouseup(Vt),qt=[]},i.circle=function(t,r,i){var n=e._engine.circle(this,t||0,r||0,i||0);return this.__set__&&this.__set__.push(n),n},i.rect=function(t,r,i,n,a){var s=e._engine.rect(this,t||0,r||0,i||0,n||0,a||0);return this.__set__&&this.__set__.push(s),s},i.ellipse=function(t,r,i,n){var a=e._engine.ellipse(this,t||0,r||0,i||0,n||0);return this.__set__&&this.__set__.push(a),a},i.path=function(t){t&&!e.is(t,"string")&&!e.is(t[0],A)&&(t+=d);var r=e._engine.path(e.format[c](e,arguments),this);return this.__set__&&this.__set__.push(r),r},i.image=function(t,r,i,n,a){var s=e._engine.image(this,t||"about:blank",r||0,i||0,n||0,a||0);return this.__set__&&this.__set__.push(s),s},i.text=function(t,r,i){var n=e._engine.text(this,t||0,r||0,x(i));return this.__set__&&this.__set__.push(n),n},i.set=function(t){!e.is(t,"array")&&(t=Array.prototype.splice.call(arguments,0,arguments.length));var r=new ce(t);return this.__set__&&this.__set__.push(r),r.paper=this,r.type="set",r},i.setStart=function(t){this.__set__=t||this.set()},i.setFinish=function(t){var e=this.__set__;return delete this.__set__,e},i.getSize=function(){var t=this.canvas.parentNode;return{width:t.offsetWidth,height:t.offsetHeight}},i.setSize=function(t,r){return e._engine.setSize.call(this,t,r)},i.setViewBox=function(t,r,i,n,a){return e._engine.setViewBox.call(this,t,r,i,n,a)},i.top=i.bottom=null,i.raphael=e;function Ht(){return this.x+g+this.y+g+this.width+" × "+this.height}i.getElementByPoint=function(t,e){var r,i,n,a,s,o,h,u=this.canvas,c=l.doc.elementFromPoint(t,e);if(l.win.opera&&"svg"==c.tagName){var f=(i=(r=u).getBoundingClientRect(),n=r.ownerDocument,a=n.body,s=n.documentElement,o=s.clientTop||a.clientTop||0,h=s.clientLeft||a.clientLeft||0,{y:i.top+(l.win.pageYOffset||s.scrollTop||a.scrollTop)-o,x:i.left+(l.win.pageXOffset||s.scrollLeft||a.scrollLeft)-h}),p=u.createSVGRect();p.x=t-f.x,p.y=e-f.y,p.width=p.height=1;var d=u.getIntersectionList(p,null);d.length&&(c=d[d.length-1])}if(!c)return null;for(;c.parentNode&&c!=u.parentNode&&!c.raphael;)c=c.parentNode;return c==this.canvas.parentNode&&(c=u),c=c&&c.raphael?this.getById(c.raphaelid):null},i.getElementsByBBox=function(t){var r=this.set();return this.forEach(function(i){e.isBBoxIntersect(i.getBBox(),t)&&r.push(i)}),r},i.getById=function(t){for(var e=this.bottom;e;){if(e.id==t)return e;e=e.next}return null},i.forEach=function(t,e){for(var r=this.bottom;r;){if(!1===t.call(e,r))return this;r=r.next}return this},i.getElementsByPoint=function(t,e){var r=this.set();return this.forEach(function(i){i.isPointInside(t,e)&&r.push(i)}),r},Wt.isPointInside=function(t,r){var i=this.realPath=Z[this.type](this);return this.attr("transform")&&this.attr("transform").length&&(i=e.transformPath(i,this.attr("transform"))),e.isPointInsidePath(i,t,r)},Wt.getBBox=function(t){if(this.removed)return{};var e=this._;return t?(!e.dirty&&e.bboxwt||(this.realPath=Z[this.type](this),e.bboxwt=yt(this.realPath),e.bboxwt.toString=Ht,e.dirty=0),e.bboxwt):((e.dirty||e.dirtyT||!e.bbox)&&(!e.dirty&&this.realPath||(e.bboxwt=0,this.realPath=Z[this.type](this)),e.bbox=yt(Q(this.realPath,this.matrix)),e.bbox.toString=Ht,e.dirty=e.dirtyT=0),e.bbox)},Wt.clone=function(){if(this.removed)return null;var t=this.paper[this.type]().attr(this.attr());return this.__set__&&this.__set__.push(t),t},Wt.glow=function(t){if("text"==this.type)return null;var e={width:((t=t||{}).width||10)+(+this.attr("stroke-width")||1),fill:t.fill||!1,opacity:null==t.opacity?.5:t.opacity,offsetx:t.offsetx||0,offsety:t.offsety||0,color:t.color||"#000"},r=e.width/2,i=this.paper,n=i.set(),a=this.realPath||Z[this.type](this);a=this.matrix?Q(a,this.matrix):a;for(var s=1;s<r+1;s++)n.push(i.path(a).attr({stroke:e.color,fill:e.fill?e.color:"none","stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(e.width/r*s).toFixed(3),opacity:+(e.opacity/r).toFixed(3)}));return n.insertBefore(this).translate(e.offsetx,e.offsety)};var Xt=function(t,r,i,n,a,s,o,l,h){return null==h?dt(t,r,i,n,a,s,o,l):e.findDotsAtSegment(t,r,i,n,a,s,o,l,function(t,e,r,i,n,a,s,o,l){if(!(l<0||dt(t,e,r,i,n,a,s,o)<l)){var h,u=.5,c=1-u;for(h=dt(t,e,r,i,n,a,s,o,c);B(h-l)>.01;)h=dt(t,e,r,i,n,a,s,o,c+=(h<l?1:-1)*(u/=2));return c}}(t,r,i,n,a,s,o,l,h))},Ut=function(t,r){return function(i,n,a){for(var s,o,l,h,u,c="",f={},p=0,d=0,g=(i=Tt(i)).length;d<g;d++){if("M"==(l=i[d])[0])s=+l[1],o=+l[2];else{if(p+(h=Xt(s,o,l[1],l[2],l[3],l[4],l[5],l[6]))>n){if(r&&!f.start){if(c+=["C"+(u=Xt(s,o,l[1],l[2],l[3],l[4],l[5],l[6],n-p)).start.x,u.start.y,u.m.x,u.m.y,u.x,u.y],a)return c;f.start=c,c=["M"+u.x,u.y+"C"+u.n.x,u.n.y,u.end.x,u.end.y,l[5],l[6]].join(),p+=h,s=+l[5],o=+l[6];continue}if(!t&&!r)return{x:(u=Xt(s,o,l[1],l[2],l[3],l[4],l[5],l[6],n-p)).x,y:u.y,alpha:u.alpha}}p+=h,s=+l[5],o=+l[6]}c+=l.shift()+l}return f.end=c,(u=t?p:r?f:e.findDotsAtSegment(s,o,l[0],l[1],l[2],l[3],l[4],l[5],1)).alpha&&(u={x:u.x,y:u.y,alpha:u.alpha}),u}},$t=Ut(1),Zt=Ut(),Qt=Ut(0,1);e.getTotalLength=$t,e.getPointAtLength=Zt,e.getSubpath=function(t,e,r){if(this.getTotalLength(t)-r<1e-6)return Qt(t,e).end;var i=Qt(t,r,1);return e?Qt(i,e).end:i},Wt.getTotalLength=function(){var t=this.getPath();if(t)return this.node.getTotalLength?this.node.getTotalLength():$t(t)},Wt.getPointAtLength=function(t){var e=this.getPath();if(e)return Zt(e,t)},Wt.getPath=function(){var t,r=e._getPath[this.type];if("text"!=this.type&&"set"!=this.type)return r&&(t=r(this)),t},Wt.getSubpath=function(t,r){var i=this.getPath();if(i)return e.getSubpath(i,t,r)};var Jt=e.easing_formulas={linear:function(t){return t},"<":function(t){return C(t,1.7)},">":function(t){return C(t,.48)},"<>":function(t){var e=.48-t/1.04,r=_.sqrt(.1734+e*e),i=r-e,n=-r-e,a=C(B(i),1/3)*(i<0?-1:1)+C(B(n),1/3)*(n<0?-1:1)+.5;return 3*(1-a)*a*a+a*a*a},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},elastic:function(t){return t==!!t?t:C(2,-10*t)*_.sin(2*S*(t-.075)/.3)+1},bounce:function(t){var e=7.5625,r=2.75;return t<1/r?e*t*t:t<2/r?e*(t-=1.5/r)*t+.75:t<2.5/r?e*(t-=2.25/r)*t+.9375:e*(t-=2.625/r)*t+.984375}};Jt.easeIn=Jt["ease-in"]=Jt["<"],Jt.easeOut=Jt["ease-out"]=Jt[">"],Jt.easeInOut=Jt["ease-in-out"]=Jt["<>"],Jt["back-in"]=Jt.backIn,Jt["back-out"]=Jt.backOut;var Kt=[],te=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){setTimeout(t,16)},ee=function(){for(var r=+new Date,i=0;i<Kt.length;i++){var n=Kt[i];if(!n.el.removed&&!n.paused){var a,s,l=r-n.start,h=n.ms,u=n.easing,c=n.from,p=n.diff,d=n.to,x=(n.t,n.el),v={},y={};if(n.initstatus?(l=(n.initstatus*n.anim.top-n.prev)/(n.percent-n.prev)*h,n.status=n.initstatus,delete n.initstatus,n.stop&&Kt.splice(i--,1)):n.status=(n.prev+(n.percent-n.prev)*(l/h))/n.anim.top,!(l<0))if(l<h){var m=u(l/h);for(var b in c)if(c[o](b)){switch(I[b]){case T:a=+c[b]+m*h*p[b];break;case"colour":a="rgb("+[re(P(c[b].r+m*h*p[b].r)),re(P(c[b].g+m*h*p[b].g)),re(P(c[b].b+m*h*p[b].b))].join(",")+")";break;case"path":a=[];for(var _=0,w=c[b].length;_<w;_++){a[_]=[c[b][_][0]];for(var k=1,B=c[b][_].length;k<B;k++)a[_][k]=+c[b][_][k]+m*h*p[b][_][k];a[_]=a[_].join(g)}a=a.join(g);break;case"transform":if(p[b].real)for(a=[],_=0,w=c[b].length;_<w;_++)for(a[_]=[c[b][_][0]],k=1,B=c[b][_].length;k<B;k++)a[_][k]=c[b][_][k]+m*h*p[b][_][k];else{var C=function(t){return+c[b][t]+m*h*p[b][t]};a=[["m",C(0),C(1),C(2),C(3),C(4),C(5)]]}break;case"csv":if("clip-rect"==b)for(a=[],_=4;_--;)a[_]=+c[b][_]+m*h*p[b][_];break;default:var S=[][f](c[b]);for(a=[],_=x.paper.customAttributes[b].length;_--;)a[_]=+S[_]+m*h*p[b][_]}v[b]=a}x.attr(v),function(e,r,i){setTimeout(function(){t("raphael.anim.frame."+e,r,i)})}(x.id,x,n.anim)}else{if(function(r,i,n){setTimeout(function(){t("raphael.anim.frame."+i.id,i,n),t("raphael.anim.finish."+i.id,i,n),e.is(r,"function")&&r.call(i)})}(n.callback,x,n.anim),x.attr(d),Kt.splice(i--,1),n.repeat>1&&!n.next){for(s in d)d[o](s)&&(y[s]=n.totalOrigin[s]);n.el.attr(y),ae(n.anim,n.el,n.anim.percents[0],null,n.totalOrigin,n.repeat-1)}n.next&&!n.stop&&ae(n.anim,n.el,n.next,null,n.totalOrigin,n.repeat)}}}Kt.length&&te(ee)},re=function(t){return t>255?255:t<0?0:t};function ie(t,e,r,i,n,a){var s=3*e,o=3*(i-e)-s,l=1-s-o,h=3*r,u=3*(n-r)-h,c=1-h-u;function f(t){return((l*t+o)*t+s)*t}return function(t,e){var r=function(t,e){var r,i,n,a,h,u;for(n=t,u=0;u<8;u++){if(a=f(n)-t,B(a)<e)return n;if(B(h=(3*l*n+2*o)*n+s)<1e-6)break;n-=a/h}if(i=1,(n=t)<(r=0))return r;if(n>i)return i;for(;r<i;){if(a=f(n),B(a-t)<e)return n;t>a?r=n:i=n,n=(i-r)/2+r}return n}(t,e);return((c*r+u)*r+h)*r}(t,1/(200*a))}function ne(t,e){var r=[],i={};if(this.ms=e,this.times=1,t){for(var n in t)t[o](n)&&(i[z(n)]=t[n],r.push(z(n)));r.sort(H)}this.anim=i,this.top=r[r.length-1],this.percents=r}function ae(r,i,a,s,l,h){a=z(a);var u,c,p,d,g,y,m=r.ms,b={},_={},w={};if(s)for(B=0,C=Kt.length;B<C;B++){var k=Kt[B];if(k.el.id==i.id&&k.anim==r){k.percent!=a?(Kt.splice(B,1),p=1):c=k,i.attr(k.totalOrigin);break}}else s=+_;for(var B=0,C=r.percents.length;B<C;B++){if(r.percents[B]==a||r.percents[B]>s*r.top){a=r.percents[B],g=r.percents[B-1]||0,m=m/r.top*(a-g),d=r.percents[B+1],u=r.anim[a];break}s&&i.attr(r.anim[r.percents[B]])}if(u){if(c)c.initstatus=s,c.start=new Date-c.ms*s;else{for(var S in u)if(u[o](S)&&(I[o](S)||i.paper.customAttributes[o](S)))switch(b[S]=i.attr(S),null==b[S]&&(b[S]=j[S]),_[S]=u[S],I[S]){case T:w[S]=(_[S]-b[S])/m;break;case"colour":b[S]=e.getRGB(b[S]);var A=e.getRGB(_[S]);w[S]={r:(A.r-b[S].r)/m,g:(A.g-b[S].g)/m,b:(A.b-b[S].b)/m};break;case"path":var M=Tt(b[S],_[S]),E=M[1];for(b[S]=M[0],w[S]=[],B=0,C=b[S].length;B<C;B++){w[S][B]=[0];for(var N=1,P=b[S][B].length;N<P;N++)w[S][B][N]=(E[B][N]-b[S][B][N])/m}break;case"transform":var F=i._,R=Lt(F[S],_[S]);if(R)for(b[S]=R.from,_[S]=R.to,w[S]=[],w[S].real=!0,B=0,C=b[S].length;B<C;B++)for(w[S][B]=[b[S][B][0]],N=1,P=b[S][B].length;N<P;N++)w[S][B][N]=(_[S][B][N]-b[S][B][N])/m;else{var D=i.matrix||new Pt,q={_:{transform:F.transform},getBBox:function(){return i.getBBox(1)}};b[S]=[D.a,D.b,D.c,D.d,D.e,D.f],Et(q,_[S]),_[S]=q._.transform,w[S]=[(q.matrix.a-D.a)/m,(q.matrix.b-D.b)/m,(q.matrix.c-D.c)/m,(q.matrix.d-D.d)/m,(q.matrix.e-D.e)/m,(q.matrix.f-D.f)/m]}break;case"csv":var O=x(u[S])[v](n),V=x(b[S])[v](n);if("clip-rect"==S)for(b[S]=V,w[S]=[],B=V.length;B--;)w[S][B]=(O[B]-b[S][B])/m;_[S]=O;break;default:for(O=[][f](u[S]),V=[][f](b[S]),w[S]=[],B=i.paper.customAttributes[S].length;B--;)w[S][B]=((O[B]||0)-(V[B]||0))/m}var W=u.easing,Y=e.easing_formulas[W];if(!Y)if((Y=x(W).match(L))&&5==Y.length){var G=Y;Y=function(t){return ie(t,+G[1],+G[2],+G[3],+G[4],m)}}else Y=X;if(k={anim:r,percent:a,timestamp:y=u.start||r.start||+new Date,start:y+(r.del||0),status:0,initstatus:s||0,stop:!1,ms:m,easing:Y,from:b,diff:w,to:_,el:i,callback:u.callback,prev:g,next:d,repeat:h||r.times,origin:i.attr(),totalOrigin:l},Kt.push(k),s&&!c&&!p&&(k.stop=!0,k.start=new Date-m*s,1==Kt.length))return ee();p&&(k.start=new Date-k.ms*s),1==Kt.length&&te(ee)}t("raphael.anim.start."+i.id,i,r)}}function se(t){for(var e=0;e<Kt.length;e++)Kt[e].el.paper==t&&Kt.splice(e--,1)}Wt.animateWith=function(t,r,i,n,a,s){if(this.removed)return s&&s.call(this),this;var o=i instanceof ne?i:e.animation(i,n,a,s);ae(o,this,o.percents[0],null,this.attr());for(var l=0,h=Kt.length;l<h;l++)if(Kt[l].anim==r&&Kt[l].el==t){Kt[h-1].start=Kt[l].start;break}return this},Wt.onAnimation=function(e){return e?t.on("raphael.anim.frame."+this.id,e):t.unbind("raphael.anim.frame."+this.id),this},ne.prototype.delay=function(t){var e=new ne(this.anim,this.ms);return e.times=this.times,e.del=+t||0,e},ne.prototype.repeat=function(t){var e=new ne(this.anim,this.ms);return e.del=this.del,e.times=_.floor(w(t,0))||1,e},e.animation=function(t,r,i,n){if(t instanceof ne)return t;!e.is(i,"function")&&i||(n=n||i||null,i=null),t=Object(t),r=+r||0;var a,s,l={};for(s in t)t[o](s)&&z(s)!=s&&z(s)+"%"!=s&&(a=!0,l[s]=t[s]);if(a)return i&&(l.easing=i),n&&(l.callback=n),new ne({100:l},r);if(n){var h=0;for(var u in t){var c=F(u);t[o](u)&&c>h&&(h=c)}!t[h+="%"].callback&&(t[h].callback=n)}return new ne(t,r)},Wt.animate=function(t,r,i,n){if(this.removed)return n&&n.call(this),this;var a=t instanceof ne?t:e.animation(t,r,i,n);return ae(a,this,a.percents[0],null,this.attr()),this},Wt.setTime=function(t,e){return t&&null!=e&&this.status(t,k(e,t.ms)/t.ms),this},Wt.status=function(t,e){var r,i,n=[],a=0;if(null!=e)return ae(t,this,-1,k(e,1)),this;for(r=Kt.length;a<r;a++)if((i=Kt[a]).el.id==this.id&&(!t||i.anim==t)){if(t)return i.status;n.push({anim:i.anim,status:i.status})}return t?0:n},Wt.pause=function(e){for(var r=0;r<Kt.length;r++)Kt[r].el.id!=this.id||e&&Kt[r].anim!=e||!1!==t("raphael.anim.pause."+this.id,this,Kt[r].anim)&&(Kt[r].paused=!0);return this},Wt.resume=function(e){for(var r=0;r<Kt.length;r++)if(Kt[r].el.id==this.id&&(!e||Kt[r].anim==e)){var i=Kt[r];!1!==t("raphael.anim.resume."+this.id,this,i.anim)&&(delete i.paused,this.status(i.anim,i.status))}return this},Wt.stop=function(e){for(var r=0;r<Kt.length;r++)Kt[r].el.id!=this.id||e&&Kt[r].anim!=e||!1!==t("raphael.anim.stop."+this.id,this,Kt[r].anim)&&Kt.splice(r--,1);return this},t.on("raphael.remove",se),t.on("raphael.clear",se),Wt.toString=function(){return"Raphaël’s object"};var oe,le,he,ue,ce=function(t){if(this.items=[],this.length=0,this.type="set",t)for(var e=0,r=t.length;e<r;e++)!t[e]||t[e].constructor!=Wt.constructor&&t[e].constructor!=ce||(this[this.items.length]=this.items[this.items.length]=t[e],this.length++)},fe=ce.prototype;for(var pe in fe.push=function(){for(var t,e,r=0,i=arguments.length;r<i;r++)!(t=arguments[r])||t.constructor!=Wt.constructor&&t.constructor!=ce||(this[e=this.items.length]=this.items[e]=t,this.length++);return this},fe.pop=function(){return this.length&&delete this[this.length--],this.items.pop()},fe.forEach=function(t,e){for(var r=0,i=this.items.length;r<i;r++)if(!1===t.call(e,this.items[r],r))return this;return this},Wt)Wt[o](pe)&&(fe[pe]=function(t){return function(){var e=arguments;return this.forEach(function(r){r[t][c](r,e)})}}(pe));return fe.attr=function(t,r){if(t&&e.is(t,A)&&e.is(t[0],"object"))for(var i=0,n=t.length;i<n;i++)this.items[i].attr(t[i]);else for(var a=0,s=this.items.length;a<s;a++)this.items[a].attr(t,r);return this},fe.clear=function(){for(;this.length;)this.pop()},fe.splice=function(t,e,r){t=t<0?w(this.length+t,0):t,e=w(0,k(this.length-t,e));var i,n=[],a=[],s=[];for(i=2;i<arguments.length;i++)s.push(arguments[i]);for(i=0;i<e;i++)a.push(this[t+i]);for(;i<this.length-t;i++)n.push(this[t+i]);var o=s.length;for(i=0;i<o+n.length;i++)this.items[t+i]=this[t+i]=i<o?s[i]:n[i-o];for(i=this.items.length=this.length-=e-o;this[i];)delete this[i++];return new ce(a)},fe.exclude=function(t){for(var e=0,r=this.length;e<r;e++)if(this[e]==t)return this.splice(e,1),!0},fe.animate=function(t,r,i,n){(e.is(i,"function")||!i)&&(n=i||null);var a,s,o=this.items.length,l=o,h=this;if(!o)return this;n&&(s=function(){!--o&&n.call(h)}),i=e.is(i,"string")?i:s;var u=e.animation(t,r,i,s);for(a=this.items[--l].animate(u);l--;)this.items[l]&&!this.items[l].removed&&this.items[l].animateWith(a,u,u),this.items[l]&&!this.items[l].removed||o--;return this},fe.insertAfter=function(t){for(var e=this.items.length;e--;)this.items[e].insertAfter(t);return this},fe.getBBox=function(){for(var t=[],e=[],r=[],i=[],n=this.items.length;n--;)if(!this.items[n].removed){var a=this.items[n].getBBox();t.push(a.x),e.push(a.y),r.push(a.x+a.width),i.push(a.y+a.height)}return{x:t=k[c](0,t),y:e=k[c](0,e),x2:r=w[c](0,r),y2:i=w[c](0,i),width:r-t,height:i-e}},fe.clone=function(t){t=this.paper.set();for(var e=0,r=this.items.length;e<r;e++)t.push(this.items[e].clone());return t},fe.toString=function(){return"Raphaël‘s set"},fe.glow=function(t){var e=this.paper.set();return this.forEach(function(r,i){var n=r.glow(t);null!=n&&n.forEach(function(t,r){e.push(t)})}),e},fe.isPointInside=function(t,e){var r=!1;return this.forEach(function(i){if(i.isPointInside(t,e))return r=!0,!1}),r},e.registerFont=function(t){if(!t.face)return t;this.fonts=this.fonts||{};var e={w:t.w,face:{},glyphs:{}},r=t.face["font-family"];for(var i in t.face)t.face[o](i)&&(e.face[i]=t.face[i]);if(this.fonts[r]?this.fonts[r].push(e):this.fonts[r]=[e],!t.svg)for(var n in e.face["units-per-em"]=F(t.face["units-per-em"],10),t.glyphs)if(t.glyphs[o](n)){var a=t.glyphs[n];if(e.glyphs[n]={w:a.w,k:{},d:a.d&&"M"+a.d.replace(/[mlcxtrv]/g,function(t){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[t]||"M"})+"z"},a.k)for(var s in a.k)a[o](s)&&(e.glyphs[n].k[s]=a.k[s])}return t},i.getFont=function(t,r,i,n){if(n=n||"normal",i=i||"normal",r=+r||{normal:400,bold:700,lighter:300,bolder:800}[r]||400,e.fonts){var a,s=e.fonts[t];if(!s){var l=new RegExp("(^|\\s)"+t.replace(/[^\w\d\s+!~.:_-]/g,d)+"(\\s|$)","i");for(var h in e.fonts)if(e.fonts[o](h)&&l.test(h)){s=e.fonts[h];break}}if(s)for(var u=0,c=s.length;u<c&&((a=s[u]).face["font-weight"]!=r||a.face["font-style"]!=i&&a.face["font-style"]||a.face["font-stretch"]!=n);u++);return a}},i.print=function(t,r,i,a,s,o,l,h){o=o||"middle",l=w(k(l||0,1),-1),h=w(k(h||1,3),1);var u,c=x(i)[v](d),f=0,p=0,g=d;if(e.is(a,"string")&&(a=this.getFont(a)),a){u=(s||16)/a.face["units-per-em"];for(var y=a.face.bbox[v](n),m=+y[0],b=y[3]-y[1],_=0,B=+y[1]+("baseline"==o?b+ +a.face.descent:b/2),C=0,S=c.length;C<S;C++){if("\n"==c[C])f=0,A=0,p=0,_+=b*h;else{var T=p&&a.glyphs[c[C-1]]||{},A=a.glyphs[c[C]];f+=p?(T.w||a.w)+(T.k&&T.k[c[C]]||0)+a.w*l:0,p=1}A&&A.d&&(g+=e.transformPath(A.d,["t",f*u,_*u,"s",u,u,m,B,"t",(t-m)/u,(r-B)/u]))}}return this.path(g).attr({fill:"#000",stroke:"none"})},i.add=function(t){if(e.is(t,"array"))for(var r,i=this.set(),n=0,s=t.length;n<s;n++)r=t[n]||{},a[o](r.type)&&i.push(this[r.type]().attr(r));return i},e.format=function(t,r){var i=e.is(r,A)?[0][f](r):arguments;return t&&e.is(t,"string")&&i.length-1&&(t=t.replace(s,function(t,e){return null==i[++e]?d:i[e]})),t||d},e.fullfill=(oe=/\{([^\}]+)\}/g,le=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g,function(t,e){return String(t).replace(oe,function(t,r){return function(t,e,r){var i=r;return e.replace(le,function(t,e,r,n,a){e=e||n,i&&(e in i&&(i=i[e]),"function"==typeof i&&a&&(i=i()))}),i=(null==i||i==r?t:i)+""}(t,r,e)})}),e.ninja=function(){if(h.was)l.win.Raphael=h.is;else{window.Raphael=void 0;try{delete window.Raphael}catch(t){}}return e},e.st=fe,t.on("raphael.DOMload",function(){r=!0}),null==(he=document).readyState&&he.addEventListener&&(he.addEventListener("DOMContentLoaded",ue=function(){he.removeEventListener("DOMContentLoaded",ue,!1),he.readyState="complete"},!1),he.readyState="loading"),function t(){/in/.test(he.readyState)?setTimeout(t,9):e.eve("raphael.DOMload")}(),e}.apply(e,i))||(t.exports=n)},function(t,e,r){var i,n;i=[r(0),r(3),r(4)],void 0===(n=function(t){return t}.apply(e,i))||(t.exports=n)},function(t,e,r){var i,n,a,s,o,l,h,u,c,f,p,d,g,x;s="hasOwnProperty",o=/[\.\/]/,l=/\s*,\s*/,h=function(t,e){return t-e},u={n:{}},c=function(){for(var t=0,e=this.length;t<e;t++)if(void 0!==this[t])return this[t]},f=function(){for(var t=this.length;--t;)if(void 0!==this[t])return this[t]},p=Object.prototype.toString,d=String,g=Array.isArray||function(t){return t instanceof Array||"[object Array]"==p.call(t)},(x=function(t,e){var r,i=a,s=Array.prototype.slice.call(arguments,2),o=x.listeners(t),l=0,u=[],p={},d=[],g=n;d.firstDefined=c,d.lastDefined=f,n=t,a=0;for(var v=0,y=o.length;v<y;v++)"zIndex"in o[v]&&(u.push(o[v].zIndex),o[v].zIndex<0&&(p[o[v].zIndex]=o[v]));for(u.sort(h);u[l]<0;)if(r=p[u[l++]],d.push(r.apply(e,s)),a)return a=i,d;for(v=0;v<y;v++)if("zIndex"in(r=o[v]))if(r.zIndex==u[l]){if(d.push(r.apply(e,s)),a)break;do{if((r=p[u[++l]])&&d.push(r.apply(e,s)),a)break}while(r)}else p[r.zIndex]=r;else if(d.push(r.apply(e,s)),a)break;return a=i,n=g,d})._events=u,x.listeners=function(t){var e,r,i,n,a,s,l,h,c=g(t)?t:t.split(o),f=u,p=[f],d=[];for(n=0,a=c.length;n<a;n++){for(h=[],s=0,l=p.length;s<l;s++)for(r=[(f=p[s].n)[c[n]],f["*"]],i=2;i--;)(e=r[i])&&(h.push(e),d=d.concat(e.f||[]));p=h}return d},x.separator=function(t){t?(t="["+(t=d(t).replace(/(?=[\.\^\]\[\-])/g,"\\"))+"]",o=new RegExp(t)):o=/[\.\/]/},x.on=function(t,e){if("function"!=typeof e)return function(){};for(var r=g(t)?g(t[0])?t:[t]:d(t).split(l),i=0,n=r.length;i<n;i++)!function(t){for(var r,i=g(t)?t:d(t).split(o),n=u,a=0,s=i.length;a<s;a++)n=(n=n.n).hasOwnProperty(i[a])&&n[i[a]]||(n[i[a]]={n:{}});for(n.f=n.f||[],a=0,s=n.f.length;a<s;a++)if(n.f[a]==e){r=!0;break}!r&&n.f.push(e)}(r[i]);return function(t){+t==+t&&(e.zIndex=+t)}},x.f=function(t){var e=[].slice.call(arguments,1);return function(){x.apply(null,[t,null].concat(e).concat([].slice.call(arguments,0)))}},x.stop=function(){a=1},x.nt=function(t){var e=g(n)?n.join("."):n;return t?new RegExp("(?:\\.|\\/|^)"+t+"(?:\\.|\\/|$)").test(e):e},x.nts=function(){return g(n)?n:n.split(o)},x.off=x.unbind=function(t,e){if(t){var r=g(t)?g(t[0])?t:[t]:d(t).split(l);if(r.length>1)for(var i=0,n=r.length;i<n;i++)x.off(r[i],e);else{r=g(t)?t:d(t).split(o);var a,h,c,f,p,v=[u];for(i=0,n=r.length;i<n;i++)for(f=0;f<v.length;f+=c.length-2){if(c=[f,1],a=v[f].n,"*"!=r[i])a[r[i]]&&c.push(a[r[i]]);else for(h in a)a[s](h)&&c.push(a[h]);v.splice.apply(v,c)}for(i=0,n=v.length;i<n;i++)for(a=v[i];a.n;){if(e){if(a.f){for(f=0,p=a.f.length;f<p;f++)if(a.f[f]==e){a.f.splice(f,1);break}!a.f.length&&delete a.f}for(h in a.n)if(a.n[s](h)&&a.n[h].f){var y=a.n[h].f;for(f=0,p=y.length;f<p;f++)if(y[f]==e){y.splice(f,1);break}!y.length&&delete a.n[h].f}}else for(h in delete a.f,a.n)a.n[s](h)&&a.n[h].f&&delete a.n[h].f;a=a.n}}}else x._events=u={n:{}}},x.once=function(t,e){var r=function(){return x.off(t,r),e.apply(this,arguments)};return x.on(t,r)},x.version="0.5.0",x.toString=function(){return"You are running Eve 0.5.0"},t.exports?t.exports=x:void 0===(i=function(){return x}.apply(e,[]))||(t.exports=i)},function(t,e,r){var i,n;i=[r(0)],void 0===(n=function(t){if(!t||t.svg){var e="hasOwnProperty",r=String,i=parseFloat,n=parseInt,a=Math,s=a.max,o=a.abs,l=a.pow,h=/[, ]+/,u=t.eve,c="",f=" ",p="http://www.w3.org/1999/xlink",d={block:"M5,0 0,2.5 5,5z",classic:"M5,0 0,2.5 5,5 3.5,3 3.5,2z",diamond:"M2.5,0 5,2.5 2.5,5 0,2.5z",open:"M6,1 1,3.5 6,6",oval:"M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z"},g={};t.toString=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var x=function(i,n){if(n)for(var a in"string"==typeof i&&(i=x(i)),n)n[e](a)&&("xlink:"==a.substring(0,6)?i.setAttributeNS(p,a.substring(6),r(n[a])):i.setAttribute(a,r(n[a])));else(i=t._g.doc.createElementNS("http://www.w3.org/2000/svg",i)).style&&(i.style.webkitTapHighlightColor="rgba(0,0,0,0)");return i},v=function(e,n){var h="linear",u=e.id+n,f=.5,p=.5,d=e.node,g=e.paper,v=d.style,m=t._g.doc.getElementById(u);if(!m){if(n=(n=r(n).replace(t._radial_gradient,function(t,e,r){if(h="radial",e&&r){f=i(e);var n=2*((p=i(r))>.5)-1;l(f-.5,2)+l(p-.5,2)>.25&&(p=a.sqrt(.25-l(f-.5,2))*n+.5)&&.5!=p&&(p=p.toFixed(5)-1e-5*n)}return c})).split(/\s*\-\s*/),"linear"==h){var b=n.shift();if(b=-i(b),isNaN(b))return null;var _=[0,0,a.cos(t.rad(b)),a.sin(t.rad(b))],w=1/(s(o(_[2]),o(_[3]))||1);_[2]*=w,_[3]*=w,_[2]<0&&(_[0]=-_[2],_[2]=0),_[3]<0&&(_[1]=-_[3],_[3]=0)}var k=t._parseDots(n);if(!k)return null;if(u=u.replace(/[\(\)\s,\xb0#]/g,"_"),e.gradient&&u!=e.gradient.id&&(g.defs.removeChild(e.gradient),delete e.gradient),!e.gradient){m=x(h+"Gradient",{id:u}),e.gradient=m,x(m,"radial"==h?{fx:f,fy:p}:{x1:_[0],y1:_[1],x2:_[2],y2:_[3],gradientTransform:e.matrix.invert()}),g.defs.appendChild(m);for(var B=0,C=k.length;B<C;B++)m.appendChild(x("stop",{offset:k[B].offset?k[B].offset:B?"100%":"
vendor: 5,480 bytes, line 3225
32250%","stop-color":k[B].color||"#fff","stop-opacity":isFinite(k[B].opacity)?k[B].opacity:1}))}}return x(d,{fill:y(u),opacity:1,"fill-opacity":1}),v.fill=c,v.opacity=1,v.fillOpacity=1,1},y=function(t){if((e=document.documentMode)&&(9===e||10===e))return"url('#"+t+"')";var e,r=document.location;return"url('"+(r.protocol+"//"+r.host+r.pathname+r.search)+"#"+t+"')"},m=function(t){var e=t.getBBox(1);x(t.pattern,{patternTransform:t.matrix.invert()+" translate("+e.x+","+e.y+")"})},b=function(i,n,a){if("path"==i.type){for(var s,o,l,h,u,f=r(n).toLowerCase().split("-"),p=i.paper,v=a?"end":"start",y=i.node,m=i.attrs,b=m["stroke-width"],_=f.length,w="classic",k=3,B=3,C=5;_--;)switch(f[_]){case"block":case"classic":case"oval":case"diamond":case"open":case"none":w=f[_];break;case"wide":B=5;break;case"narrow":B=2;break;case"long":k=5;break;case"short":k=2}if("open"==w?(k+=2,B+=2,C+=2,l=1,h=a?4:1,u={fill:"none",stroke:m.stroke}):(h=l=k/2,u={fill:m.stroke,stroke:"none"}),i._.arrows?a?(i._.arrows.endPath&&g[i._.arrows.endPath]--,i._.arrows.endMarker&&g[i._.arrows.endMarker]--):(i._.arrows.startPath&&g[i._.arrows.startPath]--,i._.arrows.startMarker&&g[i._.arrows.startMarker]--):i._.arrows={},"none"!=w){var S="raphael-marker-"+w,T="raphael-marker-"+v+w+k+B+"-obj"+i.id;t._g.doc.getElementById(S)?g[S]++:(p.defs.appendChild(x(x("path"),{"stroke-linecap":"round",d:d[w],id:S})),g[S]=1);var A,M=t._g.doc.getElementById(T);M?(g[T]++,A=M.getElementsByTagName("use")[0]):(M=x(x("marker"),{id:T,markerHeight:B,markerWidth:k,orient:"auto",refX:h,refY:B/2}),A=x(x("use"),{"xlink:href":"#"+S,transform:(a?"rotate(180 "+k/2+" "+B/2+") ":c)+"scale("+k/C+","+B/C+")","stroke-width":(1/((k/C+B/C)/2)).toFixed(4)}),M.appendChild(A),p.defs.appendChild(M),g[T]=1),x(A,u);var E=l*("diamond"!=w&&"oval"!=w);a?(s=i._.arrows.startdx*b||0,o=t.getTotalLength(m.path)-E*b):(s=E*b,o=t.getTotalLength(m.path)-(i._.arrows.enddx*b||0)),(u={})["marker-"+v]="url(#"+T+")",(o||s)&&(u.d=t.getSubpath(m.path,s,o)),x(y,u),i._.arrows[v+"Path"]=S,i._.arrows[v+"Marker"]=T,i._.arrows[v+"dx"]=E,i._.arrows[v+"Type"]=w,i._.arrows[v+"String"]=n}else a?(s=i._.arrows.startdx*b||0,o=t.getTotalLength(m.path)-s):(s=0,o=t.getTotalLength(m.path)-(i._.arrows.enddx*b||0)),i._.arrows[v+"Path"]&&x(y,{d:t.getSubpath(m.path,s,o)}),delete i._.arrows[v+"Path"],delete i._.arrows[v+"Marker"],delete i._.arrows[v+"dx"],delete i._.arrows[v+"Type"],delete i._.arrows[v+"String"];for(u in g)if(g[e](u)&&!g[u]){var N=t._g.doc.getElementById(u);N&&N.parentNode.removeChild(N)}}},_={"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},w=function(t,e,i){if(e=_[r(e).toLowerCase()]){for(var n=t.attrs["stroke-width"]||"1",a={round:n,square:n,butt:0}[t.attrs["stroke-linecap"]||i["stroke-linecap"]]||0,s=[],o=e.length;o--;)s[o]=e[o]*n+(o%2?1:-1)*a;x(t.node,{"stroke-dasharray":s.join(",")})}else x(t.node,{"stroke-dasharray":"none"})},k=function(i,a){var l=i.node,u=i.attrs,f=l.style.visibility;for(var d in l.style.visibility="hidden",a)if(a[e](d)){if(!t._availableAttrs[e](d))continue;var g=a[d];switch(u[d]=g,d){case"blur":i.blur(g);break;case"title":var y=l.getElementsByTagName("title");if(y.length&&(y=y[0]))y.firstChild.nodeValue=g;else{y=x("title");var _=t._g.doc.createTextNode(g);y.appendChild(_),l.appendChild(y)}break;case"href":case"target":var k=l.parentNode;if("a"!=k.tagName.toLowerCase()){var C=x("a");k.insertBefore(C,l),C.appendChild(l),k=C}"target"==d?k.setAttributeNS(p,"show","blank"==g?"new":g):k.setAttributeNS(p,d,g);break;case"cursor":l.style.cursor=g;break;case"transform":i.transform(g);break;case"arrow-start":b(i,g);break;case"arrow-end":b(i,g,1);break;case"clip-rect":var S=r(g).split(h);if(4==S.length){i.clip&&i.clip.parentNode.parentNode.removeChild(i.clip.parentNode);var T=x("clipPath"),A=x("rect");T.id=t.createUUID(),x(A,{x:S[0],y:S[1],width:S[2],height:S[3]}),T.appendChild(A),i.paper.defs.appendChild(T),x(l,{"clip-path":"url(#"+T.id+")"}),i.clip=A}if(!g){var M=l.getAttribute("clip-path");if(M){var E=t._g.doc.getElementById(M.replace(/(^url\(#|\)$)/g,c));E&&E.parentNode.removeChild(E),x(l,{"clip-path":c}),delete i.clip}}break;case"path":"path"==i.type&&(x(l,{d:g?u.path=t._pathToAbsolute(g):"M0,0"}),i._.dirty=1,i._.arrows&&("startString"in i._.arrows&&b(i,i._.arrows.startString),"endString"in i._.arrows&&b(i,i._.arrows.endString,1)));break;case"width":if(l.setAttribute(d,g),i._.dirty=1,!u.fx)break;d="x",g=u.x;case"x":u.fx&&(g=-u.x-(u.width||0));case"rx":if("rx"==d&&"rect"==i.type)break;case"cx":l.setAttribute(d,g),i.pattern&&m(i),i._.dirty=1;break;case"height":if(l.setAttribute(d,g),i._.dirty=1,!u.fy)break;d="y",g=u.y;case"y":u.fy&&(g=-u.y-(u.height||0));case"ry":if("ry"==d&&"rect"==i.type)break;case"cy":l.setAttribute(d,g),i.pattern&&m(i),i._.dirty=1;break;case"r":"rect"==i.type?x(l,{rx:g,ry:g}):l.setAttribute(d,g),i._.dirty=1;break;case"src":"image"==i.type&&l.setAttributeNS(p,"href",g);break;case"stroke-width":1==i._.sx&&1==i._.sy||(g/=s(o(i._.sx),o(i._.sy))||1),l.setAttribute(d,g),u["stroke-dasharray"]&&w(i,u["stroke-dasharray"],a),i._.arrows&&("startString"in i._.arrows&&b(i,i._.arrows.startString),"endString"in i._.arrows&&b(i,i._.arrows.endString,1));break;case"stroke-dasharray":w(i,g,a);break;case"fill":var N=r(g).match(t._ISURL);if(N){T=x("pattern");var L=x("image");T.id=t.createUUID(),x(T,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1}),x(L,{x:0,y:0,"xlink:href":N[1]}
vendor: 5,679 bytes, line 3225
3225),T.appendChild(L),function(e){t._preload(N[1],function(){var t=this.offsetWidth,r=this.offsetHeight;x(e,{width:t,height:r}),x(L,{width:t,height:r})})}(T),i.paper.defs.appendChild(T),x(l,{fill:"url(#"+T.id+")"}),i.pattern=T,i.pattern&&m(i);break}var P=t.getRGB(g);if(P.error){if(("circle"==i.type||"ellipse"==i.type||"r"!=r(g).charAt())&&v(i,g)){if("opacity"in u||"fill-opacity"in u){var z=t._g.doc.getElementById(l.getAttribute("fill").replace(/^url\(#|\)$/g,c));if(z){var F=z.getElementsByTagName("stop");x(F[F.length-1],{"stop-opacity":("opacity"in u?u.opacity:1)*("fill-opacity"in u?u["fill-opacity"]:1)})}}u.gradient=g,u.fill="none";break}}else delete a.gradient,delete u.gradient,!t.is(u.opacity,"undefined")&&t.is(a.opacity,"undefined")&&x(l,{opacity:u.opacity}),!t.is(u["fill-opacity"],"undefined")&&t.is(a["fill-opacity"],"undefined")&&x(l,{"fill-opacity":u["fill-opacity"]});P[e]("opacity")&&x(l,{"fill-opacity":P.opacity>1?P.opacity/100:P.opacity});case"stroke":P=t.getRGB(g),l.setAttribute(d,P.hex),"stroke"==d&&P[e]("opacity")&&x(l,{"stroke-opacity":P.opacity>1?P.opacity/100:P.opacity}),"stroke"==d&&i._.arrows&&("startString"in i._.arrows&&b(i,i._.arrows.startString),"endString"in i._.arrows&&b(i,i._.arrows.endString,1));break;case"gradient":("circle"==i.type||"ellipse"==i.type||"r"!=r(g).charAt())&&v(i,g);break;case"opacity":u.gradient&&!u[e]("stroke-opacity")&&x(l,{"stroke-opacity":g>1?g/100:g});case"fill-opacity":if(u.gradient){(z=t._g.doc.getElementById(l.getAttribute("fill").replace(/^url\(#|\)$/g,c)))&&(F=z.getElementsByTagName("stop"),x(F[F.length-1],{"stop-opacity":g}));break}default:"font-size"==d&&(g=n(g,10)+"px");var R=d.replace(/(\-.)/g,function(t){return t.substring(1).toUpperCase()});l.style[R]=g,i._.dirty=1,l.setAttribute(d,g)}}B(i,a),l.style.visibility=f},B=function(i,a){if("text"==i.type&&(a[e]("text")||a[e]("font")||a[e]("font-size")||a[e]("x")||a[e]("y"))){var s=i.attrs,o=i.node,l=o.firstChild?n(t._g.doc.defaultView.getComputedStyle(o.firstChild,c).getPropertyValue("font-size"),10):10;if(a[e]("text")){for(s.text=a.text;o.firstChild;)o.removeChild(o.firstChild);for(var h,u=r(a.text).split("\n"),f=[],p=0,d=u.length;p<d;p++)h=x("tspan"),p&&x(h,{dy:1.2*l,x:s.x}),h.appendChild(t._g.doc.createTextNode(u[p])),o.appendChild(h),f[p]=h}else for(p=0,d=(f=o.getElementsByTagName("tspan")).length;p<d;p++)p?x(f[p],{dy:1.2*l,x:s.x}):x(f[0],{dy:0});x(o,{x:s.x,y:s.y}),i._.dirty=1;var g=i._getBBox(),v=s.y-(g.y+g.height/2);v&&t.is(v,"finite")&&x(f[0],{dy:v})}},C=function(t){return t.parentNode&&"a"===t.parentNode.tagName.toLowerCase()?t.parentNode:t},S=function(e,r){this[0]=this.node=e,e.raphael=!0,this.id=("0000"+(Math.random()*Math.pow(36,5)<<0).toString(36)).slice(-5),e.raphaelid=this.id,this.matrix=t.matrix(),this.realPath=null,this.paper=r,this.attrs=this.attrs||{},this._={transform:[],sx:1,sy:1,deg:0,dx:0,dy:0,dirty:1},!r.bottom&&(r.bottom=this),this.prev=r.top,r.top&&(r.top.next=this),r.top=this,this.next=null},T=t.el;S.prototype=T,T.constructor=S,t._engine.path=function(t,e){var r=x("path");e.canvas&&e.canvas.appendChild(r);var i=new S(r,e);return i.type="path",k(i,{fill:"none",stroke:"#000",path:t}),i},T.rotate=function(t,e,n){if(this.removed)return this;if((t=r(t).split(h)).length-1&&(e=i(t[1]),n=i(t[2])),t=i(t[0]),null==n&&(e=n),null==e||null==n){var a=this.getBBox(1);e=a.x+a.width/2,n=a.y+a.height/2}return this.transform(this._.transform.concat([["r",t,e,n]])),this},T.scale=function(t,e,n,a){if(this.removed)return this;if((t=r(t).split(h)).length-1&&(e=i(t[1]),n=i(t[2]),a=i(t[3])),t=i(t[0]),null==e&&(e=t),null==a&&(n=a),null==n||null==a)var s=this.getBBox(1);return n=null==n?s.x+s.width/2:n,a=null==a?s.y+s.height/2:a,this.transform(this._.transform.concat([["s",t,e,n,a]])),this},T.translate=function(t,e){return this.removed?this:((t=r(t).split(h)).length-1&&(e=i(t[1])),t=i(t[0])||0,e=+e||0,this.transform(this._.transform.concat([["t",t,e]])),this)},T.transform=function(r){var i=this._;if(null==r)return i.transform;if(t._extractTransform(this,r),this.clip&&x(this.clip,{transform:this.matrix.invert()}),this.pattern&&m(this),this.node&&x(this.node,{transform:this.matrix}),1!=i.sx||1!=i.sy){var n=this.attrs[e]("stroke-width")?this.attrs["stroke-width"]:1;this.attr({"stroke-width":n})}return this},T.hide=function(){return this.removed||(this.node.style.display="none"),this},T.show=function(){return this.removed||(this.node.style.display=""),this},T.remove=function(){var e=C(this.node);if(!this.removed&&e.parentNode){var r=this.paper;for(var i in r.__set__&&r.__set__.exclude(this),u.unbind("raphael.*.*."+this.id),this.gradient&&r.defs.removeChild(this.gradient),t._tear(this,r),e.parentNode.removeChild(e),this.removeData(),this)this[i]="function"==typeof this[i]?t._removedFactory(i):null;this.removed=!0}},T._getBBox=function(){if("none"==this.node.style.display){this.show();var t=!0}var e,r=!1;this.paper.canvas.parentElement?e=this.paper.canvas.parentElement.style:this.paper.canvas.parentNode&&(e=this.paper.canvas.parentNode.style),e&&"none"==e.display&&(r=!0,e.display="");var i={};try{i=this.node.getBBox()}catch(t){i={x:this.node.clientLeft,y:this.node.clientTop,width:this.node.clientWidth,height:this.node.clientHeight}}finally{i=i||{},r&&(e.display="none")}return t&&this.hide(),i},T.attr=function(r,i){if(this.removed)return this;if(null==r){var n={};for(var a in this.attrs)this.attrs[e](a)&&(n[a]=this.attrs[a]);return n.gradient&&"none"==n.fill&&(n.fill=n.gradient)&&delete n.gradient,n.transform=this._.transform,n}if(null==i&&t.is(r,"string")){if("fill"==r&&"none"==this.attrs.fill&&this.attrs.gradient)return this.attrs.gradient;if("transform"==r)return this._.transform;
vendor: 5,760 bytes, line 3225
3225for(var s=r.split(h),o={},l=0,c=s.length;l<c;l++)(r=s[l])in this.attrs?o[r]=this.attrs[r]:t.is(this.paper.customAttributes[r],"function")?o[r]=this.paper.customAttributes[r].def:o[r]=t._availableAttrs[r];return c-1?o:o[s[0]]}if(null==i&&t.is(r,"array")){for(o={},l=0,c=r.length;l<c;l++)o[r[l]]=this.attr(r[l]);return o}if(null!=i){var f={};f[r]=i}else null!=r&&t.is(r,"object")&&(f=r);for(var p in f)u("raphael.attr."+p+"."+this.id,this,f[p]);for(p in this.paper.customAttributes)if(this.paper.customAttributes[e](p)&&f[e](p)&&t.is(this.paper.customAttributes[p],"function")){var d=this.paper.customAttributes[p].apply(this,[].concat(f[p]));for(var g in this.attrs[p]=f[p],d)d[e](g)&&(f[g]=d[g])}return k(this,f),this},T.toFront=function(){if(this.removed)return this;var e=C(this.node);e.parentNode.appendChild(e);var r=this.paper;return r.top!=this&&t._tofront(this,r),this},T.toBack=function(){if(this.removed)return this;var e=C(this.node),r=e.parentNode;r.insertBefore(e,r.firstChild),t._toback(this,this.paper);this.paper;return this},T.insertAfter=function(e){if(this.removed||!e)return this;var r=C(this.node),i=C(e.node||e[e.length-1].node);return i.nextSibling?i.parentNode.insertBefore(r,i.nextSibling):i.parentNode.appendChild(r),t._insertafter(this,e,this.paper),this},T.insertBefore=function(e){if(this.removed||!e)return this;var r=C(this.node),i=C(e.node||e[0].node);return i.parentNode.insertBefore(r,i),t._insertbefore(this,e,this.paper),this},T.blur=function(e){var r=this;if(0!=+e){var i=x("filter"),n=x("feGaussianBlur");r.attrs.blur=e,i.id=t.createUUID(),x(n,{stdDeviation:+e||1.5}),i.appendChild(n),r.paper.defs.appendChild(i),r._blur=i,x(r.node,{filter:"url(#"+i.id+")"})}else r._blur&&(r._blur.parentNode.removeChild(r._blur),delete r._blur,delete r.attrs.blur),r.node.removeAttribute("filter");return r},t._engine.circle=function(t,e,r,i){var n=x("circle");t.canvas&&t.canvas.appendChild(n);var a=new S(n,t);return a.attrs={cx:e,cy:r,r:i,fill:"none",stroke:"#000"},a.type="circle",x(n,a.attrs),a},t._engine.rect=function(t,e,r,i,n,a){var s=x("rect");t.canvas&&t.canvas.appendChild(s);var o=new S(s,t);return o.attrs={x:e,y:r,width:i,height:n,rx:a||0,ry:a||0,fill:"none",stroke:"#000"},o.type="rect",x(s,o.attrs),o},t._engine.ellipse=function(t,e,r,i,n){var a=x("ellipse");t.canvas&&t.canvas.appendChild(a);var s=new S(a,t);return s.attrs={cx:e,cy:r,rx:i,ry:n,fill:"none",stroke:"#000"},s.type="ellipse",x(a,s.attrs),s},t._engine.image=function(t,e,r,i,n,a){var s=x("image");x(s,{x:r,y:i,width:n,height:a,preserveAspectRatio:"none"}),s.setAttributeNS(p,"href",e),t.canvas&&t.canvas.appendChild(s);var o=new S(s,t);return o.attrs={x:r,y:i,width:n,height:a,src:e},o.type="image",o},t._engine.text=function(e,r,i,n){var a=x("text");e.canvas&&e.canvas.appendChild(a);var s=new S(a,e);return s.attrs={x:r,y:i,"text-anchor":"middle",text:n,"font-family":t._availableAttrs["font-family"],"font-size":t._availableAttrs["font-size"],stroke:"none",fill:"#000"},s.type="text",k(s,s.attrs),s},t._engine.setSize=function(t,e){return this.width=t||this.width,this.height=e||this.height,this.canvas.setAttribute("width",this.width),this.canvas.setAttribute("height",this.height),this._viewBox&&this.setViewBox.apply(this,this._viewBox),this},t._engine.create=function(){var e=t._getContainer.apply(0,arguments),r=e&&e.container;if(!r)throw new Error("SVG container not found.");var i,n=e.x,a=e.y,s=e.width,o=e.height,l=x("svg"),h="overflow:hidden;";return n=n||0,a=a||0,x(l,{height:o=o||342,version:1.1,width:s=s||512,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}),1==r?(l.style.cssText=h+"position:absolute;left:"+n+"px;top:"+a+"px",t._g.doc.body.appendChild(l),i=1):(l.style.cssText=h+"position:relative",r.firstChild?r.insertBefore(l,r.firstChild):r.appendChild(l)),(r=new t._Paper).width=s,r.height=o,r.canvas=l,r.clear(),r._left=r._top=0,i&&(r.renderfix=function(){}),r.renderfix(),r},t._engine.setViewBox=function(t,e,r,i,n){u("raphael.setViewBox",this,this._viewBox,[t,e,r,i,n]);var a,o,l=this.getSize(),h=s(r/l.width,i/l.height),c=this.top,p=n?"xMidYMid meet":"xMinYMin";for(null==t?(this._vbSize&&(h=1),delete this._vbSize,a="0 0 "+this.width+f+this.height):(this._vbSize=h,a=t+f+e+f+r+f+i),x(this.canvas,{viewBox:a,preserveAspectRatio:p});h&&c;)o="stroke-width"in c.attrs?c.attrs["stroke-width"]:1,c.attr({"stroke-width":o}),c._.dirty=1,c._.dirtyT=1,c=c.prev;return this._viewBox=[t,e,r,i,!!n],this},t.prototype.renderfix=function(){var t,e=this.canvas,r=e.style;try{t=e.getScreenCTM()||e.createSVGMatrix()}catch(r){t=e.createSVGMatrix()}var i=-t.e%1,n=-t.f%1;(i||n)&&(i&&(this._left=(this._left+i)%1,r.left=this._left+"px"),n&&(this._top=(this._top+n)%1,r.top=this._top+"px"))},t.prototype.clear=function(){t.eve("raphael.clear",this);for(var e=this.canvas;e.firstChild;)e.removeChild(e.firstChild);this.bottom=this.top=null,(this.desc=x("desc")).appendChild(t._g.doc.createTextNode("Created with Raphaël "+t.version)),e.appendChild(this.desc),e.appendChild(this.defs=x("defs"))},t.prototype.remove=function(){for(var e in u("raphael.remove",this),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this)this[e]="function"==typeof this[e]?t._removedFactory(e):null};var A=t.st;for(var M in T)T[e](M)&&!A[e](M)&&(A[M]=function(t){return function(){var e=arguments;return this.forEach(function(r){r[t].apply(r,e)})}}(M))}}.apply(e,i))||(t.exports=n)},function(t,e,r){var i,n;i=[r(0)],void 0===(n=function(t){if(!t||t.vml){var e="hasOwnProperty",r=String,i=parseFloat,n=Math,a=n.round,s=n.max,o=n.min,l=n.abs,h=/[, ]+/,u=t.eve,c=" ",f="",p={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},d=/([clmz]),?([^clmz]*)/gi,g=/ progid:\S+Blur\([^\)]+\)/g,x=/-?[^,\s-]+/g,v="position:absolute;
vendor: 8,097 bytes, line 3225
3225left:0;top:0;width:1px;height:1px;behavior:url(#default#VML)",y=21600,m={path:1,rect:1,image:1},b={circle:1,ellipse:1},_=function(e,r,i){var n=t.matrix();return n.rotate(-e,.5,.5),{dx:n.x(r,i),dy:n.y(r,i)}},w=function(t,e,r,i,n,a){var s=t._,o=t.matrix,h=s.fillpos,u=t.node,f=u.style,p=1,d="",g=y/e,x=y/r;if(f.visibility="hidden",e&&r){if(u.coordsize=l(g)+c+l(x),f.rotation=a*(e*r<0?-1:1),a){var v=_(a,i,n);i=v.dx,n=v.dy}if(e<0&&(d+="x"),r<0&&(d+=" y")&&(p=-1),f.flip=d,u.coordorigin=i*-g+c+n*-x,h||s.fillsize){var m=u.getElementsByTagName("fill");m=m&&m[0],u.removeChild(m),h&&(v=_(a,o.x(h[0],h[1]),o.y(h[0],h[1])),m.position=v.dx*p+c+v.dy*p),s.fillsize&&(m.size=s.fillsize[0]*l(e)+c+s.fillsize[1]*l(r)),u.appendChild(m)}f.visibility="visible"}};t.toString=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version};var k,B=function(t,e,i){for(var n=r(e).toLowerCase().split("-"),a=i?"end":"start",s=n.length,o="classic",l="medium",h="medium";s--;)switch(n[s]){case"block":case"classic":case"oval":case"diamond":case"open":case"none":o=n[s];break;case"wide":case"narrow":h=n[s];break;case"long":case"short":l=n[s]}var u=t.node.getElementsByTagName("stroke")[0];u[a+"arrow"]=o,u[a+"arrowlength"]=l,u[a+"arrowwidth"]=h},C=function(n,l){n.attrs=n.attrs||{};var u=n.node,g=n.attrs,v=u.style,_=m[n.type]&&(l.x!=g.x||l.y!=g.y||l.width!=g.width||l.height!=g.height||l.cx!=g.cx||l.cy!=g.cy||l.rx!=g.rx||l.ry!=g.ry||l.r!=g.r),C=b[n.type]&&(g.cx!=l.cx||g.cy!=l.cy||g.r!=l.r||g.rx!=l.rx||g.ry!=l.ry),T=n;for(var A in l)l[e](A)&&(g[A]=l[A]);if(_&&(g.path=t._getPath[n.type](n),n._.dirty=1),l.href&&(u.href=l.href),l.title&&(u.title=l.title),l.target&&(u.target=l.target),l.cursor&&(v.cursor=l.cursor),"blur"in l&&n.blur(l.blur),(l.path&&"path"==n.type||_)&&(u.path=function(e){var i=/[ahqstv]/gi,n=t._pathToAbsolute;if(r(e).match(i)&&(n=t._path2curve),i=/[clmz]/g,n==t._pathToAbsolute&&!r(e).match(i)){var s=r(e).replace(d,function(t,e,r){var i=[],n="m"==e.toLowerCase(),s=p[e];return r.replace(x,function(t){n&&2==i.length&&(s+=i+p["m"==e?"l":"L"],i=[]),i.push(a(t*y))}),s+i});return s}var o,l,h=n(e);s=[];for(var u=0,g=h.length;u<g;u++){o=h[u],"z"==(l=h[u][0].toLowerCase())&&(l="x");for(var v=1,m=o.length;v<m;v++)l+=a(o[v]*y)+(v!=m-1?",":f);s.push(l)}return s.join(c)}(~r(g.path).toLowerCase().indexOf("r")?t._pathToAbsolute(g.path):g.path),n._.dirty=1,"image"==n.type&&(n._.fillpos=[g.x,g.y],n._.fillsize=[g.width,g.height],w(n,1,1,0,0,0))),"transform"in l&&n.transform(l.transform),C){var M=+g.cx,E=+g.cy,N=+g.rx||+g.r||0,L=+g.ry||+g.r||0;u.path=t.format("ar{0},{1},{2},{3},{4},{1},{4},{1}x",a((M-N)*y),a((E-L)*y),a((M+N)*y),a((E+L)*y),a(M*y)),n._.dirty=1}if("clip-rect"in l){var P=r(l["clip-rect"]).split(h);if(4==P.length){P[2]=+P[2]+ +P[0],P[3]=+P[3]+ +P[1];var z=u.clipRect||t._g.doc.createElement("div"),F=z.style;F.clip=t.format("rect({1}px {2}px {3}px {0}px)",P),u.clipRect||(F.position="absolute",F.top=0,F.left=0,F.width=n.paper.width+"px",F.height=n.paper.height+"px",u.parentNode.insertBefore(z,u),z.appendChild(u),u.clipRect=z)}l["clip-rect"]||u.clipRect&&(u.clipRect.style.clip="auto")}if(n.textpath){var R=n.textpath.style;l.font&&(R.font=l.font),l["font-family"]&&(R.fontFamily='"'+l["font-family"].split(",")[0].replace(/^['"]+|['"]+$/g,f)+'"'),l["font-size"]&&(R.fontSize=l["font-size"]),l["font-weight"]&&(R.fontWeight=l["font-weight"]),l["font-style"]&&(R.fontStyle=l["font-style"])}if("arrow-start"in l&&B(T,l["arrow-start"]),"arrow-end"in l&&B(T,l["arrow-end"],1),null!=l.opacity||null!=l.fill||null!=l.src||null!=l.stroke||null!=l["stroke-width"]||null!=l["stroke-opacity"]||null!=l["fill-opacity"]||null!=l["stroke-dasharray"]||null!=l["stroke-miterlimit"]||null!=l["stroke-linejoin"]||null!=l["stroke-linecap"]){var j=u.getElementsByTagName("fill");if(!(j=j&&j[0])&&(j=k("fill")),"image"==n.type&&l.src&&(j.src=l.src),l.fill&&(j.on=!0),null!=j.on&&"none"!=l.fill&&null!==l.fill||(j.on=!1),j.on&&l.fill){var I=r(l.fill).match(t._ISURL);if(I){j.parentNode==u&&u.removeChild(j),j.rotate=!0,j.src=I[1],j.type="tile";var D=n.getBBox(1);j.position=D.x+c+D.y,n._.fillpos=[D.x,D.y],t._preload(I[1],function(){n._.fillsize=[this.offsetWidth,this.offsetHeight]})}else j.color=t.getRGB(l.fill).hex,j.src=f,j.type="solid",t.getRGB(l.fill).error&&(T.type in{circle:1,ellipse:1}||"r"!=r(l.fill).charAt())&&S(T,l.fill,j)&&(g.fill="none",g.gradient=l.fill,j.rotate=!1)}if("fill-opacity"in l||"opacity"in l){var q=((+g["fill-opacity"]+1||2)-1)*((+g.opacity+1||2)-1)*((+t.getRGB(l.fill).o+1||2)-1);q=o(s(q,0),1),j.opacity=q,j.src&&(j.color="none")}u.appendChild(j);var O=u.getElementsByTagName("stroke")&&u.getElementsByTagName("stroke")[0],V=!1;!O&&(V=O=k("stroke")),(l.stroke&&"none"!=l.stroke||l["stroke-width"]||null!=l["stroke-opacity"]||l["stroke-dasharray"]||l["stroke-miterlimit"]||l["stroke-linejoin"]||l["stroke-linecap"])&&(O.on=!0),("none"==l.stroke||null===l.stroke||null==O.on||0==l.stroke||0==l["stroke-width"])&&(O.on=!1);var W=t.getRGB(l.stroke);O.on&&l.stroke&&(O.color=W.hex),q=((+g["stroke-opacity"]+1||2)-1)*((+g.opacity+1||2)-1)*((+W.o+1||2)-1);var Y=.75*(i(l["stroke-width"])||1);if(q=o(s(q,0),1),null==l["stroke-width"]&&(Y=g["stroke-width"]),l["stroke-width"]&&(O.weight=Y),Y&&Y<1&&(q*=Y)&&(O.weight=1),O.opacity=q,l["stroke-linejoin"]&&(O.joinstyle=l["stroke-linejoin"]||"miter"),O.miterlimit=l["stroke-miterlimit"]||8,l["stroke-linecap"]&&(O.endcap="butt"==l["stroke-linecap"]?"flat":"square"==l["stroke-linecap"]?"square":"round"),"stroke-dasharray"in l){var G={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};O.dashstyle=G[e](l["stroke-dasharray"])?G[l["stroke-dasharray"]]:f}V&&u.appendChild(O)}if("text"==T.type){T.paper.canvas.style.display=f;var H=T.paper.span,X=g.font&&g.font.match(/\d+(?:\.\d*)?(?=px)/);v=H.style,g.font&&(v.font=g.font),g["font-family"]&&(v.fontFamily=g["font-family"]),g["font-weight"]&&(v.fontWeight=g["font-weight"]),g["font-style"]&&(v.fontStyle=g["font-style"]),X=i(g["font-size"]||X&&X[0])||10,v.fontSize=100*X+"px",T.textpath.string&&(H.innerHTML=r(T.textpath.string).replace(/</g,"&#60;").replace(/&/g,"&#38;").replace(/\n/g,"<br>"));var U=H.getBoundingClientRect();T.W=g.w=(U.right-U.left)/100,T.H=g.h=(U.bottom-U.top)/100,T.X=g.x,T.Y=g.y+T.H/2,("x"in l||"y"in l)&&(T.path.v=t.format("m{0},{1}l{2},{1}",a(g.x*y),a(g.y*y),a(g.x*y)+1));for(var $=["x","y","text","font","font-family","font-weight","font-style","font-size"],Z=0,Q=$.length;Z<Q;Z++)if($[Z]in l){T._.dirty=1;break}switch(g["text-anchor"]){case"start":T.textpath.style["v-text-align"]="left",T.bbx=T.W/2;break;case"end":T.textpath.style["v-text-align"]="right",T.bbx=-T.W/2;break;default:T.textpath.style["v-text-align"]="center",T.bbx=0}T.textpath.style["v-text-kern"]=!0}},S=function(e,a,s){e.attrs=e.attrs||{};e.attrs;var o=Math.pow,l="linear",h=".5 .5";if(e.attrs.gradient=a,a=(a=r(a).replace(t._radial_gradient,function(t,e,r){return l="radial",e&&r&&(e=i(e),r=i(r),o(e-.5,2)+o(r-.5,2)>.25&&(r=n.sqrt(.25-o(e-.5,2))*(2*(r>.5)-1)+.5),h=e+c+r),f})).split(/\s*\-\s*/),"linear"==l){var u=a.shift();if(u=-i(u),isNaN(u))return null}var p=t._parseDots(a);if(!p)return null;if(e=e.shape||e.node,p.length){e.removeChild(s),s.on=!0,s.method="none",s.color=p[0].color,s.color2=p[p.length-1].color;for(var d=[],g=0,x=p.length;g<x;g++)p[g].offset&&d.push(p[g].offset+c+p[g].color);s.colors=d.length?d.join():"0% "+s.color,"radial"==l?(s.type="gradientTitle",s.focus="100%",s.focussize="0 0",s.focusposition=h,s.angle=0):(s.type="gradient",s.angle=(270-u)%360),e.appendChild(s)}return 1},T=function(e,r){this[0]=this.node=e,e.raphael=!0,this.id=t._oid++,e.raphaelid=this.id,this.X=0,this.Y=0,this.attrs={},this.paper=r,this.matrix=t.matrix(),this._={transform:[],sx:1,sy:1,dx:0,dy:0,deg:0,dirty:1,dirtyT:1},!r.bottom&&(r.bottom=this),this.prev=r.top,r.top&&(r.top.next=this),r.top=this,this.next=null},A=t.el;T.prototype=A,A.constructor=T,A.transform=function(e){if(null==e)return this._.transform;
vendor: 9,215 bytes, line 3225
3225var i,n=this.paper._viewBoxShift,a=n?"s"+[n.scale,n.scale]+"-1-1t"+[n.dx,n.dy]:f;n&&(i=e=r(e).replace(/\.{3}|\u2026/g,this._.transform||f)),t._extractTransform(this,a+e);var s,o=this.matrix.clone(),l=this.skew,h=this.node,u=~r(this.attrs.fill).indexOf("-"),p=!r(this.attrs.fill).indexOf("url(");if(o.translate(1,1),p||u||"image"==this.type)if(l.matrix="1 0 0 1",l.offset="0 0",s=o.split(),u&&s.noRotation||!s.isSimple){h.style.filter=o.toFilter();var d=this.getBBox(),g=this.getBBox(1),x=d.x-g.x,v=d.y-g.y;h.coordorigin=x*-y+c+v*-y,w(this,1,1,x,v,0)}else h.style.filter=f,w(this,s.scalex,s.scaley,s.dx,s.dy,s.rotate);else h.style.filter=f,l.matrix=r(o),l.offset=o.offset();return null!==i&&(this._.transform=i,t._extractTransform(this,i)),this},A.rotate=function(t,e,n){if(this.removed)return this;if(null!=t){if((t=r(t).split(h)).length-1&&(e=i(t[1]),n=i(t[2])),t=i(t[0]),null==n&&(e=n),null==e||null==n){var a=this.getBBox(1);e=a.x+a.width/2,n=a.y+a.height/2}return this._.dirtyT=1,this.transform(this._.transform.concat([["r",t,e,n]])),this}},A.translate=function(t,e){return this.removed?this:((t=r(t).split(h)).length-1&&(e=i(t[1])),t=i(t[0])||0,e=+e||0,this._.bbox&&(this._.bbox.x+=t,this._.bbox.y+=e),this.transform(this._.transform.concat([["t",t,e]])),this)},A.scale=function(t,e,n,a){if(this.removed)return this;if((t=r(t).split(h)).length-1&&(e=i(t[1]),n=i(t[2]),a=i(t[3]),isNaN(n)&&(n=null),isNaN(a)&&(a=null)),t=i(t[0]),null==e&&(e=t),null==a&&(n=a),null==n||null==a)var s=this.getBBox(1);return n=null==n?s.x+s.width/2:n,a=null==a?s.y+s.height/2:a,this.transform(this._.transform.concat([["s",t,e,n,a]])),this._.dirtyT=1,this},A.hide=function(){return!this.removed&&(this.node.style.display="none"),this},A.show=function(){return!this.removed&&(this.node.style.display=f),this},A.auxGetBBox=t.el.getBBox,A.getBBox=function(){var t=this.auxGetBBox();if(this.paper&&this.paper._viewBoxShift){var e={},r=1/this.paper._viewBoxShift.scale;return e.x=t.x-this.paper._viewBoxShift.dx,e.x*=r,e.y=t.y-this.paper._viewBoxShift.dy,e.y*=r,e.width=t.width*r,e.height=t.height*r,e.x2=e.x+e.width,e.y2=e.y+e.height,e}return t},A._getBBox=function(){return this.removed?{}:{x:this.X+(this.bbx||0)-this.W/2,y:this.Y-this.H,width:this.W,height:this.H}},A.remove=function(){if(!this.removed&&this.node.parentNode){for(var e in this.paper.__set__&&this.paper.__set__.exclude(this),t.eve.unbind("raphael.*.*."+this.id),t._tear(this,this.paper),this.node.parentNode.removeChild(this.node),this.shape&&this.shape.parentNode.removeChild(this.shape),this)this[e]="function"==typeof this[e]?t._removedFactory(e):null;this.removed=!0}},A.attr=function(r,i){if(this.removed)return this;if(null==r){var n={};for(var a in this.attrs)this.attrs[e](a)&&(n[a]=this.attrs[a]);return n.gradient&&"none"==n.fill&&(n.fill=n.gradient)&&delete n.gradient,n.transform=this._.transform,n}if(null==i&&t.is(r,"string")){if("fill"==r&&"none"==this.attrs.fill&&this.attrs.gradient)return this.attrs.gradient;for(var s=r.split(h),o={},l=0,c=s.length;l<c;l++)(r=s[l])in this.attrs?o[r]=this.attrs[r]:t.is(this.paper.customAttributes[r],"function")?o[r]=this.paper.customAttributes[r].def:o[r]=t._availableAttrs[r];return c-1?o:o[s[0]]}if(this.attrs&&null==i&&t.is(r,"array")){for(o={},l=0,c=r.length;l<c;l++)o[r[l]]=this.attr(r[l]);return o}var f;for(var p in null!=i&&((f={})[r]=i),null==i&&t.is(r,"object")&&(f=r),f)u("raphael.attr."+p+"."+this.id,this,f[p]);if(f){for(p in this.paper.customAttributes)if(this.paper.customAttributes[e](p)&&f[e](p)&&t.is(this.paper.customAttributes[p],"function")){var d=this.paper.customAttributes[p].apply(this,[].concat(f[p]));for(var g in this.attrs[p]=f[p],d)d[e](g)&&(f[g]=d[g])}f.text&&"text"==this.type&&(this.textpath.string=f.text),C(this,f)}return this},A.toFront=function(){return!this.removed&&this.node.parentNode.appendChild(this.node),this.paper&&this.paper.top!=this&&t._tofront(this,this.paper),this},A.toBack=function(){return this.removed?this:(this.node.parentNode.firstChild!=this.node&&(this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild),t._toback(this,this.paper)),this)},A.insertAfter=function(e){return this.removed?this:(e.constructor==t.st.constructor&&(e=e[e.length-1]),e.node.nextSibling?e.node.parentNode.insertBefore(this.node,e.node.nextSibling):e.node.parentNode.appendChild(this.node),t._insertafter(this,e,this.paper),this)},A.insertBefore=function(e){return this.removed?this:(e.constructor==t.st.constructor&&(e=e[0]),e.node.parentNode.insertBefore(this.node,e.node),t._insertbefore(this,e,this.paper),this)},A.blur=function(e){var r=this.node.runtimeStyle,i=r.filter;return i=i.replace(g,f),0!=+e?(this.attrs.blur=e,r.filter=i+c+" progid:DXImageTransform.Microsoft.Blur(pixelradius="+(+e||1.5)+")",r.margin=t.format("-{0}px 0 0 -{0}px",a(+e||1.5))):(r.filter=i,r.margin=0,delete this.attrs.blur),this},t._engine.path=function(t,e){var r=k("shape");r.style.cssText=v,r.coordsize=y+c+y,r.coordorigin=e.coordorigin;var i=new T(r,e),n={fill:"none",stroke:"#000"};t&&(n.path=t),i.type="path",i.path=[],i.Path=f,C(i,n),e.canvas&&e.canvas.appendChild(r);var a=k("skew");return a.on=!0,r.appendChild(a),i.skew=a,i.transform(f),i},t._engine.rect=function(e,r,i,n,a,s){var o=t._rectPath(r,i,n,a,s),l=e.path(o),h=l.attrs;return l.X=h.x=r,l.Y=h.y=i,l.W=h.width=n,l.H=h.height=a,h.r=s,h.path=o,l.type="rect",l},t._engine.ellipse=function(t,e,r,i,n){var a=t.path();a.attrs;return a.X=e-i,a.Y=r-n,a.W=2*i,a.H=2*n,a.type="ellipse",C(a,{cx:e,cy:r,rx:i,ry:n}),a},t._engine.circle=function(t,e,r,i){var n=t.path();n.attrs;return n.X=e-i,n.Y=r-i,n.W=n.H=2*i,n.type="circle",C(n,{cx:e,cy:r,r:i}),n},t._engine.image=function(e,r,i,n,a,s){var o=t._rectPath(i,n,a,s),l=e.path(o).attr({stroke:"none"}),h=l.attrs,u=l.node,c=u.getElementsByTagName("fill")[0];return h.src=r,l.X=h.x=i,l.Y=h.y=n,l.W=h.width=a,l.H=h.height=s,h.path=o,l.type="image",c.parentNode==u&&u.removeChild(c),c.rotate=!0,c.src=r,c.type="tile",l._.fillpos=[i,n],l._.fillsize=[a,s],u.appendChild(c),w(l,1,1,0,0,0),l},t._engine.text=function(e,i,n,s){var o=k("shape"),l=k("path"),h=k("textpath");i=i||0,n=n||0,s=s||"",l.v=t.format("m{0},{1}l{2},{1}",a(i*y),a(n*y),a(i*y)+1),l.textpathok=!0,h.string=r(s),h.on=!0,o.style.cssText=v,o.coordsize=y+c+y,o.coordorigin="0 0";var u=new T(o,e),p={fill:"#000",stroke:"none",font:t._availableAttrs.font,text:s};u.shape=o,u.path=l,u.textpath=h,u.type="text",u.attrs.text=r(s),u.attrs.x=i,u.attrs.y=n,u.attrs.w=1,u.attrs.h=1,C(u,p),o.appendChild(h),o.appendChild(l),e.canvas.appendChild(o);var d=k("skew");return d.on=!0,o.appendChild(d),u.skew=d,u.transform(f),u},t._engine.setSize=function(e,r){var i=this.canvas.style;return this.width=e,this.height=r,e==+e&&(e+="px"),r==+r&&(r+="px"),i.width=e,i.height=r,i.clip="rect(0 "+e+" "+r+" 0)",this._viewBox&&t._engine.setViewBox.apply(this,this._viewBox),this},t._engine.setViewBox=function(e,r,i,n,a){t.eve("raphael.setViewBox",this,this._viewBox,[e,r,i,n,a]);var s,o,l=this.getSize(),h=l.width,u=l.height;return a&&(i*(s=u/n)<h&&(e-=(h-i*s)/2/s),n*(o=h/i)<u&&(r-=(u-n*o)/2/o)),this._viewBox=[e,r,i,n,!!a],this._viewBoxShift={dx:-e,dy:-r,scale:l},this.forEach(function(t){t.transform("...")}),this},t._engine.initWin=function(t){var e=t.document;e.styleSheets.length<31?e.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)"):e.styleSheets[0].addRule(".rvml","behavior:url(#default#VML)");try{!e.namespaces.rvml&&e.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),k=function(t){return e.createElement("<rvml:"+t+' class="rvml">')}}catch(t){k=function(t){return e.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}},t._engine.initWin(t._g.win),t._engine.create=function(){var e=t._getContainer.apply(0,arguments),r=e.container,i=e.height,n=e.width,a=e.x,s=e.y;if(!r)throw new Error("VML container not found.");var o=new t._Paper,l=o.canvas=t._g.doc.createElement("div"),h=l.style;return a=a||0,s=s||0,n=n||512,i=i||342,o.width=n,o.height=i,n==+n&&(n+="px"),i==+i&&(i+="px"),o.coordsize=216e5+c+216e5,o.coordorigin="0 0",o.span=t._g.doc.createElement("span"),o.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;",l.appendChild(o.span),h.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",n,i),1==r?(t._g.doc.body.appendChild(l),h.left=a+"px",h.top=s+"px",h.position="absolute"):r.firstChild?r.insertBefore(l,r.firstChild):r.appendChild(l),o.renderfix=function(){},o},t.prototype.clear=function(){t.eve("raphael.clear",this),this.canvas.innerHTML=f,this.span=t._g.doc.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},t.prototype.remove=function(){for(var e in t.eve("raphael.remove",this),this.canvas.parentNode.removeChild(this.canvas),this)this[e]="function"==typeof this[e]?t._removedFactory(e):null;return!0};var M=t.st;for(var E in A)A[e](E)&&!M[e](E)&&(M[E]=function(t){return function(){var e=arguments;return this.forEach(function(r){r[t].apply(r,e)})}}(E))}}.apply(e,i))||(t.exports=n)}])});
3225
3226
3227
3228
3229var Site = {
3230	
3231	/**
3232	 * Formatuoja kainą.
3233	 */
3234	formatPrice: function(num) {
3235		return parseFloat(num).toFixed(2).toString();
3236	},
3237	
3238	tooltipOpen: false,
3239	
3240	/**
3241	 * Atidaro tooltipą.
3242	 */
3243	showTooltip: function(e, content) {
3244		window.tooltipC = content;
3245		this.tooltipOpen = true;
3246		
3247		$('#tooltip-content').html(content);
3248		$('#tooltip').css({
3249			display: 'block'
3250		});
3251	},
3252	
3253	/**
3254	 * Paslėpia tooltipą.
3255	 */
3256	hideTooltip: function(noTimeout) {
3257		this.tooltipOpen = false;
3258		
3259		if(typeof noTimeout == 'undefined') {
3260			setTimeout(function() {
3261				if( ! Site.tooltipOpen) {
3262					$('#tooltip').css({
3263						display: 'none'
3264					});
3265				}
3266			}, 300);
3267		} else {
3268			$('#tooltip').css({
3269				display: 'none'
3270			});
3271		}
3272	},
3273	
3274	/**
3275	 * Paruošia tooltipą.
3276	 */
3277	prepTooltips: function() {
3278		$('body').append('<div id="tooltip" style="display:none"><div id="tooltip-content"></div></div>');
3279	}
3280	
3281};
3282
3283$(document).ready(function() {
3284	if (!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch)) {
3285		Site.prepTooltips();
3286
3287		var $tooltip = $('#tooltip');
3288		
3289		if($('.error').length) {
3290			$('.error').effect('shake', {
3291				times: 2,
3292				distance: 10
3293			}, 100);
3294		}
3295		
3296		$(document).mousemove(function(e) {
3297			window.mouseE = e;
3298			window.mouseXPos = e.pageX;
3299			window.mouseYPos = e.pageY;
3300			
3301			if($tooltip.css('display') == 'block') {
3302				$tooltip.css({
3303					left: e.pageX - $tooltip.width() / 2 + 'px',
3304					top: e.pageY - $tooltip.height() - 10 + 'px'
3305				});
3306			}
3307		});
3308	}
3309});
3310
3311function testJSON(text) { 
3312    if (typeof text !== "string") { 
3313        return false; 
3314    } 
3315    try { 
3316        JSON.parse(text); 
3317        return true; 
3318    } catch (error) { 
3319        return false; 
3320    } 
3321}
3322function load_getObjectPath(matrix){
3323	
3324	var path;
3325	
3326	polygon_path = JSON.parse(matrix);
3327	
3328	for(i = 0; i < polygon_path.length; i++){
3329		x = Math.floor(polygon_path[i].x)
3330		y = Math.floor(polygon_path[i].y)
3331		if(i==0){
3332			path = "M"+x+" "+y;
3333		}else{
3334			path = path+" L"+x+" "+y;
3335		}
3336	}
3337
3338	path = path+" Z";
3339
3340	
3341	return path;
3342	
3343}
3344
3345var getLayoutInstance = (function () {
3346    function getLayoutInstance(){
3347
3348        var _ = this;
3349
3350        this.SEAT_CHOSEN_FILL_COLOR = '#ffb41a';
3351        this.grid = null;
3352        this.id = '';
3353        this.drawables = [];
3354        this.measures = null;
3355        this.width = 0;
3356        this.height = 0;
3357        this.objects = [];
3358        this.manualChoice = 0;
3359        this.highlightSector = 0;
3360		this.zoomSmall = 0;
3361
3362        this.measurePoints = [];
3363        this.noTooltips = false;
3364        this.eventPlaceId = 0;
3365
3366        this.freeSeats = null;
3367        this.freeSpots = null;
3368
3369        this.priceGroups = {};
3370        this.priceGroupsArray = false;
3371		this.additional_ticket_info = {};
3372        this.groupColors = {};
3373        this.colorIteration = 0;
3374        this.url = '';
3375		this.sectorbg = 'false';						
3376		
3377
3378        //surašyti spalvu kodai eilės tvarka nuo pigiausios:
3379        this.colors = [
3380            '#37AC53',  //rgb: 55, 172, 83
3381            '#0BA1A3',  //rgb: 11, 161, 163
3382            '#825FA3',  //rgb: 130, 95, 163
3383            '#EE7D47',  //rgb: 238, 125, 71
3384            '#6067F7',  //rgb: 96, 103, 247
3385            '#F2A83A',  //rgb: 242, 168, 58
3386            '#E6718E',  //rgb: 230, 113, 142
3387            '#B37979'   //rgb: 179, 121, 121
3388        ];
3389
3390        this.init = function(options) {
3391            for (var prop in options) {
3392                this[prop] = options[prop];
3393            }
3394			
3395            if (! $.isEmptyObject(this.priceGroups)) {
3396                this.priceGroupsArray = [];
3397
3398                for(var index in this.priceGroups) {
3399                    this.priceGroupsArray.push({
3400                        "tid": index,
3401                        "price": this.priceGroups[index]
3402                    });
3403                }
3404				
3405                this.priceGroupsArray.sort(function (a, b) {
3406                    //return parseFloat(b.price) >= parseFloat(a.price);
3407                    if(parseFloat(b.price) > parseFloat(a.price)) return 1;
3408                    if(parseFloat(b.price) < parseFloat(a.price)) return -1;
3409					return 0;
3410                });
3411				
3412				
3413				this.priceGroupsArray.reverse();
3414				
3415				// IE CIRCLE COLOR FIX ===============================================
3416				var ua = window.navigator.userAgent;
3417				var msie = ua.indexOf("MSIE ");
3418				
3419				var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 && navigator.userAgent && !navigator.userAgent.match('CriOS');
3420
3421				if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)){
3422				}else if (/Edge\/|Trident\/|MSIE /.test(window.navigator.userAgent)){
3423				}else if (isSafari == true){
3424				}else{
3425				}
3426                // ===================================================================
3427                for (var i = this.priceGroupsArray.length - 1; i >= 0; i--) {                    
3428                    this.groupColors[ this.priceGroupsArray[i].tid ] = this.colors[i];  
3429                };
3430            }
3431        };
3432
3433        this.loadLayoutGrid = function(sectors) {
3434            if ((this.id !== '') && ! $('#'+this.id).length) { return; }
3435
3436            this.grid = new Raphael(this.id);
3437            this.buildLayoutGrid(sectors);
3438        };
3439
3440        this.loadSectorGrid = function(sector, seats) {
3441            if ((this.id !== '') && ! $('#'+this.id).length) { return; }
3442
3443            this.grid = new Raphael(this.id);
3444            this.buildSectorGrid(sector, seats);
3445
3446            if (this.manualChoice) {
3447                $('#'+this.id).mouseover(function() {
3448                    $(this).addClass('hover');
3449                }).mouseout(function() {
3450                    $(this).removeClass('hover');
3451                }).addClass('interactive');
3452            }
3453        };
3454
3455        /**
3456         * Sukuria išdėstymo tinklelį.
3457         */
3458        this.buildLayoutGrid = function(sectors) {
3459            if (sectors.length) {
3460                sectors = this.formatSectors(sectors);
3461
3462                if ( ! $.isEmptyObject(this.drawables)) {
3463                    for(var key in this.drawables) {
3464                        this.drawables[key].x -= this.drawables[key].width / 2;
3465                        this.drawables[key].y -= this.drawables[key].height / 2;
3466                    }
3467                }
3468
3469				if(this.sectorbg !='false'){
3470					
3471					this.measurePoints.push({
3472						x: 0,
3473						y: 0
3474					});
3475					this.measurePoints.push({
3476						x: 600,
3477						y: 600
3478					});
3479				}
3480
3481                var measures = this.getMeasures(this.measurePoints.concat(this.drawables));
3482
3483                if (measures.height > this.height) {
3484                    this.setHeight(measures.height + 30);
3485                }
3486
3487                var xo = this.width / 2 - measures.width / 2;
3488                var yo = this.height / 2 - measures.height / 2;
3489				
3490				if(this.sectorbg != 'false'){
3491					sectorbg_width = 600;
3492					sectorbg_height = 600;
3493					
3494					sectorbg_x = 0;
3495					sectorbg_y = 0;
3496
3497					if (measures.min.x !== null) {
3498						sectorbg_x = 0-measures.min.x;
3499						sectorbg_y = 0-measures.min.y;
3500					}
3501
3502                    drawableBackground = this.grid.image(this.sectorbg, Math.floor(sectorbg_x + xo), Math.floor(sectorbg_y + yo), sectorbg_width, sectorbg_height);
3503				}
3504
3505                for(var key in sectors) {
3506                    var sector = sectors[key];
3507
3508                    if ($.isEmptyObject(sector.matrix)) {
3509						
3510                        continue;
3511                    }
3512
3513                    var path = [];
3514
3515					if(!Array.isArray(sector.matrix)){
3516						var x = sector.x;
3517						var y = sector.y;
3518						
3519						if (measures.min.x !== null) {
3520							x -= measures.min.x;
3521							y -= measures.min.y;
3522						}
3523
3524						var sectorObj = this.grid.path(sector.matrix);
3525						sectorObj.transform("t"+Math.floor(x+xo)+","+Math.floor(y+yo)+"r"+sector.rotate+"s"+sector.flipx+","+sector.flipy);
3526					}else{
3527					
3528						for(var key in sector.matrix) {
3529							var matrix = sector.matrix[key];
3530							var x = matrix.x;
3531							var y = matrix.y;
3532
3533							if (measures.min.x !== null) {
3534								x -= measures.min.x;
3535								y -= measures.min.y;
3536							}
3537
3538							if ( ! path.length) {
3539								path.push('M ' + Math.floor(x+xo) + ' ' + Math.floor(y+yo));
3540							} else {
3541								path.push('L ' + Math.floor(x+xo) + ' ' + Math.floor(y+yo));
3542							}
3543						}
3544						
3545						
3546
3547						var sectorObj = this.grid.path(path.join(' '));
3548						sectorObj.transform("t"+sector.x+","+sector.y+"r"+sector.rotate+"s"+sector.flipx+","+sector.flipy);	
3549					}
3550
3551                    
3552
3553                    sectorObj.attr({
3554                        'fill': '#878e97',
3555                        'stroke': 'none',
3556                        'background': 'none',
3557                        'cursor': 'pointer',
3558                        'href': sector.url
3559                    });
3560					sectorObj.node.id = 'sector_'+sector.id;
3561					sectorObj.node.setAttribute("class","sector_path");
3562					sectorObj.node.setAttribute("sector_id",sector.id);
3563					
3564					
3565
3566
3567
3568                    /*
3569                     * Pridedame sektoriaus pavadinimą.
3570                     */
3571  
3572                    var bbox = sectorObj.getBBox();
3573                    var xu = Math.floor(bbox.x + bbox.width / 2.0);
3574                    var yu = Math.floor(bbox.y + bbox.height / 2.0);
3575                    var textObj = this.grid.text(xu, yu, sector.title + (sector.locked==1?"*":''));
3576                    textObj.attr({
3577                        'cursor': 'pointer',
3578                        'fill': '#000',
3579                        'font-family': 'Celias-regular, Tahoma, Arial',
3580                        'font-size': sector.text_size-2,
3581                        'text-transform': 'uppercase',
3582                        href: sector.url
3583                    });
3584					textObj.node.setAttribute("class","sector_path");
3585					textObj.node.setAttribute("sector_id",sector.id);
3586
3587                    var textBBox = textObj.getBBox();
3588
3589                    /*
3590                     * Jei tekstas netelpa - pasukame.
3591                     */
3592                    if ('Tribūna R' === sector.title) {
3593                    }
3594					textObj.transform('r'+sector.text_rotate);
3595					/*
3596                    if (bbox.width < textBBox.width) {
3597                        if (bbox.width * 3 < bbox.height) {
3598                            textObj.rotate(90, xu, yu);
3599                        } else if (bbox.width * 1.5 < bbox.height) {
3600                            textObj.rotate(45, xu, yu);
3601                        }
3602                    }
3603					
3604
3605                    var textLabelObj = this.grid.rect(textBBox.x - 4, textBBox.y - 2, textBBox.width + 8, textBBox.height + 4, 2);
3606                    textLabelObj.attr({
3607                        'cursor': 'pointer',
3608                        'fill': '#000',
3609                        'opacity': 0,
3610                        href: sector.url
3611                    });
3612					textLabelObj.node.setAttribute("class","sector_path");
3613					textLabelObj.node.setAttribute("sector_id",sector.id);
3614					*/
3615
3616                    textObj.toFront();
3617
3618
3619                    var result = this.addSectorLabel(sector, sectorObj);
3620                    sector = result.sector;
3621                    sectorObj = result.sectorObj;
3622
3623                    /*
3624                    * pazymu dabartini sectoriu
3625                     */
3626                    if (this.highlightSector && this.highlightSector == sector.id){
3627                        sectorObj.attr({
3628                            fill: '#ffb41a'
3629                        });
3630                    }
3631
3632                    /*
3633                     * Įvestis.
3634                     */
3635                    this.objects[sectorObj.id] = sector;
3636                    this.objects[textObj.id] = sector;
3637                    //this.objects[textLabelObj.id] = sector;
3638
3639                    this.addTooltipEvents(sectorObj);
3640                    this.addTooltipEvents(textObj);
3641                    //this.addTooltipEvents(textLabelObj);
3642                }
3643
3644                this.addObjects(measures, xo, yo);
3645                this.addZoom();
3646            }
3647        };
3648
3649        /**
3650         * Prideda pelės įvykius.
3651         */
3652        this.addTooltipEvents = function(obj) {
3653            if (this.noTooltips === true ||
3654                    (   ('ontouchstart' in window) ||
3655                            window.DocumentTouch &&
3656                            document instanceof DocumentTouch)) {
3657                return;
3658            }
3659
3660            obj.mousemove(function(e) {
3661                if (typeof _.objects[this.id] !== 'undefined') {
3662                    Site.showTooltip(e, _.objects[this.id].label);
3663                }
3664            });
3665
3666            obj.mouseout(function(e) {
3667                Site.hideTooltip();
3668            });
3669        };
3670
3671        /**
3672         * Prideda objektus.
3673         */
3674		this.addViewImages = function(measures, xOffset, yOffset) {
3675			if($.isEmptyObject(this.viewImages)) {
3676                return;
3677            }
3678			var viewImagePath = "M5 8.5c0-.828.672-1.5 1.5-1.5s1.5.672 1.5 1.5c0 .829-.672 1.5-1.5 1.5s-1.5-.671-1.5-1.5zm9 .5l-2.519 4-2.481-1.96-4 5.96h14l-5-8zm8-4v14h-20v-14h20zm2-2h-24v18h24v-18z";
3679			
3680			for(var key in this.viewImages) {
3681				var drawable = this.viewImages[key];
3682				var drawableObjView = null;
3683				
3684				var x = drawable.x;
3685				var y = drawable.y;
3686				
3687				if (measures.min.x !== null) {
3688					x -= measures.min.x;
3689					y -= measures.min.y;
3690				}
3691				
3692				drawableObjView = this.grid.path(viewImagePath);
3693				
3694				drawableObjView.transform("t"+(x+xOffset)+","+(y+yOffset));
3695				
3696				drawableObjView.attr({
3697						fill: '#EEE',
3698						opacity: '0.5',
3699						'stroke-width': '0',
3700						cursor: 'pointer'
3701					}); 
3702				
3703				drawableObjView.attr('data-image', drawable.image);
3704				drawableObjView.data('viewImage', drawable.image);
3705				drawableObjView.toFront();
3706				
3707				
3708				drawableObjView.hover(function(e) {
3709					function hoverCall($drawableObjView) {
3710						$drawableObjView.attr({'opacity':'1'});
3711					}
3712					hoverCall(this, this.seat_groups);
3713				},function(e) {
3714					function unhoverCall($drawableObjView){
3715						$drawableObjView.attr({'opacity':'0.5'});
3716					}
3717					unhoverCall(this);	
3718				});
3719				drawableObjView.click(function(e) {    
3720                    function clickCall($drawableObjView){
3721						$('#viewImage-popupBox .yg-popup').html('<img src="https://www.ticketmarket.lt/files/sector/'+$drawableObjView.data('viewImage')+'">');
3722						$('#viewImage-popupBox').toggle();     
3723                    }
3724                    clickCall(this);
3725                });
3726
3727			}
3728			
3729				
3730		}
3731		this.addObjects = function(measures, xOffset, yOffset) {
3732			if ($.isEmptyObject(this.drawables)) {
3733                return;
3734            }
3735			
3736			
3737			for(var key in this.drawables) {
3738                var drawable = this.drawables[key];
3739				var drawableObj = null;
3740				
3741				if(drawable.matrix != null && drawable.matrix !='text' && drawable.matrix != 'null'){
3742		
3743		
3744					if(testJSON(drawable.matrix)){
3745						var path = load_getObjectPath(drawable.matrix);
3746					}else{
3747						var path = drawable.matrix;
3748					}
3749					
3750					drawableObj = this.grid.path(path);
3751					
3752					
3753					
3754					var x = drawable.x;
3755					var y = drawable.y;
3756					
3757					if (measures.min.x !== null) {
3758						x -= measures.min.x;
3759						y -= measures.min.y;
3760					}
3761					
3762					drawableObj.transform("t"+(x+xOffset)+","+(y+yOffset)+"r"+drawable.rotate+"s"+drawable.flipx+","+drawable.flipy);
3763					
3764					
3765					drawableObj.attr({
3766						fill: '90-#ddd:5-#eee:95',
3767						stroke: '1px solid #30343c',
3768						cursor: 'pointer'
3769					}); 
3770					
3771					var bbox = drawableObj.getBBox();
3772					var xu = Math.floor(bbox.x + bbox.width / 2.0);
3773					var yu = Math.floor(bbox.y + bbox.height / 2.0);
3774					var textObj = this.grid.text(xu, yu, drawable.title);
3775					textObj.attr({
3776						'fill': '#000',
3777						'font-family': 'Celias-regular, Tahoma, Arial',
3778						'font-size': '10px'
3779					});
3780					//textObj.transform('t'+(x+xOffset)+','+(y+yOffset));
3781					
3782				}
3783				if(drawable.matrix == null || drawable.matrix == 'null'){
3784					var type = parseInt(drawable.type);
3785					if (measures.min.x !== null) {
3786						drawable.x -= measures.min.x;
3787						drawable.y -= measures.min.y;
3788					}
3789
3790					if (type === 2) {
3791						drawableObj = this.grid.ellipse(Math.floor(drawable.x + xOffset), Math.floor(drawable.y + yOffset), drawable.radius / 2, drawable.radius / 2);
3792					} else {
3793						drawableObj = this.grid.rect(Math.floor(drawable.x + xOffset), Math.floor(drawable.y + yOffset), drawable.width, drawable.height);
3794					}
3795
3796					drawableObj.attr({
3797						fill: '90-#ddd:5-#eee:95',
3798						stroke: '1px solid #30343c',
3799						cursor: 'pointer'
3800					});
3801
3802					var bbox = drawableObj.getBBox();
3803					var xu = Math.floor(bbox.x + bbox.width / 2.0);
3804					var yu = Math.floor(bbox.y + bbox.height / 2.0);
3805					var textObj = this.grid.text(xu, yu, drawable.title);
3806					textObj.attr({
3807						'fill': '#000',
3808						'font-family': 'Celias-regular, Tahoma, Arial',
3809						'font-size': '10px'
3810					});
3811					
3812					
3813				}
3814				if(drawable.matrix == 'text'){
3815
3816					var x = drawable.x;
3817					var y = drawable.y;
3818					
3819					if (measures.min.x !== null) {
3820						x -= measures.min.x;
3821						y -= measures.min.y;
3822					}
3823					
3824					drawableObj = this.grid.text((x+xOffset), (y+yOffset), drawable.title);
3825					
3826					drawableObj.attr({ "font-size": drawable.fontsize, "font-family": "Arial, Helvetica, sans-serif" });
3827					drawableObj.attr({'fill': '#000'});
3828					if(drawable.bold==1)
3829						drawableObj.attr({ "font-weight": "bold" });
3830					if(drawable.italic==1)
3831						drawableObj.attr({ "font-style": "italic" });
3832					
3833					drawableObj.toFront();
3834					
3835					drawableObj.transform('r'+drawable.rotate);
3836
3837					
3838
3839				}
3840				
3841				
3842			}
3843		};
3844		
3845        this.addDrawables = function(measures, xOffset, yOffset) {
3846            if ($.isEmptyObject(this.drawables)) {
3847                return;
3848            }
3849
3850            for(var key in this.drawables) {
3851                var drawable = this.drawables[key];
3852                var type = parseInt(drawable.type);
3853                var drawableObj = null;
3854
3855                if (measures.min.x !== null) {
3856                    drawable.x -= measures.min.x;
3857                    drawable.y -= measures.min.y;
3858                }
3859
3860                if (type === 2) {
3861                    drawableObj = this.grid.ellipse(Math.floor(drawable.x + xOffset), Math.floor(drawable.y + yOffset), drawable.radius / 2, drawable.radius / 2);
3862                } else {
3863                    drawableObj = this.grid.rect(Math.floor(drawable.x + xOffset), Math.floor(drawable.y + yOffset), drawable.width, drawable.height);
3864                }
3865
3866                drawableObj.attr({
3867                    fill: '90-#ddd:5-#eee:95',
3868                    stroke: '1px solid #30343c',
3869                    cursor: 'pointer'
3870                });
3871
3872                var bbox = drawableObj.getBBox();
3873                var xu = Math.floor(bbox.x + bbox.width / 2.0);
3874                var yu = Math.floor(bbox.y + bbox.height / 2.0);
3875                var textObj = this.grid.text(xu, yu, drawable.title);
3876                textObj.attr({
3877                    'fill': '#000',
3878                    'font-family': 'Celias-regular, Tahoma, Arial',
3879                    'font-size': '10px'
3880                });
3881            }
3882        };
3883
3884        /**
3885         * Prideda sektoriaus etiketę.
3886         */
3887        this.addSectorLabel = function(sector, sectorObj) {
3888            sector.label = '<h3>'+sector.title+'</h3>';
3889
3890            var hasTickets = false;
3891
3892            /*
3893             * Sėdimos vietos.
3894             */
3895
3896
3897            if ((this.freeSeats !== null) && typeof this.freeSeats[sector.id] !== 'undefined') {
3898                sector.label += '<p>'+Lang.seats+': <strong>';
3899                var prices = [];
3900                var prices2= [];
3901                for(var i in this.freeSeats[sector.id]) {
3902                    prices.push(parseFloat(this.freeSeats[sector.id][i].price));
3903                    prices2.push(parseFloat(Site.formatPrice(this.freeSeats[sector.id][i].price*Lang.currency_rate)).toFixed(2));
3904            
3905                }
3906
3907                prices.sort(function(a, b) {
3908                    return a - b;
3909                });
3910
3911                prices2.sort(function(a, b) {
3912                    return a - b;
3913                });
3914
3915                for(var i in prices) {
3916                    prices[i] = Site.formatPrice(prices[i]);
3917                }
3918
3919                sector.label += prices.join(', ')+' '+Lang.currency+'<strong></p>';
3920                hasTickets = true;
3921            }
3922
3923            /*
3924             * Stovimos vietos.
3925             */
3926            if ((this.freeSpots !== null) && typeof this.freeSpots[sector.id] !== 'undefined') {
3927                sector.label += '<p>'+Lang.standingPositions+': <strong>'+Site.formatPrice(this.freeSpots[sector.id].price)+' '+Lang.currency+'</strong></p>';
3928				
3929				if(this.freeSpots[sector.id].amount > 0)
3930					hasTickets = true;
3931            }
3932			
3933			
3934
3935            /*
3936             * Nėra vietų.
3937             */
3938            if ( ! hasTickets) {
3939                sector.label += '<p>'+Lang.noTickets+'</p>';
3940
3941                sectorObj.attr({
3942                    fill: '#878e97',
3943					opacity: 0.1
3944                });
3945            }
3946			
3947			if(sector.info){
3948				sector.label += '<br><p class="sectorHoverInfo">'+nl2br(sector.info)+'</p>';
3949			}
3950
3951            return {
3952                "sector": sector,
3953                "sectorObj": sectorObj
3954            };
3955        };
3956
3957        this.formatSectors = function(sectors) {
3958            for(var key in sectors) {
3959                var sector = sectors[key];
3960				
3961		
3962				if(testJSON(sector.matrix)){
3963					var matrix = $.parseJSON('{"obj":'+sector.matrix+'}');
3964					sector.matrix = matrix.obj;
3965
3966					if ( ! $.isEmptyObject(sector.matrix)) {
3967						var xOffset = parseFloat(sector.x);
3968						var yOffset = parseFloat(sector.y);
3969						
3970						for(var mkey in sector.matrix) {
3971							var x = parseFloat(sector.matrix[mkey].x);
3972							var y = parseFloat(sector.matrix[mkey].y);
3973
3974							this.measurePoints.push({
3975								x: x + xOffset,
3976								y: y + yOffset
3977							});
3978
3979							//sector.matrix[mkey].x += xOffset;
3980							//sector.matrix[mkey].y += yOffset;
3981						}
3982					}
3983				}else{
3984					var xOffset = 0;
3985					var yOffset = 0;
3986
3987					var x = parseFloat(sector.x);
3988					var y = parseFloat(sector.y);
3989					
3990					this.measurePoints.push({
3991						x: x+400,
3992						y: y+100
3993					});
3994					
3995					this.measurePoints.push({
3996						x: 800,
3997						y: 600
3998					});
3999
4000					
4001
4002				}
4003				
4004                
4005
4006                sectors[key] = sector;
4007            }
4008
4009            return sectors;
4010        };
4011
4012        /**
4013         * Sėdimų vietų sektoriaus atvaizdavimas.
4014         *
4015         * @param (object) sector
4016         * @param (object) seats
4017         */
4018        this.buildSectorGrid = function(sector, seats, sPriceGroups) {
4019			
4020			// var sectors = [sector];
4021			// sectors = this.formatSectors(sectors);
4022			// var measures = this.getMeasures(this.measurePoints.concat(seats));
4023			
4024            var measures = this.getMeasures(seats);
4025			if ( ! $.isEmptyObject(this.drawables)) {
4026				this.getMeasuresObject(this.drawables);
4027			}
4028			if ( ! $.isEmptyObject(this.viewImages)) {
4029				this.getMeasuresObject(this.viewImages);
4030			}
4031			
4032			
4033
4034            if (measures.height > this.height) {
4035                this.setHeight(measures.height + 30);
4036                measures = this.getMeasures(seats);
4037            }
4038			
4039
4040            var xo = this.width / 2 - measures.width / 2;
4041            var yo = this.height / 2 - measures.height / 2;
4042
4043            var url = this.url;
4044
4045            /*
4046             * Atvaizduoja kėdes.
4047             */
4048            if (seats.length) {
4049                for(var key in seats) {
4050                    var seat = seats[key];
4051                    seat.x = parseFloat(seat.x);
4052                    seat.y = parseFloat(seat.y);
4053                    seat.s = 7;
4054                    seat.reserved = ((typeof seat.reserved === 'number') && (seat.reserved === 1)) ? 1 : 0;
4055                    seat.chosen = ((typeof seat.chosen === 'number') && (seat.chosen === 1)) ? 1 : 0;
4056
4057                    if (measures.min.x !== null) {
4058                        seat.x -= measures.min.x;
4059                        seat.y -= measures.min.y;
4060                    }
4061
4062                    var seatObj = null;
4063
4064                    if (seat.reserved === 1) {
4065                        //seatObj = this.grid.rect((seat.x + xo), (seat.y + yo), 7, 7);
4066						seatObj = this.grid.circle((seat.x + xo + seat.s / 2), (seat.y + yo + seat.s / 2), seat.s / 2);
4067                    } else {
4068                        seatObj = this.grid.circle((seat.x + xo + seat.s / 2), (seat.y + yo + seat.s / 2), seat.s / 2);
4069                    }
4070
4071                    /*
4072                     * Select group color
4073                     */
4074                    var fillColor = '#444';
4075
4076
4077					
4078
4079                    if (typeof this.groupColors[seat.tid] !== 'undefined') {
4080                        fillColor = this.groupColors[seat.tid];
4081                    }
4082
4083					if(this.additional_ticket_info[seat.tid]){
4084						var seatInfo = ' | '+this.additional_ticket_info[seat.tid];
4085					}else{
4086						var seatInfo = '';
4087					}
4088					
4089                    seatObj.attr({
4090                        stroke: '',
4091                        fill: fillColor,
4092                        title: 'Eilė: '+seat.r+', vieta: '+seat.p+($('body').hasClass('is-dev') ? ', ID: '+seat.i : '')+' '+seatInfo
4093                    });
4094					
4095					/* VIETOS - vietos skaičius */
4096					var bbox = seatObj.getBBox();
4097					var tX = bbox.x + 0.3 + bbox.width/2;
4098					var tY = bbox.y + bbox.height/2;
4099					
4100					//var tX = seat.x + xo;
4101					//var tY = seat.y + yo +3.5;
4102
4103					textNode = this.grid.text(tX, tY, seat.p);
4104					textNode.attr({ "font-size": 3, "font-family": "Arial" });
4105					
4106
4107					textNode.attr('class', 'donthighlight');	
4108					textNode.toFront();
4109					/* VIETOS */					
4110					
4111
4112                    seatObj.data('sectorId', seat.sid);
4113                    seatObj.data('seatId', seat.i);
4114                    seatObj.data('ticketId', seat.tid);
4115                    seatObj.data('seatRow', seat.r);
4116                    seatObj.data('seatPlace', seat.p);
4117                    seatObj.data('seatPrice', this.priceGroups[seat.tid]);
4118                    seatObj.data('seatInfo', this.additional_ticket_info[seat.tid]);
4119                    seatObj.data('seatGroup', (seat.sg!=null?Number(seat.sg):0));
4120                    seatObj.data('fillColor', fillColor);
4121					seatObj.data('reserved', seat.reserved);
4122					seatObj.data('chosen', (seat.chosen?1:0));
4123					
4124					if(seat.sg!=null && seat.reserved == 0){
4125						seatObj.attr('class', 'seatGroupID-'+Number(seat.sg));
4126					}
4127
4128                    if ( ! seat.reserved && this.manualChoice) {
4129                        seatObj.attr({
4130                            cursor: 'pointer'
4131                        });
4132						
4133						/*seatObj.hover(
4134						  function($seatObj) {
4135							var title1 = 'Eilė: '+$seatObj.data('seatRow');
4136							$("#sector_seats_title").html(title1);
4137						  }, function() {
4138							$("#sector_seats_title").html('');
4139						  }
4140						);*/
4141						
4142						 
4143						seatObj.hover(function(e) {
4144                           
4145                            function hoverCall($seatObj) {
4146								
4147								if($seatObj.data('seatGroup')>0){
4148									$('.seatGroupID-'+$seatObj.data('seatGroup')).attr({'fill':'#ffb41a'});
4149								}else{
4150									$seatObj.attr({'fill':'#ffb41a'});
4151								}
4152								
4153								if($seatObj.data('seatInfo')){
4154									var seatInfo = ' | '+$seatObj.data('seatInfo');
4155								}else{
4156									var seatInfo = '';
4157								}
4158								
4159								var title1 = 'Eilė: '+$seatObj.data('seatRow')+', Vieta: '+$seatObj.data('seatPlace')+', Kaina: '+$seatObj.data('seatPrice')+seatInfo;
4160								$("#sector_seats_title").html(title1);
4161								
4162							}
4163
4164                            hoverCall(this, this.seat_groups);
4165                        }, function(e) {
4166							
4167							function unhoverCall($seatObj){
4168								if($seatObj.data('seatGroup')>0){
4169									if($seatObj.data('reserved')==0){
4170										$('.seatGroupID-'+$seatObj.data('seatGroup')).attr({'fill':$seatObj.data('fillColor')});
4171									}
4172								}else{
4173									if($seatObj.data('reserved')==0){
4174										$seatObj.attr({'fill':$seatObj.data('fillColor')});
4175									}
4176								}
4177
4178								$("#sector_seats_title").html('');
4179							}
4180							unhoverCall(this);
4181							
4182						 });
4183						
4184
4185                        seatObj.click(function(e) {
4186                            
4187                            function clickCall($seatObj){
4188                                $.get(url+'api/event/seat/reserve', {
4189                                    'event_place_id': _.eventPlaceId,
4190                                    'sector_id': $seatObj.data('sectorId'),
4191                                    'seat_id': $seatObj.data('seatId'),
4192                                    'ticket_id': $seatObj.data('ticketId'),
4193                                    'seat_group': $seatObj.data('seatGroup'),
4194                                }, function(data) {
4195									
4196									if($seatObj.data('seatGroup')>0){
4197										location.reload();
4198									}else{
4199										
4200										var $selectedTickets = $('#selected-tickets');
4201
4202										$('#header').find('.cart').find('.count').text(data.count);
4203										$selectedTickets.find('tr.noitem').remove();
4204										$selectedTickets.find('.total').find('span').html(data.total);
4205										$selectedTickets.find('.totalCount').find('span').html(data.totalCount);
4206										if(data.totalDiscount!='0.00 €'){
4207											$selectedTickets.find('.totalDiscount').css('display','block');
4208											$selectedTickets.find('.totalDiscount').find('span').html(data.totalDiscount);
4209										}
4210
4211										if ( $('.table-tickets > *').length > 0 ) {
4212											$selectedTickets.find('.table-tickets').append(data.row);
4213										}else{
4214											$selectedTickets.find('.table-tickets').html(data.row);
4215										}
4216
4217
4218										$selectedTickets.find('[type="submit"]').removeClass('hidden');
4219
4220										if (data.genericDiscount == 1){
4221											var lines = $selectedTickets.find('.table-tickets').find('tbody').find('tr');
4222											var lastText = $selectedTickets.find('.table-tickets').find('tbody').find('tr:last').find('td').eq(7).text();
4223											var lastClassName = $selectedTickets.find('.table-tickets').find('tbody').find('tr:last').attr('class');
4224											lines.each(function(){
4225												var singleLine = $(this);
4226
4227												if (singleLine.attr('class')==lastClassName)
4228												{
4229													singleLine.find('td').eq(7).text(lastText);
4230												}
4231											});
4232										}
4233										reservationTimer.restart(data.timeLeft);
4234										
4235										if (typeof data.error === 'string') {
4236											alert(data.error);
4237											return false;
4238										}
4239										
4240										$seatObj.data('reserved', 1);
4241										$seatObj.attr({
4242											text: 'x',
4243											stroke: this.SEAT_CHOSEN_FILL_COLOR,
4244											fill: '#ffb41a'
4245										});
4246									}
4247
4248
4249                                }, 'json');
4250                            }
4251
4252                            clickCall(this);
4253                        });
4254                    }
4255
4256                    if (seat.reserved === 1) {
4257                        seatObj.attr({
4258                            fill: '#EEE'
4259                        });
4260                    }
4261
4262                    if (seat.chosen === 1) {
4263						seatObj.data('reserved', 1);
4264                        seatObj.attr({
4265                            text: 'x',
4266                            stroke: fillColor,
4267                            fill: this.SEAT_CHOSEN_FILL_COLOR
4268                        });
4269                    }
4270
4271                    seatObj.rotate(seat.ro);
4272
4273                    this.objects.push(seatObj);
4274                }
4275				
4276				this.addObjects(measures, xo, yo);
4277				this.addViewImages(measures, xo, yo);
4278				
4279                this.addZoom2();
4280            }
4281
4282            /*
4283             * Draw prices.
4284             */
4285            var $priceRadio = $('#event-seats').find('.ticket-price').find('.radio').not(':first');
4286
4287            if ( ! $.isEmptyObject(this.priceGroups) && $priceRadio.length !== 0) {
4288                var i = 0;
4289                for(var index in this.priceGroups) {
4290                    $priceRadio.eq(i).find('[type="radio"]').next('span').css('background', this.groupColors[ this.priceGroupsArray[i].tid ]);
4291                    i++;
4292                }
4293            }
4294			
4295			var $priceRadio = $('#event-seats_table').find('.ticket-price').find('.radio');
4296
4297            if ( ! $.isEmptyObject(this.priceGroups) && $priceRadio.length !== 0) {
4298                var i = 0;
4299                for(var index in this.priceGroups) {
4300                    $priceRadio.eq(i).find('[type="radio"]').next('span').css('background', this.groupColors[ this.priceGroupsArray[i].tid ]);
4301                    i++;
4302                }
4303            }
4304			
4305			
4306        };
4307
4308        this.getMeasures = function(data) {
4309            var min = {x: null, y: null};
4310            var max = {x: null, y: null};
4311            var width = 0;
4312            var height = 0;
4313
4314            if (data.length) {
4315                for(var key in data) {
4316                    var item = data[key];
4317                    var x = parseFloat(item.x);
4318                    var y = parseFloat(item.y);
4319
4320                    if ( (min.x === null) | (x < min.x) ) min.x = x;
4321                    if ( (min.y === null) | (y < min.y) ) min.y = y;
4322                    if ( (max.x === null) | (x > max.x) ) max.x = x;
4323                    if ( (max.y === null) | (y > max.y) ) max.y = y;
4324                }
4325
4326                width = max.x - min.x;
4327                height = max.y - min.y;
4328            }
4329
4330            this.measures = {
4331                min: min,
4332                max: max,
4333                width: width,
4334                height: height
4335            };
4336
4337
4338            this.setHeight(height + 20);
4339            this.setWidth(width + 20);
4340
4341            return this.measures;
4342        };
4343		
4344		this.getMeasuresObject = function(data) {
4345			
4346			if(this.measures != null){
4347				var min = {x: this.measures.min.x, y: this.measures.min.y};
4348				var max = {x: this.measures.max.x, y: this.measures.max.y};
4349			}else{
4350				var min = {x: null, y: null};
4351				var max = {x: null, y: null};
4352			}
4353			
4354			
4355            var width = 0;
4356            var height = 0;
4357
4358            if (data.length) {
4359                for(var key in data) {
4360                    var item = data[key];
4361					
4362					
4363					if(item.matrix != null && item.matrix !='text' && item.matrix != 'null'){
4364						if(testJSON(item.matrix)){
4365							polygon_path = JSON.parse(item.matrix);
4366	
4367							for(i = 0; i < polygon_path.length; i++){
4368								var x = parseFloat(polygon_path[i].x)+parseFloat(item.x);
4369								var y = parseFloat(polygon_path[i].y)+parseFloat(item.y);
4370								
4371								if ( (min.x === null) | (x < min.x) ) min.x = x;
4372								if ( (min.y === null) | (y < min.y) ) min.y = y;
4373								if ( (max.x === null) | (x > max.x) ) max.x = x;
4374								if ( (max.y === null) | (y > max.y) ) max.y = y;
4375							}
4376						}
4377					}else{
4378					
4379						var x = parseFloat(item.x);
4380						var y = parseFloat(item.y);
4381
4382						if ( (min.x === null) | (x < min.x) ) min.x = x;
4383						if ( (min.y === null) | (y < min.y) ) min.y = y;
4384						if ( (max.x === null) | (x > max.x) ) max.x = x;
4385						if ( (max.y === null) | (y > max.y) ) max.y = y;
4386					}
4387                }
4388
4389                width = max.x-min.x;
4390                height = max.y-min.y;
4391            }
4392
4393            this.measures = {
4394                min: min,
4395                max: max,
4396                width: width,
4397                height: height
4398            };
4399
4400
4401            this.setHeight(height + 100);
4402            this.setWidth(width + 100);
4403
4404            return this.measures;
4405        };
4406
4407        this.setHeight = function(height) {
4408            this.height = height;
4409            $('#'+this.id+', #'+this.id+' svg').height(height);
4410        };
4411
4412        this.setWidth = function(width) {
4413            this.width = width;
4414            $('#'+this.id+', #'+this.id+' svg').width(width);
4415        };
4416
4417        this.addZoom = function() {
4418			if(this.zoomSmall==1){ z_height = '350px';}else{z_height='100%';}
4419            if ($.fn.smartZoom) {
4420                var $div = $("#"+this.id);
4421                $div.wrap("<div></div>");
4422                $div.smartZoom({
4423                    "containerBackground" : "rgba(0,0,0,0)",
4424					"height":z_height,
4425                    "maxScale": 5
4426                });
4427            }
4428        };
4429		
4430		
4431		this.addZoom2 = function() {
4432			
4433			z_height = '400px';
4434            if ($.fn.smartZoom) {
4435                var $div = $("#"+this.id);
4436				
4437                $div.wrap('<div class="places_zoom"></div>');
4438				
4439                
4440                $div.smartZoom({
4441                    "containerBackground" : "rgba(0,0,0,0)",
4442					"height":z_height,
4443                    "maxScale": 5
4444                });
4445				
4446
4447				var isMobile = false; //initiate as false
4448				// device detection
4449				if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 
4450					|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.
4450substr(0,4))) { 
4451					isMobile = true;
4452				}
4453				
4454				
4455
4456		
4457
4458            }
4459        };
4460		
4461		
4462    };
4463
4464    return getLayoutInstance;
4465})();
4466
4467
4468/*	
4469 *	jQuery zoom plugin
4470 *	Demo and documentation:
4471 *	http://e-smartdev.com/#!jsPluginList/panAndZoomJQuery
4472 *	
4473 *	Copyright (c) 2012 Damien Corzani
4474 *	http://e-smartdev.com/
4475 *
4476 *	Dual licensed under the MIT and GPL licenses.
4477 *	http://en.wikipedia.org/wiki/MIT_License
4478 *	http://en.wikipedia.org/wiki/GNU_General_Public_License
4479 */
4480(function( $ ){
4481
4482  $.fn.smartZoom = function(method) {
4483    // define global vars
4484	var targetElement = this; // the element target of the plugin
4485
4486	targetElement.touchStartTime = 0;
4487    
4488	/**
4489	 * ESmartZoomEvent Class 
4490	 * define const use to dispatch zoom events
4491	 */
4492	function ESmartZoomEvent(type){}
4493	ESmartZoomEvent.ZOOM = "SmartZoom_ZOOM";
4494	ESmartZoomEvent.PAN = "SmartZoom_PAN";
4495	ESmartZoomEvent.START = "START";
4496	ESmartZoomEvent.END = "END";
4497	ESmartZoomEvent.DESTROYED = "SmartZoom_DESTROYED";   	
4498
4499	/**
4500	 * define public methods that user user could call 
4501	 */
4502    var publicMethods = {
4503    	/**
4504		  * initialize zoom component
4505		  * @param {Object} options = {'top': '0' zoom target container top position in pixel
4506		  * 						   'left': '0' zoom target container left position in pixel
4507		  * 						   'width' : '100%' zoom target container width in pixel or in percent
4508		  * 						   'height' : '100%' zoom target container height in pixel or in percent 
4509		  *                            'easing' : 'smartZoomEasing' jquery easing function used when the browser doesn't support css transitions
4510		  * 						   'initCallback' : null a callback function to call after plugin initilization
4511		  * 						   'maxScale' : 3 the max scale that will be applied on the zoom target
4512		  *							   'dblClickMaxScale' : 1.8 the max scale that will be applied on the zoom target on double click
4513		  *  				     	   'mouseEnabled' : true enable plugin mouse interaction 
4514		  *					           'scrollEnabled' : true enable plugin mouse wheel behviour
4515		  *					           'dblClickEnabled' : true enable plugin mouse doubleClick behviour
4516		  *					           'mouseMoveEnabled' : true enable plugin target drag behviour
4517		  * 					       'moveCursorEnabled' : true show moveCursor for drag
4518		  * 					       'touchEnabled' : true enable plugin touch interaction 
4519		  *						       'dblTapEnabled' : true enable plugin double tap behaviour
4520		  *							   'zoomOnSimpleClick': false enable zoom on simple click (if set to true dbl lick is disabled)
4521		  *						       'pinchEnabled' : true enable zoom when user pinch on target
4522		  *						       'touchMoveEnabled' : true enable target move via touch
4523		  *                            'containerBackground' : '#FFFFFF' zoom target container background color (if containerClass is not set)
4524		  *                            'containerClass' : '' class to apply to zoom target container if you whant to change background or borders (don't change size or position via the class)
4525		  * 						  } 
4526		  */
4527	    init : function(options) {
4528	    	// is smartZoomData exists on the targetElement, we have already initialize it
4529	    	if(targetElement.data('smartZoomData'))
4530	    		return; 
4531	    		
4532	    	// Create some defaults, extending them with any options that were provided
4533			var settings = $.extend( {
4534		      'top' : "0",
4535		      'left' : "0",
4536		      'width' : "100%",
4537		      'height' : "100%",
4538		      'easing' : "smartZoomEasing",
4539		      'initCallback' : null,
4540		      'maxScale' : 3,
4541		      'dblClickMaxScale' : 1.8,
4542		      'mouseEnabled' : true,
4543		      'scrollEnabled' : true,
4544		      'dblClickEnabled' : true,
4545		      'mouseMoveEnabled' : true,
4546		      'moveCursorEnabled' : true,
4547		      'adjustOnResize' : true, 
4548		      'touchEnabled' : true,
4549		      'dblTapEnabled' : true,
4550		      'zoomOnSimpleClick': false,
4551		      'pinchEnabled' : true,
4552		      'touchMoveEnabled' : true,
4553		      'containerBackground' : "#FFFFFF",
4554		      'containerClass' : ""
4555		    }, options);
4556		    
4557			var targetElementInitialStyles = targetElement.attr('style'); // save target element initial styles
4558
4559		    // create the container that will contain the zoom target
4560		    var zoomContainerId = "smartZoomContainer"+new Date().getTime();
4561		    var containerDiv = $('<div id="'+zoomContainerId+'" class="'+settings.containerClass+'"></div>');
4562		    targetElement.before(containerDiv);
4563		    targetElement.remove();
4564		    containerDiv = $('#'+zoomContainerId);
4565		    containerDiv.css({'overflow':'hidden'});
4566		    if(settings.containerClass == "")
4567		   		containerDiv.css({'background-color':settings.containerBackground});
4568		    containerDiv.append(targetElement);
4569			
4570			// create touchInfos object that will be use to manage zoom with touch events
4571			var touchInfos = new Object();
4572			touchInfos.lastTouchEndTime = 0; // this var is use to know if user had doubleTap or not 
4573			touchInfos.lastTouchPositionArr = null; // list of touch point used for pinch
4574			touchInfos.touchMove = false; // is the user is in move mode?
4575			touchInfos.touchPinch = false; // or is the user is in pinch mode?
4576			
4577			// smartZoomData is used to saved every plugin vars
4578		    targetElement.data('smartZoomData', {
4579               settings : settings, // given settings
4580               containerDiv : containerDiv, // target container
4581               originalSize: {width:targetElement.width(), height:targetElement.height()}, // plugin target size at the beginning
4582               originalPosition: targetElement.offset(), // plugin target position at the beginning 
4583               transitionObject:getBrowserTransitionObject(), // use to know if the browser is compatible with css transition
4584               touch:touchInfos, // save touchInfos
4585               mouseWheelDeltaFactor:0.15, // enable to slow down the zoom via mouse wheel
4586               currentWheelDelta:0, // the current mouse wheel delta used to calculate scale to apply
4587               adjustedPosInfos:null, // use to save the adjust information in "adjustToContainer" method (so we can access the normal target size in plugin when we whant)
4588               moveCurrentPosition:null, // save the current mouse/touch position use in "moveOnMotion" method   
4589               moveLastPosition:null, // save the last mouse/touch position use in "moveOnMotion" method  
4590               mouseMoveForPan:false, // use to know if the user pan or not
4591               currentActionType:'', // use to save the current user action type (equal to 'ZOOM' or 'PAN')
4592               initialStyles:targetElementInitialStyles, // use in destroy method to reset initial styles
4593               currentActionStep:'' // equal to 'START' or 'END'
4594            });
4595            
4596			// adjust the contain and target size into the page            
4597		    adjustToContainer();
4598
4599			// listening mouse and touch events
4600			if(settings.touchEnabled == true)
4601	        	targetElement.bind('touchstart.smartZoom', touchStartHandler);
4602	        if(settings.mouseEnabled == true){
4603	        	if(settings.mouseMoveEnabled == true)
4604		        	targetElement.bind('mousedown.smartZoom', mouseDownHandler);
4605		        if(settings.scrollEnabled == true){
4606		        	containerDiv.bind('mousewheel.smartZoom', mouseWheelHandler);
4607			        containerDiv.bind( 'mousewheel.smartZoom DOMMouseScroll.smartZoom', containerMouseWheelHander);
4608		        }
4609		        if(settings.dblClickEnabled == true && settings.zoomOnSimpleClick == false)
4610		        	containerDiv.bind('dblclick.smartZoom', mouseDblClickHandler);
4611	        }
4612	       	document.ondragstart = function () { return false; }; // allow to remove browser default drag behaviour
4613	        if(settings.adjustOnResize == true)
4614		    	$(window).bind('resize.smartZoom', windowResizeEventHandler); // call "adjustToContainer" on resize
4615
4616		    if(settings.initCallback != null) // call callback function after plugin initialization
4617		    	settings.initCallback.apply(this, targetElement);
4618	    },
4619	   /**
4620		  * zoom function used into the plugin and accessible via direct call (ex : $('#zoomImage').smartZoom('zoom', 0.2);)
4621		  * @param {Number} scaleToAdd : the scale to add to the plugin target current scale (often < 1) 
4622		  * @param {Point} globalRequestedPosition {'x': global requested position in x
4623		  * 						                'y': global requested position in y
4624		  * 	   						           }  if this parameter is missing the zoom will target the object center
4625		  * @param {Number} duration : zoom effect duration 700ms by default
4626		  */
4627	    zoom : function(scaleToAdd, globalRequestedPosition, duration){
4628	    	
4629	    	var smartData = targetElement.data('smartZoomData');
4630	    	var globaRequestedX;
4631	    	var globaRequestedY;
4632	    	if(!globalRequestedPosition){ // use target center if globalRequestedPosition is not set
4633	    		var containerRect = getRect(smartData.containerDiv);
4634		    	globaRequestedX = containerRect.x + containerRect.width/2;
4635		    	globaRequestedY = containerRect.y + containerRect.height/2;
4636		    }else{
4637		    	globaRequestedX = globalRequestedPosition.x;
4638		    	globaRequestedY = globalRequestedPosition.y;
4639		    }
4640		    
4641	    	// stop previous effect before make calculation
4642	    	stopAnim(ESmartZoomEvent.ZOOM); 
4643	    	
4644	  		var targetRect = getTargetRect(true); // the target rectangle in global position
4645	 		var originalSize = smartData.originalSize;
4646	    	var newScale = (targetRect.width / originalSize.width) + scaleToAdd; // calculate new scale to apply
4647
4648	    	// manage scale min, max
4649	  		newScale = Math.max(smartData.adjustedPosInfos.scale, newScale); // the scale couldn't be lowest than the initial scale
4650	  		newScale = Math.min(smartData.settings.maxScale, newScale); // the scale couldn't be highest than the max setted by user
4651	  		
4652	        var newWidth = originalSize.width * newScale; // new size to apply according to new scale
4653		  	var newHeight = originalSize.height * newScale;
4654		  
4655		  	var positionGlobalXDiff = globaRequestedX - targetRect.x; // the position difference between with the target position
4656		  	var positionGlobalYDiff = globaRequestedY - targetRect.y;
4657		  	var sizeRatio =  newWidth / targetRect.width;
4658		
4659		  	var newGlobalX = targetRect.x - ((positionGlobalXDiff * sizeRatio) - positionGlobalXDiff); // apply the ratio to positionGlobalDiff and then find the final target point
4660		  	var newGlobalY = targetRect.y - ((positionGlobalYDiff * sizeRatio) - positionGlobalYDiff);
4661		    var validPosition = getValidTargetElementPosition(newGlobalX, newGlobalY, newWidth, newHeight); // return a valid position from the calculated position 
4662		
4663			if(duration == null) // default effect duration is 700ms
4664				duration = 700;
4665
4666			dispatchSmartZoomEvent(ESmartZoomEvent.ZOOM, ESmartZoomEvent.START, false); 
4667			
4668			animate(targetElement, validPosition.x, validPosition.y, newWidth, newHeight, duration, function(){ // set the new position and size via the animation function
4669				smartData.currentWheelDelta = 0; // reset the weelDelta when zoom end
4670			 	updateMouseMoveCursor(); // remove "move" cursor when zoom end
4671			 	dispatchSmartZoomEvent(ESmartZoomEvent.ZOOM, ESmartZoomEvent.END, false); 
4672			});
4673			
4674	    },
4675	     /**
4676		  * pan function accessible via direct call (ex : $('#zoomImage').smartZoom('pan', 5, 0);)
4677		  * @param {Number} xToAdd : a number to add to the object current position in X
4678		  * @param {Point} yToAdd : a number to add to the object current position in Y
4679		  * @param {Number} duration : move effect duration 700ms by default
4680		  */
4681	    pan : function(xToAdd, yToAdd, duration){
4682	    	if(xToAdd == null || yToAdd == null) // check params
4683	    		return;
4684	    		
4685	    	if(duration == null) // default pan duration is 700ms
4686				duration = 700;
4687	    	var currentPosition = targetElement.offset();
4688	    	
4689	    	var targetRect = getTargetRect();
4690	    	var validPosition = getValidTargetElementPosition(currentPosition.left+xToAdd, currentPosition.top+yToAdd, targetRect.width, targetRect.height); // add the given numbers to the current coordinates and valid the result
4691	    	
4692	    	if(validPosition.x != currentPosition.left || validPosition.y != currentPosition.top){
4693	    		// stop previous effect before make calculation
4694	    		stopAnim(ESmartZoomEvent.PAN);
4695	    		dispatchSmartZoomEvent(ESmartZoomEvent.PAN, ESmartZoomEvent.START, false); 
4696				animate(targetElement, validPosition.x, validPosition.y, targetRect.width, targetRect.height, duration, function(){ // set the new position and size via the animation function
4697				 	dispatchSmartZoomEvent(ESmartZoomEvent.PAN, ESmartZoomEvent.END, false); 
4698				});
4699			}
4700	    },
4701	     /**
4702		  * destroy function accessible via direct call (ex : $('#zoomImage').smartZoom('destroy');)
4703		  * use this function to clean and remove smartZoom plugin 
4704		  */
4705	    destroy : function() {
4706	    	var smartData = targetElement.data('smartZoomData');
4707	    	if(!smartData)
4708	    		return;
4709	    	stopAnim(); // stop current animation
4710	    	var containerDiv = smartData.containerDiv;
4711	    	// remove all listenerns 
4712	        targetElement.unbind('mousedown.smartZoom');
4713	        targetElement.unbind('touchstart.smartZoom');
4714	    	containerDiv.unbind('mousewheel.smartZoom');
4715	        containerDiv.unbind('dblclick.smartZoom');
4716	    	containerDiv.unbind( 'mousewheel.smartZoom DOMMouseScroll.smartZoom');
4717		    $(window).unbind('resize.smartZoom');
4718			$(document).unbind('mousemove.smartZoom');
4719			$(document).unbind('mouseup.smartZoom');
4720			$(document).unbind('touchmove.smartZoom');
4721	    	$(document).unbind('touchend.smartZoom');
4722		
4723			targetElement.css({"cursor":"default"}); // reset default cursor
4724		    containerDiv.before(targetElement); // move target element to original container 
4725	   		animate(targetElement, smartData.originalPosition.left, smartData.originalPosition.top,  smartData.originalSize.width, smartData.originalSize.height, 5); // reset initial position
4726	   		targetElement.removeData('smartZoomData');// clean saved data
4727		    containerDiv.remove(); // remove zoom container
4728		    targetElement.attr('style', smartData.initialStyles); // reset initial styles
4729		    targetElement.trigger(ESmartZoomEvent.DESTROYED); // dispatch event after plugin destruction
4730	    },
4731	    /**
4732	     * call this funcion to know if the plugin is used 
4733	     */
4734	    isPluginActive : function(){
4735	    	return targetElement.data('smartZoomData') != undefined;
4736	    }
4737    };
4738
4739    if (publicMethods[method] ) { // if the parameter is an existing method, then we call this method
4740    	return publicMethods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
4741    } else if (typeof method === 'object' || ! method ) { // else if it's an object we initilize the plugin
4742    	if(targetElement[0].tagName.toLowerCase() == "img" && !targetElement[0].complete){ // if the target is an image when wait for image loading before initialization
4743    		targetElement.bind('load.smartZoom',{arguments:arguments[0]},  imgLoadedHandler);
4744   	  	}else{
4745    		publicMethods.init.apply( targetElement, [arguments[0]]);
4746    	} 
4747    } else {
4748    	$.error( 'Method ' +  method + ' does not exist on e-smartzoom jquery plugin' );
4749    }    
4750    
4751    /**
4752     * call zoom function on mouse wheel event
4753 	 * @param {Object} e : mouse event
4754 	 * @param {Object} delta : wheel direction 1 or -1
4755     */
4756    function mouseWheelHandler(e, delta){
4757    	var smartData = targetElement.data('smartZoomData');
4758		if(smartData.currentWheelDelta*delta < 0) // if current and delta have != sign we set 0 to go to other direction
4759			smartData.currentWheelDelta = 0;
4760		smartData.currentWheelDelta += delta; // increment delta zoom faster when the user use wheel again
4761    	publicMethods.zoom(smartData.mouseWheelDeltaFactor*smartData.currentWheelDelta, {"x":e.pageX, "y":e.pageY}); // 0.15
4762    }
4763	  
4764	/**
4765     * prevent page scroll when scrolling on zoomableContainer
4766 	 * @param {Object} e : mouse event
4767     */  
4768    function containerMouseWheelHander(e){
4769   		e.preventDefault();
4770    }
4771    
4772    /**
4773     * update mouse cursor (move or default) if the zoom target is draggable 
4774     */
4775    function updateMouseMoveCursor(){
4776		var smartData = targetElement.data('smartZoomData');
4777    	if(smartData.settings.mouseMoveEnabled != true || smartData.settings.moveCursorEnabled != true)
4778    		return;
4779		var targetRect = getTargetRect();
4780    	var currentScale = (targetRect.width / smartData.originalSize.width);
4781    	if(parseInt(currentScale*100)>parseInt(smartData.adjustedPosInfos.scale*100)) // multiply by 100 to resolve precision problem
4782    		targetElement.css({"cursor":"move"});     
4783    	else	
4784    		targetElement.css({"cursor":"default"});
4785    }
4786    
4787    /**
4788     * call "zoomOnDblClick" when user double click
4789     * @param {Object} e : mouse event
4790     */
4791    function mouseDblClickHandler(e){
4792    	 zoomOnDblClick(e.pageX, e.pageY);
4793    }
4794    
4795    /**
4796     * save mouse position on mouse down (positions will be used in moveOnMotion function)
4797     * @param {Object} e : mouse event 
4798     */
4799    function mouseDownHandler(e){
4800    	e.preventDefault(); // prevent default browser drag
4801		$(document).on('mousemove.smartZoom', mouseMoveHandler); // add mouse move and mouseup listeners to enable drag
4802		$(document).bind('mouseup.smartZoom', mouseUpHandler);
4803		var smartData = targetElement.data('smartZoomData'); // save mouse position on mouse down
4804		smartData.moveCurrentPosition = new Point(e.pageX, e.pageY);
4805		smartData.moveLastPosition =  new Point(e.pageX, e.pageY);
4806    }
4807    
4808    /**
4809     * call "moveOnMotion" when the mouse move after mouseDown
4810     * @param {Object} e : mouse event
4811     */
4812    function mouseMoveHandler(e){
4813
4814    	var smartData = targetElement.data('smartZoomData');
4815    	if(smartData.mouseMoveForPan || (!smartData.mouseMoveForPan && smartData.moveCurrentPosition.x != e.pageX && smartData.moveCurrentPosition.y != e.pageY)){
4816    		smartData.mouseMoveForPan = true;
4817    		moveOnMotion(e.pageX, e.pageY, 0, false);
4818    	}
4819	}
4820    
4821    /**
4822     *  stop the drag on mouseup
4823     * @param {Object} e : mouse event
4824     */
4825    function mouseUpHandler(e){
4826    	
4827    	var smartData = targetElement.data('smartZoomData');
4828    	if(smartData.mouseMoveForPan){
4829    		smartData.mouseMoveForPan = false;
4830	    	if(smartData.moveLastPosition.distance(smartData.moveCurrentPosition) > 4){ // smooth the drag end when user move the mouse fast
4831				var interpolateP = smartData.moveLastPosition.interpolate(smartData.moveCurrentPosition, -4);
4832				moveOnMotion(interpolateP.x, interpolateP.y, 500, true);
4833			}else{
4834				moveOnMotion(smartData.moveLastPosition.x, smartData.moveLastPosition.y, 0, true);
4835			}
4836		}else if(smartData.settings.zoomOnSimpleClick){
4837			zoomOnDblClick(e.pageX, e.pageY);
4838		}
4839		
4840		$(document).unbind('mousemove.smartZoom'); // remove listeners when drag is done
4841		$(document).unbind('mouseup.smartZoom');    	
4842    }
4843    
4844    /**
4845     * save touch position and init vars on touch start (information will be use in touchMoveHandler function and touch end)
4846     * @param {Object} e : touch event  
4847     */
4848    function touchStartHandler(e){
4849    	targetElement.touchStartTime = e.timeStamp;
4850    	// e.preventDefault(); // prevent default browser drag
4851    	
4852    	$(document).unbind('touchmove.smartZoom'); // unbind if we already listen touch events
4853	    $(document).unbind('touchend.smartZoom');
4854    	
4855	    $(document).bind('touchmove.smartZoom', touchMoveHandler); // listen move and touch end events to manage drag on touch
4856    	$(document).bind('touchend.smartZoom', touchEndHandler);
4857    	
4858		var touchList = e.originalEvent.touches; // get touch infos from event 
4859		var firstTouch = touchList[0];
4860		     
4861		var smartData = targetElement.data('smartZoomData'); 
4862		smartData.touch.touchMove = false; // will be set to true if the user start drag
4863		smartData.touch.touchPinch = false; // will be set to true if the user whant to pinch (zoom)
4864    	smartData.moveCurrentPosition = new Point(firstTouch.pageX, firstTouch.pageY); // save the finger position on screen on touch start
4865    	smartData.moveLastPosition = new Point(firstTouch.pageX, firstTouch.pageY);
4866    	smartData.touch.lastTouchPositionArr = new Array(); // save touch position off all fingers to manage pinch
4867    	var currentTouch;
4868    	var nbTouch = touchList.length;
4869    	for(var i = 0;i<nbTouch;++i){
4870    		currentTouch = touchList[i];
4871    		smartData.touch.lastTouchPositionArr.push(new Point(currentTouch.pageX, currentTouch.pageY));
4872    	}
4873    }
4874    
4875    /**
4876     *  manage pinch or drag when touch move
4877     * @param {Object} e : touch event
4878     */
4879    function touchMoveHandler(e){ 
4880
4881 		e.preventDefault(); // prevent default browser behaviour
4882
4883    	var smartData = targetElement.data('smartZoomData');
4884    	
4885		var touchListEv = e.originalEvent.touches; // get touch information on event
4886    	var nbTouch = touchListEv.length;
4887		var currentFirstTouchEv = touchListEv[0];
4888		
4889		if(nbTouch == 1 && !smartData.touch.touchPinch && smartData.settings.touchMoveEnabled == true){ // if the user use only one finger and touchPinch==false => we manage drag
4890			if(!smartData.touch.touchMove){ 
4891				var downLastPoint = smartData.touch.lastTouchPositionArr[0];
4892				if(downLastPoint.distance(new Point(currentFirstTouchEv.pageX, currentFirstTouchEv.pageY))<3){ // check if user really had moved
4893					return;
4894				}
4895				else
4896					smartData.touch.touchMove = true;
4897			}
4898			moveOnMotion(currentFirstTouchEv.pageX, currentFirstTouchEv.pageY, 0, false);
4899		}else if(nbTouch == 2 && !smartData.touch.touchMove && smartData.settings.pinchEnabled == true){ // if the user use two fingers and touchMove==false => we manage pinch 
4900			smartData.touch.touchPinch = true;
4901			
4902			var currentSecondTouchEv = touchListEv[1]; // get current fingers position and last fingers positions
4903			var lastP1 = smartData.touch.lastTouchPositionArr[0];
4904			var lastP2 = smartData.touch.lastTouchPositionArr[1];
4905			var currentP1 = new Point(currentFirstTouchEv.pageX, currentFirstTouchEv.pageY);
4906			var currentP2 = new Point(currentSecondTouchEv.pageX, currentSecondTouchEv.pageY);
4907			
4908			var currentP1P2Distance = currentP1.distance(currentP2); // distance between current two fingers positions
4909			var lastP1P2Distance = lastP1.distance(lastP2); // distance between the last two fingers positions registered 
4910			var currentDistance = currentP1P2Distance - lastP1P2Distance; // distance between last move and current move
4911			
4912			if(Math.abs(currentDistance)<3) // finger pixel error (jump between in and out mode sometimes if i don't do this check)  
4913				return;
4914			
4915			var middle =  new Point((currentP1.x + currentP2.x) /2, (currentP1.y + currentP2.y) /2); // get the point between the two fingers
4916			var targetRect = getTargetRect(); // the current plugin target size
4917			var originSize = smartData.originalSize; // original plugin target size
4918			var currentScale = (targetRect.width / originSize.width); // current scale base on original size
4919			var newZoomValueToAdd = currentP1P2Distance/lastP1P2Distance; // scale between current distance and last fingers distance
4920			var newZoomScale = ((targetRect.width * newZoomValueToAdd) / originSize.width); // the new zoom scale
4921			
4922			publicMethods.zoom(newZoomScale - currentScale, middle, 0); // call zoom fonction with the scale to add (newZoomScale - currentScale)
4923			
4924			smartData.touch.lastTouchPositionArr[0] = currentP1; //update last touch position points for next function iteration 
4925			smartData.touch.lastTouchPositionArr[1] = currentP2;
4926		}
4927    }
4928    
4929    /**
4930     * manage touch move end or double tap at touch end
4931     * @param {Object} e : touch event
4932     */
4933    function touchEndHandler(e){
4934
4935    	if (e.timeStamp - targetElement.touchStartTime > 600) {
4936 			e.preventDefault(); // prevent default browser behaviour
4937    	}
4938 		
4939 		var nbTouchAtEnd = e.originalEvent.touches.length;
4940    	if(nbTouchAtEnd == 0){ // unbind listeners if the user take off all his fingers
4941	    	$(document).unbind('touchmove.smartZoom');
4942		    $(document).unbind('touchend.smartZoom');
4943    	}
4944    	var smartData = targetElement.data('smartZoomData');
4945    	
4946    	if(smartData.touch.touchPinch) // nothing to do for pinch behaviour in this function
4947    		return;
4948    		
4949    	if(smartData.touch.touchMove){ // smooth motion at end if we are in drag mode
4950    		if(smartData.moveLastPosition.distance(smartData.moveCurrentPosition) > 2){ // smooth only if the user drag fast
4951				var interpolateP = smartData.moveLastPosition.interpolate(smartData.moveCurrentPosition, -4); // the end smooth motion is calculate according to last finger motion 
4952				moveOnMotion(interpolateP.x, interpolateP.y, 500, true);
4953			}
4954    	}else{
4955    		if(smartData.settings.dblTapEnabled == true && smartData.touch.lastTouchEndTime != 0 && new Date().getTime() - smartData.touch.lastTouchEndTime < 400){ // if the user double tap (double tap if there is less than 300 ms between first and second tap)
4956				var lastStartPos = smartData.touch.lastTouchPositionArr[0];
4957			    zoomOnDblClick(lastStartPos.x, lastStartPos.y);  
4958	    	}
4959	    	smartData.touch.lastTouchEndTime = new Date().getTime();
4960    	}
4961    }
4962    
4963    /**
4964     *  manage plugin target move after mouse or finger motion
4965     * @param {Number} xPos : new x position to set
4966     * @param {Number} yPos : new y position to set 
4967     * @param {Number} duration : move effect duration
4968     */
4969    function moveOnMotion(xPos, yPos, duration, motionEnd){
4970    	stopAnim(ESmartZoomEvent.PAN);// stop previous effect before make calculation
4971    	
4972    	var smartData = targetElement.data('smartZoomData');
4973    	smartData.moveLastPosition.x = smartData.moveCurrentPosition.x; // save the current position in "moveLastPosition" before moving the plugin target
4974    	smartData.moveLastPosition.y = smartData.moveCurrentPosition.y; // (moveLastPosition will be use to smooth last motion in "touchEndHandler" and "mouseUpHandler")
4975    	
4976    	var currentPosition = targetElement.offset(); // the target current position
4977    	var targetRect = getTargetRect(); // current target size
4978    	
4979    	var newMarginLeft = currentPosition.left + (xPos - smartData.moveCurrentPosition.x); // add current mouseX (orTouchX) position difference to the target position
4980    	var newMarginTop = currentPosition.top + (yPos - smartData.moveCurrentPosition.y);
4981    	
4982    	var validPosition = getValidTargetElementPosition(newMarginLeft, newMarginTop, targetRect.width, targetRect.height); // check if the new position is valid
4983	   	
4984		dispatchSmartZoomEvent(ESmartZoomEvent.PAN, ESmartZoomEvent.START, false); 
4985
4986	   	animate(targetElement, validPosition.x, validPosition.y, targetRect.width, targetRect.height, duration, motionEnd == true ? function(){
4987		 	dispatchSmartZoomEvent(ESmartZoomEvent.PAN, ESmartZoomEvent.END, false); 
4988	   	}: null); // move to the right position
4989	   	
4990	 	smartData.moveCurrentPosition.x = xPos; // save the new position
4991		smartData.moveCurrentPosition.y = yPos;
4992	}
4993    
4994    /**
4995     * manage zoom when user double click or double tap 
4996     * @param {Number} pageX : double click (or tap) x position in page
4997     * @param {Number} pageY : double click (or tap) y position in page
4998     */
4999    function zoomOnDblClick(pageX, pageY){
5000    	var smartData = targetElement.data('smartZoomData');
5001 		var originalSize = smartData.originalSize; // original target size
5002 		var targetRect = getTargetRect(); // current target size
5003    	var currentScale = (targetRect.width / originalSize.width); // the current target scale
5004    	var originalScale = smartData.adjustedPosInfos.scale; // original scale
5005    	var dblClickMaxScale = parseFloat(smartData.settings.dblClickMaxScale); // the doucble click or double tap max scale
5006    	
5007    	var scaleDiff; // if the current scale is close from "dblClickMaxScale" go to "originalScale" else go to "dblClickMaxScale" 
5008    	if(currentScale.toFixed(2)>dblClickMaxScale.toFixed(2) || Math.abs(dblClickMaxScale - currentScale)>Math.abs(currentScale-originalScale)){
5009    		scaleDiff = dblClickMaxScale - currentScale;
5010    	}else{
5011    		scaleDiff = originalScale - currentScale;
5012    	}
5013
5014    	publicMethods.zoom(scaleDiff, {"x":pageX, "y":pageY});	 
5015    }
5016    
5017    /**
5018     * stop the animation
5019     */
5020    function stopAnim(userActionType){
5021
5022    	var smartData = targetElement.data('smartZoomData');
5023    	if(smartData.transitionObject){ // if css transformation is surpported
5024    		if(smartData.transitionObject.cssAnimHandler) // stop the transformation end handler if it exists
5025    		  targetElement.off($.support.transition, smartData.transitionObject.cssAnimTimer); 
5026			var originalSize = smartData.originalSize; // get the original target size   			
5027	   		var targetRect = getTargetRect(); // the target current size
5028	   	
5029		   	var cssObject = new Object(); // set the current current target size and the target scale to css transformation so it stop previous transformation
5030		  	cssObject[smartData.transitionObject.transition] = 'all 0s'; // apply transformation now
5031		  	if(smartData.transitionObject.css3dSupported){
5032			  	cssObject[smartData.transitionObject.transform] = 'translate3d('+targetRect.x+'px, '+targetRect.y+'px, 0) scale3d('+targetRect.width/originalSize.width+','+targetRect.height/originalSize.height+', 1)';
5033			}else{
5034		  		cssObject[smartData.transitionObject.transform] = 'translateX('+targetRect.x+'px) translateY('+targetRect.y+'px) scale('+targetRect.width/originalSize.width+','+targetRect.height/originalSize.height+')';
5035		    }
5036		  	targetElement.css(cssObject);	
5037    			
5038    	}else{
5039    		targetElement.stop(); // if we use a jquery transformation, just call stop function
5040    	}
5041    	updateMouseMoveCursor(); // update mouse move cursor after animation stop (set the cross cursor or not)
5042
5043    	if(userActionType != null)
5044    		dispatchSmartZoomEvent(userActionType, '', true); 
5045    }
5046    
5047    /**
5048     * manage position validation
5049     * @param {Number} marginLeft : global x position
5050     * @param {Number} marginTop : global y position
5051     * @param {Number} width : element width
5052     * @param {Number} height : element height
5053     */
5054    function getValidTargetElementPosition(xPosition, yPosition, width, height){
5055    	var smartData = targetElement.data('smartZoomData');
5056    	 // adjusting if the content is out of the initial content box from "adjustedPosInfos"
5057	    var newMarginTop = Math.min(smartData.adjustedPosInfos.top, yPosition); // adjust in top 
5058	    newMarginTop += Math.max(0, (smartData.adjustedPosInfos.top + smartData.adjustedPosInfos.height) - (ne
5058wMarginTop + height)) // adjust in bottom
5059	    var newMarginLeft = Math.min(smartData.adjustedPosInfos.left, xPosition); // adjust in left
5060	    newMarginLeft += Math.max(0, (smartData.adjustedPosInfos.left + smartData.adjustedPosInfos.width) - (newMarginLeft + width)); // adjust in right
5061	    return new Point(newMarginLeft.toFixed(2), newMarginTop.toFixed(2));
5062    }
5063    
5064    /**
5065     * when the plugin target is an image we wait for image loading before initilization 
5066     * @param {Object} e : load event
5067     */
5068    function imgLoadedHandler(e){
5069    	targetElement.unbind('load.smartZoom');
5070    	publicMethods.init.apply( targetElement, [e.data.arguments]); 
5071    }
5072    
5073	/**
5074	 * this function fit the plugin target to the zoom container at initialization and when the window is resized
5075	 */    
5076    function adjustToContainer(){
5077    	
5078 		var smartData = targetElement.data('smartZoomData');
5079 		var containerDiv = smartData.containerDiv; // the zoom container 
5080 		var originalSize = smartData.originalSize; // target original size
5081 		
5082 		// get the zoomable container position from settings
5083 		var parentOffset = containerDiv.parent().offset(); 
5084 		var containerDivNewLeft = getContainerDivPositionFromSettings(smartData.settings.left, parentOffset.left, containerDiv.parent().width());
5085 		var containerDivNewTop = getContainerDivPositionFromSettings(smartData.settings.top, parentOffset.top, containerDiv.parent().height());
5086 		
5087 		containerDiv.offset({left: containerDivNewLeft, top: containerDivNewTop}); // apply position find
5088  		containerDiv.width(getContainerDivSizeFromSettings(smartData.settings.width, containerDiv.parent().width(), containerDivNewLeft - parentOffset.left)); // apply size found to zoomablecontainer 
5089		containerDiv.height(getContainerDivSizeFromSettings(smartData.settings.height, containerDiv.parent().height(), containerDivNewTop - parentOffset.top));
5090		
5091	  	var containerRect = getRect(containerDiv); // get the rectangle from the new containerDiv position and size
5092	  	var scaleToFit = Math.min(Math.min(containerRect.width/originalSize.width, containerRect.height/originalSize.height), 1).toFixed(2); // scale to use to include the target into containerRect
5093	  	var newWidth = originalSize.width * scaleToFit; // we could now find the new size
5094	  	var newHeight = originalSize.height * scaleToFit;
5095	  
5096	    // store the position and size information in adjustedPosInfos object
5097	  	smartData.adjustedPosInfos = {"left":(containerRect.width - newWidth)/2 + parentOffset.left, "top": (containerRect.height - newHeight)/2 + parentOffset.top, "width": newWidth, "height" : newHeight, "scale":scaleToFit};
5098	  	stopAnim();
5099	  	// call animate method with 10 ms duration to apply new target position and size
5100	  	animate(targetElement,  smartData.adjustedPosInfos.left , smartData.adjustedPosInfos.top, newWidth, newHeight, 0, function() {
5101	  		targetElement.css('visibility','visible'); // set target visibility to visible if developper whant to hide it before the plugin resize
5102	  	});
5103	  	updateMouseMoveCursor(); 
5104    }
5105    
5106    /**
5107     * animate the plugin target  
5108     * @param {Object} target : the element to animate
5109     * @param {Number} globalLeft : the global x target position 
5110     * @param {Number} globalTop : the global y target position 
5111     * @param {Number} width : targeted width
5112     * @param {Number} width : targeted height
5113     * @param {Number} duration : effect duration
5114     * @param {Function} callback : function to call when effect end
5115     * 
5116     */
5117    function animate(target, globalLeft, globalTop, width, height, duration, callback){
5118    	
5119    	var smartData = targetElement.data('smartZoomData');
5120 		var parentOffset = smartData.containerDiv.offset();
5121   		var left = globalLeft - parentOffset.left; // get the relative position from parent 
5122   		var top = globalTop - parentOffset.top;
5123   		
5124    	if (smartData.transitionObject != null) { // use css transition if supported
5125    		var originalSize = smartData.originalSize;
5126		  	var cssObject = new Object();
5127		  	cssObject[smartData.transitionObject.transform+'-origin'] = '0 0';
5128		  	cssObject[smartData.transitionObject.transition] = 'all '+duration / 1000+'s ease-out'; // set effect duration
5129		  	
5130		  	if(smartData.transitionObject.css3dSupported) // use css 3d translate if supported
5131		  		cssObject[smartData.transitionObject.transform] = 'translate3d('+left+'px, '+top+'px, 0) scale3d('+width/originalSize.width+','+height/originalSize.height+', 1)';
5132		  	else
5133		  		cssObject[smartData.transitionObject.transform] = 'translateX('+left+'px) translateY('+top+'px) scale('+width/originalSize.width+','+height/originalSize.height+')';
5134		  	if(callback != null){
5135		  		smartData.transitionObject.cssAnimHandler = callback;
5136          target.one($.support.transition.end, smartData.transitionObject.cssAnimHandler);
5137        }
5138		  	target.css(cssObject); // apply css transformation
5139		}else{ // use JQuery animate if css transition is not supported
5140	    	
5141	    	target.animate({"margin-left": left, "margin-top": top, "width": width, "he
5141ight" : height}, {duration:duration, easing:smartData.settings.easing, complete:function() {
5142			 	if(callback != null)
5143			 		callback();
5144			}});
5145		}
5146    }
5147    
5148	/**
5149	 * get the plugin target rectangle on screen 
5150	 * @param {Boolean} globalPosition : if true return global position else return relative position
5151	 * @return {Object} {'x':'x Position', 'y':'y Position', 'width':' element width', 'height': 'element height'}
5152	 */	    
5153    function getTargetRect(globalPosition){
5154    	var smartData = targetElement.data('smartZoomData');
5155		var width = targetElement.width(); // get the current object size
5156		var height = targetElement.height();
5157		var position = targetElement.offset(); // global position
5158		var x = parseInt(position.left); // save global position in vars
5159		var y = parseInt(position.top);
5160		
5161		var parentOffset = smartData.containerDiv.offset(); // get zoomable container global position
5162		
5163		if(globalPosition != true){ // set local position
5164			x = parseInt(x) - parentOffset.left;    		
5165			y = parseInt(y) - parentOffset.top;  
5166		}
5167		
5168    	if (smartData.transitionObject != null) { // if CSS3 transition is enabled
5169    		var transformMatrix = targetElement.css(smartData.transitionObject.transform);
5170    		if(transformMatrix && transformMatrix != "" && transformMatrix.search('matrix') != -1){ // get the target css matrix tranform 
5171    			var scale;
5172    			var arrValues;
5173    			if(transformMatrix.search('matrix3d') != -1){ // check the matrix type
5174    				arrValues = transformMatrix.replace('matrix3d(','').replace(')','').split(',');
5175    				scale = arrValues[0]; // get target current scale
5176    			}else{
5177    				arrValues = transformMatrix.replace('matrix(','').replace(')','').split(',');
5178    				scale = arrValues[3];// get target current scale
5179    				x = parseFloat(arrValues[4]);// get target current position
5180    				y = parseFloat(arrValues[5]);
5181					if(globalPosition){ // adjust for global
5182						x = parseFloat(x) + parentOffset.left;    		
5183						y = parseFloat(y) + parentOffset.top;
5184			    	}
5185    			}
5186    			width = scale * width; // find the actual object size thanks to current scale
5187    			height = scale * height;
5188    		}
5189    	}
5190    	return {'x' : x,'y' : y, 'width' : width, 'height' : height};
5191    }
5192
5193    /**
5194     * dispatch zoom or pan event 
5195     * @param {Boolean} fromZoom : set to true if the function is call from zoom action
5196     * 
5197     **/
5198    function dispatchSmartZoomEvent(actionType, actionStep, stop){
5199		var smartData = targetElement.data('smartZoomData');
5200		var eventTypeToDispatch = '';
5201
5202		if(stop == true && smartData.currentActionType != actionType){ // if the action type has changed and that the function is called from "stopAnim" dispatch END event
5203			eventTypeToDispatch = smartData.currentActionType+'_'+ESmartZoomEvent.END;
5204			smartData.currentActionType = '';
5205			smartData.currentActionStep = '';
5206		}else{ 
5207			if(smartData.currentActionType != actionType || smartData.currentActionStep == ESmartZoomEvent.END){ // if the current action had changed (MOVE to ZOOM for exemple) and the last action step was END we whant to dispatch START
5208				smartData.currentActionType = actionType;
5209				smartData.currentActionStep = ESmartZoomEvent.START;
5210				eventTypeToDispatch = smartData.currentActionType+'_'+smartData.currentActionStep;
5211			}else if(smartData.currentActionType == actionType && actionStep == ESmartZoomEvent.END){ // dispatch END if actionstep ask is END and action type don't change
5212				smartData.currentActionStep = ESmartZoomEvent.END;
5213				eventTypeToDispatch = smartData.currentActionType+'_'+smartData.currentActionStep;
5214				smartData.currentActionType = '';
5215				smartData.currentActionStep = '';
5216			}
5217		}
5218
5219		if(eventTypeToDispatch != ''){ // dispatch event if we have to
5220			var ev = jQuery.Event(eventTypeToDispatch);
5221			ev.targetRect = getTargetRect(true);
5222			ev.scale = ev.targetRect.width / smartData.originalSize.width;
5223      //console.log(targetElement, eventTypeToDispatch);
5224			targetElement.trigger(ev);
5225		}
5226    }
5227
5228    /**
5229	 * return an object that contains the kind of CSS3 supported transition
5230	 *  @return {Object} {'transition':'-webkit-transition', 'transform':'-webkit-transform', 'css3dSupported':'true'}
5231	 */	 
5232    function getBrowserTransitionObject(){
5233    	
5234	   var pageBody = document.body || document.documentElement;
5235	   var bodyStyle = pageBody.style;
5236	   
5237	   var transitionTestArr = ['transition', 'WebkitTransition', 'MozTransition', 'MsTransition', 'OTransition']; // all type all transitions to test
5238	   var transitionArr = ['transition', '-webkit-transition', '-moz-transition', '-ms-transition', '-o-transition'];
5239	   var transformArr = ['transform', '-webkit-transform', '-moz-transform', '-ms-transform', '-o-transform'];
5240		
5241	   var length = transitionTestArr.length;
5242	   var transformObject;
5243	   for(var i=0; i<length; i++){ // for all kind of css transition we make a test
5244	   		if(bodyStyle[transitionTestArr[i]] != null){
5245   				transformStr = transformArr[i];
5246	   			var div = $('<div style="position:absolute;">Translate3d Test</div>');
5247			    $('body').append(div); // try a transformation on a new div each time
5248			    transformObject = new Object();
5249			    transformObject[transformArr[i]] = "translate3d(20px,0,0)";
5250			    div.css(transformObject);
5251			    css3dSupported = ((div.offset().left - $('body').offset().left) == 20); // if translate3d(20px,0,0) via transformArr[i] == 20px the transformation is valid for this browser
5252			    div.empty().remove();
5253	   			if(css3dSupported){ // return the kind of transformation supported
5254					return {transition:transitionArr[i], transform:transformArr[i], css3dSupported:css3dSupported};
5255				}	   			
5256	   		}
5257	   }
5258	   return null; 
5259    }
5260    
5261    /**
5262	 * get the plugin target rectangle on screen 
5263	 * @param {Object} settingsValue : a number or a string value given in plugin params
5264	 * @param {Number} zoomableContainerParentValue : zoomable container parent width or height
5265	 * @param {Number} divPosDiff : zoomable container parent and zoomable container position difference
5266	 * @return {Number} return the zoomable container size (in pixel) from setting value (pixel or percent)
5267	 */	 
5268    function getContainerDivSizeFromSettings(settingsValue, zoomableContainerParentValue, divPosDiff){
5269    	if(settingsValue.search && settingsValue.search("%") != -1)
5270	  		return (zoomableContainerParentValue - divPosDiff)* (parseInt(settingsValue)/100);
5271	  	else
5272	  		return parseInt(settingsValue);
5273    }
5274    
5275     /**
5276	 * get the plugin target rectangle on screen 
5277	 * @param {Object} settingsValue : a number or a string value given in plugin params
5278	 * @param {Number} zoomableContainerParentPosValue : zoomable container parent global x  or y
5279	 * @param {Number} zoomableContainerParentSizeValue : zoomable container parent width or height
5280	 * @return {Number} return the zoomable container position (in pixel) from setting value (pixel or percent) 
5281	 */	 
5282    function getContainerDivPositionFromSettings(settingsValue, zoomableContainerParentPosValue, zoomableContainerParentSizeValue){
5283    	if(settingsValue.search && settingsValue.search("%") != -1)
5284	  		return zoomableContainerParentPosValue + zoomableContainerParentSizeValue * (parseInt(settingsValue)/100);
5285	  	else
5286	  		return zoomableContainerParentPosValue + parseInt(settingsValue);
5287    }
5288    
5289    /**
5290     * reinit the component when the user resize the window 
5291     */
5292   	function windowResizeEventHandler(){
5293   		adjustToContainer();
5294   	}
5295
5296 	/**
5297	 * return a retangle from a JQuery object 
5298	 * @param {Object} jqObject : a JQuery object like $('#myObject')
5299	 * @return {Object} return {'x':objectX, 'y':objectY, 'width':objectWidth, 'height':objectHeight} 
5300	 */	 
5301   	function getRect(jqObject) {
5302  		var offset = jqObject.offset();
5303	  	if(!offset)
5304	  		return null;
5305		var formX = offset.left;
5306		var formY = offset.top; 
5307	    return {'x':formX, 'y':formY, 'width':jqObject.outerWidth(), 'height':jqObject.outerHeight()};
5308	}
5309	 
5310	/**
5311	 * Point Class
5312	 * @param {Number} x : point position on X axis
5313	 * @param {Number} y : point position on Y axis
5314	 */
5315	function Point(x, y) {
5316	    this.x = x;
5317	    this.y = y;
5318	     /**
5319	     * return point informations into a string
5320	     * @return {String} return (x=5, y=5) 
5321	     */
5322	    this.toString = function() {
5323		    return '(x=' + this.x + ', y=' + this.y + ')';
5324		};
5325	    /**
5326	     * return a new point who is the interpolation of this and the given point 
5327	     * the new point position is calculate thanks to percentInterpolate (the distance between this and pointToInterpolate in percent)
5328	     * @return {Point} return {'x':interpolateX, 'y':interpolateY}  
5329	     */
5330	    this.interpolate = function(pointToInterpolate, percentInterpolate) {
5331		    var x = percentInterpolate * this.x + (1 - percentInterpolate) * pointToInterpolate.x;
5332		    var y = percentInterpolate * this.y + (1 - percentInterpolate) * pointToInterpolate.y;
5333			return new Point(x, y);
5334		};
5335		/**
5336		 * return the distance between "this" point and the given point  
5337		 * @return {Number} distance between this and "point"    
5338		 */
5339		this.distance = function(point) {
5340		    return Math.sqrt(Math.pow((point.y - this.y) ,2) + Math.pow((point.x - this.x),2));
5341		} 
5342	}
5343
5344
5345  };
5346})( jQuery );
5347
5348/*
5349 * add smartZoomEasing and smartZoomOutQuad to jQuery easing function 
5350 */
5351(function($){
5352    $.extend($.easing,
5353    {
5354        smartZoomEasing: function (x, t, b, c, d) {
5355            return $.easing['smartZoomOutQuad'](x, t, b, c, d);
5356        },
5357        smartZoomOutQuad: function (x, t, b, c, d) {
5358            return -c *(t/=d)*(t-2) + b;
5359        }
5360    });
5361})(jQuery);
5362
5363/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
5364 * Licensed under the MIT License (LICENSE.txt).
5365 *
5366 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
5367 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
5368 * Thanks to: Seamus Leahy for adding deltaX and deltaY
5369 *
5370 * Version: 3.0.6
5371 * 
5372 * Requires: 1.2.2+
5373 */
5374(function(e){function r(t){var n=t||window.event,r=[].slice.call(arguments,1
5374),i=0,s=true,o=0,u=0;t=e.event.fix(n);t.type="mousewheel";if(n.wheelDelta){i=n.wheelDelta/120}if(n.detail){i=-n.detail/3}u=i;if(n.axis!==undefined&&n.axis===n.HORIZONTAL_AXIS){u=0;o=-1*i}if(n.wheelDeltaY!==undefined){u=n.wheelDeltaY/120}if(n.wheelDeltaX!==undefined){o=-1*n.wheelDeltaX/120}r.unshift(t,i,o,u);return(e.event.dispatch||e.event.handle).apply(this,r)}var t=["DOMMouseScroll","mousewheel"];if(e.event.fixHooks){for(var n=t.length;n;){e.event.fixHooks[t[--n]]=e.event.mouseHooks}}e.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var e=t.length;e;){this.addEventListener(t[--e],r,false)}}else{this.onmousewheel=r}},teardown:function(){if(this.removeEventListener){for(var e=t.length;e;){this.removeEventListener(t[--e],r,false)}}else{this.onmousewheel=null}}};e.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})})(jQuery)
5375
5376// CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
5377// ============================================================
5378
5379function transitionEnd() {
5380  var el = document.createElement('bootstrap');
5381
5382  var transEndEventNames = {
5383    'WebkitTransition' : 'webkitTransitionEnd',
5384    'MozTransition'    : 'transitionend',
5385    'OTransition'      : 'oTransitionEnd otransitionend',
5386    'transition'       : 'transitionend'
5387  };
5388
5389  for (var name in transEndEventNames) {
5390    if (el.style[name] !== undefined) {
5391      return { end: transEndEventNames[name] };
5392    }
5393  }
5394
5395  return false; // explicit for ie8 (  ._.)
5396}
5397
5398// http://blog.alexmaccaw.com/css-transitions
5399$.fn.emulateTransitionEnd = function (duration) {
5400  var called = false, $el = this;
5401  $(this).one($.support.transition.end, function () { called = true; })
5402  var callback = function () { if (!called) $($el).trigger($.support.transition.end); }
5403  setTimeout(callback, duration);
5404  return this;
5405};
5406
5407$(function () {
5408  $.support.transition = transitionEnd();
5409});
5410
5411
5412
5413
5414var reservationTimer;
5415var allZooms;
5416
5417$( document ).ready(function() {
5418	var xs = 480,
5419		smMin = 768,
5420		mdMin = 992,
5421		lgMin = 1200,
5422		
5423		xsMax = smMin - 1,
5424		smMax = mdMin - 1,
5425		mdMax = lgMin - 1;
5426	
5427	var	htmlLang = $('html').attr('lang'),
5428		lang = htmlLang ? htmlLang : 'en';
5429
5430
5431// ACCEPTANCE CONDITIONS
5432// -----------------------------------------------------------------------------
5433(function ($input) {
5434	if ($input.length === 0) {return false;}
5435	
5436	var $button = $('#acceptance-conditions');
5437
5438	if ($button.length === 0) {return false;}
5439
5440	$input.on('change', function(e){
5441		$button.prop('disabled', !$button.prop('disabled'));
5442		console.log($input.data('url'));
5443	});
5444
5445})($( '#acceptance-conditions-toggle' ));
5446
5447
5448// AMOUNT
5449// -----------------------------------------------------------------------------
5450$( '.amount' ).each(function() {
5451	var $this = $(this),
5452		$input = $this.find('input'),
5453		maxval = parseInt($this.data('max')) || 15,
5454		val = 1;
5455
5456	$this.find('.amount-plus').on('click', function () {
5457		if (++val > maxval) {val = maxval;}
5458		$input.val(val);
5459	});
5460
5461	$this.find('.amount-minus').on('click', function () {
5462		if (--val < 1) {val = 1;}
5463		$input.val(val);
5464	});
5465
5466	$input.on('change', function () {
5467		if (Number.isInteger(parseInt(this.value))) {
5468			if (parseInt(this.value) === 0) {this.value = 1;}
5469			else if (parseInt(this.value) > maxval) {this.value = maxval;}
5470		} else {
5471			this.value = 1;
5472		}
5473	});
5474
5475});
5476
5477
5478
5479// CAROUSEL-EVENTS
5480// -----------------------------------------------------------------------------
5481(function ($Carousels) {
5482	$Carousels.each(function (i, carousel) {
5483		var $carousel = $(carousel);
5484
5485		$carousel
5486			.owlCarousel({
5487				margin: 25,
5488				dots: false,
5489				nav: true,
5490				mouseDrag: false,
5491				navText: [
5492					'<span class="i i-carousel-prev"></span>',
5493					'<span class="i i-carousel-next"></span>'
5494				],
5495				stagePadding: 25,
5496				navSpeed: 800,
5497				smartSpeed: 800,
5498				filter: true,
5499				responsiveRefreshRate: 500,
5500				responsive:{
5501					0: {
5502						items: 1,
5503						stagePadding: 0,
5504						margin: 0,
5505						smartSpeed: 300
5506					},
5507					420: {
5508						items: 2,
5509						stagePadding: 0,
5510						margin: 5,
5511						smartSpeed: 300
5512					},
5513					768: {
5514						items: 3
5515					},
5516					992: {
5517						items: 4
5518					}
5519				}
5520			});
5521
5522	});
5523
5524
5525})($( '.000carousel-events' ));
5526
5527
5528// CAROUSEL-EVENTS BESTSELLERS
5529// -----------------------------------------------------------------------------
5530(function ($Carousels) {
5531	$Carousels.each(function (i, carousel) {
5532		var $carousel = $(carousel);
5533
5534		$carousel
5535			.owlCarousel({
5536				margin: 25,
5537				dots: false,
5538				nav: true,
5539				mouseDrag: false,
5540				navText: [
5541					'<span class="i i-carousel-prev"></span>',
5542					'<span class="i i-carousel-next"></span>'
5543				],
5544				stagePadding: 25,
5545				navSpeed: 800,
5546				smartSpeed: 800,
5547				filter: true,
5548				responsiveRefreshRate: 500,
5549				responsive:{
5550					0: {
5551						items: 1,
5552						stagePadding: 0,
5553						margin: 0,
5554						smartSpeed: 300
5555					},
5556					420: {
5557						items: 2,
5558						stagePadding: 0,
5559						margin: 5,
5560						smartSpeed: 300
5561					},
5562					600: {
5563						items: 3
5564					},
5565					960: {
5566						items: 4
5567					},
5568					992: {
5569						items: 5
5570					}
5571				}
5572			});
5573
5574	});
5575
5576
5577})($( '.000carousel-events2' ));
5578
5579
5580(function ($Carousels) {
5581	$Carousels.each(function (i, carousel) {
5582		var $carousel = $(carousel);
5583
5584		$carousel
5585			.owlCarousel({
5586				margin: 25,
5587				dots: true,
5588				nav: true,
5589				mouseDrag: true,
5590				autoplay: true,
5591        		autoPlaySpeed: 5000,
5592       			autoPlayTimeout: 5000,
5593				navText: [
5594					'<span class="i i-carousel-prev"></span>',
5595					'<span class="i i-carousel-next"></span>'
5596				],
5597				stagePadding: 25,
5598				navSpeed: 800,
5599				smartSpeed: 800,
5600				filter: true,
5601				responsiveRefreshRate: 500,
5602				responsive:{
5603					0: {
5604						items: 1,
5605						stagePadding: 0,
5606						margin: 0,
5607						smartSpeed: 300
5608					},
5609				}
5610			});
5611
5612	});
5613
5614
5615})($( '#carousel-org'));
5616
5617
5618
5619
5620(function ($Carousels) {
5621	$Carousels.each(function (i, carousel) {
5622		var $carousel = $(carousel);
5623
5624		$carousel
5625			.owlCarousel({
5626				margin: 25,
5627				dots: true,
5628				nav: true,
5629				mouseDrag: true,
5630				autoplay: true,
5631        		autoPlaySpeed: 5000,
5632       			autoPlayTimeout: 5000,
5633				navText: [
5634					'<span class="i i-carousel-prev"></span>',
5635					'<span class="i i-carousel-next"></span>'
5636				],
5637				stagePadding: 25,
5638				navSpeed: 800,
5639				smartSpeed: 800,
5640				filter: true,
5641				responsiveRefreshRate: 500,
5642				responsive:{
5643					0: {
5644						items: 1,
5645						stagePadding: 0,
5646						margin: 0,
5647						smartSpeed: 300
5648					},
5649				}
5650			});
5651
5652	});
5653
5654
5655})($( '#banners-top'));
5656
5657
5658// HOME-CAROUSEL
5659// -----------------------------------------------------------------------------
5660(function ($carousel) {
5661	if ($carousel.length === 0) {return false;}
5662
5663	function armonika(e) {
5664		var _ = e.relatedTarget;
5665
5666			_._items.forEach(function ($owlItem, e) {
5667				if (!$owlItem.initialized) {
5668					$owlItem.initialized = true;
5669					$owlItem.wrapInner("<div class='fx-holder'><div class='fx-stage'></div></div>");
5670				}
5671
5672				if (window.innerWidth > 992) {
5673					var $holder = $owlItem.find('.fx-holder');
5674					var $stage = $owlItem.find('.fx-stage');
5675					var item = $owlItem.find('.event-item').get(0);
5676
5677					setTimeout(function () {
5678						var stageBound = $stage.get(0).getBoundingClientRect();
5679						var itemBound = item.getBoundingClientRect();
5680
5681						$stage.css({
5682							transform: 'scale('+(stageBound.width / itemBound.width)+') translateX('+ (stageBound.left - itemBound.left) +'px)'
5683						});
5684
5685						$holder.css({
5686							height: item.getBoundingClientRect().height
5687						});						
5688					}, 500);
5689
5690
5691				} else {
5692					$owlItem.find('.fx-holder').height( 'auto' );
5693					$owlItem.find('.fx-stage').css( {transform: 'none'});
5694				}
5695			});
5696
5697	}
5698
5699	$carousel
5700	.on('initialized.owl.carousel', armonika)
5701	.on('resized.owl.carousel', armonika)
5702	.owlCarousel({
5703		autoplay: true,
5704        autoPlaySpeed: 5000,
5705        autoPlayTimeout: 5000,
5706		margin: 20,
5707		dots: false,
5708		nav: false,
5709		mouseDrag: false,
5710		center:true,
5711		loop: false,
5712		navText: [
5713			'<span class="i i-carousel-prev"></span>',
5714			'<span class="i i-carousel-next"></span>'
5715		],
5716		responsiveRefreshRate: 500,
5717		responsive:{
5718			0: 		{
5719				items: 2,
5720				loop:true,
5721			},
5722			420: 	{
5723				items: 2,
5724				loop:true
5725			},
5726			768: 	{
5727				items: 3,
5728				loop:true
5729			},
5730			992: 	{
5731				items: 4,
5732				loop:true,
5733				nav: true,
5734			},
5735			1300: 	{
5736				items: 4,
5737				loop:true,
5738				dots: true,
5739				nav: true,
5740			},
5741			
5742			1700:	{
5743				nav: true,
5744				items: 6,
5745				loop:true			
5746			}
5747		}
5748	});
5749})($( '#carousel-home, #carousel-home2' ));
5750
5751
5752
5753
5754
5755
5756// COLLAPSING
5757// -----------------------------------------------------------------------------
5758$( '.collapse' ).each(function() {
5759	var $this = $(this);
5760	
5761	if($this.hasClass('in')) {
5762		$this.next().stop().slideToggle(300);		
5763	}
5764
5765	$this.on('click', function() {
5766		$(this).toggleClass('in').next().stop().slideToggle(300);
5767	});
5768});
5769
5770
5771
5772// DATEPICKER
5773// -----------------------------------------------------------------------------
5774
5775(function ($datepicker) {
5776	$.datepicker.setDefaults( $.datepicker.regional[ lang ] );
5777
5778
5779	$datepicker.datepicker({
5780		// dateFormat: "yy-mm-dd",
5781		prevText: '',
5782		nextText: '',
5783		minDate: 0
5784	});
5785})($( '.datepicker' ));
5786
5787
5788// 
5789// -----------------------------------------------------------------------------
5790(function ($element) {
5791	if ($element.length === 0) {return false;}
5792
5793})($( '#element' ));
5794
5795
5796// 
5797// -----------------------------------------------------------------------------
5798(function ($elements) {
5799	$elements.each(function () {
5800		
5801	});
5802})($( '.elements' ));
5803
5804
5805// EVENTS-GRID
5806// -----------------------------------------------------------------------------
5807(function ($Grids) {
5808	$Grids.each(function (i, grid) {
5809		var $grid = $(grid),
5810			$sort = $grid.find('.sort'),
5811			$item = $grid.find('.event-item');
5812			$grid = $('.events-grid');
5813
5814		function ordering(order, type) {
5815			var H = $grid.height();
5816			$grid.css({'height': H});			
5817
5818			$item
5819				//SET origin order
5820				.each(function (i, item) {
5821					$(item).data('orderSet', i);
5822				})
5823
5824				//Order
5825				.sort(function (a, b) {
5826					if (order) {
5827						return $(a).data(type) - $(b).data(type);
5828					} else {
5829						return $(b).data(type) - $(a).data(type);
5830					}
5831				}).appendTo( $grid )
5832
5833				//Set destination positions top and left
5834				.each(function (i, item) {
5835					var $item = $(item);
5836
5837					$item
5838						.data('destinationLeft', this.offsetLeft)
5839						.data('destinationTop', this.offsetTop);
5840				})
5841
5842				//ReOrder to origin
5843				.sort(function (a, b) {
5844					return $(a).data('orderSet') - $(b).data('orderSet');
5845				}).appendTo( $grid )
5846
5847				//Set origin positions top and left
5848				.each(function (i, item) {
5849					$(item).css({
5850							'left': this.offsetLeft,
5851							'top': this.offsetTop
5852						});
5853				});
5854
5855
5856			setTimeout(function () {
5857				$item.each(function (i, item) {
5858					var $item = $(item);
5859					$item.css({
5860						'left': $item.data('destinationLeft'),
5861						'top': $item.data('destinationTop')
5862					});
5863				});
5864
5865				$grid.addClass('sorting');
5866			}, 100);
5867
5868			// Delay css transition duration + 100
5869			setTimeout(function () {
5870				$item.sort(function (a, b) {
5871					if (order) {
5872						return $(a).data(type) - $(b).data(type);
5873					} else {
5874						return $(b).data(type) - $(a).data(type);
5875					}
5876				}).appendTo( $grid );
5877
5878				$grid.removeClass('sorting');
5879			}, 600);
5880		}
5881
5882		if ($sort.length !==0) {
5883			$sort.on('change', function (e) {
5884				switch (this.value) {
5885					case "price-asc":
5886						ordering(true, 'minprice');
5887						break;
5888					case "price-desc":
5889						ordering(false, 'minprice');
5890						break;
5891					case "date-asc":
5892						ordering(true, 'eventdate');
5893						break;
5894					case "date-desc":
5895						ordering(false, 'eventdate');
5896						break;
5897					default:
5898						console.log( "default" );
5899				}
5900			});
5901		}
5902	});
5903})($( '.category-grid-list' ));
5904
5905
5906// FACEBOOK
5907// -----------------------------------------------------------------------------
5908var FBdiv = $('.fb-page');
5909var FBlike = $('.fb-like');
5910
5911function loadFbApi() {
5912	$('body').append('<div id="fb-root"></div>');
5913	var js, fjs = document.getElementsByTagName('script')[0];
5914	if (document.getElementById('facebook-jssdk')) {return false;}
5915	js = document.createElement('script');
5916	js.id = 'facebook-jssdk';
5917	js.src = "//connect.facebook.net/lt_LT/sdk.js#xfbml=1&version=v2.5";
5918	fjs.parentNode.insertBefore(js, fjs);
5919}
5920
5921if (!window.FB && (FBlike.length !== 0)) {
5922	//TODO: atkomentuoti kai viskas bus baigta
5923	// loadFbApi();
5924}
5925
5926if (FBdiv.length !== 0) {
5927	var FBCreateOnSize = 0;
5928	var loadFB = function() {
5929		if (window.FB) {
5930
5931			if (FBCreateOnSize === lgMin && window.innerWidth < lgMin) {
5932				FBCreateOnSize = window.innerWidth < lgMin ? mdMin : lgMin;
5933				FB.XFBML.parse();
5934
5935			} else if (FBCreateOnSize === mdMin && window.innerWidth > lgMin) {
5936				FBCreateOnSize = window.innerWidth < lgMin ? mdMin : lgMin;
5937				FB.XFBML.parse();
5938			}
5939		}
5940
5941		if (!window.FB && window.innerWidth > smMax) {
5942			loadFbApi();
5943			FBCreateOnSize = window.innerWidth < lgMin ? mdMin : lgMin;
5944		}
5945	};
5946
5947	//TODO: atkomentuoti kai viskas bus baigta
5948	// loadFB();
5949	// $(window).on('resize', loadFB);
5950}
5951
5952
5953// INVOICE AJAX TOGGLE
5954// -----------------------------------------------------------------------------
5955(function ($input) {
5956	
5957	if ($input.length === 0 || !$input.data('url')) {return false;}
5958	$input.on('change', function(e){
5959		$.ajax({
5960			method: "GET",
5961			url: $input.data('url'),
5962			data: {
5963				required: $input.prop('checked'),
5964				order: $input.data('order')
5965			}
5966		});
5967	});
5968})($( '#invoice-ajax-toggle' ));
5969
5970
5971// MENU TOGGLE
5972// -----------------------------------------------------------------------------
5973(function ($header) {
5974	if ($header.length === 0) {return false;}
5975
5976	var bodyOverflowHidden = false,
5977		menuShowing = false,
5978		searchShowing = false;
5979
5980	$header
5981		.on('click', '.menu-toggle', function(e) {
5982			menuShowing = !menuShowing;
5983
5984			$header.toggleClass('m-menu-in');
5985
5986			if (searchShowing) {
5987				searchShowing = !searchShowing;
5988				$header.removeClass('m-search-in');
5989			}
5990		})
5991		
5992		.on('click', '.menu-search', function(e) {
5993			searchShowing = !searchShowing;
5994
5995			$header.toggleClass('m-search-in');
5996			
5997			if (menuShowing) {
5998				menuShowing = !menuShowing;
5999				$header.removeClass('m-menu-in');
6000			}
6001		});
6002
6003})($( '#header' ));
6004
6005
6006// NEWSLETTER
6007// -----------------------------------------------------------------------------
6008(function ($newsletter) {
6009	if ($newsletter.length === 0) {return false;}
6010
6011	$newsletter.on('submit', function (e) {
6012		var $form = $(this);
6013		var $btn   = $form.find('button[type="submit"]');
6014
6015		var $email = $(this).find('input[type="email"]'),
6016			url = $newsletter.attr('action');
6017			
6018		var $city = $(this).find('#city'),
6019			url = $newsletter.attr('action');
6020		
6021		var sData = {email: $email.val(), city: $city.val()}
6022		
6023		if($city.val()=='0'){
6024			$city.addClass('has-error').one('focus', function () {
6025				$city.removeClass('has-error');
6026			});
6027		}
6028			
6029		if ($email.val() !== '' &&
6030			/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($email.val())) {
6031			
6032			if($city.val()!=='0'){
6033			
6034				$.ajax({
6035					url: url,
6036					//data: $email.val(),
6037					data: JSON.stringify(sData),
6038					method: 'post',
6039					dataType: 'json'
6040				})
6041
6042				.done(function (res) {
6043					if (res.msg) {
6044						$newsletter.addClass('success');
6045						$newsletter.find('.success .msg').html(res.msg);
6046
6047						// >>> BUTTON CHANGE <<<
6048						$btn.text('Naujienlaiškis užsakytas');
6049						$btn.prop('disabled', true);
6050						$btn.addClass('disabled');
6051						$email.val('')
6052					}
6053				})
6054
6055				.fail(function (res) {
6056					$newsletter.addClass('fail')
6057						.find('.fail .msg').html(res.responseText);
6058				});
6059			}
6060
6061		} else {
6062			$email.addClass('has-error').one('focus', function () {
6063				$email.removeClass('has-error');
6064			});
6065		}
6066
6067		e.preventDefault();
6068
6069	}).on('click', '.fail button', function (e) {
6070		$newsletter.removeClass('fail').removeClass('success');
6071		e.preventDefault();
6072	});
6073
6074})($( '#newsletter' ));
6075
6076
6077
6078
6079// noUiSlider
6080// -----------------------------------------------------------------------------
6081$( '.noUiSlider' ).each(function() {
6082	var $this = $(this),
6083		$priceFrom = $('#search-price-from'),
6084		$priceTo = $('#search-price-to'),
6085		min = $this.data('min'),
6086		max = $this.data('max');
6087
6088	noUiSlider.create(this, {
6089		start: [ min, max ],
6090		connect: true,
6091		step: 1,
6092		range: {
6093			'min': [ min ],
6094			'max': [ max ]
6095		},
6096		format: {
6097			to: function ( value ) {
6098				return parseInt(value);
6099			},
6100			from: function ( value ) {
6101				return parseInt(value);
6102			}
6103		}
6104	});
6105
6106	this.noUiSlider.on('update', function ( values, handle ) {
6107		$priceFrom.val(values[0]);
6108		$priceTo.val(values[1]);
6109	});
6110
6111	$priceFrom[0].addEventListener('change', function(){
6112		$this[0].noUiSlider.set([this.value, null]);
6113	});
6114
6115	$priceTo[0].addEventListener('change', function(){
6116		$this[0].noUiSlider.set([null, this.value]);
6117	});
6118});
6119
6120
6121
6122// RADIO CHECKBOX BUTTON
6123// -----------------------------------------------------------------------------
6124$( '.radio' ).each(function() {
6125	var $this = $(this);
6126	$this.find('input[type="radio"]').after("<span></span>");
6127});
6128
6129$( '.checkbox' ).each(function() {
6130	var $this = $(this);
6131	$this.find('input[type="checkbox"]').after("<span></span>");
6132});
6133
6134
6135// SCROLL-TOP
6136// -----------------------------------------------------------------------------
6137$( '.scroll-top' ).on('click', function () {
6138	$('body').animate({scrollTop: 0}, 600);
6139});
6140
6141
6142// SEARCH
6143// -----------------------------------------------------------------------------
6144(function ($search) {
6145	if ($search.length === 0) {return false;}
6146
6147	var firstLoad = true,
6148		$location = $search.find('.location'),
6149		$locationsValue = $location.find('#locations-value'),
6150
6151		$price = $search.find('.price'),
6152		$noUiSlider = $price.find('.noUiSlider'),
6153
6154		$date = $search.find('.date'),
6155		$datepicker = $date.find('.datepicker'),
6156		$dateInputFrom = $date.find('#search-date-from'),
6157		$dateInputTo = $date.find('#search-date-to'),
6158		dateFrom = 0, dateTo = 0;
6159
6160
6161	$location.find('input[type="radio"]').on('change', function (e) {
6162		var $this = $(this),
6163			text = $this.siblings('.loc-title').text();
6164
6165		$location.find('h2').find('.title').text(text);
6166
6167		if (window.innerWidth > mdMin) {
6168			$location.find('.collapse').toggleClass('in').next().stop().slideToggle(300);
6169		}
6170	});
6171
6172	function setLocationsValue() {
6173		var val = '';
6174
6175		$location.find('input[type="checkbox"]').each(function (i, checkbox) {			
6176			if (checkbox.checked) {
6177				val += val.length === 0 ? checkbox.value : ','+checkbox.value;
6178			}
6179		});
6180
6181		$locationsValue.val(val);
6182	}
6183
6184	setLocationsValue();
6185
6186	$location.find('input[type="checkbox"]').on('change', function (e) {
6187		var $this = $(this),
6188			text = $this.siblings('.loc-title').text();
6189
6190		$location.find('h2').find('.title').text(text);
6191
6192		setLocationsValue();
6193	});
6194
6195	if ($noUiSlider.length !== 0) {
6196		$noUiSlider[0].noUiSlider.on('update', function ( values, handle ) {
6197			if (!firstLoad) {
6198				$price.find('h2').find('.title').text(values[0] + ' - ' + values[1]);
6199			}
6200		});
6201	}
6202
6203	$datepicker
6204	.datepicker('option', 'beforeShowDay', function () {
6205		if (dateFrom <= arguments[0].valueOf() && arguments[0].valueOf() <= dateTo) {
6206			return [true, 'ui-datepicker-interval-day'];
6207		} else {
6208			return [true, ''];
6209		}
6210	})
6211	.datepicker('option', 'onSelect', function () {
6212		var date = $datepicker.datepicker( "getDate" ),
6213			dateUnix = Date.parse(date);
6214
6215		if (dateFrom === 0) {
6216			dateFrom = dateUnix;
6217		} else if (dateTo === 0 && dateFrom < dateUnix) {
6218			dateTo = dateUnix;
6219		} else {
6220			dateFrom = dateUnix;
6221			dateTo = 0;
6222		}
6223
6224		if (dateFrom !== 0 && dateTo !== 0 && dateFrom <= dateTo) {
6225			var dateFromObj = new Date(dateFrom),
6226				dateFromString = dateFromObj.toLocaleDateString(lang),
6227
6228				dateToObj = new Date(dateTo),
6229				dateToString = dateToObj.toLocaleDateString(lang),
6230
6231				dateText = '';
6232
6233			$dateInputFrom.val(dateFromString);
6234			$dateInputTo.val(dateToString);
6235			if (window.innerWidth > mdMin) {
6236				$date.find('.collapse').toggleClass('in').next().stop().slideToggle(300);
6237			}
6238
6239			if (dateFromObj.getFullYear() === dateToObj.getFullYear()) {
6240				var dayFrom = dateFromObj.getDate(),
6241					monthFrom = dateFromObj.getMonth() + 1,
6242					dayTo = dateToObj.getDate(),
6243					monthTo = dateToObj.getMonth() + 1;
6244
6245				dayFrom = dayFrom < 10 ? "0" + dayFrom : dayFrom;
6246				monthFrom = monthFrom < 10 ? "0" + monthFrom : monthFrom;
6247				dayTo = dayTo < 10 ? "0" + dayTo : dayTo;
6248				monthTo = monthTo < 10 ? "0" + monthTo : monthTo;
6249
6250				dateText = dateToObj.getFullYear() + " " +
6251					monthFrom + "." + dayFrom +
6252					" - " +
6253					monthTo + "." + dayTo;
6254			} else {
6255				dateText = dateFromString.replace(/-/g, ".") + " - " + dateToString.replace(/-/g, ".");
6256			}
6257
6258			$date.find('h2').find('.title').text(dateText);
6259		}
6260	});
6261
6262	$search.find('.collapse').on('click', function (e) {
6263		var $this = $(this);
6264
6265		$search.find('.collapse').not(this).each(function () {
6266			var $siblingCollapse = $(this);
6267			if ($siblingCollapse.hasClass('in')) {
6268				$siblingCollapse.toggleClass('in').next().stop().slideToggle(300);
6269			}
6270		});
6271
6272		e.stopPropagation();
6273	});
6274
6275	$(document).on('click', function (e) {
6276		var $target = $(e.target);
6277
6278		if (window.innerWidth > mdMin &&
6279				$target.closest('.filter').length === 0 &&
6280				$target.hasClass('.ui-datepicker-prev').length === 0 &&
6281				$target.hasClass('.ui-datepicker-next').length === 0) {
6282
6283			console.log( e.target);
6284
6285			$search.find('.collapse.in').each(function () {
6286				var $this = $(this);
6287				if ($this.hasClass('in')) {
6288					$this.toggleClass('in').next().stop().slideToggle(300);
6289				}
6290			});
6291		}
6292	});
6293
6294	firstLoad = false;
6295
6296})($( '#search' ));
6297
6298
6299// TABLE TICKET
6300// -----------------------------------------------------------------------------
6301$( '.table-ticket' ).each(function (i, table) {
6302	var $table = $(table),
6303		$toggle = $table.find('.toggle');
6304
6305	$toggle.on('click', function (e) {
6306		$(this).toggleClass('minus').closest('tr').next().toggle();
6307		e.preventDefault();
6308	});
6309});
6310
6311
6312// TIMER
6313// -----------------------------------------------------------------------------
6314var TimerObj = (function(){
6315	function TimerObj() {
6316		_ = this;
6317		_.$timers = $('[data-seconds]');
6318		_.intervals = [];
6319
6320		_.start = function () {
6321			_.$timers.each(function (i, timer) {
6322
6323				var $timer = $(this);
6324				var seconds = parseInt($timer.data('seconds'));
6325
6326				if (seconds) {
6327					var d = new Date(seconds*1000),
6328						unix = d.valueOf();
6329
6330					$timer.text(d.getMinutes() + ' min ' + d.getSeconds() + ' s');
6331					$timer.closest('.timer-wrapper').removeClass('off');
6332
6333					_.intervals[i] = setInterval(function () {
6334						d = new Date(--seconds*1000);
6335						$timer.text(d.getMinutes() + ' min ' + d.getSeconds() + ' s');
6336						if (seconds <= 0) {
6337							clearInterval(_.intervals[i]);
6338							$timer.text('');
6339							$timer.closest('.timer-wrapper').addClass('off');
6340
6341							//TODO kažkas po to kai baigiasi laikas.
6342							window.location = $timer.data('href');
6343						}
6344					}, 1000);
6345				}
6346			});
6347		};
6348		
6349		_.stop = function () {
6350			$.each(_.intervals , function (i, interv) {
6351				clearInterval(_.intervals[i]);
6352			});
6353		};
6354		
6355		_.restart = function (second) {
6356			_.stop();
6357			_.$timers.each(function (i, timer) {
6358				var $timer = $(this);
6359				$timer.data('seconds', second);
6360			});
6361			_.start();
6362		};
6363
6364		_.start();
6365	}
6366
6367	return TimerObj;
6368})();
6369
6370reservationTimer = new TimerObj();
6371
6372	for(i = 0; i < 2; i++) {
6373		if($(".carousel-events:eq(" + i + ") .owl-stage-outer .owl-stage .owl-item").length <= 4) {
6374			$(".carousel-events .owl-controls .owl-nav .owl-prev:eq(" + i + ")").css("display", "none");
6375			$(".carousel-events .owl-controls .owl-nav .owl-next:eq(" + i + ")").css("display", "none");
6376		}
6377	}
6378	for(i = 0; i < 2; i++) {
6379		if($(".carousel-events2:eq(" + i + ") .owl-stage-outer .owl-stage .owl-item").length <= 5) {
6380			$(".carousel-events2 .owl-controls .owl-nav .owl-prev:eq(" + i + ")").css("display", "none");
6381			$(".carousel-events2 .owl-controls .owl-nav .owl-next:eq(" + i + ")").css("display", "none");
6382		}
6383	}
6384
6385});
6386
6387$( ".form-in-pdata" ).click(function() {
6388	  $(this).removeClass('bi-inputError');
6389	});
6390	
6391$( ".open_required_code_form" ).click(function() {
6392	$(".open_required_code_form").toggle();
6393	$(".required_code_form").toggle();
6394});
6395
6396$( "#ab_closeBtn" ).click(function() {
6397	var cname = 'ads_popup';
6398	var cvalue = 'true';
6399	var d = new Date();
6400    d.setTime(d.getTime() + (60 * 60 * 1000));
6401    var expires = "expires="+d.toUTCString();
6402    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
6403	$("#advBox").toggle();
6404});
6405$(document).ready(function(){
6406	
6407/*$(".sector_select").on("click", "#layout-grid", function () {
6408	var sector_id = $(this).find(".sector_href").attr("href");
6409	$( "#layout-grid" ).toggle();
6410	alert(sector_id);
6411});*/
6412
6413$('.table.table-sector-list:not(.nolink) tr').click(function(){
6414    window.location = $(this).attr('href');
6415    return false;
6416});
6417
6418
6419$( ".sector_select" ).hover(function() {
6420	var sector_id = 'sector_'+$(this).attr("sector_id");
6421	$( "#layout-grid" ).find("#"+sector_id).css({fill: '#ffb41a'});
6422},function() {
6423	var sector_id = 'sector_'+$(this).attr("sector_id");
6424	$( "#layout-grid" ).find("#"+sector_id).css({fill: '#878e97'});
6425	
6426});
6427
6428$(document).on("mouseenter", ".sector_path", function() {
6429	//$(this).css({ fill: '#F7B21A' });
6430	var sector_id = 'sector_list_'+$(this).attr("sector_id");
6431	$( ".table-sector-list" ).find("#"+sector_id).css({'background': '#ffb41a'});
6432});
6433$(document).on("mouseleave", ".sector_path", function() {
6434	//$(this).css({ fill: '#878e97' });
6435	var sector_id = 'sector_list_'+$(this).attr("sector_id");
6436	$( ".table-sector-list" ).find("#"+sector_id).css({'background': 'transparent'});
6437});
6438
6439
6440$(document).on("click", ".ticket_price", function() {
6441	$(this).parent().parent().find('.ticket_price').removeClass('checked');
6442	$(this).addClass('checked');
6443});
6444
6445
6446	function loadOrganizerServices() {
6447		
6448		organizer_id = parseInt($('#organizer_id').val());
6449
6450		if(organizer_id < 1) {
6451			$('#service_id').html('<option class="initial-option" selected="selected" value="0">-</option>');
6452			$('#service_id').change();
6453			return false;
6454		}
6455		
6456		$.getJSON(baseURL('api/services/services_list/'+organizer_id), function(data) {
6457			$('#service_id').html('<option class="initial-option" selected="selected" value="0">-</option>');
6458
6459			if(typeof data.services_list != 'object') return;
6460				var services_list = data.services_list;
6461				var placeCount = 0;
6462
6463				for(var key in services_list) {
6464					$('#service_id').append('<option value="'+key+'">'+services_list[key]+'</option>');
6465					placeCount++;
6466				}
6467				if(placeCount>0){
6468					$('#service_id .initial-option').remove();
6469					$('#service_id').change();
6470				}
6471
6472			
6473		});
6474	}
6475	$('#organizer_id').change(function() {
6476		loadOrganizerServices();
6477	});
6478	
6479$('.arrowLeft').click(function () {
6480    $('.landingBox .eventBox').hide();
6481    $('.landingBox .eventBox:last-child').prependTo('.landingBox');
6482	$('.landingBox .eventBox:first-child').fadeIn(1000);
6483});
6484
6485$('.arrowRight').click(function () {
6486	$('.landingBox .eventBox').hide();
6487    $('.landingBox .eventBox:first-child').appendTo('.landingBox');
6488	$('.landingBox .eventBox:first-child').fadeIn(1000);
6489});
6490
6491$('.youtube-gallery-box .youtube-box .nav-left').click(function () {
6492	var iwidth = $('.youtube-gallery-box .youtube-videos .youtube_video:first').width();
6493    $('.youtube-gallery-box .youtube-videos .youtube_video:first').animate({"margin-left": '-='+iwidth});
6494	  setTimeout(function() {
6495		  $('.youtube-gallery-box .youtube-videos .youtube_video:first').css({"margin-left": '0px'}).appendTo('.youtube-gallery-box .youtube-videos');
6496		}, 500);
6497});
6498$('.youtube-gallery-box  .youtube-box .nav-right').click(function () {
6499	var iwidth = $('.youtube-gallery-box .youtube-videos .youtube_video:last').width();
6500	
6501	$('.youtube-gallery-box .youtube-videos .youtube_video:last').css({"margin-left": '-='+iwidth}).prependTo('.youtube-gallery-box .youtube-videos');
6502	setTimeout(function() {
6503    $('.youtube-gallery-box .youtube-videos .youtube_video:first').animate({"margin-left": '+='+iwidth});
6504	  
6505		}, 100);
6506});
6507
6508
6509
6510$('#youtube-gallery-popup-box').click(function () {
6511	$('#youtube-gallery-popup-box').toggle();
6512	$('#youtube-gallery-popup-box .yg-popup').html('');
6513});
6514$('#viewImage-popupBox').click(function () {
6515	$('#viewImage-popupBox').toggle();
6516	$('#viewImage-popupBox .yg-popup').html('');
6517});
6518$('.youtube-gallery-box .gallery-box .nav-left').click(function () {
6519	var iwidth = $('.youtube-gallery-box .gallery-box .img:first').width();
6520    $('.youtube-gallery-box .gallery-box .img:first').animate({"margin-left": '-='+iwidth});
6521	  setTimeout(function() {
6522		  $('.youtube-gallery-box .gallery-box .img:first').css({"margin-left": '0px'}).appendTo('.youtube-gallery-box .gallery-images');
6523		}, 500);
6524});
6525$('.youtube-gallery-box  .gallery-box .nav-right').click(function () {
6526	var iwidth = $('.youtube-gallery-box .gallery-images .img:last').width();
6527	
6528	$('.youtube-gallery-box .gallery-box .img:last').css({"margin-left": '-='+iwidth}).prependTo('.youtube-gallery-box .gallery-images');
6529	setTimeout(function() {
6530    $('.youtube-gallery-box .gallery-box .img:first').animate({"margin-left": '+='+iwidth});
6531	  
6532		}, 100);
6533});
6534
6535	var iheight = $('.category_banners > .banners_line:nth-child(2)').height();
6536	setInterval(function() {
6537	  //$('.category_banners > .banners_line:first').animate({"margin-top": '-='+iheight});
6538	  setTimeout(function() {
6539		  $('.event_group_img img:first').appendTo('.event_group_img');
6540		  $('.category_banners > .banners_line:first').appendTo('.category_banners');
6541		}, 2500);
6542	}, 3000);
6543	
6544
6545
6546});
6547
6548
6549function open_youtube_gallery(source, link){
6550	if(source=='youtube'){
6551		$('#youtube-gallery-popup-box .yg-popup').html('<iframe id="ytplayer" type="text/html" src="https://www.youtube.com/embed/'+link+'?autoplay=1&rel=0&showinfo=0&color=white&iv_load_policy=3" frameborder="0" allowfullscreen allow="autoplay;"></iframe>');
6552		$('#youtube-gallery-popup-box').toggle();
6553	}
6554	if(source=='gallery'){
6555		
6556		$('#youtube-gallery-popup-box .yg-popup').html('<img src="https://www.ticketmarket.lt/files/events_gallery/'+link+'">');
6557		$('#youtube-gallery-popup-box').toggle();
6558	}
6559}
6560
6561$('.opage-content .ob-left').click(function () {
6562    $('.obanner-box .images img:last-child').prependTo('.obanner-box .images');
6563});
6564$('.opage-content .ob-right').click(function () {
6565    $('.obanner-box .images img:first-child').appendTo('.obanner-box .images');
6566});
6567
6568
6569
6570
6571$(document).ready(function() {
6572	if ( $( ".opage-content .sticky" ).length ) {
6573	  var stickyTop = $('.opage-content .sticky').offset().top;
6574	  
6575	  setInterval(function() {
6576	  setTimeout(function() {
6577		  $('.obanner-box .images img:first-child').appendTo('.obanner-box .images');
6578		}, 2500);
6579	  }, 3000);
6580	  
6581	  if ($('.org-news').find('.news-item').length > 10) { //if looking for direct descendants then do .children('div').length
6582		  $('.org-news').addClass('scroll');
6583	  }
6584
6585	  $(window).scroll(function() {
6586		var windowTop = $(window).scrollTop();
6587		if (stickyTop < windowTop && $(".opage-content .banner-ad-box").height()-100 > windowTop) {
6588		  $('.opage-content .sticky').css('position', 'fixed');
6589		} else {
6590		  $('.opage-content .sticky').css('position', 'relative');
6591		}
6592	  });
6593	}
6594});
6595
6596
6597
6598
6599$(function(){
6600    $('#transaction_email').change(function() {
6601		order = $(this).data('order');
6602		price = $(this).data('price');
6603        if($(this).is(':checked')){
6604            $.post(baseURL('cart/transaction_add'), {'order_id': order, 'price': price}, function(data) {});
6605        }else{
6606			
6607			
6608			if ($("#transaction_sms")[0]){
6609				if($('#transaction_sms').is(':checked')){}else{
6610					$.post(baseURL('cart/transaction_delete'), {'order_id': order}, function(data) {});
6611					$('#transaction_sms').click();
6612				}
6613			} else {
6614				$('#transaction_email').prop('checked', true);
6615			}
6616			
6617			
6618			
6619			
6620		}
6621    });
6622	
6623	$('#transaction_sms').change(function() {
6624		order = $(this).data('order');
6625		price = $(this).data('price');
6626        if($(this).is(':checked')){
6627            $.post(baseURL('cart/transaction_sms_add'), {'order_id': order, 'price': price}, function(data) {});
6628        }else{
6629			
6630			
6631			
6632			if ($("#transaction_email")[0]){
6633				if($('#transaction_email').is(':checked')){}else{
6634					$.post(baseURL('cart/transaction_sms_delete'), {'order_id': order}, function(data) {});
6635					$('#transaction_email').click();
6636				}
6637			} else {
6638				$('#transaction_sms').prop('checked', true);
6639			}
6640
6641		}
6642    });
6643    
6644});
6645
6646$('.auto-ticket-options .ato-add').click(function () {
6647    var atox = parseInt($(this).siblings('.auto-ticket-input').val());
6648	
6649	if(!atox) atox = 0;
6650		atox = atox+1;
6651
6652	$(this).siblings('.auto-ticket-input').val(atox);
6653	$(this).siblings('.auto-ticket-input-hidden').val(atox);
6654});
6655$('.auto-ticket-options .ato-reduce').click(function () {
6656    var atox = parseInt($(this).siblings('.auto-ticket-input').val());
6657	if(!atox) atox =0;
6658	if(atox<=1)
6659		atox = '';
6660	else
6661		atox = atox-1;
6662
6663	$(this).siblings('.auto-ticket-input').val(atox);
6664	$(this).siblings('.auto-ticket-input-hidden').val(atox);
6665});				   
6666
6667$(document).ready(function() {
6668	sort_table_column();
6669	function sort_table_column(){
6670		 var tbody =$('#table_sort');
6671
6672		 tbody.find('tr').sort(function(a, b) 
6673		 {
6674			 
6675		   return $('td.sort_column', a).text().localeCompare($('td.sort_column', b).text(), 'en', {numeric: true});
6676
6677		   //return $('td.sort_column', b).text().localeCompare($('td,sort_column', a).text());
6678		  
6679				
6680		 }).appendTo(tbody);
6681			
6682		 var sort_order='asc';
6683	 
6684	}
6685});	
6686
6687
6688
6689/*
6690 * jQuery.ReadAll ia a jQuery plugin to shrink large blocks of content and place a read more button below.
6691 * Created by Anders Fjأ¤llstrأ¶m - [email protected] - http://www.morriz.net
6692 * For documentation see https://github.com/morriznet/jquery.readall
6693 * Released under MIT license
6694 * version 1.1
6695 */
6696
6697!function (e) { e.fn.readall = function (s) { var t = e.extend({ showheight: 96, showrows: null, animationspeed: 200, btnTextShowmore: "Read more", btnTextShowless: "Read less", btnClassShowmore: "readall-button", btnClassShowless: "readall-button" }, s); return e(this).each(function () { var s = e(this), a = function () { return s[0].scrollHeight }; if (null != t.showrows) { var h = Math.floor(1.5 * parseFloat(s.css("font-size"))); t.showheight = h * t.showrows } s.addClass("readall").css({ overflow: "hidden" }); var o = function (h) { var o = s.parent().find("button." + t.btnClassShowmore.replace(/\s+/g, ".") + ", button." + t.btnClassShowless.replace(/\s+/g, ".")); a() > t.showheight + e(o).outerHeight() ? e(o).is(":visible") && null != h || (s.css({ height: t.showheight + "px", "max-height": t.showheight + "px" }), e(o).text(t.btnTextShowmore), s.addClass("readall-hide"), e(o).removeClass(t.btnClassShowless).addClass(t.btnClassShowmore), e(o).show()) : (e(o).is(":visible") || null == h) && (s.css({ height: "", "max-height": "" }), s.removeClass("readall-hide"), e(o).hide()) }; if (s.parent().not("readall-wrapper")) { s.wrap(e("<div />").addClass("readall-wrapper")); var l = e("<button />").addClass(t.btnClassShowmore).text(t.btnTextShowmore).click(function (h) { h.preventDefault(), s.hasClass("readall-hide") ? s.css({ height: t.showheight + "px", "max-height": "" }).animate({ height: a() + "px" }, t.animationspeed, function () { s.css({ height: "" }), e(l).text(t.btnTextShowless) }) : s.animate({ height: t.showheight + "px" }, t.animationspeed, function () { s.css({ "max-height": t.showheight + "px" }), e(l).text(t.btnTextShowmore) }), s.toggleClass("readall-hide"), e(this).toggleClass(t.btnClassShowmore).toggleClass(t.btnClassShowless) }); s.after(l), e(window).bind("orientationchange resize", o), o(null) } }), this } }(jQuery);
6698
6699$(document).ready(function () {
6700    $('.readmore').readall({
6701        // Default values
6702        showheight: 160,                         // height to show
6703        showrows: null,                         // rows to show (overrides showheight)
6704        animationspeed: 200,                    // speed of transition
6705        btnTextShowmore: 'Rodyti daugiau',           // text shown on button to show more
6706        btnTextShowless: 'Rodyti mažiau',           // text shown on button to show less
6707        btnClassShowmore: 'readall-button more',     // class(es) on button to show more
6708        btnClassShowless: 'readall-button'      // class(es) on button to show less
6709    });
6710});
6711
6712$(document).on('click', '.other-events-tabs .tab:not(.active)', function () {
6713	$('.other-events-tabs .tab').removeClass('active');
6714	$(this).addClass('active');
6715	data = $(this).attr("data-type");
6716
6717	$('.carousel-home').addClass('disable');
6718	$('.carousel-home').removeClass('active');
6719	$('.carousel-home[data-type="'+data+'"]').removeClass('disable');
6720	$('.carousel-home[data-type="'+data+'"]').addClass('active');
6721
6722});
6723
6724$(document).on('click', '.block-events-menu .tab-btn:not(.active)', function () {
6725	$(this).parent().find('.tab-btn').removeClass('active');
6726	$(this).addClass('active');
6727	data = $(this).attr("data-tab");
6728
6729
6730	$(this).parent().parent().find('.events-grid').removeClass('active');
6731	$(this).parent().parent().find('.events-grid[data-tab="'+data+'"]').addClass('active');
6732
6733});
6734
6735
6736$(document).ready(function() {
6737	if ($(window).width() < 992){
6738		tags_show = 4;
6739	}else{
6740		tags_show = 8;
6741	}
6742	$(".tag-blocks .events-grid").each(function(){
6743		$(this).find(".event-item").hide();
6744		$(this).find(".event-item:lt("+tags_show+")").show();
6745		len = $(this).find(".event-item").length;
6746		if(len > 8)
6747			$(this).find(".events-grid-more").html('<button class="show-more-tag-events" data-total="'+len+'" data-show="'+tags_show+'" data-more="'+tags_show+'">Rodyti daugiau</button>');
6748	});
6749
6750});
6751$(document).on('click', '.show-more-tag-events', function () {
6752	cshow = $(this).data('show');
6753	mshow = $(this).data('more');
6754	tshow = $(this).data('total');
6755
6756	nshow = cshow+mshow;
6757
6758	$(this).parent().parent().find(".event-item:lt("+nshow+")").show();
6759	$(this).data('show', nshow);
6760	if(nshow > tshow){
6761		$(this).hide();
6762	}
6763});
6764
6765
6766$("#search").submit(function(e){
6767	e.preventDefault();
6768});
6769let searchKey = null;
6770let timeoutID = null;
6771let currentURL = window.location.href;
6772let lastSearch = '';
6773$("#search-input:input").on("keyup", function(e) {
6774	
6775	search  = $(this).val();
6776	search = search.replace(/\s+/g, '-');
6777
6778	search_data = search;
6779	
6780
6781	search = search.normalize('NFD').replace(/[\u0300-\u036f]/g, "");
6782	search = search.replace(/[^a-zA-Z0-9\-\_]/g, '');
6783
6784
6785
6786	if(search.length > 1) {
6787		if(searchKey != search){
6788			clearTimeout(timeoutID);
6789
6790			searchKey = search;
6791
6792			const newURL = "/search?q="+search_data;
6793			history.pushState(null, null, newURL);
6794
6795			
6796			if ($(".l-main.search-results").length) {
6797	
6798			} else {
6799				$('.l-main').before('<div class="l-main search-results"></div>');
6800			}
6801			
6802			$('.l-main:not(.search-results)').hide();
6803			timeoutID = setTimeout(() =>
6803 searchAjax(search_data), 500);
6804
6805		}
6806		
6807
6808	}else{
6809		history.pushState(null, null, currentURL);
6810		$('.l-main').show();
6811		$('.l-main.search-results').remove();
6812
6813	}
6814});
6815function searchAjax(search) {
6816	$.post(baseURL('search/searchAjax'), {'search': search}, function(data){
6817		$('.l-main.search-results').html(data);
6818	});
6819}
6820function isEmpty( el ){
6821	return !$.trim(el.html())
6822}
6823
6824$('.deduction_cart .for_events').on('click', function () {
6825    $('.deduction_cart .events').toggle();
6826});
6827
6828$(function () {
6829  const map = {
6830    'ą':'a','č':'c','ę':'e','ė':'e','į':'i','š':'s','ų':'u','ū':'u','ž':'z',
6831    'Ą':'A','Č':'C','Ę':'E','Ė':'E','Į':'I','Š':'S','Ų':'U','Ū':'U','Ž':'Z'
6832  };
6833
6834  function normalizeEmail(val) {
6835    // 1. replace LT letters
6836    val = val.replace(/[ąčęėįšųūžĄČĘĖĮŠŲŪŽ]/g, c => map[c]);
6837
6838    // 2. remove everything NOT allowed in email
6839    // allowed: a-z A-Z 0-9 . _ % + - @
6840    val = val.replace(/[^a-zA-Z0-9._%+-@]/g, '');
6841
6842    // 3. allow only one "@"
6843    const parts = val.split('@');
6844    if (parts.length > 2) {
6845      val = parts.shift() + '@' + parts.join('');
6846    }
6847
6848    return val;
6849  }
6850
6851  $('.email_smart').on('input', function () {
6852    const v = this.value;
6853    const nv = normalizeEmail(v);
6854    if (v !== nv) {
6855      const pos = this.selectionStart;
6856      this.value = nv;
6857      this.setSelectionRange(pos, pos);
6858    }
6859  });
6860});

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.