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