PageSourceSearch

https://www.lubycza.pl/asp/js/jssor.js

js lubycza.pl collected 2026-10-02 20:30:10 UTC 90,694 bytes, 2,763 lines download raw bytes

1/*
2* Jssor 19.0
3* http://www.jssor.com/
4*
5* Licensed under the MIT license:
6* http://www.opensource.org/licenses/MIT
7* 
8* TERMS OF USE - Jssor
9* 
10* Copyright 2014 Jssor
11*
12* Permission is hereby granted, free of charge, to any person obtaining
13* a copy of this software and associated documentation files (the
14* "Software"), to deal in the Software without restriction, including
15* without limitation the rights to use, copy, modify, merge, publish,
16* distribute, sublicense, and/or sell copies of the Software, and to
17* permit persons to whom the Software is furnished to do so, subject to
18* the following conditions:
19* 
20* The above copyright notice and this permission notice shall be
21* included in all copies or substantial portions of the Software.
22* 
23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30*/
31
32/*! Jssor */
33
34//$JssorDebug$
35var $JssorDebug$ = new function () {
36
37    this.$DebugMode = true;
38
39    // Methods
40
41    this.$Log = function (msg, important) {
42        var console = window.console || {};
43        var debug = this.$DebugMode;
44
45        if (debug && console.log) {
46            console.log(msg);
47        } else if (debug && important) {
48            alert(msg);
49        }
50    };
51
52    this.$Error = function (msg, e) {
53        var console = window.console || {};
54        var debug = this.$DebugMode;
55
56        if (debug && console.error) {
57            console.error(msg);
58        } else if (debug) {
59            alert(msg);
60        }
61
62        if (debug) {
63            // since we're debugging, fail fast by crashing
64            throw e || new Error(msg);
65        }
66    };
67
68    this.$Fail = function (msg) {
69        throw new Error(msg);
70    };
71
72    this.$Assert = function (value, msg) {
73        var debug = this.$DebugMode;
74        if (debug) {
75            if (!value)
76                throw new Error("Assert failed " + msg || "");
77        }
78    };
79
80    this.$Trace = function (msg) {
81        var console = window.console || {};
82        var debug = this.$DebugMode;
83
84        if (debug && console.log) {
85            console.log(msg);
86        }
87    };
88
89    this.$Execute = function (func) {
90        var debug = this.$DebugMode;
91        if (debug)
92            func();
93    };
94
95    this.$LiveStamp = function (obj, id) {
96        var debug = this.$DebugMode;
97        if (debug) {
98            var stamp = document.createElement("DIV");
99            stamp.setAttribute("id", id);
100
101            obj.$Live = stamp;
102        }
103    };
104
105    this.$C_AbstractProperty = function () {
106        ///	<summary>
107        ///		Tells compiler the property is abstract, it should be implemented by subclass.
108        ///	</summary>
109
110        throw new Error("The property is abstract, it should be implemented by subclass.");
111    };
112
113    this.$C_AbstractMethod = function () {
114        ///	<summary>
115        ///		Tells compiler the method is abstract, it should be implemented by subclass.
116        ///	</summary>
117
118        throw new Error("The method is abstract, it should be implemented by subclass.");
119    };
120
121    function C_AbstractClass(instance) {
122        ///	<summary>
123        ///		Tells compiler the class is abstract, it should be implemented by subclass.
124        ///	</summary>
125
126        if (instance.constructor === C_AbstractClass.caller)
127            throw new Error("Cannot create instance of an abstract class.");
128    }
129
130    this.$C_AbstractClass = C_AbstractClass;
131};
132
133//$JssorEasing$
134var $JssorEasing$ = window.$JssorEasing$ = {
135    $EaseSwing: function (t) {
136        return -Math.cos(t * Math.PI) / 2 + .5;
137    },
138    $EaseLinear: function (t) {
139        return t;
140    },
141    $EaseInQuad: function (t) {
142        return t * t;
143    },
144    $EaseOutQuad: function (t) {
145        return -t * (t - 2);
146    },
147    $EaseInOutQuad: function (t) {
148        return (t *= 2) < 1 ? 1 / 2 * t * t : -1 / 2 * (--t * (t - 2) - 1);
149    },
150    $EaseInCubic: function (t) {
151        return t * t * t;
152    },
153    $EaseOutCubic: function (t) {
154        return (t -= 1) * t * t + 1;
155    },
156    $EaseInOutCubic: function (t) {
157        return (t *= 2) < 1 ? 1 / 2 * t * t * t : 1 / 2 * ((t -= 2) * t * t + 2);
158    },
159    $EaseInQuart: function (t) {
160        return t * t * t * t;
161    },
162    $EaseOutQuart: function (t) {
163        return -((t -= 1) * t * t * t - 1);
164    },
165    $EaseInOutQuart: function (t) {
166        return (t *= 2) < 1 ? 1 / 2 * t * t * t * t : -1 / 2 * ((t -= 2) * t * t * t - 2);
167    },
168    $EaseInQuint: function (t) {
169        return t * t * t * t * t;
170    },
171    $EaseOutQuint: function (t) {
172        return (t -= 1) * t * t * t * t + 1;
173    },
174    $EaseInOutQuint: function (t) {
175        return (t *= 2) < 1 ? 1 / 2 * t * t * t * t * t : 1 / 2 * ((t -= 2) * t * t * t * t + 2);
176    },
177    $EaseInSine: function (t) {
178        return 1 - Math.cos(t * Math.PI / 2);
179    },
180    $EaseOutSine: function (t) {
181        return Math.sin(t * Math.PI / 2);
182    },
183    $EaseInOutSine: function (t) {
184        return -1 / 2 * (Math.cos(Math.PI * t) - 1);
185    },
186    $EaseInExpo: function (t) {
187        return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));
188    },
189    $EaseOutExpo: function (t) {
190        return t == 1 ? 1 : -Math.pow(2, -10 * t) + 1;
191    },
192    $EaseInOutExpo: function (t) {
193        return t == 0 || t == 1 ? t : (t *= 2) < 1 ? 1 / 2 * Math.pow(2, 10 * (t - 1)) : 1 / 2 * (-Math.pow(2, -10 * --t) + 2);
194    },
195    $EaseInCirc: function (t) {
196        return -(Math.sqrt(1 - t * t) - 1);
197    },
198    $EaseOutCirc: function (t) {
199        return Math.sqrt(1 - (t -= 1) * t);
200    },
201    $EaseInOutCirc: function (t) {
202        return (t *= 2) < 1 ? -1 / 2 * (Math.sqrt(1 - t * t) - 1) : 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1);
203    },
204    $EaseInElastic: function (t) {
205        if (!t || t == 1)
206            return t;
207        var p = .3, s = .075;
208        return -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p));
209    },
210    $EaseOutElastic: function (t) {
211        if (!t || t == 1)
212            return t;
213        var p = .3, s = .075;
214        return Math.pow(2, -10 * t) * Math.sin((t - s) * 2 * Math.PI / p) + 1;
215    },
216    $EaseInOutElastic: function (t) {
217        if (!t || t == 1)
218            return t;
219        var p = .45, s = .1125;
220        return (t *= 2) < 1 ? -.5 * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p) : Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p) * .5 + 1;
221    },
222    $EaseInBack: function (t) {
223        var s = 1.70158;
224        return t * t * ((s + 1) * t - s);
225    },
226    $EaseOutBack: function (t) {
227        var s = 1.70158;
228        return (t -= 1) * t * ((s + 1) * t + s) + 1;
229    },
230    $EaseInOutBack: function (t) {
231        var s = 1.70158;
232        return (t *= 2) < 1 ? 1 / 2 * t * t * (((s *= 1.525) + 1) * t - s) : 1 / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2);
233    },
234    $EaseInBounce: function (t) {
235        return 1 - $JssorEasing$.$EaseOutBounce(1 - t)
236    },
237    $EaseOutBounce: function (t) {
238        return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
239    },
240    $EaseInOutBounce: function (t) {
241        return t < 1 / 2 ? $JssorEasing$.$EaseInBounce(t * 2) * .5 : $JssorEasing$.$EaseOutBounce(t * 2 - 1) * .5 + .5;
242    },
243    $EaseGoBack: function (t) {
244        return 1 - Math.abs((t *= 2) - 1);
245    },
246    $EaseInWave: function (t) {
247        return 1 - Math.cos(t * Math.PI * 2)
248    },
249    $EaseOutWave: function (t) {
250        return Math.sin(t * Math.PI * 2);
251    },
252    $EaseOutJump: function (t) {
253        return 1 - (((t *= 2) < 1) ? (t = 1 - t) * t * t : (t -= 1) * t * t);
254    },
255    $EaseInJump: function (t) {
256        return ((t *= 2) < 1) ? t * t * t : (t = 2 - t) * t * t;
257    }
258};
259
260var $JssorDirection$ = window.$JssorDirection$ = {
261    $TO_LEFT: 0x0001,
262    $TO_RIGHT: 0x0002,
263    $TO_TOP: 0x0004,
264    $TO_BOTTOM: 0x0008,
265    $HORIZONTAL: 0x0003,
266    $VERTICAL: 0x000C,
267    //$LEFTRIGHT: 0x0003,
268    //$TOPBOTOM: 0x000C,
269    //$TOPLEFT: 0x0005,
270    //$TOPRIGHT: 0x0006,
271    //$BOTTOMLEFT: 0x0009,
272    //$BOTTOMRIGHT: 0x000A,
273    //$AROUND: 0x000F,
274
275    $GetDirectionHorizontal: function (direction) {
276        return direction & 0x0003;
277    },
278    $GetDirectionVertical: function (direction) {
279        return direction & 0x000C;
280    },
281    //$ChessHorizontal: function (direction) {
282    //    return (~direction & 0x0003) + (direction & 0x000C);
283    //},
284    //$ChessVertical: function (direction) {
285    //    return (~direction & 0x000C) + (direction & 0x0003);
286    //},
287    //$IsToLeft: function (direction) {
288    //    return (direction & 0x0003) == 0x0001;
289    //},
290    //$IsToRight: function (direction) {
291    //    return (direction & 0x0003) == 0x0002;
292    //},
293    //$IsToTop: function (direction) {
294    //    return (direction & 0x000C) == 0x0004;
295    //},
296    //$IsToBottom: function (direction) {
297    //    return (direction & 0x000C) == 0x0008;
298    //},
299    $IsHorizontal: function (direction) {
300        return direction & 0x0003;
301    },
302    $IsVertical: function (direction) {
303        return direction & 0x000C;
304    }
305};
306
307var $JssorKeyCode$ = {
308    $BACKSPACE: 8,
309    $COMMA: 188,
310    $DELETE: 46,
311    $DOWN: 40,
312    $END: 35,
313    $ENTER: 13,
314    $ESCAPE: 27,
315    $HOME: 36,
316    $LEFT: 37,
317    $NUMPAD_ADD: 107,
318    $NUMPAD_DECIMAL: 110,
319    $NUMPAD_DIVIDE: 111,
320    $NUMPAD_ENTER: 108,
321    $NUMPAD_MULTIPLY: 106,
322    $NUMPAD_SUBTRACT: 109,
323    $PAGE_DOWN: 34,
324    $PAGE_UP: 33,
325    $PERIOD: 190,
326    $RIGHT: 39,
327    $SPACE: 32,
328    $TAB: 9,
329    $UP: 38
330};
331
332// $Jssor$ is a static class, so make it singleton instance
333var $Jssor$ = window.$Jssor$ = new function () {
334    var _This = this;
335
336    //#region Constants
337    var REGEX_WHITESPACE_GLOBAL = /\S+/g;
338    var ROWSER_OTHER = -1;
339    var ROWSER_UNKNOWN = 0;
340    var BROWSER_IE = 1;
341    var BROWSER_FIREFOX = 2;
342    var BROWSER_SAFARI = 3;
343    var BROWSER_CHROME = 4;
344    var BROWSER_OPERA = 5;
345    //var arrActiveX = ["Msxml2.XMLHTTP", "Msxml3.XMLHTTP", "Microsoft.XMLHTTP"];
346    //#endregion
347
348    //#region Variables
349    var _Device;
350    var _Browser = 0;
351    var _BrowserRuntimeVersion = 0;
352    var _BrowserEngineVersion = 0;
353    var _BrowserJavascriptVersion = 0;
354    var _WebkitVersion = 0;
355
356    var _Navigator = navigator;
357    var _AppName = _Navigator.appName;
358    var _AppVersion = _Navigator.appVersion;
359    var _UserAgent = _Navigator.userAgent;
360
361    var _DocElmt = document.documentElement;
362    var _TransformProperty;
363    //#endregion
364
365    function Device() {
366        _Device = _Device || { $Touchable: "ontouchstart" in window || "createTouch" in document };
367
368        return _Device;
369    }
370
371    function DetectBrowser(browser) {
372        if (!_Browser) {
373            _Browser = -1;
374
375            if (_AppName == "Microsoft Internet Explorer" &&
376                !!window.attachEvent && !!window.ActiveXObject) {
377
378                var ieOffset = _UserAgent.indexOf("MSIE");
379                _Browser = BROWSER_IE;
380                _BrowserEngineVersion = ParseFloat(_UserAgent.substring(ieOffset + 5, _UserAgent.indexOf(";", ieOffset)));
381
382                //check IE javascript version
383                /*@cc_on
384                _BrowserJavascriptVersion = @_jscript_version;
385                @*/
386
387                // update: for intranet sites and compat view list sites, IE sends
388                // an IE7 User-Agent to the server to be interoperable, and even if
389                // the page requests a later IE version, IE will still report the
390                // IE7 UA to JS. we should be robust to self
391                //var docMode = document.documentMode;
392                //if (typeof docMode !== "undefined") {
393                //    _BrowserRuntimeVersion = docMode;
394                //}
395
396                _BrowserRuntimeVersion = document.documentMode || _BrowserEngineVersion;
397
398            }
399            else if (_AppName == "Netscape" && !!window.addEventListener) {
400
401                var ffOffset = _UserAgent.indexOf("Firefox");
402                var saOffset = _UserAgent.indexOf("Safari");
403                var chOffset = _UserAgent.indexOf("Chrome");
404                var webkitOffset = _UserAgent.indexOf("AppleWebKit");
405
406                if (ffOffset >= 0) {
407                    _Browser = BROWSER_FIREFOX;
408                    _BrowserRuntimeVersion = ParseFloat(_UserAgent.substring(ffOffset + 8));
409                }
410                else if (saOffset >= 0) {
411                    var slash = _UserAgent.substring(0, saOffset).lastIndexOf("/");
412                    _Browser = (chOffset >= 0) ? BROWSER_CHROME : BROWSER_SAFARI;
413                    _BrowserRuntimeVersion = ParseFloat(_UserAgent.substring(slash + 1, saOffset));
414                }
415                else {
416                    //(/Trident.*rv[ :]*11\./i
417                    var match = /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i.exec(_UserAgent);
418                    if (match) {
419                        _Browser = BROWSER_IE;
420                        _BrowserRuntimeVersion = _BrowserEngineVersion = ParseFloat(match[1]);
421                    }
422                }
423
424                if (webkitOffset >= 0)
425                    _WebkitVersion = ParseFloat(_UserAgent.substring(webkitOffset + 12));
426            }
427            else {
428                var match = /(opera)(?:.*version|)[ \/]([\w.]+)/i.exec(_UserAgent);
429                if (match) {
430                    _Browser = BROWSER_OPERA;
431                    _BrowserRuntimeVersion = ParseFloat(match[2]);
432                }
433            }
434        }
435
436        return browser == _Browser;
437    }
438
439    function IsBrowserIE() {
440        return DetectBrowser(BROWSER_IE);
441    }
442
443    function IsBrowserIeQuirks() {
444        return IsBrowserIE() && (_BrowserRuntimeVersion < 6 || document.compatMode == "BackCompat");   //Composite to "CSS1Compat"
445    }
446
447    function IsBrowserFireFox() {
448        return DetectBrowser(BROWSER_FIREFOX);
449    }
450
451    function IsBrowserSafari() {
452        return DetectBrowser(BROWSER_SAFARI);
453    }
454
455    function IsBrowserChrome() {
456        return DetectBrowser(BROWSER_CHROME);
457    }
458
459    function IsBrowserOpera() {
460        return DetectBrowser(BROWSER_OPERA);
461    }
462
463    function IsBrowserBadTransform() {
464        return IsBrowserSafari() && (_WebkitVersion > 534) && (_WebkitVersion < 535);
465    }
466
467    function IsBrowserIe9Earlier() {
468        return IsBrowserIE() && _BrowserRuntimeVersion < 9;
469    }
470
471    function GetTransformProperty(elmt) {
472
473        if (!_TransformProperty) {
474            // Note that in some versions of IE9 it is critical that
475            // msTransform appear in this list before MozTransform
476
477            Each(['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform'], function (property) {
478                if (elmt.style[property] != undefined) {
479                    _TransformProperty = property;
480                    return true;
481                }
482            });
483
484            _TransformProperty = _TransformProperty || "transform";
485        }
486
487        return _TransformProperty;
488    }
489
490    // Helpers
491    function getOffsetParent(elmt, isFixed) {
492        // IE and Opera "fixed" position elements don't have offset parents.
493        // regardless, if it's fixed, its offset parent is the body.
494        if (isFixed && elmt != document.body) {
495            return document.body;
496        } else {
497            return elmt.offsetParent;
498        }
499    }
500
501    function toString(obj) {
502        return {}.toString.call(obj);
503    }
504
505    // [[Class]] -> type pairs
506    var _Class2type;
507
508    function GetClass2Type() {
509        if (!_Class2type) {
510            _Class2type = {};
511            Each(["Boolean", "Number", "String", "Function", "Array", "Date", "RegExp", "Object"], function (name) {
512                _Class2type["[object " + name + "]"] = name.toLowerCase();
513            });
514        }
515
516        return _Class2type;
517    }
518
519    function Each(obj, callback) {
520        if (toString(obj) == "[object Array]") {
521            for (var i = 0; i < obj.length; i++) {
522                if (callback(obj[i], i, obj)) {
523                    return true;
524                }
525            }
526        }
527        else {
528            for (var name in obj) {
529                if (callback(obj[name], name, obj)) {
530                    return true;
531                }
532            }
533        }
534    }
535
536    function Type(obj) {
537        return obj == null ? String(obj) : GetClass2Type()[toString(obj)] || "object";
538    }
539
540    function IsNotEmpty(obj) {
541        for(var name in obj)
542            return true;
543    }
544
545    function IsPlainObject(obj) {
546        // Not plain objects:
547        // - Any object or value whose internal [[Class]] property is not "[object Object]"
548        // - DOM nodes
549        // - window
550        try {
551            return Type(obj) == "object"
552                && !obj.nodeType
553                && obj != obj.window
554                && (!obj.constructor || { }.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf"));
555        }
556        catch (e) { }
557    }
558
559    function Point(x, y) {
560        return { x: x, y: y };
561    }
562
563    function Delay(code, delay) {
564        setTimeout(code, delay || 0);
565    }
566
567    function RemoveByReg(str, reg) {
568        var m = reg.exec(str);
569
570        if (m) {
571            var header = str.substr(0, m.index);
572            var tailer = str.substr(m.lastIndex + 1, str.length - (m.lastIndex + 1));
573            str = header + tailer;
574        }
575
576        return str;
577    }
578
579    function BuildNewCss(oldCss, removeRegs, replaceValue) {
580        var css = (!oldCss || oldCss == "inherit") ? "" : oldCss;
581
582        Each(removeRegs, function (removeReg) {
583            var m = removeReg.exec(css);
584
585            if (m) {
586                var header = css.substr(0, m.index);
587                var tailer = css.substr(m.lastIndex + 1, css.length - (m.lastIndex + 1));
588                css = header + tailer;
589            }
590        });
591
592        css = replaceValue + (css.indexOf(" ") != 0 ? " " : "") + css;
593
594        return css;
595    }
596
597    function SetStyleFilterIE(elmt, value) {
598        if (_BrowserRuntimeVersion < 9) {
599            elmt.style.filter = value;
600        }
601    }
602
603    function SetStyleMatrixIE(elmt, matrix, offset) {
604        //matrix is not for ie9+ running in ie8- mode
605        if (_BrowserJavascriptVersion < 9) {
606            var oldFilterValue = elmt.style.filter;
607            var matrixReg = new RegExp(/[\s]*progid:DXImageTransform\.Microsoft\.Matrix\([^\)]*\)/g);
608            var matrixValue = matrix ? "progid:DXImageTransform.Microsoft.Matrix(" + "M11=" + matrix[0][0] + ", M12=" + matrix[0][1] + ", M21=" + matrix[1][0] + ", M22=" + matrix[1][1] + ", SizingMethod='auto expand')" : "";
609
610            var newFilterValue = BuildNewCss(oldFilterValue, [matrixReg], matrixValue);
611
612            SetStyleFilterIE(elmt, newFilterValue);
613
614            _This.$CssMarginTop(elmt, offset.y);
615            _This.$CssMarginLeft(elmt, offset.x);
616        }
617    }
618
619    // Methods
620
621    _This.$Device = Device;
622
623    _This.$IsBrowserIE = IsBrowserIE;
624
625    _This.$IsBrowserIeQuirks = IsBrowserIeQuirks;
626
627    _This.$IsBrowserFireFox = IsBrowserFireFox;
628
629    _This.$IsBrowserSafari = IsBrowserSafari;
630
631    _This.$IsBrowserChrome = IsBrowserChrome;
632
633    _This.$IsBrowserOpera = IsBrowserOpera;
634
635    _This.$IsBrowserBadTransform = IsBrowserBadTransform;
636
637    _This.$IsBrowserIe9Earlier = IsBrowserIe9Earlier;
638
639    _This.$BrowserVersion = function () {
640        return _BrowserRuntimeVersion;
641    };
642
643    _This.$BrowserEngineVersion = function () {
644        return _BrowserEngineVersion || _BrowserRuntimeVersion;
645    };
646
647    _This.$WebKitVersion = function () {
648        DetectBrowser();
649
650        return _WebkitVersion;
651    };
652
653    _This.$Delay = Delay;
654
655    _This.$Inherit = function (instance, baseClass) {
656        baseClass.call(instance);
657        return Extend({}, instance);
658    };
659
660    function Construct(instance) {
661        instance.constructor === Construct.caller && instance.$Construct && instance.$Construct.apply(instance, Construct.caller.arguments);
662    }
663
664    _This.$Construct = Construct;
665
666    _This.$GetElement = function (elmt) {
667        if (_This.$IsString(elmt)) {
668            elmt = document.getElementById(elmt);
669        }
670
671        return elmt;
672    };
673
674    function GetEvent(event) {
675        return event || window.event;
676    }
677
678    _This.$GetEvent = GetEvent;
679
680    _This.$EvtSrc = function (event) {
681        event = GetEvent(event);
682        return event.target || event.srcElement || document;
683    };
684
685    _This.$EvtTarget = function (event) {
686        event = GetEvent(event);
687        return event.relatedTarget || event.toElement;
688    };
689
690    _This.$EvtWhich = function (event) {
691        event = GetEvent(event);
692        return event.which || [0, 1, 3, 0, 2][event.button] || event.charCode || event.keyCode;
693    };
694
695    _This.$MousePosition = function (event) {
696        event = GetEvent(event);
697        //var body = document.body;
698
699        return {
700            x: event.pageX || event.clientX/* + (_DocElmt.scrollLeft || body.scrollLeft || 0) - (_DocElmt.clientLeft || body.clientLeft || 0)*/ || 0,
701            y: event.pageY || event.clientY/* + (_DocElmt.scrollTop || body.scrollTop || 0) - (_DocElmt.clientTop || body.clientTop || 0)*/ || 0
702        };
703    };
704
705    _This.$PageScroll = function () {
706        var body = document.body;
707
708        return {
709            x: (window.pageXOffset || _DocElmt.scrollLeft || body.scrollLeft || 0) - (_DocElmt.clientLeft || body.clientLeft || 0),
710            y: (window.pageYOffset || _DocElmt.scrollTop || body.scrollTop || 0) - (_DocElmt.clientTop || body.clientTop || 0)
711        };
712    };
713
714    _This.$WindowSize = function () {
715        var body = document.body;
716
717        return {
718            x: body.clientWidth || _DocElmt.clientWidth,
719            y: body.clientHeight || _DocElmt.clientHeight
720        };
721    };
722
723    //_This.$GetElementPosition = function (elmt) {
724    //    elmt = _This.$GetElement(elmt);
725    //    var result = Point();
726
727    //    // technique from:
728    //    // http://www.quirksmode.org/js/findpos.html
729    //    // with special check for "fixed" elements.
730
731    //    while (elmt) {
732    //        result.x += elmt.offsetLeft;
733    //        result.y += elmt.offsetTop;
734
735    //        var isFixed = _This.$GetElementStyle(elmt).position == "fixed";
736
737    //        if (isFixed) {
738    //            result = result.$Plus(_This.$PageScroll(window));
739    //        }
740
741    //        elmt = getOffsetParent(elmt, isFixed);
742    //    }
743
744    //    return result;
745    //};
746
747    //_This.$GetMouseScroll = function (event) {
748    //    event = GetEvent(event);
749    //    var delta = 0; // default value
750
751    //    // technique from:
752    //    // http://blog.paranoidferret.com/index.php/2007/10/31/javascript-tutorial-the-scroll-wheel/
753
754    //    if (typeof (event.wheelDelta) == "number") {
755    //        delta = event.wheelDelta;
756    //    } else if (typeof (event.detail) == "number") {
757    //        delta = event.detail * -1;
758    //    } else {
759    //        $JssorDebug$.$Fail("Unknown event mouse scroll, no known technique.");
760    //    }
761
762    //    // normalize value to [-1, 1]
763    //    return delta ? delta / Math.abs(delta) : 0;
764    //};
765
766    //_This.$MakeAjaxRequest = function (url, callback) {
767    //    var async = typeof (callback) == "function";
768    //    var req = null;
769
770    //    if (async) {
771    //        var actual = callback;
772    //        var callback = function () {
773    //            Delay($Jssor$.$CreateCallback(null, actual, req), 1);
774    //        };
775    //    }
776
777    //    if (window.ActiveXObject) {
778    //        for (var i = 0; i < arrActiveX.length; i++) {
779    //            try {
780    //                req = new ActiveXObject(arrActiveX[i]);
781    //                break;
782    //            } catch (e) {
783    //                continue;
784    //            }
785    //        }
786    //    } else if (window.XMLHttpRequest) {
787    //        req = new XMLHttpRequest();
788    //    }
789
790    //    if (!req) {
791    //        $JssorDebug$.$Fail("Browser doesn't support XMLHttpRequest.");
792    //    }
793
794    //    if (async) {
795    //        req.onreadystatechange = function () {
796    //            if (req.readyState == 4) {
797    //                // prevent memory leaks by breaking circular reference now
798    //                req.onreadystatechange = new Function();
799    //                callback();
800    //            }
801    //        };
802    //    }
803
804    //    try {
805    //        req.open("GET", url, async);
806    //        req.send(null);
807    //    } catch (e) {
808    //        $JssorDebug$.$Log(e.name + " while making AJAX request: " + e.message);
809
810    //        req.onreadystatechange = null;
811    //        req = null;
812
813    //        if (async) {
814    //            callback();
815    //        }
816    //    }
817
818    //    return async ? null : req;
819    //};
820
821    //_This.$ParseXml = function (string) {
822    //    var xmlDoc = null;
823
824    //    if (window.ActiveXObject) {
825    //        try {
826    //            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
827    //            xmlDoc.async = false;
828    //            xmlDoc.loadXML(string);
829    //        } catch (e) {
830    //            $JssorDebug$.$Log(e.name + " while parsing XML (ActiveX): " + e.message);
831    //        }
832    //    } else if (window.DOMParser) {
833    //        try {
834    //            var parser = new DOMParser();
835    //            xmlDoc = parser.parseFromString(string, "text/xml");
836    //        } catch (e) {
837    //            $JssorDebug$.$Log(e.name + " while parsing XML (DOMParser): " + e.message);
838    //        }
839    //    } else {
840    //        $JssorDebug$.$Fail("Browser doesn't support XML DOM.");
841    //    }
842
843    //    return xmlDoc;
844    //};
845
846    function Css(elmt, name, value) {
847        ///	<summary>
848        ///		access css
849        ///     $Jssor$.$Css(elmt, name);         //get css value
850        ///     $Jssor$.$Css(elmt, name, value);  //set css value
851        ///	</summary>
852        ///	<param name="elmt" type="HTMLElement">
853        ///		the element to access css
854        ///	</param>
855        ///	<param name="name" type="String">
856        ///		the name of css property
857        ///	</param>
858        ///	<param name="value" optional="true">
859        ///		the value to set
860        ///	</param>
861        if (value != undefined) {
862            elmt.style[name] = value;
863        }
864        else {
865            var style = elmt.currentStyle || elmt.style;
866            value = style[name];
867
868            if (value == "" && window.getComputedStyle) {
869                style = elmt.ownerDocument.defaultView.getComputedStyle(elmt, null);
870
871                style && (value = style.getPropertyValue(name) || style[name]);
872            }
873
874            return value;
875        }
876    }
877
878    function CssN(elmt, name, value, isDimensional) {
879        ///	<summary>
880        ///		access css as numeric
881        ///     $Jssor$.$CssN(elmt, name);         //get css value
882        ///     $Jssor$.$CssN(elmt, name, value);  //set css value
883        ///	</summary>
884        ///	<param name="elmt" type="HTMLElement">
885        ///		the element to access css
886        ///	</param>
887        ///	<param name="name" type="String">
888        ///		the name of css property
889        ///	</param>
890        ///	<param name="value" type="Number" optional="true">
891        ///		the value to set
892        ///	</param>
893        if (value != undefined) {
894            isDimensional && (value += "px");
895            Css(elmt, name, value);
896        }
897        else {
898            return ParseFloat(Css(elmt, name));
899        }
900    }
901
902    function CssP(elmt, name, value) {
903        ///	<summary>
904        ///		access css in pixel as numeric, like 'top', 'left', 'width', 'height'
905        ///     $Jssor$.$CssP(elmt, name);         //get css value
906        ///     $Jssor$.$CssP(elmt, name, value);  //set css value
907        ///	</summary>
908        ///	<param name="elmt" type="HTMLElement">
909        ///		the element to access css
910        ///	</param>
911        ///	<param name="name" type="String">
912        ///		the name of css property
913        ///	</param>
914        ///	<param name="value" type="Number" optional="true">
915        ///		the value to set
916        ///	</param>
917        return CssN(elmt, name, value, true);
918    }
919
920    function CssProxy(name, numericOrDimension) {
921        ///	<summary>
922        ///		create proxy to access css, CssProxy(name[, numericOrDimension]);
923        ///	</summary>
924        ///	<param name="elmt" type="HTMLElement">
925        ///		the element to access css
926        ///	</param>
927        ///	<param name="numericOrDimension" type="Number" optional="true">
928        ///		not set: access original css, 1: access css as numeric, 2: access css in pixel as numeric
929        ///	</param>
930        var isDimensional = numericOrDimension & 2;
931        var cssAccessor = numericOrDimension ? CssN : Css;
932        return function (elmt, value) {
933            return cssAccessor(elmt, name, value, isDimensional);
934        };
935    }
936
937    function GetStyleOpacity(elmt) {
938        if (IsBrowserIE() && _BrowserEngineVersion < 9) {
939            var match = /opacity=([^)]*)/.exec(elmt.style.filter || "");
940            return match ? (ParseFloat(match[1]) / 100) : 1;
941        }
942        else
943            return ParseFloat(elmt.style.opacity || "1");
944    }
945
946    function SetStyleOpacity(elmt, opacity, ie9EarlierForce) {
947
948        if (IsBrowserIE() && _BrowserEngineVersion < 9) {
949            //var filterName = "filter"; // _BrowserEngineVersion < 8 ? "filter" : "-ms-filter";
950            var finalFilter = elmt.style.filter || "";
951
952            // for CSS filter browsers (IE), remove alpha filter if it's unnecessary.
953            // update: doing _This always since IE9 beta seems to have broken the
954            // behavior if we rely on the programmatic filters collection.
955            var alphaReg = new RegExp(/[\s]*alpha\([^\)]*\)/g);
956
957            // important: note the lazy star! _This protects against
958            // multiple filters; we don't want to delete the other ones.
959            // update: also trimming extra whitespace around filter.
960
961            var ieOpacity = Math.round(100 * opacity);
962            var alphaFilter = "";
963            if (ieOpacity < 100 || ie9EarlierForce) {
964                alphaFilter = "alpha(opacity=" + ieOpacity + ") ";
965            }
966
967            var newFilterValue = BuildNewCss(finalFilter, [alphaReg], alphaFilter);
968
969            SetStyleFilterIE(elmt, newFilterValue);
970        }
971        else {
972            elmt.style.opacity = opacity == 1 ? "" : Math.round(opacity * 100) / 100;
973        }
974    }
975
976    function SetStyleTransformInternal(elmt, transform) {
977        var rotate = transform.$Rotate || 0;
978        var scale = transform.$Scale == undefined ? 1 : transform.$Scale;
979
980        if (IsBrowserIe9Earlier()) {
981            var matrix = _This.$CreateMatrix(rotate / 180 * Math.PI, scale, scale);
982            SetStyleMatrixIE(elmt, (!rotate && scale == 1) ? null : matrix, _This.$GetMatrixOffset(matrix, transform.$OriginalWidth, transform.$OriginalHeight));
983        }
984        else {
985            //rotate(15deg) scale(.5) translateZ(0)
986            var transformProperty = GetTransformProperty(elmt);
987            if (transformProperty) {
988                var transformValue = "rotate(" + rotate % 360 + "deg) scale(" + scale + ")";
989
990                //needed for touch device, no need for desktop device
991                if (IsBrowserChrome() && _WebkitVersion > 535 && "ontouchstart" in window)
992                    transformValue += " perspective(2000px)";
993
994                elmt.style[transformProperty] = transformValue;
995            }
996        }
997    }
998
999    _This.$SetStyleTransform = function (elmt, transform) {
1000        if (IsBrowserBadTransform()) {
1001            Delay(_This.$CreateCallback(null, SetStyleTransformInternal, elmt, transform));
1002        }
1003        else {
1004            SetStyleTransformInternal(elmt, transform);
1005        }
1006    };
1007
1008    _This.$SetStyleTransformOrigin = function (elmt, transformOrigin) {
1009        var transformProperty = GetTransformProperty(elmt);
1010
1011        if (transformProperty)
1012            elmt.style[transformProperty + "Origin"] = transformOrigin;
1013    };
1014
1015    _This.$CssScale = function (elmt, scale) {
1016
1017        if (IsBrowserIE() && _BrowserEngineVersion < 9 || (_BrowserEngineVersion < 10 && IsBrowserIeQuirks())) {
1018            elmt.style.zoom = (scale == 1) ? "" : scale;
1019        }
1020        else {
1021            var transformProperty = GetTransformProperty(elmt);
1022
1023            if (transformProperty) {
1024                //rotate(15deg) scale(.5)
1025                var transformValue = "scale(" + scale + ")";
1026
1027                var oldTransformValue = elmt.style[transformProperty];
1028                var scaleReg = new RegExp(/[\s]*scale\(.*?\)/g);
1029
1030                var newTransformValue = BuildNewCss(oldTransformValue, [scaleReg], transformValue);
1031
1032                elmt.style[transformProperty] = newTransformValue;
1033            }
1034        }
1035    };
1036
1037    _This.$EnableHWA = function (elmt) {
1038        if (!elmt.style[GetTransformProperty(elmt)] || elmt.style[GetTransformProperty(elmt)] == "none")
1039            elmt.style[GetTransformProperty(elmt)] = "perspective(2000px)";
1040    };
1041
1042    _This.$DisableHWA = function (elmt) {
1043        elmt.style[GetTransformProperty(elmt)] = "none";
1044    };
1045
1046    var ie8OffsetWidth = 0;
1047    var ie8OffsetHeight = 0;
1048
1049    _This.$WindowResizeFilter = function (window, handler) {
1050        return IsBrowserIe9Earlier() ? function () {
1051
1052            var trigger = true;
1053
1054            var checkElement = (IsBrowserIeQuirks() ? window.document.body : window.document.documentElement);
1055            if (checkElement) {
1056                var widthChange = checkElement.offsetWidth - ie8OffsetWidth;
1057                var heightChange = checkElement.offsetHeight - ie8OffsetHeight;
1058                if (widthChange || heightChange) {
1059                    ie8OffsetWidth += widthChange;
1060                    ie8OffsetHeight += heightChange;
1061                }
1062                else
1063                    trigger = false;
1064            }
1065
1066            trigger && handler();
1067
1068        } : handler;
1069    };
1070
1071    _This.$MouseOverOutFilter = function (handler, target) {
1072        ///	<param name="target" type="HTMLDomElement">
1073        ///		The target element to detect mouse over/out events. (for ie < 9 compatibility)
1074        ///	</param>
1075
1076        $JssorDebug$.$Execute(function () {
1077            if (!target) {
1078                throw new Error("Null reference, parameter \"target\".");
1079            }
1080        });
1081
1082        return function (event) {
1083            event = GetEvent(event);
1084
1085            var eventName = event.type;
1086            var related = event.relatedTarget || (eventName == "mouseout" ? event.toElement : event.fromElement);
1087
1088            if (!related || (related !== target && !_This.$IsChild(target, related))) {
1089                handler(event);
1090            }
1091        };
1092    };
1093
1094    _This.$AddEvent = function (elmt, eventName, handler, useCapture) {
1095        elmt = _This.$GetElement(elmt);
1096
1097        $JssorDebug$.$Execute(function () {
1098            if (!elmt) {
1099                $JssorDebug$.$Fail("Parameter 'elmt' not specified.");
1100            }
1101
1102            if (!handler) {
1103                $JssorDebug$.$Fail("Parameter 'handler' not specified.");
1104            }
1105
1106            if (!elmt.addEventListener && !elmt.attachEvent) {
1107                $JssorDebug$.$Fail("Unable to attach event handler, no known technique.");
1108            }
1109        });
1110
1111        // technique from:
1112        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1113
1114        if (elmt.addEventListener) {
1115            if (eventName == "mousewheel") {
1116                elmt.addEventListener("DOMMouseScroll", handler, useCapture);
1117            }
1118            // we are still going to add the mousewheel -- not a mistake!
1119            // _This is for opera, since it uses onmousewheel but needs addEventListener.
1120            elmt.addEventListener(eventName, handler, useCapture);
1121        }
1122        else if (elmt.attachEvent) {
1123            elmt.attachEvent("on" + eventName, handler);
1124            if (useCapture && elmt.setCapture) {
1125                elmt.setCapture();
1126            }
1127        }
1128    };
1129
1130    _This.$RemoveEvent = function (elmt, eventName, handler, useCapture) {
1131        elmt = _This.$GetElement(elmt);
1132
1133        // technique from:
1134        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1135
1136        if (elmt.removeEventListener) {
1137            if (eventName == "mousewheel") {
1138                elmt.removeEventListener("DOMMouseScroll", handler, useCapture);
1139            }
1140            // we are still going to remove the mousewheel -- not a mistake!
1141            // _This is for opera, since it uses onmousewheel but needs removeEventListener.
1142            elmt.removeEventListener(eventName, handler, useCapture);
1143        }
1144        else if (elmt.detachEvent) {
1145            elmt.detachEvent("on" + eventName, handler);
1146            if (useCapture && elmt.releaseCapture) {
1147                elmt.releaseCapture();
1148            }
1149        }
1150    };
1151
1152    _This.$FireEvent = function (elmt, eventName) {
1153        //var document = elmt.document;
1154
1155        $JssorDebug$.$Execute(function () {
1156            if (!document.createEvent && !document.createEventObject) {
1157                $JssorDebug$.$Fail("Unable to fire event, no known technique.");
1158            }
1159
1160            if (!elmt.dispatchEvent && !elmt.fireEvent) {
1161                $JssorDebug$.$Fail("Unable to fire event, no known technique.");
1162            }
1163        });
1164
1165        var evento;
1166
1167        if (document.createEvent) {
1168            evento = document.createEvent("HTMLEvents");
1169            evento.initEvent(eventName, false, false);
1170            elmt.dispatchEvent(evento);
1171        }
1172        else {
1173            var ieEventName = "on" + eventName;
1174            evento = document.createEventObject();
1175
1176            elmt.fireEvent(ieEventName, evento);
1177        }
1178    };
1179
1180    _This.$CancelEvent = function (event) {
1181        event = GetEvent(event);
1182
1183        // technique from:
1184        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1185
1186        if (event.preventDefault) {
1187            event.preventDefault();     // W3C for preventing default
1188        }
1189
1190        event.cancel = true;            // legacy for preventing default
1191        event.returnValue = false;      // IE for preventing default
1192    };
1193
1194    _This.$StopEvent = function (event) {
1195        event = GetEvent(event);
1196
1197        // technique from:
1198        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1199
1200        if (event.stopPropagation) {
1201            event.stopPropagation();    // W3C for stopping propagation
1202        }
1203
1204        event.cancelBubble = true;      // IE for stopping propagation
1205    };
1206
1207    _This.$CreateCallback = function (object, method) {
1208        // create callback args
1209        var initialArgs = [].slice.call(arguments, 2);
1210
1211        // create closure to apply method
1212        var callback = function () {
1213            // concatenate new args, but make a copy of initialArgs first
1214            var args = initialArgs.concat([].slice.call(arguments, 0));
1215
1216            return method.apply(object, args);
1217        };
1218
1219        //$JssorDebug$.$LiveStamp(callback, "callback_" + ($Jssor$.$GetNow() & 0xFFFFFF));
1220
1221        return callback;
1222    };
1223
1224    _This.$InnerText = function (elmt, text) {
1225        if (text == undefined)
1226            return elmt.textContent || elmt.innerText;
1227
1228        var textNode = document.createTextNode(text);
1229        _This.$Empty(elmt);
1230        elmt.appendChild(textNode);
1231    };
1232
1233    _This.$InnerHtml = function (elmt, html) {
1234        if (html == undefined)
1235            return elmt.innerHTML;
1236
1237        elmt.innerHTML = html;
1238    };
1239
1240    _This.$GetClientRect = function (elmt) {
1241        var rect = elmt.getBoundingClientRect();
1242
1243        return { x: rect.left, y: rect.top, w: rect.right - rect.left, h: rect.bottom - rect.top };
1244    };
1245
1246    _This.$ClearInnerHtml = function (elmt) {
1247        elmt.innerHTML = "";
1248    };
1249
1250    _This.$EncodeHtml = function (text) {
1251        var div = _This.$CreateDiv();
1252        _This.$InnerText(div, text);
1253        return _This.$InnerHtml(div);
1254    };
1255
1256    _This.$DecodeHtml = function (html) {
1257        var div = _This.$CreateDiv();
1258        _This.$InnerHtml(div, html);
1259        return _This.$InnerText(div);
1260    };
1261
1262    _This.$SelectElement = function (elmt) {
1263        var userSelection;
1264        if (window.getSelection) {
1265            //W3C default
1266            userSelection = window.getSelection();
1267        }
1268        var theRange = null;
1269        if (document.createRange) {
1270            theRange = document.createRange();
1271            theRange.selectNode(elmt);
1272        }
1273        else {
1274            theRange = document.body.createTextRange();
1275            theRange.moveToElementText(elmt);
1276            theRange.select();
1277        }
1278        //set user selection
1279        if (userSelection)
1280            userSelection.addRange(theRange);
1281    };
1282
1283    _This.$DeselectElements = function () {
1284        if (document.selection) {
1285            document.selection.empty();
1286        } else if (window.getSelection) {
1287            window.getSelection().removeAllRanges();
1288        }
1289    };
1290
1291    _This.$Children = function (elmt, includeAll) {
1292        var children = [];
1293
1294        for (var tmpEl = elmt.firstChild; tmpEl; tmpEl = tmpEl.nextSibling) {
1295            if (includeAll || tmpEl.nodeType == 1) {
1296                children.push(tmpEl);
1297            }
1298        }
1299
1300        return children;
1301    };
1302
1303    function FindChild(elmt, attrValue, noDeep, attrName) {
1304        attrName = attrName || "u";
1305
1306        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1307            if (elmt.nodeType == 1) {
1308                if (AttributeEx(elmt, attrName) == attrValue)
1309                    return elmt;
1310
1311                if (!noDeep) {
1312                    var childRet = FindChild(elmt, attrValue, noDeep, attrName);
1313                    if (childRet)
1314                        return childRet;
1315                }
1316            }
1317        }
1318    }
1319
1320    _This.$FindChild = FindChild;
1321
1322    function FindChildren(elmt, attrValue, noDeep, attrName) {
1323        attrName = attrName || "u";
1324
1325        var ret = [];
1326
1327        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1328            if (elmt.nodeType == 1) {
1329                if (AttributeEx(elmt, attrName) == attrValue)
1330                    ret.push(elmt);
1331
1332                if (!noDeep) {
1333                    var childRet = FindChildren(elmt, attrValue, noDeep, attrName);
1334                    if (childRet.length)
1335                        ret = ret.concat(childRet);
1336                }
1337            }
1338        }
1339
1340        return ret;
1341    }
1342
1343    _This.$FindChildren = FindChildren;
1344
1345    function FindChildByTag(elmt, tagName, noDeep) {
1346
1347        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1348            if (elmt.nodeType == 1) {
1349                if (elmt.tagName == tagName)
1350                    return elmt;
1351
1352                if (!noDeep) {
1353                    var childRet = FindChildByTag(elmt, tagName, noDeep);
1354                    if (childRet)
1355                        return childRet;
1356                }
1357            }
1358        }
1359    }
1360
1361    _This.$FindChildByTag = FindChildByTag;
1362
1363    function FindChildrenByTag(elmt, tagName, noDeep) {
1364        var ret = [];
1365
1366        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1367            if (elmt.nodeType == 1) {
1368                if (!tagName || elmt.tagName == tagName)
1369                    ret.push(elmt);
1370
1371                if (!noDeep) {
1372                    var childRet = FindChildrenByTag(elmt, tagName, noDeep);
1373                    if (childRet.length)
1374                        ret = ret.concat(childRet);
1375                }
1376            }
1377        }
1378
1379        return ret;
1380    }
1381
1382    _This.$FindChildrenByTag = FindChildrenByTag;
1383
1384    _This.$GetElementsByTag = function (elmt, tagName) {
1385        return elmt.getElementsByTagName(tagName);
1386    };
1387
1388    //function Extend() {
1389    //    var args = arguments;
1390    //    var target;
1391    //    var options;
1392    //    var propName;
1393    //    var propValue;
1394    //    var targetPropValue;
1395    //    var purpose = 7 & args[0];
1396    //    var deep = 1 & purpose;
1397    //    var unextend = 2 & purpose;
1398    //    var i = purpose ? 2 : 1;
1399    //    target = args[i - 1] || {};
1400
1401    //    for (; i < args.length; i++) {
1402    //        // Only deal with non-null/undefined values
1403    //        if (options = args[i]) {
1404    //            // Extend the base object
1405    //            for (propName in options) {
1406    //                propValue = options[propName];
1407
1408    //                if (propValue !== undefined) {
1409    //                    propValue = options[propName];
1410
1411    //                    if (unextend) {
1412    //                        targetPropValue = target[propName];
1413    //                        if (propValue === targetPropValue)
1414    //                            delete target[propName];
1415    //                        else if (deep && IsPlainObject(targetPropValue)) {
1416    //                            Extend(purpose, targetPropValue, propValue);
1417    //                        }
1418    //                    }
1419    //                    else {
1420    //                        target[propName] = (deep && IsPlainObject(target[propName])) ? Extend(purpose | 4, {}, propValue) : propValue;
1421    //                    }
1422    //                }
1423    //            }
1424    //        }
1425    //    }
1426
1427    //    // Return the modified object
1428    //    return target;
1429    //}
1430
1431    //function Unextend() {
1432    //    var args = arguments;
1433    //    var newArgs = [].slice.call(arguments);
1434    //    var purpose = 1 & args[0];
1435
1436    //    purpose && newArgs.shift();
1437    //    newArgs.unshift(purpose | 2);
1438
1439    //    return Extend.apply(null, newArgs);
1440    //}
1441
1442    function Extend() {
1443        var args = arguments;
1444        var target;
1445        var options;
1446        var propName;
1447        var propValue;
1448        var deep = 1 & args[0];
1449        var i = 1 + deep;
1450        target = args[i - 1] || {};
1451
1452        for (; i < args.length; i++) {
1453            // Only deal with non-null/undefined values
1454            if (options = args[i]) {
1455                // Extend the base object
1456                for (propName in options) {
1457                    propValue = options[propName];
1458
1459                    if (propValue !== undefined) {
1460                        propValue = options[propName];
1461                        target[propName] = (deep && IsPlainObject(target[propName])) ? Extend(deep, {}, propValue) : propValue;
1462                    }
1463                }
1464            }
1465        }
1466
1467        // Return the modified object
1468        return target;
1469    }
1470
1471    _This.$Extend = Extend;
1472
1473    function Unextend(target, option) {
1474        $JssorDebug$.$Assert(option);
1475
1476        var unextended = {};
1477        var name;
1478        var targetProp;
1479        var optionProp;
1480
1481        // Extend the base object
1482        for (name in target) {
1483            targetProp = target[name];
1484            optionProp = option[name];
1485
1486            if (targetProp !== optionProp) {
1487                var exclude;
1488
1489                if (IsPlainObject(targetProp) && IsPlainObject(optionProp)) {
1490                    targetProp = Unextend(optionProp);
1491                    exclude = !IsNotEmpty(targetProp);
1492                }
1493                
1494                !exclude && (unextended[name] = targetProp);
1495            }
1496        }
1497
1498        // Return the modified object
1499        return unextended;
1500    }
1501
1502    _This.$Unextend = Unextend;
1503
1504    _This.$IsFunction = function (obj) {
1505        return Type(obj) == "function";
1506    };
1507
1508    _This.$IsArray = function (obj) {
1509        return Type(obj) == "array";
1510    };
1511
1512    _This.$IsString = function (obj) {
1513        return Type(obj) == "string";
1514    };
1515
1516    _This.$IsNumeric = function (obj) {
1517        return !isNaN(ParseFloat(obj)) && isFinite(obj);
1518    };
1519
1520    _This.$Type = Type;
1521
1522    // args is for internal usage only
1523    _This.$Each = Each;
1524
1525    _This.$IsNotEmpty = IsNotEmpty;
1526
1527    _This.$IsPlainObject = IsPlainObject;
1528
1529    function CreateElement(tagName) {
1530        return document.createElement(tagName);
1531    }
1532
1533    _This.$CreateElement = CreateElement;
1534
1535    _This.$CreateDiv = function () {
1536        return CreateElement("DIV");
1537    };
1538
1539    _This.$CreateSpan = function () {
1540        return CreateElement("SPAN");
1541    };
1542
1543    _This.$EmptyFunction = function () { };
1544
1545    function Attribute(elmt, name, value) {
1546        if (value == undefined)
1547            return elmt.getAttribute(name);
1548
1549        elmt.setAttribute(name, value);
1550    }
1551
1552    function AttributeEx(elmt, name) {
1553        return Attribute(elmt, name) || Attribute(elmt, "data-" + name);
1554    }
1555
1556    _This.$Attribute = Attribute;
1557    _This.$AttributeEx = AttributeEx;
1558
1559    function ClassName(elmt, className) {
1560        if (className == undefined)
1561            return elmt.className;
1562
1563        elmt.className = className;
1564    }
1565
1566    _This.$ClassName = ClassName;
1567
1568    function ToHash(array) {
1569        var hash = {};
1570
1571        Each(array, function (item) {
1572            hash[item] = item;
1573        });
1574
1575        return hash;
1576    }
1577
1578    function Split(str, separator) {
1579        return str.match(separator || REGEX_WHITESPACE_GLOBAL);
1580    }
1581
1582    function StringToHashObject(str, regExp) {
1583        return ToHash(Split(str || "", regExp));
1584    }
1585
1586    _This.$ToHash = ToHash;
1587    _This.$Split = Split;
1588
1589    function Join(separator, strings) {
1590        ///	<param name="separator" type="String">
1591        ///	</param>
1592        ///	<param name="strings" type="Array" value="['1']">
1593        ///	</param>
1594
1595        var joined = "";
1596
1597        Each(strings, function (str) {
1598            joined && (joined += separator);
1599            joined += str;
1600        });
1601
1602        return joined;
1603    }
1604
1605    function ReplaceClass(elmt, oldClassName, newClassName) {
1606        ClassName(elmt, Join(" ", Extend(Unextend(StringToHashObject(ClassName(elmt)), StringToHashObject(oldClassName)), StringToHashObject(newClassName))));
1607    }
1608
1609    _This.$Join = Join;
1610
1611    _This.$AddClass = function (elmt, className) {
1612        ReplaceClass(elmt, null, className);
1613    };
1614
1615    _This.$RemoveClass = ReplaceClass;
1616
1617    _This.$ReplaceClass = ReplaceClass;
1618
1619    _This.$ParentNode = function (elmt) {
1620        return elmt.parentNode;
1621    };
1622
1623    _This.$HideElement = function (elmt) {
1624        _This.$CssDisplay(elmt, "none");
1625    };
1626
1627    _This.$EnableElement = function (elmt, notEnable) {
1628        if (notEnable) {
1629            _This.$Attribute(elmt, "disabled", true);
1630        }
1631        else {
1632            _This.$RemoveAttribute(elmt, "disabled");
1633        }
1634    };
1635
1636    _This.$HideElements = function (elmts) {
1637        for (var i = 0; i < elmts.length; i++) {
1638            _This.$HideElement(elmts[i]);
1639        }
1640    };
1641
1642    _This.$ShowElement = function (elmt, hide) {
1643        _This.$CssDisplay(elmt, hide ? "none" : "");
1644    };
1645
1646    _This.$ShowElements = function (elmts, hide) {
1647        for (var i = 0; i < elmts.length; i++) {
1648            _This.$ShowElement(elmts[i], hide);
1649        }
1650    };
1651
1652    _This.$RemoveAttribute = function (elmt, attrbuteName) {
1653        elmt.removeAttribute(attrbuteName);
1654    };
1655
1656    _This.$CanClearClip = function () {
1657        return IsBrowserIE() && _BrowserRuntimeVersion < 10;
1658    };
1659
1660    _This.$SetStyleClip = function (elmt, clip) {
1661        if (clip) {
1662            elmt.style.clip = "rect(" + Math.round(clip.$Top) + "px " + Math.round(clip.$Right) + "px " + Math.round(clip.$Bottom) + "px " + Math.round(clip.$Left) + "px)";
1663        }
1664        else {
1665            var cssText = elmt.style.cssText;
1666            var clipRegs = [
1667                new RegExp(/[\s]*clip: rect\(.*?\)[;]?/i),
1668                new RegExp(/[\s]*cliptop: .*?[;]?/i),
1669                new RegExp(/[\s]*clipright: .*?[;]?/i),
1670                new RegExp(/[\s]*clipbottom: .*?[;]?/i),
1671                new RegExp(/[\s]*clipleft: .*?[;]?/i)
1672            ];
1673
1674            var newCssText = BuildNewCss(cssText, clipRegs, "");
1675
1676            $Jssor$.$CssCssText(elmt, newCssText);
1677        }
1678    };
1679
1680    _This.$GetNow = function () {
1681        return new Date().getTime();
1682    };
1683
1684    _This.$AppendChild = function (elmt, child) {
1685        elmt.appendChild(child);
1686    };
1687
1688    _This.$AppendChildren = function (elmt, children) {
1689        Each(children, function (child) {
1690            _This.$AppendChild(elmt, child);
1691        });
1692    };
1693
1694    _This.$InsertBefore = function (newNode, refNode, pNode) {
1695        ///	<summary>
1696        ///		Insert a node before a reference node
1697        ///	</summary>
1698        ///	<param name="newNode" type="HTMLElement">
1699        ///		A new node to insert
1700        ///	</param>
1701        ///	<param name="refNode" type="HTMLElement">
1702        ///		The reference node to insert a new node before
1703        ///	</param>
1704        ///	<param name="pNode" type="HTMLElement" optional="true">
1705        ///		The parent node to insert node to
1706        ///	</param>
1707
1708        (pNode || refNode.parentNode).insertBefore(newNode, refNode);
1709    };
1710
1711    _This.$InsertAfter = function (newNode, refNode, pNode) {
1712        ///	<summary>
1713        ///		Insert a node after a reference node
1714        ///	</summary>
1715        ///	<param name="newNode" type="HTMLElement">
1716        ///		A new node to insert
1717        ///	</param>
1718        ///	<param name="refNode" type="HTMLElement">
1719        ///		The reference node to insert a new node after
1720        ///	</param>
1721        ///	<param name="pNode" type="HTMLElement" optional="true">
1722        ///		The parent node to insert node to
1723        ///	</param>
1724
1725        _This.$InsertBefore(newNode, refNode.nextSibling, pNode || refNode.parentNode);
1726    };
1727
1728    _This.$InsertAdjacentHtml = function (elmt, where, html) {
1729        elmt.insertAdjacentHTML(where, html);
1730    };
1731
1732    _This.$RemoveElement = function (elmt, pNode) {
1733        ///	<summary>
1734        ///		Remove element from parent node
1735        ///	</summary>
1736        ///	<param name="elmt" type="HTMLElement">
1737        ///		The element to remove
1738        ///	</param>
1739        ///	<param name="pNode" type="HTMLElement" optional="true">
1740        ///		The parent node to remove elment from
1741        ///	</param>
1742        (pNode || elmt.parentNode).removeChild(elmt);
1743    };
1744
1745    _This.$RemoveElements = function (elmts, pNode) {
1746        Each(elmts, function (elmt) {
1747            _This.$RemoveElement(elmt, pNode);
1748        });
1749    };
1750
1751    _This.$Empty = function (elmt) {
1752        _This.$RemoveElements(_This.$Children(elmt, true), elmt);
1753    };
1754
1755    _This.$ParseInt = function (str, radix) {
1756        return parseInt(str, radix || 10);
1757    };
1758
1759    var ParseFloat = parseFloat;
1760
1761    _This.$ParseFloat = ParseFloat;
1762
1763    _This.$IsChild = function (elmtA, elmtB) {
1764        var body = document.body;
1765
1766        while (elmtB && elmtA !== elmtB && body !== elmtB) {
1767            try {
1768                elmtB = elmtB.parentNode;
1769            } catch (e) {
1770                // Firefox sometimes fires events for XUL elements, which throws
1771                // a "permission denied" error. so this is not a child.
1772                return false;
1773            }
1774        }
1775
1776        return elmtA === elmtB;
1777    };
1778
1779    function CloneNode(elmt, noDeep, keepId) {
1780        var clone = elmt.cloneNode(!noDeep);
1781        if (!keepId) {
1782            _This.$RemoveAttribute(clone, "id");
1783        }
1784
1785        return clone;
1786    }
1787
1788    _This.$CloneNode = CloneNode;
1789
1790    _This.$LoadImage = function (src, callback) {
1791        var image = new Image();
1792
1793        function LoadImageCompleteHandler(event, abort) {
1794            _This.$RemoveEvent(image, "load", LoadImageCompleteHandler);
1795            _This.$RemoveEvent(image, "abort", ErrorOrAbortHandler);
1796            _This.$RemoveEvent(image, "error", ErrorOrAbortHandler);
1797
1798            if (callback)
1799                callback(image, abort);
1800        }
1801
1802        function ErrorOrAbortHandler(event) {
1803            LoadImageCompleteHandler(event, true);
1804        }
1805
1806        if (IsBrowserOpera() && _BrowserRuntimeVersion < 11.6 || !src) {
1807            LoadImageCompleteHandler(!src);
1808        }
1809        else {
1810
1811            _This.$AddEvent(image, "load", LoadImageCompleteHandler);
1812            _This.$AddEvent(image, "abort", ErrorOrAbortHandler);
1813            _This.$AddEvent(image, "error", ErrorOrAbortHandler);
1814
1815            image.src = src;
1816        }
1817    };
1818
1819    _This.$LoadImages = function (imageElmts, mainImageElmt, callback) {
1820
1821        var _ImageLoading = imageElmts.length + 1;
1822
1823        function LoadImageCompleteEventHandler(image, abort) {
1824
1825            _ImageLoading--;
1826            if (mainImageElmt && image && image.src == mainImageElmt.src)
1827                mainImageElmt = image;
1828            !_ImageLoading && callback && callback(mainImageElmt);
1829        }
1830
1831        Each(imageElmts, function (imageElmt) {
1832            _This.$LoadImage(imageElmt.src, LoadImageCompleteEventHandler);
1833        });
1834
1835        LoadImageCompleteEventHandler();
1836    };
1837
1838    _This.$BuildElement = function (template, tagName, replacer, createCopy) {
1839        if (createCopy)
1840            template = CloneNode(template);
1841
1842        var templateHolders = FindChildren(template, tagName);
1843        if (!templateHolders.length)
1844            templateHolders = $Jssor$.$GetElementsByTag(template, tagName);
1845
1846        for (var j = templateHolders.length - 1; j > -1; j--) {
1847            var templateHolder = templateHolders[j];
1848            var replaceItem = CloneNode(replacer);
1849            ClassName(replaceItem, ClassName(templateHolder));
1850            $Jssor$.$CssCssText(replaceItem, templateHolder.style.cssText);
1851
1852            $Jssor$.$InsertBefore(replaceItem, templateHolder);
1853            $Jssor$.$RemoveElement(templateHolder);
1854        }
1855
1856        return template;
1857    };
1858
1859    function JssorButtonEx(elmt) {
1860        var _Self = this;
1861
1862        var _OriginClassName = "";
1863        var _ToggleClassSuffixes = ["av", "pv", "ds", "dn"];
1864        var _ToggleClasses = [];
1865        var _ToggleClassName;
1866
1867        var _IsMouseDown = 0;   //class name 'dn'
1868        var _IsSelected = 0;    //class name 1(active): 'av', 2(passive): 'pv'
1869        var _IsDisabled = 0;    //class name 'ds'
1870
1871        function Highlight() {
1872            ReplaceClass(elmt, _ToggleClassName, _ToggleClasses[_IsDisabled || _IsMouseDown || (_IsSelected & 2) || _IsSelected]);
1873        }
1874
1875        function MouseUpOrCancelEventHandler(event) {
1876            _IsMouseDown = 0;
1877
1878            Highlight();
1879
1880            _This.$RemoveEvent(document, "mouseup", MouseUpOrCancelEventHandler);
1881            _This.$RemoveEvent(document, "touchend", MouseUpOrCancelEventHandler);
1882            _This.$RemoveEvent(document, "touchcancel", MouseUpOrCancelEventHandler);
1883        }
1884
1885        function MouseDownEventHandler(event) {
1886            if (_IsDisabled) {
1887                _This.$CancelEvent(event);
1888            }
1889            else {
1890
1891                _IsMouseDown = 4;
1892
1893                Highlight();
1894
1895                _This.$AddEvent(document, "mouseup", MouseUpOrCancelEventHandler);
1896                _This.$AddEvent(document, "touchend", MouseUpOrCancelEventHandler);
1897                _This.$AddEvent(document, "touchcancel", MouseUpOrCancelEventHandler);
1898            }
1899        }
1900
1901        _Self.$Selected = function (activate) {
1902            if (activate != undefined) {
1903                _IsSelected = (activate & 2) || (activate & 1);
1904
1905                Highlight();
1906            }
1907            else {
1908                return _IsSelected;
1909            }
1910        };
1911
1912        _Self.$Enable = function (enable) {
1913            if (enable == undefined) {
1914                return !_IsDisabled;
1915            }
1916
1917            _IsDisabled = enable ? 0 : 3;
1918
1919            Highlight();
1920        };
1921
1922        //JssorButtonEx Constructor
1923        {
1924            elmt = _This.$GetElement(elmt);
1925
1926            var originalClassNameArray = $Jssor$.$Split(ClassName(elmt));
1927            if (originalClassNameArray)
1928                _OriginClassName = originalClassNameArray.shift();
1929
1930            Each(_ToggleClassSuffixes, function (toggleClassSuffix) {
1931                _ToggleClasses.push(_OriginClassName +toggleClassSuffix);
1932            });
1933
1934            _ToggleClassName = Join(" ", _ToggleClasses);
1935
1936            _ToggleClasses.unshift("");
1937
1938            _This.$AddEvent(elmt, "mousedown", MouseDownEventHandler);
1939            _This.$AddEvent(elmt, "touchstart", MouseDownEventHandler);
1940        }
1941    }
1942
1943    _This.$Buttonize = function (elmt) {
1944        return new JssorButtonEx(elmt);
1945    };
1946
1947    _This.$Css = Css;
1948    _This.$CssN = CssN;
1949    _This.$CssP = CssP;
1950
1951    _This.$CssOverflow = CssProxy("overflow");
1952
1953    _This.$CssTop = CssProxy("top", 2);
1954    _This.$CssLeft = CssProxy("left", 2);
1955    _This.$CssWidth = CssProxy("width", 2);
1956    _This.$CssHeight = CssProxy("height", 2);
1957    _This.$CssMarginLeft = CssProxy("marginLeft", 2);
1958    _This.$CssMarginTop = CssProxy("marginTop", 2);
1959    _This.$CssPosition = CssProxy("position");
1960    _This.$CssDisplay = CssProxy("display");
1961    _This.$CssZIndex = CssProxy("zIndex", 1);
1962    _This.$CssFloat = function (elmt, floatValue) {
1963        return Css(elmt, IsBrowserIE() ? "styleFloat" : "cssFloat", floatValue);
1964    };
1965    _This.$CssOpacity = function (elmt, opacity, ie9EarlierForce) {
1966        if (opacity != undefined) {
1967            SetStyleOpacity(elmt, opacity, ie9EarlierForce);
1968        }
1969        else {
1970            return GetStyleOpacity(elmt);
1971        }
1972    };
1973
1974    _This.$CssCssText = function (elmt, text) {
1975        if (text != undefined) {
1976            elmt.style.cssText = text;
1977        }
1978        else {
1979            return elmt.style.cssText;
1980        }
1981    };
1982
1983    var _StyleGetter = {
1984        $Opacity: _This.$CssOpacity,
1985        $Top: _This.$CssTop,
1986        $Left: _This.$CssLeft,
1987        $Width: _This.$CssWidth,
1988        $Height: _This.$CssHeight,
1989        $Position: _This.$CssPosition,
1990        $Display: _This.$CssDisplay,
1991        $ZIndex: _This.$CssZIndex
1992    };
1993
1994    var _StyleSetterReserved;
1995
1996    function StyleSetter() {
1997        if (!_StyleSetterReserved) {
1998            _StyleSetterReserved = Extend({
1999                $MarginTop: _This.$CssMarginTop,
2000                $MarginLeft: _This.$CssMarginLeft,
2001                $Clip: _This.$SetStyleClip,
2002                $Transform: _This.$SetStyleTransform
2003            }, _StyleGetter);
2004        }
2005        return _StyleSetterReserved;
2006    }
2007
2008    function StyleSetterEx() {
2009        StyleSetter();
2010
2011        //For Compression Only
2012        _StyleSetterReserved.$Transform = _StyleSetterReserved.$Transform;
2013
2014        return _StyleSetterReserved;
2015    }
2016
2017    _This.$StyleSetter = StyleSetter;
2018
2019    _This.$StyleSetterEx = StyleSetterEx;
2020
2021    _This.$GetStyles = function (elmt, originStyles) {
2022        StyleSetter();
2023
2024        var styles = {};
2025
2026        Each(originStyles, function (value, key) {
2027            if (_StyleGetter[key]) {
2028                styles[key] = _StyleGetter[key](elmt);
2029            }
2030        });
2031
2032        return styles;
2033    };
2034
2035    _This.$SetStyles = function (elmt, styles) {
2036        var styleSetter = StyleSetter();
2037
2038        Each(styles, function (value, key) {
2039            styleSetter[key] && styleSetter[key](elmt, value);
2040        });
2041    };
2042
2043    _This.$SetStylesEx = function (elmt, styles) {
2044        StyleSetterEx();
2045
2046        _This.$SetStyles(elmt, styles);
2047    };
2048
2049    var $JssorMatrix$ = new function () {
2050        var _ThisMatrix = this;
2051
2052        function Multiply(ma, mb) {
2053            var acs = ma[0].length;
2054            var rows = ma.length;
2055            var cols = mb[0].length;
2056
2057            var matrix = [];
2058
2059            for (var r = 0; r < rows; r++) {
2060                var row = matrix[r] = [];
2061                for (var c = 0; c < cols; c++) {
2062                    var unitValue = 0;
2063
2064                    for (var ac = 0; ac < acs; ac++) {
2065                        unitValue += ma[r][ac] * mb[ac][c];
2066                    }
2067
2068                    row[c] = unitValue;
2069                }
2070            }
2071
2072            return matrix;
2073        }
2074
2075        _ThisMatrix.$ScaleX = function (matrix, sx) {
2076            return _ThisMatrix.$ScaleXY(matrix, sx, 0);
2077        };
2078
2079        _ThisMatrix.$ScaleY = function (matrix, sy) {
2080            return _ThisMatrix.$ScaleXY(matrix, 0, sy);
2081        };
2082
2083        _ThisMatrix.$ScaleXY = function (matrix, sx, sy) {
2084            return Multiply(matrix, [[sx, 0], [0, sy]]);
2085        };
2086
2087        _ThisMatrix.$TransformPoint = function (matrix, p) {
2088            var pMatrix = Multiply(matrix, [[p.x], [p.y]]);
2089
2090            return Point(pMatrix[0][0], pMatrix[1][0]);
2091        };
2092    };
2093
2094    _This.$CreateMatrix = function (alpha, scaleX, scaleY) {
2095        var cos = Math.cos(alpha);
2096        var sin = Math.sin(alpha);
2097        //var r11 = cos;
2098        //var r21 = sin;
2099        //var r12 = -sin;
2100        //var r22 = cos;
2101
2102        //var m11 = cos * scaleX;
2103        //var m12 = -sin * scaleY;
2104        //var m21 = sin * scaleX;
2105        //var m22 = cos * scaleY;
2106
2107        return [[cos * scaleX, -sin * scaleY], [sin * scaleX, cos * scaleY]];
2108    };
2109
2110    _This.$GetMatrixOffset = function (matrix, width, height) {
2111        var p1 = $JssorMatrix$.$TransformPoint(matrix, Point(-width / 2, -height / 2));
2112        var p2 = $JssorMatrix$.$TransformPoint(matrix, Point(width / 2, -height / 2));
2113        var p3 = $JssorMatrix$.$TransformPoint(matrix, Point(width / 2, height / 2));
2114        var p4 = $JssorMatrix$.$TransformPoint(matrix, Point(-width / 2, height / 2));
2115
2116        return Point(Math.min(p1.x, p2.x, p3.x, p4.x) + width / 2, Math.min(p1.y, p2.y, p3.y, p4.y) + height / 2);
2117    };
2118
2119    _This.$Cast = function (fromStyles, difStyles, interPosition, easings, durings, rounds, options) {
2120
2121        var currentStyles = difStyles;
2122
2123        if (fromStyles) {
2124            currentStyles = {};
2125
2126            for (var key in difStyles) {
2127
2128                var round = rounds[key] || 1;
2129                var during = durings[key] || [0, 1];
2130                var propertyInterPosition = (interPosition - during[0]) / during[1];
2131                propertyInterPosition = Math.min(Math.max(propertyInterPosition, 0), 1);
2132                propertyInterPosition = propertyInterPosition * round;
2133                var floorPosition = Math.floor(propertyInterPosition);
2134                if (propertyInterPosition != floorPosition)
2135                    propertyInterPosition -= floorPosition;
2136
2137                var easing = easings[key] || easings.$Default || $JssorEasing$.$EaseSwing;
2138                var easingValue = easing(propertyInterPosition);
2139                var currentPropertyValue;
2140                var value = fromStyles[key];
2141                var toValue = difStyles[key];
2142                var difValue = difStyles[key];
2143
2144                if ($Jssor$.$IsNumeric(difValue)) {
2145                    currentPropertyValue = value + difValue * easingValue;
2146                }
2147                else {
2148                    currentPropertyValue = $Jssor$.$Extend({ $Offset: {} }, fromStyles[key]);
2149
2150                    $Jssor$.$Each(difValue.$Offset, function (rectX, n) {
2151                        var offsetValue = rectX * easingValue;
2152                        currentPropertyValue.$Offset[n] = offsetValue;
2153                        currentPropertyValue[n] += offsetValue;
2154                    });
2155                }
2156                currentStyles[key] = currentPropertyValue;
2157            }
2158
2159            if (difStyles.$Zoom || difStyles.$Rotate) {
2160                currentStyles.$Transform = { $Rotate: currentStyles.$Rotate || 0, $Scale: currentStyles.$Zoom, $OriginalWidth: options.$OriginalWidth, $OriginalHeight: options.$OriginalHeight };
2161            }
2162        }
2163
2164        if (difStyles.$Clip && options.$Move) {
2165            var styleFrameNClipOffset = currentStyles.$Clip.$Offset;
2166
2167            var offsetY = (styleFrameNClipOffset.$Top || 0) + (styleFrameNClipOffset.$Bottom || 0);
2168            var offsetX = (styleFrameNClipOffset.$Left || 0) + (styleFrameNClipOffset.$Right || 0
2168);
2169
2170            currentStyles.$Left = (currentStyles.$Left || 0) + offsetX;
2171            currentStyles.$Top = (currentStyles.$Top || 0) + offsetY;
2172            currentStyles.$Clip.$Left -= offsetX;
2173            currentStyles.$Clip.$Right -= offsetX;
2174            currentStyles.$Clip.$Top -= offsetY;
2175            currentStyles.$Clip.$Bottom -= offsetY;
2176        }
2177
2178        if (currentStyles.$Clip && $Jssor$.$CanClearClip() && !currentStyles.$Clip.$Top && !currentStyles.$Clip.$Left && (currentStyles.$Clip.$Right == options.$OriginalWidth) && (currentStyles.$Clip.$Bottom == options.$OriginalHeight))
2179            currentStyles.$Clip = null;
2180
2181        return currentStyles;
2182    };
2183};
2184
2185//$JssorObject$
2186function $JssorObject$() {
2187    var _ThisObject = this;
2188    // Fields
2189
2190    var _Listeners = []; // dictionary of eventName --> array of handlers
2191    var _Listenees = [];
2192
2193    // Private Methods
2194    function AddListener(eventName, handler) {
2195
2196        $JssorDebug$.$Execute(function () {
2197            if (eventName == undefined || eventName == null)
2198                throw new Error("param 'eventName' is null or empty.");
2199
2200            if (typeof (handler) != "function") {
2201                throw "param 'handler' must be a function.";
2202            }
2203
2204            $Jssor$.$Each(_Listeners, function (listener) {
2205                if (listener.$EventName == eventName && listener.$Handler === handler) {
2206                    throw new Error("The handler listened to the event already, cannot listen to the same event of the same object with the same handler twice.");
2207                }
2208            });
2209        });
2210
2211        _Listeners.push({ $EventName: eventName, $Handler: handler });
2212    }
2213
2214    function RemoveListener(eventName, handler) {
2215
2216        $JssorDebug$.$Execute(function () {
2217            if (eventName == undefined || eventName == null)
2218                throw new Error("param 'eventName' is null or empty.");
2219
2220            if (typeof (handler) != "function") {
2221                throw "param 'handler' must be a function.";
2222            }
2223        });
2224
2225        $Jssor$.$Each(_Listeners, function (listener, index) {
2226            if (listener.$EventName == eventName && listener.$Handler === handler) {
2227                _Listeners.splice(index, 1);
2228            }
2229        });
2230    }
2231
2232    function ClearListeners() {
2233        _Listeners = [];
2234    }
2235
2236    function ClearListenees() {
2237
2238        $Jssor$.$Each(_Listenees, function (listenee) {
2239            $Jssor$.$RemoveEvent(listenee.$Obj, listenee.$EventName, listenee.$Handler);
2240        });
2241
2242        _Listenees = [];
2243    }
2244
2245    //Protected Methods
2246    _ThisObject.$Listen = function (obj, eventName, handler, useCapture) {
2247
2248        $JssorDebug$.$Execute(function () {
2249            if (!obj)
2250                throw new Error("param 'obj' is null or empty.");
2251
2252            if (eventName == undefined || eventName == null)
2253                throw new Error("param 'eventName' is null or empty.");
2254
2255            if (typeof (handler) != "function") {
2256                throw "param 'handler' must be a function.";
2257            }
2258
2259            $Jssor$.$Each(_Listenees, function (listenee) {
2260                if (listenee.$Obj === obj && listenee.$EventName == eventName && listenee.$Handler === handler) {
2261                    throw new Error("The handler listened to the event already, cannot listen to the same event of the same object with the same handler twice.");
2262                }
2263            });
2264        });
2265
2266        $Jssor$.$AddEvent(obj, eventName, handler, useCapture);
2267        _Listenees.push({ $Obj: obj, $EventName: eventName, $Handler: handler });
2268    };
2269
2270    _ThisObject.$Unlisten = function (obj, eventName, handler) {
2271
2272        $JssorDebug$.$Execute(function () {
2273            if (!obj)
2274                throw new Error("param 'obj' is null or empty.");
2275
2276            if (eventName == undefined || eventName == null)
2277                throw new Error("param 'eventName' is null or empty.");
2278
2279            if (typeof (handler) != "function") {
2280                throw "param 'handler' must be a function.";
2281            }
2282        });
2283
2284        $Jssor$.$Each(_Listenees, function (listenee, index) {
2285            if (listenee.$Obj === obj && listenee.$EventName == eventName && listenee.$Handler === handler) {
2286                $Jssor$.$RemoveEvent(obj, eventName, handler);
2287                _Listenees.splice(index, 1);
2288            }
2289        });
2290    };
2291
2292    _ThisObject.$UnlistenAll = ClearListenees;
2293
2294    // Public Methods
2295    _ThisObject.$On = _ThisObject.addEventListener = AddListener;
2296
2297    _ThisObject.$Off = _ThisObject.removeEventListener = RemoveListener;
2298
2299    _ThisObject.$TriggerEvent = function (eventName) {
2300
2301        var args = [].slice.call(arguments, 1);
2302
2303        $Jssor$.$Each(_Listeners, function (listener) {
2304            listener.$EventName == eventName && listener.$Handler.apply(window, args);
2305        });
2306    };
2307
2308    _ThisObject.$Destroy = function () {
2309        ClearListenees();
2310        ClearListeners();
2311
2312        for (var name in _ThisObject)
2313            delete _ThisObject[name];
2314    };
2315
2316    $JssorDebug$.$C_AbstractClass(_ThisObject);
2317};
2318
2319function $JssorAnimator$(delay, duration, options, elmt, fromStyles, difStyles) {
2320    delay = delay || 0;
2321
2322    var _ThisAnimator = this;
2323    var _AutoPlay;
2324    var _Hiden;
2325    var _CombineMode;
2326    var _PlayToPosition;
2327    var _PlayDirection;
2328    var _NoStop;
2329    var _TimeStampLastFrame = 0;
2330
2331    var _SubEasings;
2332    var _SubRounds;
2333    var _SubDurings;
2334    var _Callback;
2335
2336    var _Shift = 0;
2337    var _Position_Current = 0;
2338    var _Position_Display = 0;
2339    var _Hooked;
2340
2341    var _Position_InnerBegin = delay;
2342    var _Position_InnerEnd = delay + duration;
2343    var _Position_OuterBegin;
2344    var _Position_OuterEnd;
2345    var _LoopLength;
2346
2347    var _NestedAnimators = [];
2348    var _StyleSetter;
2349
2350    function GetPositionRange(position, begin, end) {
2351        var range = 0;
2352
2353        if (position < begin)
2354            range = -1;
2355
2356        else if (position > end)
2357            range = 1;
2358
2359        return range;
2360    }
2361
2362    function GetInnerPositionRange(position) {
2363        return GetPositionRange(position, _Position_InnerBegin, _Position_InnerEnd);
2364    }
2365
2366    function GetOuterPositionRange(position) {
2367        return GetPositionRange(position, _Position_OuterBegin, _Position_OuterEnd);
2368    }
2369
2370    function Shift(offset) {
2371        _Position_OuterBegin += offset;
2372        _Position_OuterEnd += offset;
2373        _Position_InnerBegin += offset;
2374        _Position_InnerEnd += offset;
2375
2376        _Position_Current += offset;
2377        _Position_Display += offset;
2378
2379        _Shift = offset;
2380    }
2381
2382    function Locate(position, relative) {
2383        var offset = position - _Position_OuterBegin + delay * relative;
2384
2385        Shift(offset);
2386
2387        //$JssorDebug$.$Execute(function () {
2388        //    _ThisAnimator.$Position_InnerBegin = _Position_InnerBegin;
2389        //    _ThisAnimator.$Position_InnerEnd = _Position_InnerEnd;
2390        //    _ThisAnimator.$Position_OuterBegin = _Position_OuterBegin;
2391        //    _ThisAnimator.$Position_OuterEnd = _Position_OuterEnd;
2392        //});
2393
2394        return _Position_OuterEnd;
2395    }
2396
2397    function GoToPosition(positionOuter, force) {
2398        var trimedPositionOuter = positionOuter;
2399
2400        if (_LoopLength && (trimedPositionOuter >= _Position_OuterEnd || trimedPositionOuter <= _Position_OuterBegin)) {
2401            trimedPositionOuter = ((trimedPositionOuter - _Position_OuterBegin) % _LoopLength + _LoopLength) % _LoopLength + _Position_OuterBegin;
2402        }
2403
2404        if (!_Hooked || _NoStop || force || _Position_Current != trimedPositionOuter) {
2405
2406            var positionToDisplay = Math.min(trimedPositionOuter, _Position_OuterEnd);
2407            positionToDisplay = Math.max(positionToDisplay, _Position_OuterBegin);
2408
2409            if (!_Hooked || _NoStop || force || positionToDisplay != _Position_Display) {
2410                if (difStyles) {
2411
2412                    var interPosition = (positionToDisplay - _Position_InnerBegin) / (duration || 1);
2413
2414                    if (options.$Reverse)
2415                        interPosition = 1 - interPosition;
2416
2417                    var currentStyles = $Jssor$.$Cast(fromStyles, difStyles, interPosition, _SubEasings, _SubDurings, _SubRounds, options);
2418
2419                    $Jssor$.$Each(currentStyles, function (value, key) {
2420                        _StyleSetter[key] && _StyleSetter[key](elmt, value);
2421                    });
2422                }
2423
2424                _ThisAnimator.$OnInnerOffsetChange(_Position_Display - _Position_InnerBegin, positionToDisplay - _Position_InnerBegin);
2425            }
2426
2427            _Position_Display = positionToDisplay;
2428
2429            $Jssor$.$Each(_NestedAnimators, function (animator, i) {
2430                var nestedAnimator = positionOuter < _Position_Current ? _NestedAnimators[_NestedAnimators.length - i - 1] : animator;
2431                nestedAnimator.$GoToPosition(positionOuter - _Shift, force);
2432            });
2433
2434            var positionOld = _Position_Current;
2435            var positionNew = positionOuter;
2436
2437            _Position_Current = trimedPositionOuter;
2438            _Hooked = true;
2439
2440            _ThisAnimator.$OnPositionChange(positionOld, positionNew);
2441        }
2442    }
2443
2444    function Join(animator, combineMode, noExpand) {
2445        ///	<summary>
2446        ///		Combine another animator as nested animator
2447        ///	</summary>
2448        ///	<param name="animator" type="$JssorAnimator$">
2449        ///		An instance of $JssorAnimator$
2450        ///	</param>
2451        ///	<param name="combineMode" type="int">
2452        ///		0: parallel - place the animator parallel to this animator.
2453        ///		1: chain - chain the animator at the _Position_InnerEnd of this animator.
2454        ///	</param>
2455        $JssorDebug$.$Execute(function () {
2456            if (combineMode !== 0 && combineMode !== 1)
2457                $JssorDebug$.$Fail("Argument out of range, the value of 'combineMode' should be either 0 or 1.");
2458        });
2459
2460        if (combineMode)
2461            animator.$Locate(_Position_OuterEnd, 1);
2462
2463        !noExpand && (_Position_OuterEnd = Math.max(_Position_OuterEnd, animator.$GetPosition_OuterEnd() + _Shift));
2464        _NestedAnimators.push(animator);
2465    }
2466
2467    var RequestAnimationFrame = window.requestAnimationFrame
2468    || window.webkitRequestAnimationFrame
2469    || window.mozRequestAnimationFrame
2470    || window.msRequestAnimationFrame;
2471
2472    if ($Jssor$.$IsBrowserSafari() && $Jssor$.$BrowserVersion() < 7) {
2473        RequestAnimationFrame = null;
2474
2475        $JssorDebug$.$Log("Custom animation frame for safari before 7.");
2476    }
2477
2478    RequestAnimationFrame = RequestAnimationFrame || function (callback) {
2479        $Jssor$.$Delay(callback, options.$Interval);
2480    };
2481
2482    function ShowFrame() {
2483        if (_AutoPlay) {
2484            var now = $Jssor$.$GetNow();
2485            var timeOffset = Math.min(now - _TimeStampLastFrame, options.$IntervalMax);
2486            var timePosition = _Position_Current + timeOffset * _PlayDirection;
2487            _TimeStampLastFrame = now;
2488
2489            if (timePosition * _PlayDirection >= _PlayToPosition * _PlayDirection)
2490                timePosition = _PlayToPosition;
2491
2492            GoToPosition(timePosition);
2493
2494            if (!_NoStop && timePosition * _PlayDirection >= _PlayToPosition * _PlayDirection) {
2495                Stop(_Callback);
2496            }
2497            else {
2498                RequestAnimationFrame(ShowFrame);
2499            }
2500        }
2501    }
2502
2503    function PlayToPosition(toPosition, callback, noStop) {
2504        if (!_AutoPlay) {
2505            _AutoPlay = true;
2506            _NoStop = noStop
2507            _Callback = callback;
2508            toPosition = Math.max(toPosition, _Position_OuterBegin);
2509            toPosition = Math.min(toPosition, _Position_OuterEnd);
2510            _PlayToPosition = toPosition;
2511            _PlayDirection = _PlayToPosition < _Position_Current ? -1 : 1;
2512            _ThisAnimator.$OnStart();
2513            _TimeStampLastFrame = $Jssor$.$GetNow();
2514            RequestAnimationFrame(ShowFrame);
2515        }
2516    }
2517
2518    function Stop(callback) {
2519        if (_AutoPlay) {
2520            _NoStop = _AutoPlay = _Callback = false;
2521            _ThisAnimator.$OnStop();
2522
2523            if (callback)
2524                callback();
2525        }
2526    }
2527
2528    _ThisAnimator.$Play = function (positionLength, callback, noStop) {
2529        PlayToPosition(positionLength ? _Position_Current + positionLength : _Position_OuterEnd, callback, noStop);
2530    };
2531
2532    _ThisAnimator.$PlayToPosition = PlayToPosition;
2533
2534    _ThisAnimator.$PlayToBegin = function (callback, noStop) {
2535        PlayToPosition(_Position_OuterBegin, callback, noStop);
2536    };
2537
2538    _ThisAnimator.$PlayToEnd = function (callback, noStop) {
2539        PlayToPosition(_Position_OuterEnd, callback, noStop);
2540    };
2541
2542    _ThisAnimator.$Stop = Stop;
2543
2544    _ThisAnimator.$Continue = function (toPosition) {
2545        PlayToPosition(toPosition);
2546    };
2547
2548    _ThisAnimator.$GetPosition = function () {
2549        return _Position_Current;
2550    };
2551
2552    _ThisAnimator.$GetPlayToPosition = function () {
2553        return _PlayToPosition;
2554    };
2555
2556    _ThisAnimator.$GetPosition_Display = function () {
2557        return _Position_Display;
2558    };
2559
2560    _ThisAnimator.$GoToPosition = GoToPosition;
2561
2562    _ThisAnimator.$GoToBegin = function () {
2563        GoToPosition(_Position_OuterBegin, true);
2564    };
2565
2566    _ThisAnimator.$GoToEnd = function () {
2567        GoToPosition(_Position_OuterEnd, true);
2568    };
2569
2570    _ThisAnimator.$Move = function (offset) {
2571        GoToPosition(_Position_Current + offset);
2572    };
2573
2574    _ThisAnimator.$CombineMode = function () {
2575        return _CombineMode;
2576    };
2577
2578    _ThisAnimator.$GetDuration = function () {
2579        return duration;
2580    };
2581
2582    _ThisAnimator.$IsPlaying = function () {
2583        return _AutoPlay;
2584    };
2585
2586    _ThisAnimator.$IsOnTheWay = function () {
2587        return _Position_Current > _Position_InnerBegin && _Position_Current <= _Position_InnerEnd;
2588    };
2589
2590    _ThisAnimator.$SetLoopLength = function (length) {
2591        _LoopLength = length;
2592    };
2593
2594    _ThisAnimator.$Locate = Locate;
2595
2596    _ThisAnimator.$Shift = Shift;
2597
2598    _ThisAnimator.$Join = Join;
2599
2600    _ThisAnimator.$Combine = function (animator) {
2601        ///	<summary>
2602        ///		Combine another animator parallel to this animator
2603        ///	</summary>
2604        ///	<param name="animator" type="$JssorAnimator$">
2605        ///		An instance of $JssorAnimator$
2606        ///	</param>
2607        Join(animator, 0);
2608    };
2609
2610    _ThisAnimator.$Chain = function (animator) {
2611        ///	<summary>
2612        ///		Chain another animator at the _Position_InnerEnd of this animator
2613        ///	</summary>
2614        ///	<param name="animator" type="$JssorAnimator$">
2615        ///		An instance of $JssorAnimator$
2616        ///	</param>
2617        Join(animator, 1);
2618    };
2619
2620    _ThisAnimator.$GetPosition_InnerBegin = function () {
2621        ///	<summary>
2622        ///		Internal member function, do not use it.
2623        ///	</summary>
2624        ///	<private />
2625        ///	<returns type="int" />
2626        return _Position_InnerBegin;
2627    };
2628
2629    _ThisAnimator.$GetPosition_InnerEnd = function () {
2630        ///	<summary>
2631        ///		Internal member function, do not use it.
2632        ///	</summary>
2633        ///	<private />
2634        ///	<returns type="int" />
2635        return _Position_InnerEnd;
2636    };
2637
2638    _ThisAnimator.$GetPosition_OuterBegin = function () {
2639        ///	<summary>
2640        ///		Internal member function, do not use it.
2641        ///	</summary>
2642        ///	<private />
2643        ///	<returns type="int" />
2644        return _Position_OuterBegin;
2645    };
2646
2647    _ThisAnimator.$GetPosition_OuterEnd = function () {
2648        ///	<summary>
2649        ///		Internal member function, do not use it.
2650        ///	</summary>
2651        ///	<private />
2652        ///	<returns type="int" />
2653        return _Position_OuterEnd;
2654    };
2655
2656    _ThisAnimator.$OnPositionChange = _ThisAnimator.$OnStart = _ThisAnimator.$OnStop = _ThisAnimator.$OnInnerOffsetChange = $Jssor$.$EmptyFunction;
2657    _ThisAnimator.$Version = $Jssor$.$GetNow();
2658
2659    //Constructor  1
2660    {
2661        options = $Jssor$.$Extend({
2662            $Interval: 16,
2663            $IntervalMax: 50
2664        }, options);
2665
2666        //Sodo statement, for development time intellisence only
2667        $JssorDebug$.$Execute(function () {
2668            options = $Jssor$.$Extend({
2669                $LoopLength: undefined,
2670                $Setter: undefined,
2671                $Easing: undefined
2672            }, options);
2673        });
2674
2675        _LoopLength = options.$LoopLength;
2676
2677        _StyleSetter = $Jssor$.$Extend({}, $Jssor$.$StyleSetter(), options.$Setter);
2678
2679        _Position_OuterBegin = _Position_InnerBegin = delay;
2680        _Position_OuterEnd = _Position_InnerEnd = delay + duration;
2681
2682        _SubRounds = options.$Round || {};
2683        _SubDurings = options.$During || {};
2684        _SubEasings = $Jssor$.$Extend({ $Default: $Jssor$.$IsFunction(options.$Easing) && options.$Easing || $JssorEasing$.$EaseSwing }, options.$Easing);
2685    }
2686};
2687
2688function $JssorPlayerClass$() {
2689
2690    var _ThisPlayer = this;
2691    var _PlayerControllers = [];
2692
2693    function PlayerController(playerElement) {
2694        var _SelfPlayerController = this;
2695        var _PlayerInstance;
2696        var _PlayerInstantces = [];
2697
2698        function OnPlayerInstanceDataAvailable(event) {
2699            var srcElement = $Jssor$.$EvtSrc(event);
2700            _PlayerInstance = srcElement.pInstance;
2701
2702            $Jssor$.$RemoveEvent(srcElement, "dataavailable", OnPlayerInstanceDataAvailable);
2703            $Jssor$.$Each(_PlayerInstantces, function (playerInstance) {
2704                if (playerInstance != _PlayerInstance) {
2705                    playerInstance.$Remove();
2706                }
2707            });
2708
2709            playerElement.pTagName = _PlayerInstance.tagName;
2710            _PlayerInstantces = null;
2711        }
2712
2713        function HandlePlayerInstance(playerInstanceElement) {
2714            var playerHandler;
2715
2716            if (!playerInstanceElement.pInstance) {
2717                var playerHandlerAttribute = $Jssor$.$AttributeEx(playerInstanceElement, "pHandler");
2718
2719                if ($JssorPlayer$[playerHandlerAttribute]) {
2720                    $Jssor$.$AddEvent(playerInstanceElement, "dataavailable", OnPlayerInstanceDataAvailable);
2721                    playerHandler = new $JssorPlayer$[playerHandlerAttribute](playerElement, playerInstanceElement);
2722                    _PlayerInstantces.push(playerHandler);
2723
2724                    $JssorDebug$.$Execute(function () {
2725                        if ($Jssor$.$Type(playerHandler.$Remove) != "function") {
2726                            $JssorDebug$.$Fail("'pRemove' interface not implemented for player handler '" + playerHandlerAttribute + "'.");
2727                        }
2728                    });
2729                }
2730            }
2731
2732            return playerHandler;
2733        }
2734
2735        _SelfPlayerController.$InitPlayerController = function () {
2736            if (!playerElement.pInstance && !HandlePlayerInstance(playerElement)) {
2737
2738                var playerInstanceElements = $Jssor$.$Children(playerElement);
2739
2740                $Jssor$.$Each(playerInstanceElements, function (playerInstanceElement) {
2741                    HandlePlayerInstance(playerInstanceElement);
2742                });
2743            }
2744        };
2745    }
2746
2747    _ThisPlayer.$EVT_SWITCH = 21;
2748
2749    _ThisPlayer.$FetchPlayers = function (elmt) {
2750        elmt = elmt || document.body;
2751
2752        var playerElements = $Jssor$.$FindChildren(elmt, "player");
2753
2754        $Jssor$.$Each(playerElements, function (playerElement) {
2755            if (!_PlayerControllers[playerElement.pId]) {
2756                playerElement.pId = _PlayerControllers.length;
2757                _PlayerControllers.push(new PlayerController(playerElement));
2758            }
2759            var playerController = _PlayerControllers[playerElement.pId];
2760            playerController.$InitPlayerController();
2761        });
2762    };
2763}

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.