swfobject_source.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. /*
  2. * SWFObject 1.5 & 2.2 hybrid solution for the Chamilo LMS
  3. *
  4. * The problem to be solved:
  5. *
  6. * The SWFObject 2.x javascript for embedding flash-based multimedia is the
  7. * successor of SWFObject 1.5, but it does not provide backward compatibility.
  8. * The Chamilo LMS under its past brand used the version 1.5 of the script,
  9. * a lot of pages have been created. On the other hand, SWFObject 1.5
  10. * gets old, there must be a way found for using the modern version of the
  11. * script for the newly created pages without breaking the old ones.
  12. * Note that both vesrsions of the script share a common file name swfobject.js
  13. *
  14. * The solution:
  15. *
  16. * ... is simply merging sources of 1.5 and 2.2 scripts into one. Javsscript is
  17. * a case-sensitive language, and fortunately there are no name-conflicts between
  18. * both versions of the script. So, version 2.2 part of this combined script
  19. * is to be used for creation of new pages, while the version 1.5 part is to
  20. * provide the desired compatibility for old pages. Also, the "compressed"
  21. * production scripts are merged.
  22. *
  23. * Links:
  24. * http://blog.deconcept.com/swfobject/
  25. * http://code.google.com/p/swfobject/
  26. *
  27. * License:
  28. * The MIT License - http://www.opensource.org/licenses/mit-license.php
  29. *
  30. * Authors:
  31. * (c) 2007 Geoff Stearns (SWFObject 1.5)
  32. * For SWFObject 2.2, a list of the authors may be seen at:
  33. * http://code.google.com/p/swfobject/people/list
  34. *
  35. * This hybrid solution has been prepared by Ivan Tcholakov
  36. * July 2009 - first implementation
  37. * January 2010 - this description has been updated
  38. */
  39. /******************************************************************************/
  40. /**
  41. * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
  42. *
  43. * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
  44. * http://www.opensource.org/licenses/mit-license.php
  45. *
  46. */
  47. if(typeof deconcept == "undefined") var deconcept = new Object();
  48. if(typeof deconcept.util == "undefined") deconcept.util = new Object();
  49. if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
  50. deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
  51. if (!document.getElementById) { return; }
  52. this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  53. this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
  54. this.params = new Object();
  55. this.variables = new Object();
  56. this.attributes = new Array();
  57. if(swf) { this.setAttribute('swf', swf); }
  58. if(id) { this.setAttribute('id', id); }
  59. if(w) { this.setAttribute('width', w); }
  60. if(h) { this.setAttribute('height', h); }
  61. if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
  62. this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
  63. if (!window.opera && document.all && this.installedVer.major > 7) {
  64. // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
  65. deconcept.SWFObject.doPrepUnload = true;
  66. }
  67. if(c) { this.addParam('bgcolor', c); }
  68. var q = quality ? quality : 'high';
  69. this.addParam('quality', q);
  70. this.setAttribute('useExpressInstall', false);
  71. this.setAttribute('doExpressInstall', false);
  72. var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  73. this.setAttribute('xiRedirectUrl', xir);
  74. this.setAttribute('redirectUrl', '');
  75. if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
  76. }
  77. deconcept.SWFObject.prototype = {
  78. useExpressInstall: function(path) {
  79. this.xiSWFPath = !path ? "expressinstall.swf" : path;
  80. this.setAttribute('useExpressInstall', true);
  81. },
  82. setAttribute: function(name, value){
  83. this.attributes[name] = value;
  84. },
  85. getAttribute: function(name){
  86. return this.attributes[name];
  87. },
  88. addParam: function(name, value){
  89. this.params[name] = value;
  90. },
  91. getParams: function(){
  92. return this.params;
  93. },
  94. addVariable: function(name, value){
  95. this.variables[name] = value;
  96. },
  97. getVariable: function(name){
  98. return this.variables[name];
  99. },
  100. getVariables: function(){
  101. return this.variables;
  102. },
  103. getVariablePairs: function(){
  104. var variablePairs = new Array();
  105. var key;
  106. var variables = this.getVariables();
  107. for(key in variables){
  108. variablePairs[variablePairs.length] = key +"="+ variables[key];
  109. }
  110. return variablePairs;
  111. },
  112. getSWFHTML: function() {
  113. var swfNode = "";
  114. if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
  115. if (this.getAttribute("doExpressInstall")) {
  116. this.addVariable("MMplayerType", "PlugIn");
  117. this.setAttribute('swf', this.xiSWFPath);
  118. }
  119. swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
  120. swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
  121. var params = this.getParams();
  122. for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
  123. var pairs = this.getVariablePairs().join("&");
  124. if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
  125. swfNode += '/>';
  126. } else { // PC IE
  127. if (this.getAttribute("doExpressInstall")) {
  128. this.addVariable("MMplayerType", "ActiveX");
  129. this.setAttribute('swf', this.xiSWFPath);
  130. }
  131. swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
  132. swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
  133. var params = this.getParams();
  134. for(var key in params) {
  135. swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
  136. }
  137. var pairs = this.getVariablePairs().join("&");
  138. if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
  139. swfNode += "</object>";
  140. }
  141. return swfNode;
  142. },
  143. write: function(elementId){
  144. if(this.getAttribute('useExpressInstall')) {
  145. // check to see if we need to do an express install
  146. var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
  147. if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
  148. this.setAttribute('doExpressInstall', true);
  149. this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
  150. document.title = document.title.slice(0, 47) + " - Flash Player Installation";
  151. this.addVariable("MMdoctitle", document.title);
  152. }
  153. }
  154. if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
  155. var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
  156. n.innerHTML = this.getSWFHTML();
  157. return true;
  158. }else{
  159. if(this.getAttribute('redirectUrl') != "") {
  160. document.location.replace(this.getAttribute('redirectUrl'));
  161. }
  162. }
  163. return false;
  164. }
  165. }
  166. /* ---- detection functions ---- */
  167. deconcept.SWFObjectUtil.getPlayerVersion = function(){
  168. var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
  169. if(navigator.plugins && navigator.mimeTypes.length){
  170. var x = navigator.plugins["Shockwave Flash"];
  171. if(x && x.description) {
  172. PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
  173. }
  174. }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
  175. var axo = 1;
  176. var counter = 3;
  177. while(axo) {
  178. try {
  179. counter++;
  180. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
  181. // document.write("player v: "+ counter);
  182. PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
  183. } catch (e) {
  184. axo = null;
  185. }
  186. }
  187. } else { // Win IE (non mobile)
  188. // do minor version lookup in IE, but avoid fp6 crashing issues
  189. // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
  190. try{
  191. var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  192. }catch(e){
  193. try {
  194. var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  195. PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
  196. axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
  197. } catch(e) {
  198. if (PlayerVersion.major == 6) {
  199. return PlayerVersion;
  200. }
  201. }
  202. try {
  203. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  204. } catch(e) {}
  205. }
  206. if (axo != null) {
  207. PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
  208. }
  209. }
  210. return PlayerVersion;
  211. }
  212. deconcept.PlayerVersion = function(arrVersion){
  213. this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
  214. this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
  215. this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
  216. }
  217. deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
  218. if(this.major < fv.major) return false;
  219. if(this.major > fv.major) return true;
  220. if(this.minor < fv.minor) return false;
  221. if(this.minor > fv.minor) return true;
  222. if(this.rev < fv.rev) return false;
  223. return true;
  224. }
  225. /* ---- get value of query string param ---- */
  226. deconcept.util = {
  227. getRequestParameter: function(param) {
  228. var q = document.location.search || document.location.hash;
  229. if (param == null) { return q; }
  230. if(q) {
  231. var pairs = q.substring(1).split("&");
  232. for (var i=0; i < pairs.length; i++) {
  233. if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
  234. return pairs[i].substring((pairs[i].indexOf("=")+1));
  235. }
  236. }
  237. }
  238. return "";
  239. }
  240. }
  241. /* fix for video streaming bug */
  242. deconcept.SWFObjectUtil.cleanupSWFs = function() {
  243. var objects = document.getElementsByTagName("OBJECT");
  244. for (var i = objects.length - 1; i >= 0; i--) {
  245. objects[i].style.display = 'none';
  246. for (var x in objects[i]) {
  247. if (typeof objects[i][x] == 'function') {
  248. objects[i][x] = function(){};
  249. }
  250. }
  251. }
  252. }
  253. // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
  254. if (deconcept.SWFObject.doPrepUnload) {
  255. if (!deconcept.unloadSet) {
  256. deconcept.SWFObjectUtil.prepUnload = function() {
  257. __flash_unloadHandler = function(){};
  258. __flash_savedUnloadHandler = function(){};
  259. window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
  260. }
  261. window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
  262. deconcept.unloadSet = true;
  263. }
  264. }
  265. /* add document.getElementById if needed (mobile IE < 5) */
  266. if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
  267. /* add some aliases for ease of use/backwards compatibility */
  268. var getQueryParamValue = deconcept.util.getRequestParameter;
  269. var FlashObject = deconcept.SWFObject; // for legacy support
  270. var SWFObject = deconcept.SWFObject;
  271. /******************************************************************************/
  272. /*! SWFObject v2.2 <http://code.google.com/p/swfobject/>
  273. is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
  274. */
  275. var swfobject = function() {
  276. var UNDEF = "undefined",
  277. OBJECT = "object",
  278. SHOCKWAVE_FLASH = "Shockwave Flash",
  279. SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
  280. FLASH_MIME_TYPE = "application/x-shockwave-flash",
  281. EXPRESS_INSTALL_ID = "SWFObjectExprInst",
  282. ON_READY_STATE_CHANGE = "onreadystatechange",
  283. win = window,
  284. doc = document,
  285. nav = navigator,
  286. plugin = false,
  287. domLoadFnArr = [main],
  288. regObjArr = [],
  289. objIdArr = [],
  290. listenersArr = [],
  291. storedAltContent,
  292. storedAltContentId,
  293. storedCallbackFn,
  294. storedCallbackObj,
  295. isDomLoaded = false,
  296. isExpressInstallActive = false,
  297. dynamicStylesheet,
  298. dynamicStylesheetMedia,
  299. autoHideShow = true,
  300. /* Centralized function for browser feature detection
  301. - User agent string detection is only used when no good alternative is possible
  302. - Is executed directly for optimal performance
  303. */
  304. ua = function() {
  305. var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
  306. u = nav.userAgent.toLowerCase(),
  307. p = nav.platform.toLowerCase(),
  308. windows = p ? /win/.test(p) : /win/.test(u),
  309. mac = p ? /mac/.test(p) : /mac/.test(u),
  310. webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
  311. ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
  312. playerVersion = [0,0,0],
  313. d = null;
  314. if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
  315. d = nav.plugins[SHOCKWAVE_FLASH].description;
  316. if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
  317. plugin = true;
  318. ie = false; // cascaded feature detection for Internet Explorer
  319. d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
  320. playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
  321. playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
  322. playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
  323. }
  324. }
  325. else if (typeof win.ActiveXObject != UNDEF) {
  326. try {
  327. var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
  328. if (a) { // a will return null when ActiveX is disabled
  329. d = a.GetVariable("$version");
  330. if (d) {
  331. ie = true; // cascaded feature detection for Internet Explorer
  332. d = d.split(" ")[1].split(",");
  333. playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
  334. }
  335. }
  336. }
  337. catch(e) {}
  338. }
  339. return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
  340. }(),
  341. /* Cross-browser onDomLoad
  342. - Will fire an event as soon as the DOM of a web page is loaded
  343. - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/
  344. - Regular onload serves as fallback
  345. */
  346. onDomLoad = function() {
  347. if (!ua.w3) { return; }
  348. if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically
  349. callDomLoadFunctions();
  350. }
  351. if (!isDomLoaded) {
  352. if (typeof doc.addEventListener != UNDEF) {
  353. doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
  354. }
  355. if (ua.ie && ua.win) {
  356. doc.attachEvent(ON_READY_STATE_CHANGE, function() {
  357. if (doc.readyState == "complete") {
  358. doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
  359. callDomLoadFunctions();
  360. }
  361. });
  362. if (win == top) { // if not inside an iframe
  363. (function(){
  364. if (isDomLoaded) { return; }
  365. try {
  366. doc.documentElement.doScroll("left");
  367. }
  368. catch(e) {
  369. setTimeout(arguments.callee, 0);
  370. return;
  371. }
  372. callDomLoadFunctions();
  373. })();
  374. }
  375. }
  376. if (ua.wk) {
  377. (function(){
  378. if (isDomLoaded) { return; }
  379. if (!/loaded|complete/.test(doc.readyState)) {
  380. setTimeout(arguments.callee, 0);
  381. return;
  382. }
  383. callDomLoadFunctions();
  384. })();
  385. }
  386. addLoadEvent(callDomLoadFunctions);
  387. }
  388. }();
  389. function callDomLoadFunctions() {
  390. if (isDomLoaded) { return; }
  391. try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
  392. var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
  393. t.parentNode.removeChild(t);
  394. }
  395. catch (e) { return; }
  396. isDomLoaded = true;
  397. var dl = domLoadFnArr.length;
  398. for (var i = 0; i < dl; i++) {
  399. domLoadFnArr[i]();
  400. }
  401. }
  402. function addDomLoadEvent(fn) {
  403. if (isDomLoaded) {
  404. fn();
  405. }
  406. else {
  407. domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
  408. }
  409. }
  410. /* Cross-browser onload
  411. - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
  412. - Will fire an event as soon as a web page including all of its assets are loaded
  413. */
  414. function addLoadEvent(fn) {
  415. if (typeof win.addEventListener != UNDEF) {
  416. win.addEventListener("load", fn, false);
  417. }
  418. else if (typeof doc.addEventListener != UNDEF) {
  419. doc.addEventListener("load", fn, false);
  420. }
  421. else if (typeof win.attachEvent != UNDEF) {
  422. addListener(win, "onload", fn);
  423. }
  424. else if (typeof win.onload == "function") {
  425. var fnOld = win.onload;
  426. win.onload = function() {
  427. fnOld();
  428. fn();
  429. };
  430. }
  431. else {
  432. win.onload = fn;
  433. }
  434. }
  435. /* Main function
  436. - Will preferably execute onDomLoad, otherwise onload (as a fallback)
  437. */
  438. function main() {
  439. if (plugin) {
  440. testPlayerVersion();
  441. }
  442. else {
  443. matchVersions();
  444. }
  445. }
  446. /* Detect the Flash Player version for non-Internet Explorer browsers
  447. - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
  448. a. Both release and build numbers can be detected
  449. b. Avoid wrong descriptions by corrupt installers provided by Adobe
  450. c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
  451. - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
  452. */
  453. function testPlayerVersion() {
  454. var b = doc.getElementsByTagName("body")[0];
  455. var o = createElement(OBJECT);
  456. o.setAttribute("type", FLASH_MIME_TYPE);
  457. var t = b.appendChild(o);
  458. if (t) {
  459. var counter = 0;
  460. (function(){
  461. if (typeof t.GetVariable != UNDEF) {
  462. var d = t.GetVariable("$version");
  463. if (d) {
  464. d = d.split(" ")[1].split(",");
  465. ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
  466. }
  467. }
  468. else if (counter < 10) {
  469. counter++;
  470. setTimeout(arguments.callee, 10);
  471. return;
  472. }
  473. b.removeChild(o);
  474. t = null;
  475. matchVersions();
  476. })();
  477. }
  478. else {
  479. matchVersions();
  480. }
  481. }
  482. /* Perform Flash Player and SWF version matching; static publishing only
  483. */
  484. function matchVersions() {
  485. var rl = regObjArr.length;
  486. if (rl > 0) {
  487. for (var i = 0; i < rl; i++) { // for each registered object element
  488. var id = regObjArr[i].id;
  489. var cb = regObjArr[i].callbackFn;
  490. var cbObj = {success:false, id:id};
  491. if (ua.pv[0] > 0) {
  492. var obj = getElementById(id);
  493. if (obj) {
  494. if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
  495. setVisibility(id, true);
  496. if (cb) {
  497. cbObj.success = true;
  498. cbObj.ref = getObjectById(id);
  499. cb(cbObj);
  500. }
  501. }
  502. else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
  503. var att = {};
  504. att.data = regObjArr[i].expressInstall;
  505. att.width = obj.getAttribute("width") || "0";
  506. att.height = obj.getAttribute("height") || "0";
  507. if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
  508. if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
  509. // parse HTML object param element's name-value pairs
  510. var par = {};
  511. var p = obj.getElementsByTagName("param");
  512. var pl = p.length;
  513. for (var j = 0; j < pl; j++) {
  514. if (p[j].getAttribute("name").toLowerCase() != "movie") {
  515. par[p[j].getAttribute("name")] = p[j].getAttribute("value");
  516. }
  517. }
  518. showExpressInstall(att, par, id, cb);
  519. }
  520. else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
  521. displayAltContent(obj);
  522. if (cb) { cb(cbObj); }
  523. }
  524. }
  525. }
  526. else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
  527. setVisibility(id, true);
  528. if (cb) {
  529. var o = getObjectById(id); // test whether there is an HTML object element or not
  530. if (o && typeof o.SetVariable != UNDEF) {
  531. cbObj.success = true;
  532. cbObj.ref = o;
  533. }
  534. cb(cbObj);
  535. }
  536. }
  537. }
  538. }
  539. }
  540. function getObjectById(objectIdStr) {
  541. var r = null;
  542. var o = getElementById(objectIdStr);
  543. if (o && o.nodeName == "OBJECT") {
  544. if (typeof o.SetVariable != UNDEF) {
  545. r = o;
  546. }
  547. else {
  548. var n = o.getElementsByTagName(OBJECT)[0];
  549. if (n) {
  550. r = n;
  551. }
  552. }
  553. }
  554. return r;
  555. }
  556. /* Requirements for Adobe Express Install
  557. - only one instance can be active at a time
  558. - fp 6.0.65 or higher
  559. - Win/Mac OS only
  560. - no Webkit engines older than version 312
  561. */
  562. function canExpressInstall() {
  563. return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
  564. }
  565. /* Show the Adobe Express Install dialog
  566. - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
  567. */
  568. function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
  569. isExpressInstallActive = true;
  570. storedCallbackFn = callbackFn || null;
  571. storedCallbackObj = {success:false, id:replaceElemIdStr};
  572. var obj = getElementById(replaceElemIdStr);
  573. if (obj) {
  574. if (obj.nodeName == "OBJECT") { // static publishing
  575. storedAltContent = abstractAltContent(obj);
  576. storedAltContentId = null;
  577. }
  578. else { // dynamic publishing
  579. storedAltContent = obj;
  580. storedAltContentId = replaceElemIdStr;
  581. }
  582. att.id = EXPRESS_INSTALL_ID;
  583. if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
  584. if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
  585. doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
  586. var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
  587. fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
  588. if (typeof par.flashvars != UNDEF) {
  589. par.flashvars += "&" + fv;
  590. }
  591. else {
  592. par.flashvars = fv;
  593. }
  594. // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
  595. // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
  596. if (ua.ie && ua.win && obj.readyState != 4) {
  597. var newObj = createElement("div");
  598. replaceElemIdStr += "SWFObjectNew";
  599. newObj.setAttribute("id", replaceElemIdStr);
  600. obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf
  601. obj.style.display = "none";
  602. (function(){
  603. if (obj.readyState == 4) {
  604. obj.parentNode.removeChild(obj);
  605. }
  606. else {
  607. setTimeout(arguments.callee, 10);
  608. }
  609. })();
  610. }
  611. createSWF(att, par, replaceElemIdStr);
  612. }
  613. }
  614. /* Functions to abstract and display alternative content
  615. */
  616. function displayAltContent(obj) {
  617. if (ua.ie && ua.win && obj.readyState != 4) {
  618. // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
  619. // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
  620. var el = createElement("div");
  621. obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
  622. el.parentNode.replaceChild(abstractAltContent(obj), el);
  623. obj.style.display = "none";
  624. (function(){
  625. if (obj.readyState == 4) {
  626. obj.parentNode.removeChild(obj);
  627. }
  628. else {
  629. setTimeout(arguments.callee, 10);
  630. }
  631. })();
  632. }
  633. else {
  634. obj.parentNode.replaceChild(abstractAltContent(obj), obj);
  635. }
  636. }
  637. function abstractAltContent(obj) {
  638. var ac = createElement("div");
  639. if (ua.win && ua.ie) {
  640. ac.innerHTML = obj.innerHTML;
  641. }
  642. else {
  643. var nestedObj = obj.getElementsByTagName(OBJECT)[0];
  644. if (nestedObj) {
  645. var c = nestedObj.childNodes;
  646. if (c) {
  647. var cl = c.length;
  648. for (var i = 0; i < cl; i++) {
  649. if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
  650. ac.appendChild(c[i].cloneNode(true));
  651. }
  652. }
  653. }
  654. }
  655. }
  656. return ac;
  657. }
  658. /* Cross-browser dynamic SWF creation
  659. */
  660. function createSWF(attObj, parObj, id) {
  661. var r, el = getElementById(id);
  662. if (ua.wk && ua.wk < 312) { return r; }
  663. if (el) {
  664. if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
  665. attObj.id = id;
  666. }
  667. if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
  668. var att = "";
  669. for (var i in attObj) {
  670. if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
  671. if (i.toLowerCase() == "data") {
  672. parObj.movie = attObj[i];
  673. }
  674. else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
  675. att += ' class="' + attObj[i] + '"';
  676. }
  677. else if (i.toLowerCase() != "classid") {
  678. att += ' ' + i + '="' + attObj[i] + '"';
  679. }
  680. }
  681. }
  682. var par = "";
  683. for (var j in parObj) {
  684. if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
  685. par += '<param name="' + j + '" value="' + parObj[j] + '" />';
  686. }
  687. }
  688. el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
  689. objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
  690. r = getElementById(attObj.id);
  691. }
  692. else { // well-behaving browsers
  693. var o = createElement(OBJECT);
  694. o.setAttribute("type", FLASH_MIME_TYPE);
  695. for (var m in attObj) {
  696. if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
  697. if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
  698. o.setAttribute("class", attObj[m]);
  699. }
  700. else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
  701. o.setAttribute(m, attObj[m]);
  702. }
  703. }
  704. }
  705. for (var n in parObj) {
  706. if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
  707. createObjParam(o, n, parObj[n]);
  708. }
  709. }
  710. el.parentNode.replaceChild(o, el);
  711. r = o;
  712. }
  713. }
  714. return r;
  715. }
  716. function createObjParam(el, pName, pValue) {
  717. var p = createElement("param");
  718. p.setAttribute("name", pName);
  719. p.setAttribute("value", pValue);
  720. el.appendChild(p);
  721. }
  722. /* Cross-browser SWF removal
  723. - Especially needed to safely and completely remove a SWF in Internet Explorer
  724. */
  725. function removeSWF(id) {
  726. var obj = getElementById(id);
  727. if (obj && obj.nodeName == "OBJECT") {
  728. if (ua.ie && ua.win) {
  729. obj.style.display = "none";
  730. (function(){
  731. if (obj.readyState == 4) {
  732. removeObjectInIE(id);
  733. }
  734. else {
  735. setTimeout(arguments.callee, 10);
  736. }
  737. })();
  738. }
  739. else {
  740. obj.parentNode.removeChild(obj);
  741. }
  742. }
  743. }
  744. function removeObjectInIE(id) {
  745. var obj = getElementById(id);
  746. if (obj) {
  747. for (var i in obj) {
  748. if (typeof obj[i] == "function") {
  749. obj[i] = null;
  750. }
  751. }
  752. obj.parentNode.removeChild(obj);
  753. }
  754. }
  755. /* Functions to optimize JavaScript compression
  756. */
  757. function getElementById(id) {
  758. var el = null;
  759. try {
  760. el = doc.getElementById(id);
  761. }
  762. catch (e) {}
  763. return el;
  764. }
  765. function createElement(el) {
  766. return doc.createElement(el);
  767. }
  768. /* Updated attachEvent function for Internet Explorer
  769. - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
  770. */
  771. function addListener(target, eventType, fn) {
  772. target.attachEvent(eventType, fn);
  773. listenersArr[listenersArr.length] = [target, eventType, fn];
  774. }
  775. /* Flash Player and SWF content version matching
  776. */
  777. function hasPlayerVersion(rv) {
  778. var pv = ua.pv, v = rv.split(".");
  779. v[0] = parseInt(v[0], 10);
  780. v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
  781. v[2] = parseInt(v[2], 10) || 0;
  782. return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
  783. }
  784. /* Cross-browser dynamic CSS creation
  785. - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
  786. */
  787. function createCSS(sel, decl, media, newStyle) {
  788. if (ua.ie && ua.mac) { return; }
  789. var h = doc.getElementsByTagName("head")[0];
  790. if (!h) { return; } // to also support badly authored HTML pages that lack a head element
  791. var m = (media && typeof media == "string") ? media : "screen";
  792. if (newStyle) {
  793. dynamicStylesheet = null;
  794. dynamicStylesheetMedia = null;
  795. }
  796. if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
  797. // create dynamic stylesheet + get a global reference to it
  798. var s = createElement("style");
  799. s.setAttribute("type", "text/css");
  800. s.setAttribute("media", m);
  801. dynamicStylesheet = h.appendChild(s);
  802. if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
  803. dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
  804. }
  805. dynamicStylesheetMedia = m;
  806. }
  807. // add style rule
  808. if (ua.ie && ua.win) {
  809. if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
  810. dynamicStylesheet.addRule(sel, decl);
  811. }
  812. }
  813. else {
  814. if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
  815. dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
  816. }
  817. }
  818. }
  819. function setVisibility(id, isVisible) {
  820. if (!autoHideShow) { return; }
  821. var v = isVisible ? "visible" : "hidden";
  822. if (isDomLoaded && getElementById(id)) {
  823. getElementById(id).style.visibility = v;
  824. }
  825. else {
  826. createCSS("#" + id, "visibility:" + v);
  827. }
  828. }
  829. /* Filter to avoid XSS attacks
  830. */
  831. function urlEncodeIfNecessary(s) {
  832. var regex = /[\\\"<>\.;]/;
  833. var hasBadChars = regex.exec(s) != null;
  834. return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
  835. }
  836. /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
  837. */
  838. var cleanup = function() {
  839. if (ua.ie && ua.win) {
  840. window.attachEvent("onunload", function() {
  841. // remove listeners to avoid memory leaks
  842. var ll = listenersArr.length;
  843. for (var i = 0; i < ll; i++) {
  844. listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
  845. }
  846. // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
  847. var il = objIdArr.length;
  848. for (var j = 0; j < il; j++) {
  849. removeSWF(objIdArr[j]);
  850. }
  851. // cleanup library's main closures to avoid memory leaks
  852. for (var k in ua) {
  853. ua[k] = null;
  854. }
  855. ua = null;
  856. for (var l in swfobject) {
  857. swfobject[l] = null;
  858. }
  859. swfobject = null;
  860. });
  861. }
  862. }();
  863. return {
  864. /* Public API
  865. - Reference: http://code.google.com/p/swfobject/wiki/documentation
  866. */
  867. registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
  868. if (ua.w3 && objectIdStr && swfVersionStr) {
  869. var regObj = {};
  870. regObj.id = objectIdStr;
  871. regObj.swfVersion = swfVersionStr;
  872. regObj.expressInstall = xiSwfUrlStr;
  873. regObj.callbackFn = callbackFn;
  874. regObjArr[regObjArr.length] = regObj;
  875. setVisibility(objectIdStr, false);
  876. }
  877. else if (callbackFn) {
  878. callbackFn({success:false, id:objectIdStr});
  879. }
  880. },
  881. getObjectById: function(objectIdStr) {
  882. if (ua.w3) {
  883. return getObjectById(objectIdStr);
  884. }
  885. },
  886. embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
  887. var callbackObj = {success:false, id:replaceElemIdStr};
  888. if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
  889. setVisibility(replaceElemIdStr, false);
  890. addDomLoadEvent(function() {
  891. widthStr += ""; // auto-convert to string
  892. heightStr += "";
  893. var att = {};
  894. if (attObj && typeof attObj === OBJECT) {
  895. for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
  896. att[i] = attObj[i];
  897. }
  898. }
  899. att.data = swfUrlStr;
  900. att.width = widthStr;
  901. att.height = heightStr;
  902. var par = {};
  903. if (parObj && typeof parObj === OBJECT) {
  904. for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
  905. par[j] = parObj[j];
  906. }
  907. }
  908. if (flashvarsObj && typeof flashvarsObj === OBJECT) {
  909. for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
  910. if (typeof par.flashvars != UNDEF) {
  911. par.flashvars += "&" + k + "=" + flashvarsObj[k];
  912. }
  913. else {
  914. par.flashvars = k + "=" + flashvarsObj[k];
  915. }
  916. }
  917. }
  918. if (hasPlayerVersion(swfVersionStr)) { // create SWF
  919. var obj = createSWF(att, par, replaceElemIdStr);
  920. if (att.id == replaceElemIdStr) {
  921. setVisibility(replaceElemIdStr, true);
  922. }
  923. callbackObj.success = true;
  924. callbackObj.ref = obj;
  925. }
  926. else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install
  927. att.data = xiSwfUrlStr;
  928. showExpressInstall(att, par, replaceElemIdStr, callbackFn);
  929. return;
  930. }
  931. else { // show alternative content
  932. setVisibility(replaceElemIdStr, true);
  933. }
  934. if (callbackFn) { callbackFn(callbackObj); }
  935. });
  936. }
  937. else if (callbackFn) { callbackFn(callbackObj); }
  938. },
  939. switchOffAutoHideShow: function() {
  940. autoHideShow = false;
  941. },
  942. ua: ua,
  943. getFlashPlayerVersion: function() {
  944. return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
  945. },
  946. hasFlashPlayerVersion: hasPlayerVersion,
  947. createSWF: function(attObj, parObj, replaceElemIdStr) {
  948. if (ua.w3) {
  949. return createSWF(attObj, parObj, replaceElemIdStr);
  950. }
  951. else {
  952. return undefined;
  953. }
  954. },
  955. showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
  956. if (ua.w3 && canExpressInstall()) {
  957. showExpressInstall(att, par, replaceElemIdStr, callbackFn);
  958. }
  959. },
  960. removeSWF: function(objElemIdStr) {
  961. if (ua.w3) {
  962. removeSWF(objElemIdStr);
  963. }
  964. },
  965. createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
  966. if (ua.w3) {
  967. createCSS(selStr, declStr, mediaStr, newStyleBoolean);
  968. }
  969. },
  970. addDomLoadEvent: addDomLoadEvent,
  971. addLoadEvent: addLoadEvent,
  972. getQueryParamValue: function(param) {
  973. var q = doc.location.search || doc.location.hash;
  974. if (q) {
  975. if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark
  976. if (param == null) {
  977. return urlEncodeIfNecessary(q);
  978. }
  979. var pairs = q.split("&");
  980. for (var i = 0; i < pairs.length; i++) {
  981. if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
  982. return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
  983. }
  984. }
  985. }
  986. return "";
  987. },
  988. // For internal usage only
  989. expressInstallCallback: function() {
  990. if (isExpressInstallActive) {
  991. var obj = getElementById(EXPRESS_INSTALL_ID);
  992. if (obj && storedAltContent) {
  993. obj.parentNode.replaceChild(storedAltContent, obj);
  994. if (storedAltContentId) {
  995. setVisibility(storedAltContentId, true);
  996. if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
  997. }
  998. if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
  999. }
  1000. isExpressInstallActive = false;
  1001. }
  1002. }
  1003. };
  1004. }();
  1005. /******************************************************************************/