swfobject_modified.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /*! SWFObject v2.0 <http://code.google.com/p/swfobject/>
  2. Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
  3. This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
  4. */
  5. var swfobject = function() {
  6. var UNDEF = "undefined",
  7. OBJECT = "object",
  8. SHOCKWAVE_FLASH = "Shockwave Flash",
  9. SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
  10. FLASH_MIME_TYPE = "application/x-shockwave-flash",
  11. EXPRESS_INSTALL_ID = "SWFObjectExprInst",
  12. win = window,
  13. doc = document,
  14. nav = navigator,
  15. domLoadFnArr = [],
  16. regObjArr = [],
  17. timer = null,
  18. storedAltContent = null,
  19. storedAltContentId = null,
  20. isDomLoaded = false,
  21. isExpressInstallActive = false;
  22. /* Centralized function for browser feature detection
  23. - Proprietary feature detection (conditional compiling) is used to detect Internet Explorer's features
  24. - User agent string detection is only used when no alternative is possible
  25. - Is executed directly for optimal performance
  26. */
  27. var ua = function() {
  28. var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF && typeof doc.appendChild != UNDEF && typeof doc.replaceChild != UNDEF && typeof doc.removeChild != UNDEF && typeof doc.cloneNode != UNDEF,
  29. playerVersion = [0,0,0],
  30. d = null;
  31. if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
  32. d = nav.plugins[SHOCKWAVE_FLASH].description;
  33. if (d) {
  34. d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
  35. playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
  36. playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
  37. playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
  38. }
  39. }
  40. else if (typeof win.ActiveXObject != UNDEF) {
  41. var a = null, fp6Crash = false;
  42. try {
  43. a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
  44. }
  45. catch(e) {
  46. try {
  47. a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
  48. playerVersion = [6,0,21];
  49. a.AllowScriptAccess = "always"; // Introduced in fp6.0.47
  50. }
  51. catch(e) {
  52. if (playerVersion[0] == 6) {
  53. fp6Crash = true;
  54. }
  55. }
  56. if (!fp6Crash) {
  57. try {
  58. a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
  59. }
  60. catch(e) {}
  61. }
  62. }
  63. if (!fp6Crash && a) { // a will return null when ActiveX is disabled
  64. try {
  65. d = a.GetVariable("$version"); // Will crash fp6.0.21/23/29
  66. if (d) {
  67. d = d.split(" ")[1].split(",");
  68. playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
  69. }
  70. }
  71. catch(e) {}
  72. }
  73. }
  74. var u = nav.userAgent.toLowerCase(),
  75. p = nav.platform.toLowerCase(),
  76. webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
  77. ie = false,
  78. windows = p ? /win/.test(p) : /win/.test(u),
  79. mac = p ? /mac/.test(p) : /mac/.test(u);
  80. /*@cc_on
  81. ie = true;
  82. @if (@_win32)
  83. windows = true;
  84. @elif (@_mac)
  85. mac = true;
  86. @end
  87. @*/
  88. return { w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac };
  89. }();
  90. /* Cross-browser onDomLoad
  91. - Based on Dean Edwards' solution: http://dean.edwards.name/weblog/2006/06/again/
  92. - Will fire an event as soon as the DOM of a page is loaded (supported by Gecko based browsers - like Firefox -, IE, Opera9+, Safari)
  93. */
  94. var onDomLoad = function() {
  95. if (!ua.w3cdom) {
  96. return;
  97. }
  98. addDomLoadEvent(main);
  99. if (ua.ie && ua.win) {
  100. try { // Avoid a possible Operation Aborted error
  101. doc.write("<scr" + "ipt id=__ie_ondomload defer=true src=//:></scr" + "ipt>"); // String is split into pieces to avoid Norton AV to add code that can cause errors
  102. var s = getElementById("__ie_ondomload");
  103. if (s) {
  104. s.onreadystatechange = function() {
  105. if (this.readyState == "complete") {
  106. this.parentNode.removeChild(this);
  107. callDomLoadFunctions();
  108. }
  109. };
  110. }
  111. }
  112. catch(e) {}
  113. }
  114. if (ua.webkit && typeof doc.readyState != UNDEF) {
  115. timer = setInterval(function() { if (/loaded|complete/.test(doc.readyState)) { callDomLoadFunctions(); }}, 10);
  116. }
  117. if (typeof doc.addEventListener != UNDEF) {
  118. doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, null);
  119. }
  120. addLoadEvent(callDomLoadFunctions);
  121. }();
  122. function callDomLoadFunctions() {
  123. if (isDomLoaded) {
  124. return;
  125. }
  126. if (ua.ie && ua.win) { // Test if we can really add elements to the DOM; we don't want to fire it too early
  127. var s = createElement("span");
  128. try { // Avoid a possible Operation Aborted error
  129. var t = doc.getElementsByTagName("body")[0].appendChild(s);
  130. t.parentNode.removeChild(t);
  131. }
  132. catch (e) {
  133. return;
  134. }
  135. }
  136. isDomLoaded = true;
  137. if (timer) {
  138. clearInterval(timer);
  139. timer = null;
  140. }
  141. var dl = domLoadFnArr.length;
  142. for (var i = 0; i < dl; i++) {
  143. domLoadFnArr[i]();
  144. }
  145. }
  146. function addDomLoadEvent(fn) {
  147. if (isDomLoaded) {
  148. fn();
  149. }
  150. else {
  151. domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
  152. }
  153. }
  154. /* Cross-browser onload
  155. - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
  156. - Will fire an event as soon as a web page including all of its assets are loaded
  157. */
  158. function addLoadEvent(fn) {
  159. if (typeof win.addEventListener != UNDEF) {
  160. win.addEventListener("load", fn, false);
  161. }
  162. else if (typeof doc.addEventListener != UNDEF) {
  163. doc.addEventListener("load", fn, false);
  164. }
  165. else if (typeof win.attachEvent != UNDEF) {
  166. win.attachEvent("onload", fn);
  167. }
  168. else if (typeof win.onload == "function") {
  169. var fnOld = win.onload;
  170. win.onload = function() {
  171. fnOld();
  172. fn();
  173. };
  174. }
  175. else {
  176. win.onload = fn;
  177. }
  178. }
  179. /* Main function
  180. - Will preferably execute onDomLoad, otherwise onload (as a fallback)
  181. */
  182. function main() { // Static publishing only
  183. var rl = regObjArr.length;
  184. for (var i = 0; i < rl; i++) { // For each registered object element
  185. var id = regObjArr[i].id;
  186. if (ua.pv[0] > 0) {
  187. var obj = getElementById(id);
  188. if (obj) {
  189. regObjArr[i].width = obj.getAttribute("width") ? obj.getAttribute("width") : "0";
  190. regObjArr[i].height = obj.getAttribute("height") ? obj.getAttribute("height") : "0";
  191. if (hasPlayerVersion(regObjArr[i].swfVersion)) { // Flash plug-in version >= Flash content version: Houston, we have a match!
  192. if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements
  193. fixParams(obj);
  194. }
  195. setVisibility(id, true);
  196. }
  197. else if (regObjArr[i].expressInstall && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) { // Show the Adobe Express Install dialog if set by the web page author and if supported (fp6.0.65+ on Win/Mac OS only)
  198. showExpressInstall(regObjArr[i]);
  199. }
  200. else { // Flash plug-in and Flash content version mismatch: display alternative content instead of Flash content
  201. displayAltContent(obj);
  202. }
  203. }
  204. }
  205. else { // If no fp is installed, we let the object element do its job (show alternative content)
  206. setVisibility(id, true);
  207. }
  208. }
  209. }
  210. /* Fix nested param elements, which are ignored by older webkit engines
  211. - This includes Safari up to and including version 1.2.2 on Mac OS 10.3
  212. - Fall back to the proprietary embed element
  213. */
  214. function fixParams(obj) {
  215. var nestedObj = obj.getElementsByTagName(OBJECT)[0];
  216. if (nestedObj) {
  217. var e = createElement("embed"), a = nestedObj.attributes;
  218. if (a) {
  219. var al = a.length;
  220. for (var i = 0; i < al; i++) {
  221. if (a[i].nodeName.toLowerCase() == "data") {
  222. e.setAttribute("src", a[i].nodeValue);
  223. }
  224. else {
  225. e.setAttribute(a[i].nodeName, a[i].nodeValue);
  226. }
  227. }
  228. }
  229. var c = nestedObj.childNodes;
  230. if (c) {
  231. var cl = c.length;
  232. for (var j = 0; j < cl; j++) {
  233. if (c[j].nodeType == 1 && c[j].nodeName.toLowerCase() == "param") {
  234. e.setAttribute(c[j].getAttribute("name"), c[j].getAttribute("value"));
  235. }
  236. }
  237. }
  238. obj.parentNode.replaceChild(e, obj);
  239. }
  240. }
  241. /* Fix hanging audio/video threads and force open sockets and NetConnections to disconnect
  242. - Occurs when unloading a web page in IE using fp8+ and innerHTML/outerHTML
  243. - Dynamic publishing only
  244. */
  245. function fixObjectLeaks(id) {
  246. if (ua.ie && ua.win && hasPlayerVersion("8.0.0")) {
  247. win.attachEvent("onunload", function () {
  248. var obj = getElementById(id);
  249. if (obj) {
  250. for (var i in obj) {
  251. if (typeof obj[i] == "function") {
  252. obj[i] = function() {};
  253. }
  254. }
  255. obj.parentNode.removeChild(obj);
  256. }
  257. });
  258. }
  259. }
  260. /* Show the Adobe Express Install dialog
  261. - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
  262. */
  263. function showExpressInstall(regObj) {
  264. isExpressInstallActive = true;
  265. var obj = getElementById(regObj.id);
  266. if (obj) {
  267. if (regObj.altContentId) {
  268. var ac = getElementById(regObj.altContentId);
  269. if (ac) {
  270. storedAltContent = ac;
  271. storedAltContentId = regObj.altContentId;
  272. }
  273. }
  274. else {
  275. storedAltContent = abstractAltContent(obj);
  276. }
  277. if (!(/%$/.test(regObj.width)) && parseInt(regObj.width, 10) < 310) {
  278. regObj.width = "310";
  279. }
  280. if (!(/%$/.test(regObj.height)) && parseInt(regObj.height, 10) < 137) {
  281. regObj.height = "137";
  282. }
  283. doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
  284. var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
  285. dt = doc.title,
  286. fv = "MMredirectURL=" + win.location + "&MMplayerType=" + pt + "&MMdoctitle=" + dt,
  287. replaceId = regObj.id;
  288. // For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
  289. // In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
  290. if (ua.ie && ua.win && obj.readyState != 4) {
  291. var newObj = createElement("div");
  292. replaceId += "SWFObjectNew";
  293. newObj.setAttribute("id", replaceId);
  294. obj.parentNode.insertBefore(newObj, obj); // Insert placeholder div that will be replaced by the object element that loads expressinstall.swf
  295. obj.style.display = "none";
  296. win.attachEvent("onload", function() { obj.parentNode.removeChild(obj); });
  297. }
  298. createSWF({ data:regObj.expressInstall, id:EXPRESS_INSTALL_ID, width:regObj.width, height:regObj.height }, { flashvars:fv }, replaceId);
  299. }
  300. }
  301. /* Functions to abstract and display alternative content
  302. */
  303. function displayAltContent(obj) {
  304. if (ua.ie && ua.win && obj.readyState != 4) {
  305. // For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
  306. // In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
  307. var el = createElement("div");
  308. obj.parentNode.insertBefore(el, obj); // Insert placeholder div that will be replaced by the alternative content
  309. el.parentNode.replaceChild(abstractAltContent(obj), el);
  310. obj.style.display = "none";
  311. win.attachEvent("onload", function() { obj.parentNode.removeChild(obj); });
  312. }
  313. else {
  314. obj.parentNode.replaceChild(abstractAltContent(obj), obj);
  315. }
  316. }
  317. function abstractAltContent(obj) {
  318. var ac = createElement("div");
  319. if (ua.win && ua.ie) {
  320. ac.innerHTML = obj.innerHTML;
  321. }
  322. else {
  323. var nestedObj = obj.getElementsByTagName(OBJECT)[0];
  324. if (nestedObj) {
  325. var c = nestedObj.childNodes;
  326. if (c) {
  327. var cl = c.length;
  328. for (var i = 0; i < cl; i++) {
  329. if (!(c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "param") && !(c[i].nodeType == 8)) {
  330. ac.appendChild(c[i].cloneNode(true));
  331. }
  332. }
  333. }
  334. }
  335. }
  336. return ac;
  337. }
  338. /* Cross-browser dynamic SWF creation
  339. */
  340. function createSWF(attObj, parObj, id) {
  341. var r, el = getElementById(id);
  342. if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
  343. attObj.id = id;
  344. }
  345. if (ua.ie && ua.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
  346. var att = "";
  347. for (var i in attObj) {
  348. if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries, like Object.prototype.toJSONString = function() {}
  349. if (i == "data") {
  350. parObj.movie = attObj[i];
  351. }
  352. else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
  353. att += ' class="' + attObj[i] + '"';
  354. }
  355. else if (i != "classid") {
  356. att += ' ' + i + '="' + attObj[i] + '"';
  357. }
  358. }
  359. }
  360. var par = "";
  361. for (var j in parObj) {
  362. if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
  363. par += '<param name="' + j + '" value="' + parObj[j] + '" />';
  364. }
  365. }
  366. el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
  367. fixObjectLeaks(attObj.id); // This bug affects dynamic publishing only
  368. r = getElementById(attObj.id);
  369. }
  370. else if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements: fall back to the proprietary embed element
  371. var e = createElement("embed");
  372. e.setAttribute("type", FLASH_MIME_TYPE);
  373. for (var k in attObj) {
  374. if (attObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
  375. if (k == "data") {
  376. e.setAttribute("src", attObj[k]);
  377. }
  378. else if (k.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
  379. e.setAttribute("class", attObj[k]);
  380. }
  381. else if (k != "classid") { // Filter out IE specific attribute
  382. e.setAttribute(k, attObj[k]);
  383. }
  384. }
  385. }
  386. for (var l in parObj) {
  387. if (parObj[l] != Object.prototype[l]) { // Filter out prototype additions from other potential libraries
  388. if (l != "movie") { // Filter out IE specific param element
  389. e.setAttribute(l, parObj[l]);
  390. }
  391. }
  392. }
  393. el.parentNode.replaceChild(e, el);
  394. r = e;
  395. }
  396. else { // Well-behaving browsers
  397. var o = createElement(OBJECT);
  398. o.setAttribute("type", FLASH_MIME_TYPE);
  399. for (var m in attObj) {
  400. if (attObj[m] != Object.prototype[m]) { // Filter out prototype additions from other potential libraries
  401. if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
  402. o.setAttribute("class", attObj[m]);
  403. }
  404. else if (m != "classid") { // Filter out IE specific attribute
  405. o.setAttribute(m, attObj[m]);
  406. }
  407. }
  408. }
  409. for (var n in parObj) {
  410. if (parObj[n] != Object.prototype[n] && n != "movie") { // Filter out prototype additions from other potential libraries and IE specific param element
  411. createObjParam(o, n, parObj[n]);
  412. }
  413. }
  414. el.parentNode.replaceChild(o, el);
  415. r = o;
  416. }
  417. return r;
  418. }
  419. function createObjParam(el, pName, pValue) {
  420. var p = createElement("param");
  421. p.setAttribute("name", pName);
  422. p.setAttribute("value", pValue);
  423. el.appendChild(p);
  424. }
  425. function getElementById(id) {
  426. return doc.getElementById(id);
  427. }
  428. function createElement(el) {
  429. return doc.createElement(el);
  430. }
  431. function hasPlayerVersion(rv) {
  432. var pv = ua.pv, v = rv.split(".");
  433. v[0] = parseInt(v[0], 10);
  434. v[1] = parseInt(v[1], 10);
  435. v[2] = parseInt(v[2], 10);
  436. 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;
  437. }
  438. /* Cross-browser dynamic CSS creation
  439. - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
  440. */
  441. function createCSS(sel, decl) {
  442. if (ua.ie && ua.mac) {
  443. return;
  444. }
  445. var h = doc.getElementsByTagName("head")[0], s = createElement("style");
  446. s.setAttribute("type", "text/css");
  447. s.setAttribute("media", "screen");
  448. if (!(ua.ie && ua.win) && typeof doc.createTextNode != UNDEF) {
  449. s.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
  450. }
  451. h.appendChild(s);
  452. if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
  453. var ls = doc.styleSheets[doc.styleSheets.length - 1];
  454. if (typeof ls.addRule == OBJECT) {
  455. ls.addRule(sel, decl);
  456. }
  457. }
  458. }
  459. function setVisibility(id, isVisible) {
  460. var v = isVisible ? "visible" : "hidden";
  461. if (isDomLoaded) {
  462. getElementById(id).style.visibility = v;
  463. }
  464. else {
  465. createCSS("#" + id, "visibility:" + v);
  466. }
  467. }
  468. function getTargetVersion(obj) {
  469. if (!obj)
  470. return 0;
  471. var c = obj.childNodes;
  472. var cl = c.length;
  473. for (var i = 0; i < cl; i++) {
  474. if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "object") {
  475. c = c[i].childNodes;
  476. cl = c.length;
  477. i = 0;
  478. }
  479. if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "param" && c[i].getAttribute("name") == "swfversion") {
  480. return c[i].getAttribute("value");
  481. }
  482. }
  483. return 0;
  484. }
  485. function getExpressInstall(obj) {
  486. if (!obj)
  487. return "";
  488. var c = obj.childNodes;
  489. var cl = c.length;
  490. for (var i = 0; i < cl; i++) {
  491. if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "object") {
  492. c = c[i].childNodes;
  493. cl = c.length;
  494. i = 0;
  495. }
  496. if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "param" && c[i].getAttribute("name") == "expressinstall") {
  497. return c[i].getAttribute("value");
  498. }
  499. }
  500. return "";
  501. }
  502. return {
  503. /* Public API
  504. - Reference: http://code.google.com/p/swfobject/wiki/SWFObject_2_0_documentation
  505. */
  506. registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr) {
  507. if (!ua.w3cdom || !objectIdStr) {
  508. return;
  509. }
  510. var obj = document.getElementById(objectIdStr);
  511. var xi = getExpressInstall(obj);
  512. var regObj = {};
  513. regObj.id = objectIdStr;
  514. regObj.swfVersion = swfVersionStr ? swfVersionStr : getTargetVersion(obj);
  515. regObj.expressInstall = xiSwfUrlStr ? xiSwfUrlStr : ((xi != "") ? xi : false);
  516. regObjArr[regObjArr.length] = regObj;
  517. setVisibility(objectIdStr, false);
  518. },
  519. getObjectById: function(objectIdStr) {
  520. var r = null;
  521. if (ua.w3cdom && isDomLoaded) {
  522. var o = getElementById(objectIdStr);
  523. if (o) {
  524. var n = o.getElementsByTagName(OBJECT)[0];
  525. if (!n || (n && typeof o.SetVariable != UNDEF)) {
  526. r = o;
  527. }
  528. else if (typeof n.SetVariable != UNDEF) {
  529. r = n;
  530. }
  531. }
  532. }
  533. return r;
  534. },
  535. embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj) {
  536. if (!ua.w3cdom || !swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr || !swfVersionStr) {
  537. return;
  538. }
  539. widthStr += ""; // Auto-convert to string to make it idiot proof
  540. heightStr += "";
  541. if (hasPlayerVersion(swfVersionStr)) {
  542. setVisibility(replaceElemIdStr, false);
  543. var att = (typeof attObj == OBJECT) ? attObj : {};
  544. att.data = swfUrlStr;
  545. att.width = widthStr;
  546. att.height = heightStr;
  547. var par = (typeof parObj == OBJECT) ? parObj : {};
  548. if (typeof flashvarsObj == OBJECT) {
  549. for (var i in flashvarsObj) {
  550. if (flashvarsObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries
  551. if (typeof par.flashvars != UNDEF) {
  552. par.flashvars += "&" + i + "=" + flashvarsObj[i];
  553. }
  554. else {
  555. par.flashvars = i + "=" + flashvarsObj[i];
  556. }
  557. }
  558. }
  559. }
  560. addDomLoadEvent(function() {
  561. createSWF(att, par, replaceElemIdStr);
  562. if (att.id == replaceElemIdStr) {
  563. setVisibility(replaceElemIdStr, true);
  564. }
  565. });
  566. }
  567. else if (xiSwfUrlStr && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) {
  568. setVisibility(replaceElemIdStr, false);
  569. addDomLoadEvent(function() {
  570. var regObj = {};
  571. regObj.id = regObj.altContentId = replaceElemIdStr;
  572. regObj.width = widthStr;
  573. regObj.height = heightStr;
  574. regObj.expressInstall = xiSwfUrlStr;
  575. showExpressInstall(regObj);
  576. });
  577. }
  578. },
  579. getFlashPlayerVersion: function() {
  580. return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
  581. },
  582. hasFlashPlayerVersion:hasPlayerVersion,
  583. createSWF: function(attObj, parObj, replaceElemIdStr) {
  584. if (ua.w3cdom && isDomLoaded) {
  585. return createSWF(attObj, parObj, replaceElemIdStr);
  586. }
  587. else {
  588. return undefined;
  589. }
  590. },
  591. createCSS: function(sel, decl) {
  592. if (ua.w3cdom) {
  593. createCSS(sel, decl);
  594. }
  595. },
  596. addDomLoadEvent:addDomLoadEvent,
  597. addLoadEvent:addLoadEvent,
  598. getQueryParamValue: function(param) {
  599. var q = doc.location.search || doc.location.hash;
  600. if (param == null) {
  601. return q;
  602. }
  603. if(q) {
  604. var pairs = q.substring(1).split("&");
  605. for (var i = 0; i < pairs.length; i++) {
  606. if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
  607. return pairs[i].substring((pairs[i].indexOf("=") + 1));
  608. }
  609. }
  610. }
  611. return "";
  612. },
  613. // For internal usage only
  614. expressInstallCallback: function() {
  615. if (isExpressInstallActive && storedAltContent) {
  616. var obj = getElementById(EXPRESS_INSTALL_ID);
  617. if (obj) {
  618. obj.parentNode.replaceChild(storedAltContent, obj);
  619. if (storedAltContentId) {
  620. setVisibility(storedAltContentId, true);
  621. if (ua.ie && ua.win) {
  622. storedAltContent.style.display = "block";
  623. }
  624. }
  625. storedAltContent = null;
  626. storedAltContentId = null;
  627. isExpressInstallActive = false;
  628. }
  629. }
  630. }
  631. };
  632. }();