MDL-54934 workshop: ensure "Current phase" is always separated
[moodle.git] / lib / flowplayer / flowplayer-3.2.13.js
blobcb8dd86a5a16d8982f4f6fa891ce0cd317d230fd
1 /*
2  * flowplayer.js The Flowplayer API
3  *
4  * Copyright 2009-2011 Flowplayer Oy
5  *
6  * This file is part of Flowplayer.
7  *
8  * Flowplayer is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Flowplayer is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Flowplayer.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 !function () {
23     function h(p) {
24         console.log("$f.fireEvent", [].slice.call(p))
25     }
27     function l(r) {
28         if (!r || typeof r != "object") {
29             return r
30         }
31         var p = new r.constructor();
32         for (var q in r) {
33             if (r.hasOwnProperty(q)) {
34                 p[q] = l(r[q])
35             }
36         }
37         return p
38     }
40     function n(u, r) {
41         if (!u) {
42             return
43         }
44         var p, q = 0, s = u.length;
45         if (s === undefined) {
46             for (p in u) {
47                 if (r.call(u[p], p, u[p]) === false) {
48                     break
49                 }
50             }
51         } else {
52             for (var t = u[0]; q < s && r.call(t, q, t) !== false; t = u[++q]) {
53             }
54         }
55         return u
56     }
58     function c(p) {
59         return document.getElementById(p)
60     }
62     function j(r, q, p) {
63         if (typeof q != "object") {
64             return r
65         }
66         if (r && q) {
67             n(q, function (s, t) {
68                 if (!p || typeof t != "function") {
69                     r[s] = t
70                 }
71             })
72         }
73         return r
74     }
76     function o(t) {
77         var r = t.indexOf(".");
78         if (r != -1) {
79             var q = t.slice(0, r) || "*";
80             var p = t.slice(r + 1, t.length);
81             var s = [];
82             n(document.getElementsByTagName(q), function () {
83                 if (this.className && this.className.indexOf(p) != -1) {
84                     s.push(this)
85                 }
86             });
87             return s
88         }
89     }
91     function g(p) {
92         p = p || window.event;
93         if (p.preventDefault) {
94             p.stopPropagation();
95             p.preventDefault()
96         } else {
97             p.returnValue = false;
98             p.cancelBubble = true
99         }
100         return false
101     }
103     function k(r, p, q) {
104         r[p] = r[p] || [];
105         r[p].push(q)
106     }
108     function e(p) {
109         return p.replace(/&amp;/g, "%26").replace(/&/g, "%26").replace(/=/g, "%3D")
110     }
112     function f() {
113         return"_" + ("" + Math.random()).slice(2, 10)
114     }
116     var i = function (u, s, t) {
117         var r = this, q = {}, v = {};
118         r.index = s;
119         if (typeof u == "string") {
120             u = {url: u}
121         }
122         j(this, u, true);
123         n(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","), function () {
124             var w = "on" + this;
125             if (w.indexOf("*") != -1) {
126                 w = w.slice(0, w.length - 1);
127                 var x = "onBefore" + w.slice(2);
128                 r[x] = function (y) {
129                     k(v, x, y);
130                     return r
131                 }
132             }
133             r[w] = function (y) {
134                 k(v, w, y);
135                 return r
136             };
137             if (s == -1) {
138                 if (r[x]) {
139                     t[x] = r[x]
140                 }
141                 if (r[w]) {
142                     t[w] = r[w]
143                 }
144             }
145         });
146         j(this, {onCuepoint: function (y, x) {
147             if (arguments.length == 1) {
148                 q.embedded = [null, y];
149                 return r
150             }
151             if (typeof y == "number") {
152                 y = [y]
153             }
154             var w = f();
155             q[w] = [y, x];
156             if (t.isLoaded()) {
157                 t._api().fp_addCuepoints(y, s, w)
158             }
159             return r
160         }, update: function (x) {
161             j(r, x);
162             if (t.isLoaded()) {
163                 t._api().fp_updateClip(x, s)
164             }
165             var w = t.getConfig();
166             var y = (s == -1) ? w.clip : w.playlist[s];
167             j(y, x, true)
168         }, _fireEvent: function (w, z, x, B) {
169             if (w == "onLoad") {
170                 n(q, function (C, D) {
171                     if (D[0]) {
172                         t._api().fp_addCuepoints(D[0], s, C)
173                     }
174                 });
175                 return false
176             }
177             B = B || r;
178             if (w == "onCuepoint") {
179                 var A = q[z];
180                 if (A) {
181                     return A[1].call(t, B, x)
182                 }
183             }
184             if (z && "onBeforeBegin,onMetaData,onMetaDataChange,onStart,onUpdate,onResume".indexOf(w) != -1) {
185                 j(B, z);
186                 if (z.metaData) {
187                     if (!B.duration) {
188                         B.duration = z.metaData.duration
189                     } else {
190                         B.fullDuration = z.metaData.duration
191                     }
192                 }
193             }
194             var y = true;
195             n(v[w], function () {
196                 y = this.call(t, B, z, x)
197             });
198             return y
199         }});
200         if (u.onCuepoint) {
201             var p = u.onCuepoint;
202             r.onCuepoint.apply(r, typeof p == "function" ? [p] : p);
203             delete u.onCuepoint
204         }
205         n(u, function (w, x) {
206             if (typeof x == "function") {
207                 k(v, w, x);
208                 delete u[w]
209             }
210         });
211         if (s == -1) {
212             t.onCuepoint = this.onCuepoint
213         }
214     };
215     var m = function (q, s, r, u) {
216         var p = this, t = {}, v = false;
217         if (u) {
218             j(t, u)
219         }
220         n(s, function (w, x) {
221             if (typeof x == "function") {
222                 t[w] = x;
223                 delete s[w]
224             }
225         });
226         j(this, {animate: function (z, A, y) {
227             if (!z) {
228                 return p
229             }
230             if (typeof A == "function") {
231                 y = A;
232                 A = 500
233             }
234             if (typeof z == "string") {
235                 var x = z;
236                 z = {};
237                 z[x] = A;
238                 A = 500
239             }
240             if (y) {
241                 var w = f();
242                 t[w] = y
243             }
244             if (A === undefined) {
245                 A = 500
246             }
247             s = r._api().fp_animate(q, z, A, w);
248             return p
249         }, css: function (x, y) {
250             if (y !== undefined) {
251                 var w = {};
252                 w[x] = y;
253                 x = w
254             }
255             s = r._api().fp_css(q, x);
256             j(p, s);
257             return p
258         }, show: function () {
259             this.display = "block";
260             r._api().fp_showPlugin(q);
261             return p
262         }, hide: function () {
263             this.display = "none";
264             r._api().fp_hidePlugin(q);
265             return p
266         }, toggle: function () {
267             this.display = r._api().fp_togglePlugin(q);
268             return p
269         }, fadeTo: function (z, y, x) {
270             if (typeof y == "function") {
271                 x = y;
272                 y = 500
273             }
274             if (x) {
275                 var w = f();
276                 t[w] = x
277             }
278             this.display = r._api().fp_fadeTo(q, z, y, w);
279             this.opacity = z;
280             return p
281         }, fadeIn: function (x, w) {
282             return p.fadeTo(1, x, w)
283         }, fadeOut: function (x, w) {
284             return p.fadeTo(0, x, w)
285         }, getName: function () {
286             return q
287         }, getPlayer: function () {
288             return r
289         }, _fireEvent: function (x, w, y) {
290             if (x == "onUpdate") {
291                 var A = r._api().fp_getPlugin(q);
292                 if (!A) {
293                     return
294                 }
295                 j(p, A);
296                 delete p.methods;
297                 if (!v) {
298                     n(A.methods, function () {
299                         var C = "" + this;
300                         p[C] = function () {
301                             var D = [].slice.call(arguments);
302                             var E = r._api().fp_invoke(q, C, D);
303                             return E === "undefined" || E === undefined ? p : E
304                         }
305                     });
306                     v = true
307                 }
308             }
309             var B = t[x];
310             if (B) {
311                 var z = B.apply(p, w);
312                 if (x.slice(0, 1) == "_") {
313                     delete t[x]
314                 }
315                 return z
316             }
317             return p
318         }})
319     };
321     function b(r, H, u) {
322         var x = this, w = null, E = false, v, t, G = [], z = {}, y = {}, F, s, q, D, p, B;
323         j(x, {id: function () {
324             return F
325         }, isLoaded: function () {
326             return(w !== null && w.fp_play !== undefined && !E)
327         }, getParent: function () {
328             return r
329         }, hide: function (I) {
330             if (I) {
331                 r.style.height = "0px"
332             }
333             if (x.isLoaded()) {
334                 w.style.height = "0px"
335             }
336             return x
337         }, show: function () {
338             r.style.height = B + "px";
339             if (x.isLoaded()) {
340                 w.style.height = p + "px"
341             }
342             return x
343         }, isHidden: function () {
344             return x.isLoaded() && parseInt(w.style.height, 10) === 0
345         }, load: function (K) {
346             if (!x.isLoaded() && x._fireEvent("onBeforeLoad") !== false) {
347                 var I = function () {
348                     if (v && !flashembed.isSupported(H.version)) {
349                         r.innerHTML = ""
350                     }
351                     if (K) {
352                         K.cached = true;
353                         k(y, "onLoad", K)
354                     }
355                     flashembed(r, H, {config: u})
356                 };
357                 var J = 0;
358                 n(a, function () {
359                     this.unload(function (L) {
360                         if (++J == a.length) {
361                             I()
362                         }
363                     })
364                 })
365             }
366             return x
367         }, unload: function (K) {
368             if (v.replace(/\s/g, "") !== "") {
369                 if (x._fireEvent("onBeforeUnload") === false) {
370                     if (K) {
371                         K(false)
372                     }
373                     return x
374                 }
375                 E = true;
376                 try {
377                     if (w) {
378                         if (w.fp_isFullscreen()) {
379                             w.fp_toggleFullscreen()
380                         }
381                         w.fp_close();
382                         x._fireEvent("onUnload")
383                     }
384                 } catch (I) {
385                 }
386                 var J = function () {
387                     w = null;
388                     r.innerHTML = v;
389                     E = false;
390                     if (K) {
391                         K(true)
392                     }
393                 };
394                 if (/WebKit/i.test(navigator.userAgent) && !/Chrome/i.test(navigator.userAgent)) {
395                     setTimeout(J, 0)
396                 } else {
397                     J()
398                 }
399             } else {
400                 if (K) {
401                     K(false)
402                 }
403             }
404             return x
405         }, getClip: function (I) {
406             if (I === undefined) {
407                 I = D
408             }
409             return G[I]
410         }, getCommonClip: function () {
411             return t
412         }, getPlaylist: function () {
413             return G
414         }, getPlugin: function (I) {
415             var K = z[I];
416             if (!K && x.isLoaded()) {
417                 var J = x._api().fp_getPlugin(I);
418                 if (J) {
419                     K = new m(I, J, x);
420                     z[I] = K
421                 }
422             }
423             return K
424         }, getScreen: function () {
425             return x.getPlugin("screen")
426         }, getControls: function () {
427             return x.getPlugin("controls")._fireEvent("onUpdate")
428         }, getLogo: function () {
429             try {
430                 return x.getPlugin("logo")._fireEvent("onUpdate")
431             } catch (I) {
432             }
433         }, getPlay: function () {
434             return x.getPlugin("play")._fireEvent("onUpdate")
435         }, getConfig: function (I) {
436             return I ? l(u) : u
437         }, getFlashParams: function () {
438             return H
439         }, loadPlugin: function (L, K, N, M) {
440             if (typeof N == "function") {
441                 M = N;
442                 N = {}
443             }
444             var J = M ? f() : "_";
445             x._api().fp_loadPlugin(L, K, N, J);
446             var I = {};
447             I[J] = M;
448             var O = new m(L, null, x, I);
449             z[L] = O;
450             return O
451         }, getState: function () {
452             return x.isLoaded() ? w.fp_getState() : -1
453         }, play: function (J, I) {
454             var K = function () {
455                 if (J !== undefined) {
456                     x._api().fp_play(J, I)
457                 } else {
458                     x._api().fp_play()
459                 }
460             };
461             if (x.isLoaded()) {
462                 K()
463             } else {
464                 if (E) {
465                     setTimeout(function () {
466                         x.play(J, I)
467                     }, 50)
468                 } else {
469                     x.load(function () {
470                         K()
471                     })
472                 }
473             }
474             return x
475         }, getVersion: function () {
476             var J = "flowplayer.js @VERSION";
477             if (x.isLoaded()) {
478                 var I = w.fp_getVersion();
479                 I.push(J);
480                 return I
481             }
482             return J
483         }, _api: function () {
484             if (!x.isLoaded()) {
485                 throw"Flowplayer " + x.id() + " not loaded when calling an API method"
486             }
487             return w
488         }, setClip: function (I) {
489             n(I, function (J, K) {
490                 if (typeof K == "function") {
491                     k(y, J, K);
492                     delete I[J]
493                 } else {
494                     if (J == "onCuepoint") {
495                         $f(r).getCommonClip().onCuepoint(I[J][0], I[J][1])
496                     }
497                 }
498             });
499             x.setPlaylist([I]);
500             return x
501         }, getIndex: function () {
502             return q
503         }, bufferAnimate: function (I) {
504             w.fp_bufferAnimate(I === undefined || I);
505             return x
506         }, _swfHeight: function () {
507             return w.clientHeight
508         }});
509         n(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","), function () {
510             var I = "on" + this;
511             if (I.indexOf("*") != -1) {
512                 I = I.slice(0, I.length - 1);
513                 var J = "onBefore" + I.slice(2);
514                 x[J] = function (K) {
515                     k(y, J, K);
516                     return x
517                 }
518             }
519             x[I] = function (K) {
520                 k(y, I, K);
521                 return x
522             }
523         });
524         n(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","), function () {
525             var I = this;
526             x[I] = function (K, J) {
527                 if (!x.isLoaded()) {
528                     return x
529                 }
530                 var L = null;
531                 if (K !== undefined && J !== undefined) {
532                     L = w["fp_" + I](K, J)
533                 } else {
534                     L = (K === undefined) ? w["fp_" + I]() : w["fp_" + I](K)
535                 }
536                 return L === "undefined" || L === undefined ? x : L
537             }
538         });
539         x._fireEvent = function (R) {
540             if (typeof R == "string") {
541                 R = [R]
542             }
543             var S = R[0], P = R[1], N = R[2], M = R[3], L = 0;
544             if (u.debug) {
545                 h(R)
546             }
547             if (!x.isLoaded() && S == "onLoad" && P == "player") {
548                 w = w || c(s);
549                 p = x._swfHeight();
550                 n(G, function () {
551                     this._fireEvent("onLoad")
552                 });
553                 n(z, function (T, U) {
554                     U._fireEvent("onUpdate")
555                 });
556                 t._fireEvent("onLoad")
557             }
558             if (S == "onLoad" && P != "player") {
559                 return
560             }
561             if (S == "onError") {
562                 if (typeof P == "string" || (typeof P == "number" && typeof N == "number")) {
563                     P = N;
564                     N = M
565                 }
566             }
567             if (S == "onContextMenu") {
568                 n(u.contextMenu[P], function (T, U) {
569                     U.call(x)
570                 });
571                 return
572             }
573             if (S == "onPluginEvent" || S == "onBeforePluginEvent") {
574                 var I = P.name || P;
575                 var J = z[I];
576                 if (J) {
577                     J._fireEvent("onUpdate", P);
578                     return J._fireEvent(N, R.slice(3))
579                 }
580                 return
581             }
582             if (S == "onPlaylistReplace") {
583                 G = [];
584                 var O = 0;
585                 n(P, function () {
586                     G.push(new i(this, O++, x))
587                 })
588             }
589             if (S == "onClipAdd") {
590                 if (P.isInStream) {
591                     return
592                 }
593                 P = new i(P, N, x);
594                 G.splice(N, 0, P);
595                 for (L = N + 1; L < G.length; L++) {
596                     G[L].index++
597                 }
598             }
599             var Q = true;
600             if (typeof P == "number" && P < G.length) {
601                 D = P;
602                 var K = G[P];
603                 if (K) {
604                     Q = K._fireEvent(S, N, M)
605                 }
606                 if (!K || Q !== false) {
607                     Q = t._fireEvent(S, N, M, K)
608                 }
609             }
610             n(y[S], function () {
611                 Q = this.call(x, P, N);
612                 if (this.cached) {
613                     y[S].splice(L, 1)
614                 }
615                 if (Q === false) {
616                     return false
617                 }
618                 L++
619             });
620             return Q
621         };
622         function C() {
623             r.innerHTML=''; // Moodle hack - we do not want splashscreens, unfortunately there is not switch to disable them
624             if ($f(r)) {
625                 $f(r).getParent().innerHTML = "";
626                 q = $f(r).getIndex();
627                 a[q] = x
628             } else {
629                 a.push(x);
630                 q = a.length - 1
631             }
632             B = parseInt(r.style.height, 10) || r.clientHeight;
633             F = r.id || "fp" + f();
634             s = H.id || F + "_api";
635             H.id = s;
636             v = r.innerHTML;
637             if (typeof u == "string") {
638                 u = {clip: {url: u}}
639             }
640             u.playerId = F;
641             u.clip = u.clip || {};
642             if (r.getAttribute("href", 2) && !u.clip.url) {
643                 u.clip.url = r.getAttribute("href", 2)
644             }
645             if (u.clip.url) {
646                 u.clip.url = e(u.clip.url)
647             }
648             t = new i(u.clip, -1, x);
649             u.playlist = u.playlist || [u.clip];
650             var J = 0;
651             n(u.playlist, function () {
652                 var M = this;
653                 if (typeof M == "object" && M.length) {
654                     M = {url: "" + M}
655                 }
656                 if (M.url) {
657                     M.url = e(M.url)
658                 }
659                 n(u.clip, function (N, O) {
660                     if (O !== undefined && M[N] === undefined && typeof O != "function") {
661                         M[N] = O
662                     }
663                 });
664                 u.playlist[J] = M;
665                 M = new i(M, J, x);
666                 G.push(M);
667                 J++
668             });
669             n(u, function (M, N) {
670                 if (typeof N == "function") {
671                     if (t[M]) {
672                         t[M](N)
673                     } else {
674                         k(y, M, N)
675                     }
676                     delete u[M]
677                 }
678             });
679             n(u.plugins, function (M, N) {
680                 if (N) {
681                     z[M] = new m(M, N, x)
682                 }
683             });
684             if (!u.plugins || u.plugins.controls === undefined) {
685                 z.controls = new m("controls", null, x)
686             }
687             z.canvas = new m("canvas", null, x);
688             v = r.innerHTML;
689             function L(M) {
690                 if (/iPad|iPhone|iPod/i.test(navigator.userAgent) && !/.flv$/i.test(G[0].url) && !K()) {
691                     return true
692                 }
693                 if (!x.isLoaded() && x._fireEvent("onBeforeClick") !== false) {
694                     x.load()
695                 }
696                 return g(M)
697             }
699             function K() {
700                 return x.hasiPadSupport && x.hasiPadSupport()
701             }
703             function I() {
704                 if (v.replace(/\s/g, "") !== "") {
705                     if (r.addEventListener) {
706                         r.addEventListener("click", L, false)
707                     } else {
708                         if (r.attachEvent) {
709                             r.attachEvent("onclick", L)
710                         }
711                     }
712                 } else {
713                     if (r.addEventListener && !K()) {
714                         r.addEventListener("click", g, false)
715                     }
716                     x.load()
717                 }
718             }
720             setTimeout(I, 0)
721         }
723         if (typeof r == "string") {
724             var A = c(r);
725             if (!A) {
726                 throw"Flowplayer cannot access element: " + r
727             }
728             r = A;
729             C()
730         } else {
731             C()
732         }
733     }
735     var a = [];
737     function d(p) {
738         this.length = p.length;
739         this.each = function (r) {
740             n(p, r)
741         };
742         this.size = function () {
743             return p.length
744         };
745         var q = this;
746         for (name in b.prototype) {
747             q[name] = function () {
748                 var r = arguments;
749                 q.each(function () {
750                     this[name].apply(this, r)
751                 })
752             }
753         }
754     }
756     window.flowplayer = window.$f = function () {
757         var q = null;
758         var p = arguments[0];
759         if(!flashembed.isSupported([6, 65])){return null;} // Moodle hack - we do not want the missing flash hints - we need the original links for accessibility and incompatible browsers
760         if (!arguments.length) {
761             n(a, function () {
762                 if (this.isLoaded()) {
763                     q = this;
764                     return false
765                 }
766             });
767             return q || a[0]
768         }
769         if (arguments.length == 1) {
770             if (typeof p == "number") {
771                 return a[p]
772             } else {
773                 if (p == "*") {
774                     return new d(a)
775                 }
776                 n(a, function () {
777                     if (this.id() == p.id || this.id() == p || this.getParent() == p) {
778                         q = this;
779                         return false
780                     }
781                 });
782                 return q
783             }
784         }
785         if (arguments.length > 1) {
786             var u = arguments[1], r = (arguments.length == 3) ? arguments[2] : {};
787             if (typeof u == "string") {
788                 u = {src: u}
789             }
790             u = j({bgcolor: "#000000", version: [10, 1], expressInstall: "http://releases.flowplayer.org/swf/expressinstall.swf", cachebusting: false}, u);
791             if (typeof p == "string") {
792                 if (p.indexOf(".") != -1) {
793                     var t = [];
794                     n(o(p), function () {
795                         t.push(new b(this, l(u), l(r)))
796                     });
797                     return new d(t)
798                 } else {
799                     var s = c(p);
800                     return new b(s !== null ? s : l(p), l(u), l(r))
801                 }
802             } else {
803                 if (p) {
804                     return new b(p, l(u), l(r))
805                 }
806             }
807         }
808         return null
809     };
810     j(window.$f, {fireEvent: function () {
811         var q = [].slice.call(arguments);
812         var r = $f(q[0]);
813         return r ? r._fireEvent(q.slice(1)) : null
814     }, addPlugin: function (p, q) {
815         b.prototype[p] = q;
816         return $f
817     }, each: n, extend: j});
818     if (typeof jQuery == "function") {
819         jQuery.fn.flowplayer = function (r, q) {
820             if (!arguments.length || typeof arguments[0] == "number") {
821                 var p = [];
822                 this.each(function () {
823                     var s = $f(this);
824                     if (s) {
825                         p.push(s)
826                     }
827                 });
828                 return arguments.length ? p[arguments[0]] : new d(p)
829             }
830             return this.each(function () {
831                 $f(this, l(r), q ? l(q) : {})
832             })
833         }
834     }
835 }();
836 !function () {
837     var h = document.all, j = "http://get.adobe.com/flashplayer", c = typeof jQuery == "function", e = /(\d+)[^\d]+(\d+)[^\d]*(\d*)/, b = {width: "100%", height: "100%", id: "_" + ("" + Math.random()).slice(9), allowfullscreen: true, allowscriptaccess: "always", quality: "high", version: [3, 0], onFail: null, expressInstall: null, w3c: false, cachebusting: false};
838     if (window.attachEvent) {
839         window.attachEvent("onbeforeunload", function () {
840             __flash_unloadHandler = function () {
841             };
842             __flash_savedUnloadHandler = function () {
843             }
844         })
845     }
846     function i(m, l) {
847         if (l) {
848             for (var f in l) {
849                 if (l.hasOwnProperty(f)) {
850                     m[f] = l[f]
851                 }
852             }
853         }
854         return m
855     }
857     function a(f, n) {
858         var m = [];
859         for (var l in f) {
860             if (f.hasOwnProperty(l)) {
861                 m[l] = n(f[l])
862             }
863         }
864         return m
865     }
867     window.flashembed = function (f, m, l) {
868         if (typeof f == "string") {
869             f = document.getElementById(f.replace("#", ""))
870         }
871         if (!f) {
872             return
873         }
874         if (typeof m == "string") {
875             m = {src: m}
876         }
877         return new d(f, i(i({}, b), m), l)
878     };
879     var g = i(window.flashembed, {conf: b, getVersion: function () {
880         var m, f, o;
881         try {
882             o = navigator.plugins["Shockwave Flash"];
883             if (o[0].enabledPlugin != null) {
884                 f = o.description.slice(16)
885             }
886         } catch (p) {
887             try {
888                 m = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
889                 f = m && m.GetVariable("$version")
890             } catch (n) {
891                 try {
892                     m = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
893                     f = m && m.GetVariable("$version")
894                 } catch (l) {
895                 }
896             }
897         }
898         f = e.exec(f);
899         return f ? [1 * f[1], 1 * f[(f[1] * 1 > 9 ? 2 : 3)] * 1] : [0, 0]
900     }, asString: function (l) {
901         if (l === null || l === undefined) {
902             return null
903         }
904         var f = typeof l;
905         if (f == "object" && l.push) {
906             f = "array"
907         }
908         switch (f) {
909             case"string":
910                 l = l.replace(new RegExp('(["\\\\])', "g"), "\\$1");
911                 l = l.replace(/^\s?(\d+\.?\d*)%/, "$1pct");
912                 return'"' + l + '"';
913             case"array":
914                 return"[" + a(l,function (o) {
915                     return g.asString(o)
916                 }).join(",") + "]";
917             case"function":
918                 return'"function()"';
919             case"object":
920                 var m = [];
921                 for (var n in l) {
922                     if (l.hasOwnProperty(n)) {
923                         m.push('"' + n + '":' + g.asString(l[n]))
924                     }
925                 }
926                 return"{" + m.join(",") + "}"
927         }
928         return String(l).replace(/\s/g, " ").replace(/\'/g, '"')
929     }, getHTML: function (o, l) {
930         o = i({}, o);
931         var n = '<object width="' + o.width + '" height="' + o.height + '" id="' + o.id + '" name="' + o.id + '"';
932         if (o.cachebusting) {
933             o.src += ((o.src.indexOf("?") != -1 ? "&" : "?") + Math.random())
934         }
935         if (o.w3c || !h) {
936             n += ' data="' + o.src + '" type="application/x-shockwave-flash"'
937         } else {
938             n += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
939         }
940         n += ">";
941         if (o.w3c || h) {
942             n += '<param name="movie" value="' + o.src + '" />'
943         }
944         o.width = o.height = o.id = o.w3c = o.src = null;
945         o.onFail = o.version = o.expressInstall = null;
946         for (var m in o) {
947             if (o[m]) {
948                 n += '<param name="' + m + '" value="' + o[m] + '" />'
949             }
950         }
951         var p = "";
952         if (l) {
953             for (var f in l) {
954                 if (l[f]) {
955                     var q = l[f];
956                     p += f + "=" + (/function|object/.test(typeof q) ? g.asString(q) : q) + "&"
957                 }
958             }
959             p = p.slice(0, -1);
960             n += '<param name="flashvars" value=\'' + p + "' />"
961         }
962         n += "</object>";
963         return n
964     }, isSupported: function (f) {
965         return k[0] > f[0] || k[0] == f[0] && k[1] >= f[1]
966     }});
967     var k = g.getVersion();
969     function d(f, n, m) {
970         if (g.isSupported(n.version)) {
971             f.innerHTML = g.getHTML(n, m)
972         } else {
973             if (n.expressInstall && g.isSupported([6, 65])) {
974                 f.innerHTML = g.getHTML(i(n, {src: n.expressInstall}), {MMredirectURL: encodeURIComponent(location.href), MMplayerType: "PlugIn", MMdoctitle: document.title})
975             } else {
976                 if (!f.innerHTML.replace(/\s/g, "")) {
977                     f.innerHTML = "<h2>Flash version " + n.version + " or greater is required</h2><h3>" + (k[0] > 0 ? "Your version is " + k : "You have no flash plugin installed") + "</h3>" + (f.tagName == "A" ? "<p>Click here to download latest version</p>" : "<p>Download latest version from <a href='" + j + "'>here</a></p>");
978                     if (f.tagName == "A" || f.tagName == "DIV") {
979                         f.onclick = function () {
980                             location.href = j
981                         }
982                     }
983                 }
984                 if (n.onFail) {
985                     var l = n.onFail.call(this);
986                     if (typeof l == "string") {
987                         f.innerHTML = l
988                     }
989                 }
990             }
991         }
992         if (h) {
993             window[n.id] = document.getElementById(n.id)
994         }
995         i(this, {getRoot: function () {
996             return f
997         }, getOptions: function () {
998             return n
999         }, getConf: function () {
1000             return m
1001         }, getApi: function () {
1002             return f.firstChild
1003         }})
1004     }
1006     if (c) {
1007         jQuery.tools = jQuery.tools || {version: "@VERSION"};
1008         jQuery.tools.flashembed = {conf: b};
1009         jQuery.fn.flashembed = function (l, f) {
1010             return this.each(function () {
1011                 $(this).data("flashembed", flashembed(this, l, f))
1012             })
1013         }
1014     }
1015 }();