PageSourceSearch

https://freeknife.ru/plugins/content/jw_allvideos/jw_allvideos/includes/js/jwp.js.php?v=4.8.0

js freeknife.ru collected 2026-10-03 01:06:41 UTC 54,305 bytes, 1,744 lines download raw bytes

1/* behaviour.js */
2/**
3 * @version    4.8.0
4 * @package    AllVideos (plugin)
5 * @author     JoomlaWorks - http://www.joomlaworks.net
6 * @copyright  Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
7 * @license    GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
8 */
9
10var allvideos = {
11    ready: function(cb) {
12        /in/.test(document.readyState) ? setTimeout('allvideos.ready(' + cb + ')', 9) : cb();
13    },
14
15    getRemoteJson: function(url) {
16        var remoteJsonScript = document.createElement('script');
17        remoteJsonScript.setAttribute('charset', 'utf-8');
18        remoteJsonScript.setAttribute('type', 'text/javascript');
19        remoteJsonScript.setAttribute('async', 'true');
20        remoteJsonScript.setAttribute('src', url);
21        return remoteJsonScript;
22    },
23
24    embed: function(el) {
25        var jsonpCallback = el.callback;
26        var tempId = Math.floor(Math.random() * 1000) + 1;
27        var responseContainer = [];
28        window[jsonpCallback] = function(response) {
29            responseContainer.tempId = [response];
30        };
31        var head = document.getElementsByTagName('head')[0];
32        var jsonp = this.getRemoteJson(el.url);
33        jsonp.onloadDone = false;
34        jsonp.onload = function() {
35            if (!jsonp.onloadDone) {
36                jsonp.onloadDone = true;
37                document.getElementById(el.playerID).innerHTML = responseContainer.tempId[0].html;
38            }
39        };
40        jsonp.onreadystatechange = function() {
41            if (("loaded" === jsonp.readyState || "complete" === jsonp.readyState) && !jsonp.onloadDone) {
42                jsonp.onloadDone = true;
43                document.getElementById(el.playerID).innerHTML = responseContainer.tempId[0].html;
44            }
45        }
46        head.appendChild(jsonp);
47    }
48}
49/* silverlight.js */
50///////////////////////////////////////////////////////////////////////////////
51//
52//  Silverlight.js   			version 2.0.30523.6
53//
54//  This file is provided by Microsoft as a helper file for websites that
55//  incorporate Silverlight Objects. This file is provided under the Microsoft
56//  Public License available at
57//  http://code.msdn.microsoft.com/silverlightjs/Project/License.aspx.
58//  You may not use or distribute this file or the code in this file except as
59//  expressly permitted under that license.
60//
61//  Copyright (c) Microsoft Corporation. All rights reserved.
62//
63///////////////////////////////////////////////////////////////////////////////
64
65if (!window.Silverlight)
66{
67    window.Silverlight = { };
68}
69
70//////////////////////////////////////////////////////////////////
71//
72// _silverlightCount:
73//
74// Counter of globalized event handlers
75//
76//////////////////////////////////////////////////////////////////
77Silverlight._silverlightCount = 0;
78
79//////////////////////////////////////////////////////////////////
80//
81// fwlinkRoot:
82//
83// Prefix for fwlink URL's
84//
85//////////////////////////////////////////////////////////////////
86Silverlight.fwlinkRoot='http://go2.microsoft.com/fwlink/?LinkID=';
87
88//////////////////////////////////////////////////////////////////
89//
90// onGetSilverlight:
91//
92// Called by Silverlight.GetSilverlight to notify the page that a user
93// has requested the Silverlight installer
94//
95//////////////////////////////////////////////////////////////////
96Silverlight.onGetSilverlight = null;
97
98//////////////////////////////////////////////////////////////////
99//
100// onSilverlightInstalled:
101//
102// Called by Silverlight.WaitForInstallCompletion when the page detects
103// that Silverlight has been installed. The event handler is not called
104// in upgrade scenarios.
105//
106//////////////////////////////////////////////////////////////////
107Silverlight.onSilverlightInstalled = function () {window.location.reload(false);};
108
109//////////////////////////////////////////////////////////////////
110//
111// isInstalled:
112//
113// Checks to see if the correct version is installed
114//
115//////////////////////////////////////////////////////////////////
116Silverlight.isInstalled = function(version)
117{
118    var isVersionSupported=false;
119    var container = null;
120
121    try
122    {
123        var control = null;
124
125        try
126        {
127            control = new ActiveXObject('AgControl.AgControl');
128            if ( version == null )
129            {
130                isVersionSupported = true;
131            }
132            else if ( control.IsVersionSupported(version) )
133            {
134                isVersionSupported = true;
135            }
136            control = null;
137        }
138        catch (e)
139        {
140            var plugin = navigator.plugins["Silverlight Plug-In"] ;
141            if ( plugin )
142            {
143                if ( version === null )
144                {
145                    isVersionSupported = true;
146                }
147                else
148                {
149                    var actualVer = plugin.description;
150                    if ( actualVer === "1.0.30226.2")
151                        actualVer = "2.0.30226.2";
152                    var actualVerArray =actualVer.split(".");
153                    while ( actualVerArray.length > 3)
154                    {
155                        actualVerArray.pop();
156                    }
157                    while ( actualVerArray.length < 4)
158                    {
159                        actualVerArray.push(0);
160                    }
161                    var reqVerArray = version.split(".");
162                    while ( reqVerArray.length > 4)
163                    {
164                        reqVerArray.pop();
165                    }
166
167                    var requiredVersionPart ;
168                    var actualVersionPart
169                    var index = 0;
170
171
172                    do
173                    {
174                        requiredVersionPart = parseInt(reqVerArray[index]);
175                        actualVersionPart = parseInt(actualVerArray[index]);
176                        index++;
177                    }
178                    while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
179
180                    if ( requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart) )
181                    {
182                        isVersionSupported = true;
183                    }
184                }
185            }
186        }
187    }
188    catch (e)
189    {
190        isVersionSupported = false;
191    }
192    if (container)
193    {
194        document.body.removeChild(container);
195    }
196
197    return isVersionSupported;
198}
199//////////////////////////////////////////////////////////////////
200//
201// WaitForInstallCompletion:
202//
203// Occasionally checks for Silverlight installation status. If it
204// detects that Silverlight has been installed then it calls
205// Silverlight.onSilverlightInstalled();. This is only supported
206// if Silverlight was not previously installed on this computer.
207//
208//////////////////////////////////////////////////////////////////
209Silverlight.WaitForInstallCompletion = function()
210{
211    if ( ! Silverlight.isBrowserRestartRequired && Silverlight.onSilverlightInstalled )
212    {
213        try
214        {
215            navigator.plugins.refresh();
216        }
217        catch(e)
218        {
219        }
220        if ( Silverlight.isInstalled(null) )
221        {
222            Silverlight.onSilverlightInstalled();
223        }
224        else
225        {
226              setTimeout(Silverlight.WaitForInstallCompletion, 3000);
227        }
228    }
229}
230//////////////////////////////////////////////////////////////////
231//
232// __startup:
233//
234// Performs startup tasks
235//////////////////////////////////////////////////////////////////
236Silverlight.__startup = function()
237{
238    Silverlight.isBrowserRestartRequired = Silverlight.isInstalled(null);
239    if ( !Silverlight.isBrowserRestartRequired)
240    {
241        Silverlight.WaitForInstallCompletion();
242    }
243    if (window.removeEventListener) {
244       window.removeEventListener('load', Silverlight.__startup , false);
245    }
246    else {
247        window.detachEvent('onload', Silverlight.__startup );
248    }
249}
250
251if (window.addEventListener)
252{
253    window.addEventListener('load', Silverlight.__startup , false);
254}
255else
256{
257    window.attachEvent('onload', Silverlight.__startup );
258}
259
260///////////////////////////////////////////////////////////////////////////////
261// createObject:
262//
263// Inserts a Silverlight <object> tag or installation experience into the HTML
264// DOM based on the current installed state of Silverlight.
265//
266/////////////////////////////////////////////////////////////////////////////////
267
268Silverlight.createObject = function(source, parentElement, id, properties, events, initParams, userContext)
269{
270    var slPluginHelper = new Object();
271    var slProperties = properties;
272    var slEvents = events;
273
274    slPluginHelper.version = slProperties.version;
275    slProperties.source = source;
276    slPluginHelper.alt = slProperties.alt;
277
278    //rename properties to their tag property names. For bacwards compatibility
279    //with Silverlight.js version 1.0
280    if ( initParams )
281        slProperties.initParams = initParams;
282    if ( slProperties.isWindowless && !slProperties.windowless)
283        slProperties.windowless = slProperties.isWindowless;
284    if ( slProperties.framerate && !slProperties.maxFramerate)
285        slProperties.maxFramerate = slProperties.framerate;
286    if ( id && !slProperties.id)
287        slProperties.id = id;
288
289    // remove elements which are not to be added to the instantiation tag
290    delete slProperties.ignoreBrowserVer;
291    delete slProperties.inplaceInstallPrompt;
292    delete slProperties.version;
293    delete slProperties.isWindowless;
294    delete slProperties.framerate;
295    delete slProperties.data;
296    delete slProperties.src;
297    delete slProperties.alt;
298
299
300    // detect that the correct version of Silverlight is installed, else display install
301
302    if (Silverlight.isInstalled(slPluginHelper.version))
303    {
304        //move unknown events to the slProperties array
305        for (var name in slEvents)
306        {
307            if ( slEvents[name])
308            {
309                if ( name == "onLoad" && typeof slEvents[name] == "function" && slEvents[name].length != 1 )
310                {
311                    var onLoadHandler = slEvents[name];
312                    slEvents[name]=function (sender){ return onLoadHandler(document.getElementById(id), userContext, sender)};
313                }
314                var handlerName = Silverlight.__getHandlerName(slEvents[name]);
315                if ( handlerName != null )
316                {
317                    slProperties[name] = handlerName;
318                    slEvents[name] = null;
319                }
320                else
321                {
322                    throw "typeof events."+name+" must be 'function' or 'string'";
323                }
324            }
325        }
326        slPluginHTML = Silverlight.buildHTML(slProperties);
327    }
328    //The control could not be instantiated. Show the installation prompt
329    else
330    {
331        slPluginHTML = Silverlight.buildPromptHTML(slPluginHelper);
332    }
333
334    // insert or return the HTML
335    if(parentElement)
336    {
337        parentElement.innerHTML = slPluginHTML;
338    }
339    else
340    {
341        return slPluginHTML;
342    }
343
344}
345
346///////////////////////////////////////////////////////////////////////////////
347//
348//  buildHTML:
349//
350//  create HTML that instantiates the control
351//
352///////////////////////////////////////////////////////////////////////////////
353Silverlight.buildHTML = function( slProperties)
354{
355    var htmlBuilder = [];
356
357    htmlBuilder.push('<object type=\"application/x-silverlight\" data="data:application/x-silverlight,"');
358    if ( slProperties.id != null )
359    {
360        htmlBuilder.push(' id="' + slProperties.id + '"');
361    }
362    if ( slProperties.width != null )
363    {
364        htmlBuilder.push(' width="' + slProperties.width+ '"');
365    }
366    if ( slProperties.height != null )
367    {
368        htmlBuilder.push(' height="' + slProperties.height + '"');
369    }
370    htmlBuilder.push(' >');
371
372    delete slProperties.id;
373    delete slProperties.width;
374    delete slProperties.height;
375
376    for (var name in slProperties)
377    {
378        if (slProperties[name])
379        {
380            htmlBuilder.push('<param name="'+Silverlight.HtmlAttributeEncode(name)+'" value="'+Silverlight.HtmlAttributeEncode(slProperties[name])+'" />');
381        }
382    }
383    htmlBuilder.push('<\/object>');
384    return htmlBuilder.join('');
385}
386
387
388
389//////////////////////////////////////////////////////////////////
390//
391// createObjectEx:
392//
393// takes a single parameter of all createObject
394// parameters enclosed in {}
395//
396//////////////////////////////////////////////////////////////////
397
398Silverlight.createObjectEx = function(params)
399{
400    var parameters = params;
401    var html = Silverlight.createObject(parameters.source, parameters.parentElement, parameters.id, parameters.properties, parameters.events, parameters.initParams, parameters.context);
402    if (parameters.parentElement == null)
403    {
404        return html;
405    }
406}
407
408///////////////////////////////////////////////////////////////////////////////////////////////
409//
410// buildPromptHTML
411//
412// Builds the HTML to prompt the user to download and install Silverlight
413//
414///////////////////////////////////////////////////////////////////////////////////////////////
415Silverlight.buildPromptHTML = function(slPluginHelper)
416{
417    var slPluginHTML = "";
418    var urlRoot = Silverlight.fwlinkRoot;
419    var shortVer = slPluginHelper.version ;
420    if ( slPluginHelper.alt )
421    {
422        slPluginHTML = slPluginHelper.alt;
423    }
424    else
425    {
426        if (! shortVer )
427        {
428            shortVer="";
429        }
430        slPluginHTML = "<a href='javascript:Silverlight.getSilverlight(\"{1}\");' style='text-decoration: none;'><img src='{2}' alt='Get Microsoft Silverlight' style='border-style: none'/></a>";
431        slPluginHTML = slPluginHTML.replace('{1}', shortVer );
432        slPluginHTML = slPluginHTML.replace('{2}', urlRoot + '108181');
433    }
434
435    return slPluginHTML;
436}
437
438///////////////////////////////////////////////////////////////////////////////////////////////
439//
440// getSilverlight:
441//
442// Navigates the browser to the appropriate Silverlight installer
443//
444///////////////////////////////////////////////////////////////////////////////////////////////
445Silverlight.getSilverlight = function(version)
446{
447    if (Silverlight.onGetSilverlight )
448    {
449        Silverlight.onGetSilverlight();
450    }
451
452    var shortVer = "";
453    var reqVerArray = String(version).split(".");
454    if (reqVerArray.length > 1)
455    {
456        var majorNum = parseInt(reqVerArray[0] );
457        if ( isNaN(majorNum) || majorNum < 2 )
458        {
459            shortVer = "1.0";
460        }
461        else
462        {
463            shortVer = reqVerArray[0]+'.'+reqVerArray[1];
464        }
465    }
466
467    var verArg = "";
468
469    if (shortVer.match(/^\d+\056\d+$/) )
470    {
471        verArg = "&v="+shortVer;
472    }
473
474    Silverlight.followFWLink("114576" + verArg);
475}
476
477
478///////////////////////////////////////////////////////////////////////////////////////////////
479//
480// followFWLink:
481//
482// Navigates to a url based on fwlinkid
483//
484///////////////////////////////////////////////////////////////////////////////////////////////
485Silverlight.followFWLink = function(linkid)
486{
487    top.location=Silverlight.fwlinkRoot+String(linkid);
488}
489
490///////////////////////////////////////////////////////////////////////////////////////////////
491//
492// HtmlAttributeEncode:
493//
494// Encodes special characters in input strings as charcodes
495//
496///////////////////////////////////////////////////////////////////////////////////////////////
497Silverlight.HtmlAttributeEncode = function( strInput )
498{
499      var c;
500      var retVal = '';
501
502    if(strInput == null)
503      {
504          return null;
505    }
506
507      for(var cnt = 0; cnt < strInput.length; cnt++)
508      {
509            c = strInput.charCodeAt(cnt);
510
511            if (( ( c > 96 ) && ( c < 123 ) ) ||
512                  ( ( c > 64 ) && ( c < 91 ) ) ||
513                  ( ( c > 43 ) && ( c < 58 ) && (c!=47)) ||
514                  ( c == 95 ))
515            {
516                  retVal = retVal + String.fromCharCode(c);
517            }
518            else
519            {
520                  retVal = retVal + '&#' + c + ';';
521            }
522      }
523
524      return retVal;
525}
526///////////////////////////////////////////////////////////////////////////////
527//
528//  default_error_handler:
529//
530//  Default error handling function
531//
532///////////////////////////////////////////////////////////////////////////////
533
534Silverlight.default_error_handler = function (sender, args)
535{
536    var iErrorCode;
537    var errorType = args.ErrorType;
538
539    iErrorCode = args.ErrorCode;
540
541    var errMsg = "\nSilverlight error message     \n" ;
542
543    errMsg += "ErrorCode: "+ iErrorCode + "\n";
544
545
546    errMsg += "ErrorType: " + errorType + "       \n";
547    errMsg += "Message: " + args.ErrorMessage + "     \n";
548
549    if (errorType == "ParserError")
550    {
551        errMsg += "XamlFile: " + args.xamlFile + "     \n";
552        errMsg += "Line: " + args.lineNumber + "     \n";
553        errMsg += "Position: " + args.charPosition + "     \n";
554    }
555    else if (errorType == "RuntimeError")
556    {
557        if (args.lineNumber != 0)
558        {
559            errMsg += "Line: " + args.lineNumber + "     \n";
560            errMsg += "Position: " +  args.charPosition + "     \n";
561        }
562        errMsg += "MethodName: " + args.methodName + "     \n";
563    }
564    alert (errMsg);
565}
566
567///////////////////////////////////////////////////////////////////////////////////////////////
568//
569// __cleanup:
570//
571// Releases event handler resources when the page is unloaded
572//
573///////////////////////////////////////////////////////////////////////////////////////////////
574Silverlight.__cleanup = function ()
575{
576    for (var i = Silverlight._silverlightCount - 1; i >= 0; i--) {
577        window['__slEvent' + i] = null;
578    }
579    Silverlight._silverlightCount = 0;
580    if (window.removeEventListener) {
581       window.removeEventListener('unload', Silverlight.__cleanup , false);
582    }
583    else {
584        window.detachEvent('onunload', Silverlight.__cleanup );
585    }
586}
587
588///////////////////////////////////////////////////////////////////////////////////////////////
589//
590// __getHandlerName:
591//
592// Generates named event handlers for delegates.
593//
594///////////////////////////////////////////////////////////////////////////////////////////////
595Silverlight.__getHandlerName = function (handler)
596{
597    var handlerName = "";
598    if ( typeof handler == "string")
599    {
600        handlerName = handler;
601    }
602    else if ( typeof handler == "function" )
603    {
604        if (Silverlight._silverlightCount == 0)
605        {
606            if (window.addEventListener)
607            {
608                window.addEventListener('onunload', Silverlight.__cleanup , false);
609            }
610            else
611            {
612                window.attachEvent('onunload', Silverlight.__cleanup );
613            }
614        }
615        var count = Silverlight._silverlightCount++;
616        handlerName = "__slEvent"+count;
617
618        window[handlerName]=handler;
619    }
620    else
621    {
622        handlerName = null;
623    }
624    return handlerName;
625}
626
627
628/* wmvplayer.js */
629/****************************************************************************
630* JW WMV Player version 1.1, created with M$ Silverlight 1.0
631*
632* This file contains all logic for the JW WMV Player. For a functional setup,
633* the following two files are also needed:
634* - silverlight.js (for instantiating the silverlight plugin)
635* - wmvplayer.xaml (or another XAML skin describing the player graphics)
636*
637* More info: http://www.jeroenwijering.com/?item=JW_WMV_Player
638****************************************************************************/
639if(typeof jeroenwijering == "undefined") {
640	var jeroenwijering = new Object();
641	jeroenwijering.utils = new Object();
642}
643
644/****************************************************************************
645* The player wrapper; loads config variables and starts MVC cycle.
646****************************************************************************/
647jeroenwijering.Player = function(cnt,src,cfg) {
648	this.controller;
649	this.model;
650	this.view;
651	this.configuration = {
652		backgroundcolor:'FFFFFF',
653		windowless:'false',
654		file:'',
655		height:'260',
656		image:'',
657		backcolor:'FFFFFF',
658		frontcolor:'000000',
659		lightcolor:'000000',
660		screencolor:'000000',
661		width:'320',
662		logo:'',
663		overstretch:'false',
664		shownavigation:'true',
665		showstop:'false',
666		showdigits:'true',
667		usefullscreen:'true',
668		usemute:'false',
669		autostart:'false',
670		bufferlength:'3',
671		duration:'0',
672		repeat:'false',
673		sender:'',
674		start:'0',
675		volume:'90',
676		link:'',
677		linkfromdisplay:'false',
678		linktarget:'_self'
679	};
680	for(itm in this.configuration) {
681		if(cfg[itm] != undefined) {
682			if (itm.indexOf('color') > 0) {
683				this.configuration[itm] = cfg[itm].substr(cfg[itm].length-6);
684			} else {
685				this.configuration[itm] = cfg[itm];
686			}
687		}
688	}
689	Silverlight.createObjectEx({
690		source:src,
691		parentElement:cnt,
692		properties:{
693			width:this.configuration['width'],
694			height:this.configuration['height'],
695			version:'1.0',
696			inplaceInstallPrompt:true,
697			isWindowless:this.configuration['windowless'],
698			background:'#'+this.configuration['backgroundcolor']
699		},
700		events:{
701			onLoad:this.onLoadHandler,
702			onError:null
703		},
704		context:this
705	});
706}
707
708jeroenwijering.Player.prototype = {
709	addListener: function(typ,fcn) {
710		this.view.listeners.push({type:typ,func:fcn});
711	},
712
713	getConfig: function() {
714		return this.configuration;
715	},
716
717	onLoadHandler: function(pid,tgt,sdr) {
718		tgt.configuration['sender'] = sdr;
719		tgt.controller = new jeroenwijering.Controller(tgt.configuration);
720		tgt.view = new jeroenwijering.View(tgt.configuration,tgt.controller);
721		tgt.model = new jeroenwijering.Model(tgt.configuration,tgt.controller,tgt.view
721);
722		tgt.controller.startMVC(tgt.view,tgt.model);
723	},
724
725	sendEvent: function(typ,prm) {
726		switch(typ.toUpperCase()) {
727			case 'LINK':
728				this.controller.setLink();
729				break;
730			case 'LOAD':
731				this.controller.setLoad(prm);
732				break;
733			case 'MUTE':
734				this.controller.setMute();
735				break;
736			case 'PLAY':
737				this.controller.setPlay();
738				break;
739			case 'SCRUB':
740				this.controller.setScrub(prm);
741				break;
742			case 'STOP':
743				this.controller.setStop();
744				break;
745			case 'VOLUME':
746				this.controller.setVolume(prm);
747				break;
748		}
749	}
750}
751
752/****************************************************************************
753* The controller of the player MVC triad, which processes all user input.
754****************************************************************************/
755jeroenwijering.Controller = function(cfg) {
756	this.configuration = cfg;
757}
758
759jeroenwijering.Controller.prototype = {
760	startMVC: function(vie,mdl) {
761		this.view = vie;
762		this.model = mdl;
763		if(this.configuration['usemute'] == 'true') {
764			this.view.onVolume(0);
765			this.view.onMute(true);
766			this.model.goVolume(0);
767		} else {
768			this.view.onVolume(this.configuration['volume']);
769			this.model.goVolume(this.configuration['volume']);
770		}
771		if(this.configuration['autostart'] == 'true') {
772			this.model.goStart();
773		} else {
774			this.model.goPause();
775		}
776	},
777
778	setState: function(old,stt) {
779		this.state = stt;
780		var pos = this.configuration['start'];
781		if(old == 'Closed' && pos > 0) {
782			setTimeout(jeroenwijering.utils.delegate(this,this.setScrub),200,pos);
783		}
784	},
785
786	setLink: function() {
787		if (this.configuration['linktarget'].indexOf('javascript:') == 0) {
788			return Function(this.configuration['linktarget']).apply();
789		} else if (this.configuration['linktarget'] == '_blank') {
790			window.open(this.configuration['link']);
791		} else if (this.configuration['linktarget'] != '') {
792			window.location = this.configuration['link'];
793		}
794	},
795
796	setLoad: function(fil) {
797		if(this.model.state != "Closed") {
798			this.model.goStop();
799		}
800		this.configuration['file'] = fil;
801		if(this.configuration['autostart'] == 'true') {
802			setTimeout(jeroenwijering.utils.delegate(this.model,this.model.goStart),100);
803		}
804	},
805
806	setMute: function() {
807		if(this.configuration['usemute'] == 'true') {
808			this.configuration['usemute'] = 'false';
809			this.model.goVolume(this.configuration['volume']);
810			this.view.onMute(false);
811		} else {
812			this.configuration['usemute'] = 'true';
813			this.model.goVolume(0);
814			this.view.onMute(true);
815		}
816	},
817
818	setPlay: function() {
819		if(this.state == 'Buffering' || this.state == 'Playing') {
820			if(this.configuration['duration'] == 0) {
821				this.model.goStop();
822			} else {
823				this.model.goPause();
824			}
825		} else {
826			this.model.goStart();
827		}
828	},
829
830	setScrub: function(sec) {
831		if(sec < 2) {
832			sec = 0;
833		} else if (sec > this.configuration['duration']-4) {
834			sec = this.configuration['duration']-4;
835		}
836		if(this.state == 'Buffering' || this.state == 'Playing') {
837			this.model.goStart(sec);
838		} else {
839			this.model.goPause(sec);
840		}
841	},
842
843	setStop: function() {
844		this.model.goStop();
845	},
846
847	setVolume: function(pct) {
848		if(pct < 0) { pct = 0; } else if(pct > 100) { pct = 100; }
849		this.configuration['volume'] = Math.round(pct);
850		this.model.goVolume(pct);
851		this.view.onVolume(pct);
852		if(this.configuration['usemute'] == 'true') {
853			this.configuration['usemute'] = 'false';
854			this.view.onMute(false);
855		}
856	},
857
858	setFullscreen: function() {
859		var fss = !this.configuration['sender'].getHost().content.FullScreen;
860		this.configuration['sender'].getHost().content.FullScreen = fss;
861		jeroenwijering.utils.delegate(this.view,this.view.onFullscreen);
862	}
863}
864
865/****************************************************************************
866* The view of the player MVC triad, which manages the graphics.
867****************************************************************************/
868jeroenwijering.View = function(cfg,ctr) {
869	this.configuration = cfg;
870	this.listeners = Array();
871	this.controller = ctr;
872	this.fstimeout;
873	this.fslistener;
874	this.display = this.configuration['sender'].findName("PlayerDisplay");
875	this.controlbar = this.configuration['sender'].findName("PlayerControls");
876	this.configuration['sender'].getHost().content.onResize =
877		jeroenwijering.utils.delegate(this,this.resizePlayer);
878	this.configuration['sender'].getHost().content.onFullScreenChange =
879		jeroenwijering.utils.delegate(this,this.onFullscreen);
880	this.assignColorsClicks();
881	this.resizePlayer();
882}
883
884jeroenwijering.View.prototype = {
885	onBuffer: function(pct) {
886		var snd = this.configuration['sender'];
887		if(pct == 0) {
888			snd.findName("BufferText").Text = null;
889		} else {
890			pct < 10 ? pct = "0"+pct: pct = ""+pct;
891			snd.findName("BufferText").Text = pct;
892		}
893		this.delegate('BUFFER',[pct]);
894	},
895
896	onFullscreen: function(fss) {
897		var snd = this.configuration['sender'];
898		var fst = snd.getHost().content.FullScreen;
899		if(fst) {
900			this.fstimeout = setTimeout(jeroenwijering.utils.delegate(this,
901				this.hideFSControls),2000);
902			this.fslistener = this.display.addEventListener('MouseMove',
903				jeroenwijering.utils.delegate(this,this.showFSControls));
904			snd.findName("FullscreenSymbol").Visibility = "Collapsed";
905			snd.findName("FullscreenOffSymbol").Visibility = "Visible";
906		} else {
907			clearTimeout(this.fstimeout);
908			this.display.removeEventListener("MouseMove",this.fslistener);
909			this.controlbar.Visibility = "Visible";
910			this.display.Cursor = "Hand";
911			snd.findName("FullscreenSymbol").Visibility = "Visible";
912			snd.findName("FullscreenOffSymbol").Visibility = "Collapsed";
913		}
914		this.resizePlayer();
915		this.delegate('FULLSCREEN');
916	},
917
918	showFSControls: function(sdr,arg) {
919		var vbt = sdr.findName('PlayerControls');
920		var yps = arg.GetPosition(vbt).Y;
921		clearTimeout(this.fstimeout);
922		this.controlbar.Visibility = "Visible";
923		this.display.Cursor = "Hand";
924		if(yps < 0) {
925			this.fstimeout = setTimeout(jeroenwijering.utils.delegate(this,
926				this.hideFSControls),2000);
927		}
928	},
929
930	hideFSControls: function() {
931		this.controlbar.Visibility = "Collapsed";
932		this.display.Cursor = "None";
933	},
934
935	onLoad: function(pct) {
936		var snd = this.configuration['sender'];
937		var max = snd.findName("TimeSlider").Width;
938		snd.findName("DownloadProgress").Width = Math.round(max*pct/100);
939		this.delegate('LOAD',[pct]);
940	},
941
942	onMute: function(mut) {
943		var snd = this.configuration['sender'];
944		this.configuration['usemute'] = ''+mut;
945		if(mut) {
946			snd.findName("VolumeHighlight").Visibility = "Collapsed";
947			snd.findName("MuteSymbol").Visibility = "Visible";
948			snd.findName("MuteOffSymbol").Visibility = "Collapsed";
949			if(this.state == 'Playing') {
950				snd.findName("MuteIcon").Visibility = "Visible";
951			}
952		} else {
953			snd.findName("VolumeHighlight").Visibility = "Visible";
954			snd.findName("MuteSymbol").Visibility = "Collapsed";
955			snd.findName("MuteOffSymbol").Visibility = "Visible";
956			snd.findName("MuteIcon").Visibility = "Collapsed";
957		}
958		this.delegate('MUTE');
959	},
960
961	onState: function(old,stt) {
962		var snd = this.configuration['sender'];
963		this.state = stt;
964		if(stt == 'Buffering' || stt == 'Playing' || stt == 'Opening') {
965			snd.findName("PlayIcon").Visibility = "Collapsed";
966			snd.findName("PlaySymbol").Visibility = "Collapsed";
967			snd.findName("PlayOffSymbol").Visibility = "Visible";
968			if (stt=='Playing') {
969				snd.findName("BufferIcon").Visibility = "Collapsed";
970				snd.findName("BufferText").Visibility = "Collapsed";
971				if(this.configuration['usemute'] == 'true') {
972					snd.findName("MuteIcon").Visibility = "Visible";
973				}
974			} else{
975				snd.findName("BufferIcon").Visibility = "Visible";
976				snd.findName("BufferText").Visibility = "Visible";
977			}
978		} else {
979			snd.findName("MuteIcon").Visibility = "Collapsed";
980			snd.findName("BufferIcon").Visibility = "Collapsed";
981			snd.findName("BufferText").Visibility = "Collapsed";
982			snd.findName("PlayOffSymbol").Visibility = "Collapsed";
983			snd.findName("PlaySymbol").Visibility = "Visible";
984			if(this.configuration['linkfromdisplay'] == 'true') {
985				snd.findName("PlayIcon").Visibility = "Collapsed";
986			} else {
987				snd.findName("PlayIcon").Visibility = "Visible";
988			}
989		}
990		try {
991			if(!(old == 'Completed' && stt == 'Buffering') &&
992				!(old == 'Buffering' && stt == 'Paused')) {
993				playerStatusChange(old.toUpperCase(),stt.toUpperCase());
994			}
995		} catch (err) {}
996		this.delegate('STATE',[old,stt]);
997	},
998
999	onTime: function(elp,dur) {
1000		var snd = this.configuration['sender'];
1001		var snd = this.configuration['sender'];
1002		var max = snd.findName("TimeSlider").Width;
1003		if(dur > 0) {
1004			var pos = Math.round(max*elp/dur);
1005			this.configuration['duration'] = dur;
1006			snd.findName("ElapsedText").Text = jeroenwijering.utils.timestring(elp);
1007			snd.findName("RemainingText").Text = jeroenwijering.utils.timestring(dur-elp);
1008			snd.findName("TimeSymbol").Visibility = "Visible";
1009			snd.findName("TimeSymbol")['Canvas.Left'] = pos+4;
1010			snd.findName("TimeHighlight").Width = pos-2;
1011		} else  {
1012			snd.findName("TimeSymbol").Visibility = "Collapsed";
1013		}
1014		this.delegate('TIME',[elp,dur]);
1015	},
1016
1017	onVolume: function(pct) {
1018		var snd = this.configuration['sender'];
1019		snd.findName("VolumeHighlight").Width = Math.round(pct/5);
1020		this.delegate('VOLUME',[pct]);
1021	},
1022
1023	assignColorsClicks: function() {
1024		this.display.Cursor = "Hand";
1025		this.display.Background = "#FF"+this.configuration['screencolor'];
1026		if(this.configuration['linkfromdisplay'] == 'false') {
1027			this.display.addEventListener('MouseLeftButtonUp',
1028				jeroenwijering.utils.delegate(this.controller,
1029				this.controller.setPlay));
1030		} else {
1031			this.display.addEventListener('MouseLeftButtonUp',
1032				jeroenwijering.utils.delegate(this.controller,
1033				this.controller.setLink));
1034			this.display.findName("PlayIcon").Visibility = "Collapsed";
1035		}
1036		if(this.configuration['logo'] != '') {
1037			this.display.findName('OverlayCanvas').Visibility = "Visible";
1038			this.display.findName('OverlayLogo').ImageSource =
1039				this.configuration['logo'];
1040		}
1041		this.controlbar.findName("ControlbarBack").Fill =
1042			"#FF"+this.configuration['backcolor'];
1043		this.assignButton('Play',this.controller.setPlay);
1044		this.assignButton('Stop',this.controller.setStop);
1045		this.configuration['sender'].findName('ElapsedText').Foreground =
1046			"#FF"+this.configuration['frontcolor'];
1047		this.assignSlider('Time',this.changeTime);
1048		this.configuration['sender'].findName('DownloadProgress').Fill =
1049			"#FF"+this.configuration['frontcolor'];
1050		this.configuration['sender'].findName('RemainingText').Foreground =
1051			"#FF"+this.configuration['frontcolor'];
1052		this.assignButton('Link',this.controller.setLink);
1053		this.assignButton('Fullscreen',this.controller.setFullscreen);
1054		this.assignButton('Mute',this.controller.setMute);
1055		this.assignSlider('Volume',this.changeVolume);
1056	},
1057
1058	assignButton: function(btn,act) {
1059		var el1 = this.configuration['sender'].findName(btn+'Button');
1060		el1.Cursor = "Hand";
1061		el1.addEventListener('MouseLeftButtonUp',
1062			jeroenwijering.utils.delegate(this.controller,act));
1063		el1.addEventListener('MouseEnter',
1064			jeroenwijering.utils.delegate(this,this.rollOver));
1065		el1.addEventListener('MouseLeave',
1066			jeroenwijering.utils.delegate(this,this.rollOut));
1067		this.configuration['sender'].findName(btn+'Symbol').Fill =
1068			"#FF"+this.configuration['frontcolor'];
1069		try {
1070			this.configuration['sender'].findName(btn+'OffSymbol').Fill =
1071				"#FF"+this.configuration['frontcolor'];
1072		} catch(e) {}
1073	},
1074
1075	assignSlider: function(sld,act) {
1076		var el1 = this.configuration['sender'].findName(sld+'Button');
1077		el1.Cursor = "Hand";
1078		el1.addEventListener('MouseLeftButtonUp',
1079			jeroenwijering.utils.delegate(this,act));
1080		el1.addEventListener('MouseEnter',
1081			jeroenwijering.utils.delegate(this,this.rollOver));
1082		el1.addEventListener('MouseLeave',
1083			jeroenwijering.utils.delegate(this,this.rollOut));
1084		this.configuration['sender'].findName(sld+'Slider').Fill =
1085			"#FF"+this.configuration['frontcolor'];
1086		this.configuration['sender'].findName(sld+'Highlight').Fill =
1087			"#FF"+this.configuration['frontcolor'];
1088		this.configuration['sender'].findName(sld+'Symbol').Fill =
1089			"#FF"+this.configuration['frontcolor'];
1090	},
1091
1092	delegate: function(typ,arg) {
1093		for(var i=0; i<this.listeners.length; i++) {
1094			if(this.listeners[i]['type'].toUpperCase() == typ) {
1095				this.listeners[i]['func'].apply(null,arg);
1096			}
1097		}
1098	},
1099
1100	rollOver: function(sdr) {
1101		var str = sdr.Name.substr(0,sdr.Name.length-6);
1102		this.configuration['sender'].findName(str+'Symbol').Fill =
1103			"#FF"+this.configuration['lightcolor'];
1104		try {
1105			this.configuration['sender'].findName(str+'OffSymbol').Fill =
1106				"#FF"+this.configuration['lightcolor'];
1107		} catch(e) {}
1108	},
1109
1110	rollOut: function(sdr) {
1111		var str = sdr.Name.substr(0,sdr.Name.length-6);
1112		this.configuration['sender'].findName(str+'Symbol').Fill =
1113			"#FF"+this.configuration['frontcolor'];
1114		try {
1115			this.configuration['sender'].findName(str+'OffSymbol').Fill =
1116				"#FF"+this.configuration['frontcolor'];
1117		} catch(e) {}
1118	},
1119
1120	changeTime: function(sdr,arg) {
1121		var tbt = sdr.findName('TimeSlider');
1122		var xps = arg.GetPosition(tbt).X;
1123		var sec = Math.floor(xps/tbt.Width*this.configuration['duration']);
1124		this.controller.setScrub(sec);
1125	},
1126
1127	changeVolume: function(sdr,arg) {
1128		var vbt = sdr.findName('VolumeButton');
1129		var xps = arg.GetPosition(vbt).X;
1130		this.controller.setVolume(xps*5);
1131	},
1132
1133	resizePlayer: function() {
1134		var wid = this.configuration['sender'].getHost().content.actualWidth;
1135		var hei = this.configuration['sender'].getHost().content.actualHeight;
1136		var fss = this.configuration['sender'].getHost().content.FullScreen;
1137		if(this.configuration['shownavigation'] == 'true') {
1138			if(fss == true) {
1139				this.resizeDisplay(wid,hei);
1140				this.controlbar['Canvas.Left'] = Math.round(wid/2-250);
1141				this.resizeControlbar(500,hei-this.controlbar.Height-16);
1142				this.controlbar.findName('ControlbarBack')['Opacity'] = 0.5;
1143			} else {
1144				this.resizeDisplay(wid,hei-20);
1145				this.controlbar['Canvas.Left'] = 0;
1146				this.resizeControlbar(wid,hei-this.controlbar.Height);
1147				this.controlbar.findName('ControlbarBack')['Opacity'] = 1;
1148			}
1149		} else {
1150			this.resizeDisplay(wid,hei);
1151		}
1152	},
1153
1154	resizeDisplay: function(wid,hei) {
1155		this.stretchElement('PlayerDisplay',wid,hei);
1156		this.stretchElement('VideoWindow',wid,hei);
1157		this.stretchElement('PlaceholderImage',wid,hei);
1158		this.centerElement('PlayIcon',wid,hei);
1159		this.centerElement('MuteIcon',wid,hei);
1160		this.centerElement('BufferIcon',wid,hei);
1161		this.centerElement('BufferText',wid,hei);
1162		this.display.findName('OverlayCanvas')['Canvas.Left'] = wid -
1163			this.display.findName('OverlayCanvas').Width - 10;
1164		this.display.Visibility = "Visible";
1165	},
1166
1167	resizeControlbar: function(wid,yps,alp) {
1168		this.controlbar['Canvas.Top'] = yps;
1169		this.stretchElement('PlayerControls',wid);
1170		this.stretchElement('ControlbarBack',wid);
1171		this.placeElement('PlayButton',0);
1172		var lft = 17;
1173		this.placeElement('VolumeButton',wid-24);
1174		this.placeElement('MuteButton',wid-37);
1175		var rgt = 37;
1176		if(this.configuration['showstop'] == 'true') {
1177			this.placeElement('StopButton',lft);
1178			lft += 17;
1179		} else {
1180			this.controlbar.findName('StopButton').Visibility="Collapsed";
1181		}
1182		if(this.configuration['usefullscreen'] == 'true') {
1183			rgt += 18;
1184			this.placeElement('FullscreenButton',wid-rgt);
1185		} else {
1186			this.controlbar.findName('FullscreenButton').Visibility =
1187				"Collapsed";
1188		}
1189		if(this.configuration['link'] != '') {
1190			rgt += 18;
1191			this.placeElement('LinkButton',wid-rgt);
1192		} else {
1193			this.controlbar.findName('LinkButton').Visibility="Collapsed";
1194		}
1195		if(this.configuration['showdigits'] == 'true' && wid-rgt-lft> 160) {
1196			rgt += 35;
1197			this.controlbar.findName('RemainingButton').Visibility="Visible";
1198			this.controlbar.findName('ElapsedButton').Visibility="Visible";
1199			this.placeElement('RemainingButton',wid-rgt);
1200			this.placeElement('ElapsedButton',lft);
1201			lft +=35;
1202		} else {
1203			this.controlbar.findName('RemainingButton').Visibility =
1204				"Collapsed";
1205			this.controlbar.findName('ElapsedButton').Visibility="Collapsed";
1206		}
1207		this.placeElement('TimeButton',lft);
1208		this.stretchElement('TimeButton',wid-lft-rgt);
1209		this.stretchElement('TimeShadow',wid-lft-rgt);
1210		this.stretchElement('TimeStroke',wid-lft-rgt);
1211		this.stretchElement('TimeFill',wid-lft-rgt);
1212		this.stretchElement('TimeSlider',wid-lft-rgt-10);
1213		this.stretchElement('DownloadProgress',wid-lft-rgt-10);
1214		var tsb = this.configuration['sender'].findName('TimeSymbol');
1215		this.stretchElement('TimeHighlight',tsb['Canvas.Left']-5);
1216		this.controlbar.Visibility = "Visible";
1217	},
1218
1219	centerElement: function(nam,wid,hei) {
1220		var elm = this.configuration['sender'].findName(nam);
1221		elm['Canvas.Left'] = Math.round(wid/2 - elm.Width/2);
1222		elm['Canvas.Top'] = Math.round(hei/2 - elm.Height/2);
1223	},
1224
1225	stretchElement: function(nam,wid,hei) {
1226		var elm = this.configuration['sender'].findName(nam);
1227		elm.Width = wid;
1228		if (hei != undefined) { elm.Height = hei; }
1229	},
1230
1231	placeElement: function(nam,xps,yps) {
1232		var elm = this.configuration['sender'].findName(nam);
1233		elm['Canvas.Left'] = xps;
1234		if(yps) { elm['Canvas.Top'] = yps; }
1235	}
1236}
1237
1238/****************************************************************************
1239* The model of the player MVC triad, which stores all playback logic.
1240****************************************************************************/
1241jeroenwijering.Model = function(cfg,ctr,vie) {
1242	this.configuration = cfg;
1243	this.controller = ctr;
1244	this.view = vie;
1245	this.video = this.configuration['sender'].findName("VideoWindow");
1246	this.preview = this.configuration['sender'].findName("PlaceholderImage");
1247	var str = {
1248		'true':'UniformToFill',
1249		'false':'Uniform',
1250		'fit':'Fill',
1251		'none':'None'
1252	}
1253	this.state = this.video.CurrentState;
1254	this.timeint;
1255	this.video.Stretch = str[this.configuration['overstretch']];
1256	this.preview.Stretch = str[this.configuration['overstretch']];
1257	this.video.BufferingTime =
1258		jeroenwijering.utils.spanstring(this.configuration['bufferlength']);
1259	this.video.AutoPlay = true;
1260	this.video.AddEventListener("CurrentStateChanged",
1261		jeroenwijering.utils.delegate(this,this.stateChanged));
1262	this.video.AddEventListener("MediaEnded",
1263		jeroenwijering.utils.delegate(this,this.mediaEnded));
1264	this.video.AddEventListener("BufferingProgressChanged",
1265		jeroenwijering.utils.delegate(this,this.bufferChanged));
1266	this.video.AddEventListener("DownloadProgressChanged",
1267		jeroenwijering.utils.delegate(this,this.downloadChanged));
1268	if(this.configuration['image'] != '') {
1269		this.preview.Source = this.configuration['image'];
1270	}
1271}
1272
1273jeroenwijering.Model.prototype = {
1274	goPause: function(sec) {
1275		this.video.pause();
1276		if(!isNaN(sec)) {
1277			this.video.Position = jeroenwijering.utils.spanstring(sec);
1278		}
1279		this.timeChanged();
1280	},
1281
1282	goStart: function(sec) {
1283		this.video.Visibility = 'Visible';
1284		this.preview.Visibility = 'Collapsed';
1285		if(this.state == "Closed") {
1286			this.video.Source = this.configuration['file'];
1287		} else {
1288			this.video.play();
1289		}
1290		if(!isNaN(sec)) {
1291			this.video.Position = jeroenwijering.utils.spanstring(sec);
1292		}
1293	},
1294
1295	goStop: function() {
1296		this.video.Visibility = 'Collapsed';
1297		this.preview.Visibility = 'Visible';
1298		this.goPause(0);
1299		this.video.Source = 'null';
1300		this.view.onBuffer(0);
1301		clearInterval(this.timeint);
1302	},
1303
1304	goVolume: function(pct) {
1305		this.video.Volume = pct/100;
1306	},
1307
1308	stateChanged: function() {
1309		var stt = this.video.CurrentState;
1310		if(stt != this.state) {
1311			this.controller.setState(this.state,stt);
1312			this.view.onState(this.state,stt);
1313			this.state = stt;
1314			this.configuration['duration'] =
1315				Math.round(this.video.NaturalDuration.Seconds*10)/10;
1316			if(stt != "Playing" && stt != "Buffering" && stt != "Opening") {
1317				clearInterval(this.timeint);
1318			} else {
1319				this.timeint = setInterval(jeroenwijering.utils.delegate(
1320					this,this.timeChanged),100);
1321			}
1322		}
1323	},
1324
1325	mediaEnded: function() {
1326		if(this.configuration['repeat'] == 'true') {
1327			this.goStart(0);
1328		} else {
1329			this.state = 'Completed';
1330			this.view.onState(this.state,'Completed');
1331			this.video.Visibility = 'Collapsed';
1332			this.preview.Visibility = 'Visible';
1333			this.goPause(0);
1334		}
1335	},
1336
1337	bufferChanged: function() {
1338		var bfr = Math.round(this.video.BufferingProgress*100);
1339		this.view.onBuffer(bfr);
1340	},
1341
1342	downloadChanged: function() {
1343		var dld = Math.round(this.video.DownloadProgress*100);
1344		this.view.onLoad(dld);
1345	},
1346
1347	timeChanged: function() {
1348		var pos = Math.round(this.video.Position.Seconds*10)/10;
1349		this.view.onTime(pos,this.configuration['duration']);
1350	}
1351}
1352
1353/****************************************************************************
1354* Some utility functions.
1355****************************************************************************/
1356jeroenwijering.utils.delegate = function(obj,fcn) {
1357	return function() {
1358		return fcn.apply(obj,arguments);
1359	}
1360}
1361jeroenwijering.utils.timestring = function(stp) {
1362	var hrs = Math.floor(stp/3600);
1363	var min = Math.floor(stp%3600/60);
1364	var sec = Math.round(stp%60);
1365	var str = "";
1366	sec > 9 ? str += sec: str +='0'+sec;
1367	min > 9 ? str = min+":"+str: str='0'+min+":"+str;
1368	hrs > 0 ? str = hrs+":"+str: null;
1369	return str;
1370}
1371jeroenwijering.utils.spanstring = function(stp) {
1372	var hrs = Math.floor(stp/3600);
1373	var min = Math.floor(stp%3600/60);
1374	var sec = Math.round(stp%60*10)/10;
1375	var str = hrs+':'+min+':'+sec;
1376	return str;
1377}
1378
1379
1380/* ac_quicktime.js */
1381/*
1382
1383File: AC_QuickTime.js
1384
1385Abstract: This file contains functions to generate OBJECT and EMBED tags for QuickTime content.
1386
1387Version: <1.2>
1388
1389Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
1390Computer, Inc. ("Apple") in consideration of your agreement to the
1391following terms, and your use, installation, modification or
1392redistribution of this Apple software constitutes acceptance of these
1393terms.  If you do not agree with these terms, please do not use,
1394install, modify or redistribute this Apple software.
1395
1396In consideration of your agreement to abide by the following terms, and
1397subject to these terms, Apple grants you a personal, non-exclusive
1398license, under Apple's copyrights in this original Apple software (the
1399"Apple Software"), to use, reproduce, modify and redistribute the Apple
1400Software, with or without modifications, in source and/or binary forms;
1401provided that if you redistribute the Apple Software in its entirety and
1402without modifications, you must retain this notice and the following
1403text and disclaimers in all such redistributions of the Apple Software.
1404Neither the name, trademarks, service marks or logos of Apple Computer,
1405Inc. may be used to endorse or promote products derived from the Apple
1406Software without specific prior written permission from Apple.  Except
1407as expressly stated in this notice, no other rights or licenses, express
1408or implied, are granted by Apple herein, including but not limited to
1409any patent rights that may be infringed by your derivative works or by
1410other works in which the Apple Software may be incorporated.
1411
1412The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
1413MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
1414THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
1415FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
1416OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
1417
1418IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
1419OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1420SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1421INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
1422MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
1423AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
1424STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
1425POSSIBILITY OF SUCH DAMAGE.
1426
1427Copyright © 2006-2007 Apple Computer, Inc., All Rights Reserved
1428
1429*/
1430
1431/*
1432 * This file contains functions to generate OBJECT and EMBED tags for QuickTime content.
1433 */
1434
1435/************** LOCALIZABLE GLOBAL VARIABLES ****************/
1436
1437var gArgCountErr =	'The "%%" function requires an even number of arguments.'
1438				+	'\nArguments should be in the form "atttributeName", "attributeValue", ...';
1439
1440/******************** END LOCALIZABLE **********************/
1441
1442var gTagAttrs				= null;
1443var gQTGeneratorVersion		= 1.2;
1444var gQTBehaviorID			= "qt_event_source";
1445var gQTEventsEnabled		= false;
1446
1447function AC_QuickTimeVersion()	{ return gQTGeneratorVersion; }
1448
1449function _QTComplain(callingFcnName, errMsg)
1450{
1451    errMsg = errMsg.replace("%%", callingFcnName);
1452	alert(errMsg);
1453}
1454
1455function _QTIsMSIE()
1456{
1457    var ua = navigator.userAgent.toLowerCase();
1458	var msie = /msie/.test(ua) && !/opera/.test(ua);
1459
1460	return msie;
1461}
1462
1463
1464function _QTGenerateBehavior()
1465{
1466	return objTag = '<!--[if IE]>'
1467				 + '<object id="' + gQTBehaviorID + '" classid="clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598"></object>'
1468				 + '<![endif]-->';
1469}
1470
1471function _QTPageHasBehaviorObject(callingFcnName, args)
1472{
1473	var haveBehavior = false;
1474	var objects = document.getElementsByTagName('object');
1475
1476	for ( var ndx = 0, obj; obj = objects[ndx]; ndx++ )
1477	{
1478		if ( obj.getAttribute('classid') == "clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598" )
1479		{
1480			if ( obj.getAttribute('id') == gQTBehaviorID )
1481				haveBehavior = false;
1482			break;
1483		}
1484	}
1485
1486	return haveBehavior;
1487}
1488
1489
1490function _QTShouldInsertBehavior()
1491{
1492	var		shouldDo = false;
1493
1494	if ( gQTEventsEnabled && _QTIsMSIE() && !_QTPageHasBehaviorObject() )
1495		shouldDo = true;
1496
1497	return shouldDo;
1498}
1499
1500
1501function _QTAddAttribute(prefix, slotName, tagName)
1502{
1503	var		value;
1504
1505	value = gTagAttrs[prefix + slotName];
1506	if ( null == value )
1507		value = gTagAttrs[slotName];
1508
1509	if ( null != value )
1510	{
1511		if ( 0 == slotName.indexOf(prefix) && (null == tagName) )
1512			tagName = slotName.substring(prefix.length);
1513		if ( null == tagName )
1514			tagName = slotName;
1515		return ' ' + tagName + '="' + value + '"';
1516	}
1517	else
1518		return "";
1519}
1520
1521function _QTAddObjectAttr(slotName, tagName)
1522{
1523	// don't bother if it is only for the embed tag
1524	if ( 0 == slotName.indexOf("emb#") )
1525		return "";
1526
1527	if ( 0 == slotName.indexOf("obj#") && (null == tagName) )
1528		tagName = slotName.substring(4);
1529
1530	return _QTAddAttribute("obj#", slotName, tagName);
1531}
1532
1533function _QTAddEmbedAttr(slotName, tagName)
1534{
1535	// don't bother if it is only for the object tag
1536	if ( 0 == slotName.indexOf("obj#") )
1537		return "";
1538
1539	if ( 0 == slotName.indexOf("emb#") && (null == tagName) )
1540		tagName = slotName.substring(4);
1541
1542	return _QTAddAttribute("emb#", slotName, tagName);
1543}
1544
1545
1546function _QTAddObjectParam(slotName, generateXHTML)
1547{
1548	var		paramValue;
1549	var		paramStr = "";
1550	var		endTagChar = (generateXHTML) ? ' />' : '>';
1551
1552	if ( -1 == slotName.indexOf("emb#") )
1553	{
1554		// look for the OBJECT-only param first. if there is none, look for a generic one
1555		paramValue = gTagAttrs["obj#" + slotName];
1556		if ( null == paramValue )
1557			paramValue = gTagAttrs[slotName];
1558
1559		if ( 0 == slotName.indexOf("obj#") )
1560			slotName = slotName.substring(4);
1561
1562		if ( null != paramValue )
1563			paramStr = '<param name="' + slotName + '" value="' + paramValue + '"' + endTagChar;
1564	}
1565
1566	return paramStr;
1567}
1568
1569function _QTDeleteTagAttrs()
1570{
1571	for ( var ndx = 0; ndx < arguments.length; ndx++ )
1572	{
1573		var attrName = arguments[ndx];
1574		delete gTagAttrs[attrName];
1575		delete gTagAttrs["emb#" + attrName];
1576		delete gTagAttrs["obj#" + attrName];
1577	}
1578}
1579
1580
1581// generate an embed and object tag, return as a string
1582function _QTGenerate(callingFcnName, generateXHTML, args)
1583{
1584	// is the number of optional arguments even?
1585	if ( args.length < 4 || (0 != (args.length % 2)) )
1586	{
1587		_QTComplain(callingFcnName, gArgCountErr);
1588		return "";
1589	}
1590
1591	// allocate an array, fill in the required attributes with fixed place params and defaults
1592	gTagAttrs = new Object();
1593	gTagAttrs["src"] = args[0];
1594	gTagAttrs["width"] = args[1];
1595	gTagAttrs["height"] = args[2];
1596	gTagAttrs["classid"] = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
1597		//Impportant note: It is recommended that you use this exact classid in order to ensure a seamless experience for all viewers
1598	gTagAttrs["pluginspage"] = "http://www.apple.com/quicktime/download/";
1599
1600	// set up codebase attribute with specified or default version before parsing args so
1601	//  anything passed in will override
1602	var activexVers = args[3]
1603	if ( (null == activexVers) || ("" == activexVers) )
1604		activexVers = "7,3,0,0";
1605	gTagAttrs["codebase"] = "http://www.apple.com/qtactivex/qtplugin.cab#version=" + activexVers;
1606
1607	var	attrName,
1608		attrValue;
1609
1610	// add all of the optional attributes to the array
1611	for ( var ndx = 4; ndx < args.length; ndx += 2)
1612	{
1613		attrName = args[ndx].toLowerCase();
1614		attrValue = args[ndx + 1];
1615
1616		gTagAttrs[attrName] = attrValue;
1617
1618		if ( ("postdomevents" == attrName) && (attrValue.toLowerCase() != "false") )
1619		{
1620			gQTEventsEnabled = true;
1621			if ( _QTIsMSIE() )
1622				gTagAttrs["obj#style"] = "behavior:url(#" + gQTBehaviorID + ")";
1623		}
1624	}
1625
1626	// init both tags with the required and "special" attributes
1627	var objTag =  '<object '
1628					+ _QTAddObjectAttr("classid")
1629					+ _QTAddObjectAttr("width")
1630					+ _QTAddObjectAttr("height")
1631					+ _QTAddObjectAttr("codebase")
1632					+ _QTAddObjectAttr("name")
1633					+ _QTAddObjectAttr("id")
1634					+ _QTAddObjectAttr("tabindex")
1635					+ _QTAddObjectAttr("hspace")
1636					+ _QTAddObjectAttr("vspace")
1637					+ _QTAddObjectAttr("border")
1638					+ _QTAddObjectAttr("align")
1639					+ _QTAddObjectAttr("class")
1640					+ _QTAddObjectAttr("title")
1641					+ _QTAddObjectAttr("accesskey")
1642					+ _QTAddObjectAttr("noexternaldata")
1643					+ _QTAddObjectAttr("obj#style")
1644					+ '>'
1645					+ _QTAddObjectParam("src", generateXHTML);
1646	var embedTag = '<embed '
1647					+ _QTAddEmbedAttr("src")
1648					+ _QTAddEmbedAttr("width")
1649					+ _QTAddEmbedAttr("height")
1650					+ _QTAddEmbedAttr("pluginspage")
1651					+ _QTAddEmbedAttr("name")
1652					+ _QTAddEmbedAttr("id")
1653					+ _QTAddEmbedAttr("align")
1654					+ _QTAddEmbedAttr("tabindex")
1655					+ _QTAddEmbedAttr("title");
1656
1657	// delete the attributes/params we have already added
1658	_QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex",
1659					"hspace","vspace","border","align","noexternaldata","class","title","accesskey","id","style");
1660
1661	// and finally, add all of the remaining attributes to the embed and object
1662	for ( var attrName in gTagAttrs )
1663	{
1664		attrValue = gTagAttrs[attrName];
1665		if ( null != attrValue )
1666		{
1667			embedTag += _QTAddEmbedAttr(attrName);
1668			objTag += _QTAddObjectParam(attrName, generateXHTML);
1669		}
1670	}
1671
1672	// end both tags, we're done
1673	return objTag + embedTag + '></em' + 'bed></ob' + 'ject' + '>';
1674}
1675
1676
1677// return the object/embed as a string
1678function QT_GenerateOBJECTText()
1679{
1680	var	txt = _QTGenerate("QT_GenerateOBJECTText", false, arguments);
1681	if ( _QTShouldInsertBehavior() )
1682		txt = _QTGenerateBehavior() + txt;
1683	return txt;
1684}
1685
1686function QT_GenerateOBJECTText_XHTML()
1687{
1688	var	txt = _QTGenerate("QT_GenerateOBJECTText_XHTML", true, arguments);
1689	if ( _QTShouldInsertBehavior() )
1690		txt = _QTGenerateBehavior() + txt;
1691	return txt;
1692}
1693
1694function QT_WriteOBJECT()
1695{
1696	var	txt = _QTGenerate("QT_WriteOBJECT", false, arguments);
1697	if ( _QTShouldInsertBehavior() )
1698		document.writeln(_QTGenerateBehavior());
1699	document.writeln(txt);
1700}
1701
1702function QT_WriteOBJECT_XHTML()
1703{
1704	var	txt = _QTGenerate("QT_WriteOBJECT_XHTML", true, arguments);
1705	if ( _QTShouldInsertBehavior() )
1706		document.writeln(_QTGenerateBehavior());
1707	document.writeln(txt);
1708}
1709
1710function QT_GenerateBehaviorOBJECT()
1711{
1712	return _QTGenerateBehavior();
1713}
1714
1715function QT_ReplaceElementContents()
1716{
1717	var element = arguments[0];
1718	var args = [];
1719
1720	// copy all other arguments we want to pass through to the fcn
1721	for ( var ndx = 1; ndx < arguments.length; ndx++ )
1722		args.push(arguments[ndx]);
1723
1724	var	txt = _QTGenerate("QT_ReplaceElementContents", false, args);
1725	if ( txt.length > 0 )
1726		element.innerHTML = txt;
1727}
1728
1729
1730function QT_ReplaceElementContents_XHTML()
1731{
1732	var element = arguments[0];
1733	var args = [];
1734
1735	// copy all other arguments we want to pass through to the fcn
1736	for ( var ndx = 1; ndx < arguments.length; ndx++ )
1737		args.push(arguments[ndx]);
1738
1739	var	txt = _QTGenerate("QT_ReplaceElementContents_XHTML", true, args
1739);
1740	if ( txt.length > 0 )
1741		element.innerHTML = txt;
1742}
1743
1744

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.