/*! swfobject v2.1 copyright (c) 2007-2008 geoff stearns, michael williams, and bobby van der sluis this software is released under the mit license */ var swfobject = function() { var undef = "undefined", object = "object", shockwave_flash = "shockwave flash", shockwave_flash_ax = "shockwaveflash.shockwaveflash", flash_mime_type = "application/x-shockwave-flash", express_install_id = "swfobjectexprinst", win = window, doc = document, nav = navigator, domloadfnarr = [], regobjarr = [], objidarr = [], listenersarr = [], script, timer = null, storedaltcontent = null, storedaltcontentid = null, isdomloaded = false, isexpressinstallactive = false; /* centralized function for browser feature detection - proprietary feature detection (conditional compiling) is used to detect internet explorer's features - user agent string detection is only used when no alternative is possible - is executed directly for optimal performance */ var ua = function() { var w3cdom = typeof doc.getelementbyid != undef && typeof doc.getelementsbytagname != undef && typeof doc.createelement != undef, playerversion = [0,0,0], d = null; if (typeof nav.plugins != undef && typeof nav.plugins[shockwave_flash] == object) { d = nav.plugins[shockwave_flash].description; 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+ d = d.replace(/^.*\s+(\s+\s+\s+$)/, "$1"); playerversion[0] = parseint(d.replace(/^(.*)\..*$/, "$1"), 10); playerversion[1] = parseint(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); playerversion[2] = /r/.test(d) ? parseint(d.replace(/^.*r(.*)$/, "$1"), 10) : 0; } } else if (typeof win.activexobject != undef) { var a = null, fp6crash = false; try { a = new activexobject(shockwave_flash_ax + ".7"); } catch(e) { try { a = new activexobject(shockwave_flash_ax + ".6"); playerversion = [6,0,21]; a.allowscriptaccess = "always"; // introduced in fp6.0.47 } catch(e) { if (playerversion[0] == 6) { fp6crash = true; } } if (!fp6crash) { try { a = new activexobject(shockwave_flash_ax); } catch(e) {} } } if (!fp6crash && a) { // a will return null when activex is disabled try { d = a.getvariable("$version"); // will crash fp6.0.21/23/29 if (d) { d = d.split(" ")[1].split(","); playerversion = [parseint(d[0], 10), parseint(d[1], 10), parseint(d[2], 10)]; } } catch(e) {} } } var u = nav.useragent.tolowercase(), p = nav.platform.tolowercase(), webkit = /webkit/.test(u) ? parsefloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit ie = false, windows = p ? /win/.test(p) : /win/.test(u), mac = p ? /mac/.test(p) : /mac/.test(u); /*@cc_on ie = true; @if (@_win32) windows = true; @elif (@_mac) mac = true; @end @*/ return { w3cdom:w3cdom, pv:playerversion, webkit:webkit, ie:ie, win:windows, mac:mac }; }(); /* cross-browser ondomload - based on dean edwards' solution: http://dean.edwards.name/weblog/2006/06/again/ - will fire an event as soon as the dom of a page is loaded (supported by gecko based browsers - like firefox -, ie, opera9+, safari) */ var ondomload = function() { if (!ua.w3cdom) { return; } adddomloadevent(main); if (ua.ie && ua.win) { try { // avoid a possible operation aborted error doc.write(""); // string is split into pieces to avoid norton av to add code that can cause errors script = getelementbyid("__ie_ondomload"); if (script) { addlistener(script, "onreadystatechange", checkreadystate); } } catch(e) {} } if (ua.webkit && typeof doc.readystate != undef) { timer = setinterval(function() { if (/loaded|complete/.test(doc.readystate)) { calldomloadfunctions(); }}, 10); } if (typeof doc.addeventlistener != undef) { doc.addeventlistener("domcontentloaded", calldomloadfunctions, null); } addloadevent(calldomloadfunctions); }(); function checkreadystate() { if (script.readystate == "complete") { script.parentnode.removechild(script); calldomloadfunctions(); } } function calldomloadfunctions() { if (isdomloaded) { return; } if (ua.ie && ua.win) { // test if we can really add elements to the dom; we don't want to fire it too early var s = createelement("span"); try { // avoid a possible operation aborted error var t = doc.getelementsbytagname("body")[0].appendchild(s); t.parentnode.removechild(t); } catch (e) { return; } } isdomloaded = true; if (timer) { clearinterval(timer); timer = null; } var dl = domloadfnarr.length; for (var i = 0; i < dl; i++) { domloadfnarr[i](); } } function adddomloadevent(fn) { if (isdomloaded) { fn(); } else { domloadfnarr[domloadfnarr.length] = fn; // array.push() is only available in ie5.5+ } } /* cross-browser onload - based on james edwards' solution: http://brothercake.com/site/resources/scripts/onload/ - will fire an event as soon as a web page including all of its assets are loaded */ function addloadevent(fn) { if (typeof win.addeventlistener != undef) { win.addeventlistener("load", fn, false); } else if (typeof doc.addeventlistener != undef) { doc.addeventlistener("load", fn, false); } else if (typeof win.attachevent != undef) { addlistener(win, "onload", fn); } else if (typeof win.onload == "function") { var fnold = win.onload; win.onload = function() { fnold(); fn(); }; } else { win.onload = fn; } } /* main function - will preferably execute ondomload, otherwise onload (as a fallback) */ function main() { // static publishing only var rl = regobjarr.length; for (var i = 0; i < rl; i++) { // for each registered object element var id = regobjarr[i].id; if (ua.pv[0] > 0) { var obj = getelementbyid(id); if (obj) { regobjarr[i].width = obj.getattribute("width") ? obj.getattribute("width") : "0"; regobjarr[i].height = obj.getattribute("height") ? obj.getattribute("height") : "0"; if (hasplayerversion(regobjarr[i].swfversion)) { // flash plug-in version >= flash content version: houston, we have a match! if (ua.webkit && ua.webkit < 312) { // older webkit engines ignore the object element's nested param elements fixparams(obj); } setvisibility(id, true); } 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) showexpressinstall(regobjarr[i]); } else { // flash plug-in and flash content version mismatch: display alternative content instead of flash content displayaltcontent(obj); } } } else { // if no fp is installed, we let the object element do its job (show alternative content) setvisibility(id, true); } } } /* fix nested param elements, which are ignored by older webkit engines - this includes safari up to and including version 1.2.2 on mac os 10.3 - fall back to the proprietary embed element */ function fixparams(obj) { var nestedobj = obj.getelementsbytagname(object)[0]; if (nestedobj) { var e = createelement("embed"), a = nestedobj.attributes; if (a) { var al = a.length; for (var i = 0; i < al; i++) { if (a[i].nodename == "data") { e.setattribute("src", a[i].nodevalue); } else { e.setattribute(a[i].nodename, a[i].nodevalue); } } } var c = nestedobj.childnodes; if (c) { var cl = c.length; for (var j = 0; j < cl; j++) { if (c[j].nodetype == 1 && c[j].nodename == "param") { e.setattribute(c[j].getattribute("name"), c[j].getattribute("value")); } } } obj.parentnode.replacechild(e, obj); } } /* show the adobe express install dialog - reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 */ function showexpressinstall(regobj) { isexpressinstallactive = true; var obj = getelementbyid(regobj.id); if (obj) { if (regobj.altcontentid) { var ac = getelementbyid(regobj.altcontentid); if (ac) { storedaltcontent = ac; storedaltcontentid = regobj.altcontentid; } } else { storedaltcontent = abstractaltcontent(obj); } if (!(/%$/.test(regobj.width)) && parseint(regobj.width, 10) < 310) { regobj.width = "310"; } if (!(/%$/.test(regobj.height)) && parseint(regobj.height, 10) < 137) { regobj.height = "137"; } doc.title = doc.title.slice(0, 47) + " - flash player installation"; var pt = ua.ie && ua.win ? "activex" : "plugin", dt = doc.title, fv = "mmredirecturl=" + win.location + "&mmplayertype=" + pt + "&mmdoctitle=" + dt, replaceid = regobj.id; // 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 // in ie you cannot properly cancel a loading swf file without breaking browser load references, also obj.onreadystatechange doesn't work if (ua.ie && ua.win && obj.readystate != 4) { var newobj = createelement("div"); replaceid += "swfobjectnew"; newobj.setattribute("id", replaceid); obj.parentnode.insertbefore(newobj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf obj.style.display = "none"; var fn = function() { obj.parentnode.removechild(obj); }; addlistener(win, "onload", fn); } createswf({ data:regobj.expressinstall, id:express_install_id, width:regobj.width, height:regobj.height }, { flashvars:fv }, replaceid); } } /* functions to abstract and display alternative content */ function displayaltcontent(obj) { if (ua.ie && ua.win && obj.readystate != 4) { // 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 // in ie you cannot properly cancel a loading swf file without breaking browser load references, also obj.onreadystatechange doesn't work var el = createelement("div"); obj.parentnode.insertbefore(el, obj); // insert placeholder div that will be replaced by the alternative content el.parentnode.replacechild(abstractaltcontent(obj), el); obj.style.display = "none"; var fn = function() { obj.parentnode.removechild(obj); }; addlistener(win, "onload", fn); } else { obj.parentnode.replacechild(abstractaltcontent(obj), obj); } } function abstractaltcontent(obj) { var ac = createelement("div"); if (ua.win && ua.ie) { ac.innerhtml = obj.innerhtml; } else { var nestedobj = obj.getelementsbytagname(object)[0]; if (nestedobj) { var c = nestedobj.childnodes; if (c) { var cl = c.length; for (var i = 0; i < cl; i++) { if (!(c[i].nodetype == 1 && c[i].nodename == "param") && !(c[i].nodetype == 8)) { ac.appendchild(c[i].clonenode(true)); } } } } } return ac; } /* cross-browser dynamic swf creation */ function createswf(attobj, parobj, id) { var r, el = getelementbyid(id); if (el) { if (typeof attobj.id == undef) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content attobj.id = id; } if (ua.ie && ua.win) { // ie, the object element and w3c dom methods do not combine: fall back to outerhtml var att = ""; for (var i in attobj) { if (attobj[i] != object.prototype[i]) { // filter out prototype additions from other potential libraries, like object.prototype.tojsonstring = function() {} if (i.tolowercase() == "data") { parobj.movie = attobj[i]; } else if (i.tolowercase() == "styleclass") { // 'class' is an ecma4 reserved keyword att += ' class="' + attobj[i] + '"'; } else if (i.tolowercase() != "classid") { att += ' ' + i + '="' + attobj[i] + '"'; } } } var par = ""; for (var j in parobj) { if (parobj[j] != object.prototype[j]) { // filter out prototype additions from other potential libraries par += ''; } } el.outerhtml = '' + par + ''; objidarr[objidarr.length] = attobj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) r = getelementbyid(attobj.id); } 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 var e = createelement("embed"); e.setattribute("type", flash_mime_type); for (var k in attobj) { if (attobj[k] != object.prototype[k]) { // filter out prototype additions from other potential libraries if (k.tolowercase() == "data") { e.setattribute("src", attobj[k]); } else if (k.tolowercase() == "styleclass") { // 'class' is an ecma4 reserved keyword e.setattribute("class", attobj[k]); } else if (k.tolowercase() != "classid") { // filter out ie specific attribute e.setattribute(k, attobj[k]); } } } for (var l in parobj) { if (parobj[l] != object.prototype[l]) { // filter out prototype additions from other potential libraries if (l.tolowercase() != "movie") { // filter out ie specific param element e.setattribute(l, parobj[l]); } } } el.parentnode.replacechild(e, el); r = e; } else { // well-behaving browsers var o = createelement(object); o.setattribute("type", flash_mime_type); for (var m in attobj) { if (attobj[m] != object.prototype[m]) { // filter out prototype additions from other potential libraries if (m.tolowercase() == "styleclass") { // 'class' is an ecma4 reserved keyword o.setattribute("class", attobj[m]); } else if (m.tolowercase() != "classid") { // filter out ie specific attribute o.setattribute(m, attobj[m]); } } } for (var n in parobj) { if (parobj[n] != object.prototype[n] && n.tolowercase() != "movie") { // filter out prototype additions from other potential libraries and ie specific param element createobjparam(o, n, parobj[n]); } } el.parentnode.replacechild(o, el); r = o; } } return r; } function createobjparam(el, pname, pvalue) { var p = createelement("param"); p.setattribute("name", pname); p.setattribute("value", pvalue); el.appendchild(p); } /* cross-browser swf removal - especially needed to safely and completely remove a swf in internet explorer */ function removeswf(id) { var obj = getelementbyid(id); if (obj && (obj.nodename == "object" || obj.nodename == "embed")) { if (ua.ie && ua.win) { if (obj.readystate == 4) { removeobjectinie(id); } else { win.attachevent("onload", function() { removeobjectinie(id); }); } } else { obj.parentnode.removechild(obj); } } } function removeobjectinie(id) { var obj = getelementbyid(id); if (obj) { for (var i in obj) { if (typeof obj[i] == "function") { obj[i] = null; } } obj.parentnode.removechild(obj); } } /* functions to optimize javascript compression */ function getelementbyid(id) { var el = null; try { el = doc.getelementbyid(id); } catch (e) {} return el; } function createelement(el) { return doc.createelement(el); } /* updated attachevent function for internet explorer - stores attachevent information in an array, so on unload the detachevent functions can be called to avoid memory leaks */ function addlistener(target, eventtype, fn) { target.attachevent(eventtype, fn); listenersarr[listenersarr.length] = [target, eventtype, fn]; } /* flash player and swf content version matching */ function hasplayerversion(rv) { var pv = ua.pv, v = rv.split("."); v[0] = parseint(v[0], 10); v[1] = parseint(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" v[2] = parseint(v[2], 10) || 0; 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; } /* cross-browser dynamic css creation - based on bobby van der sluis' solution: http://www.bobbyvandersluis.com/articles/dynamiccss.php */ function createcss(sel, decl) { if (ua.ie && ua.mac) { return; } var h = doc.getelementsbytagname("head")[0], s = createelement("style"); s.setattribute("type", "text/css"); s.setattribute("media", "screen"); if (!(ua.ie && ua.win) && typeof doc.createtextnode != undef) { s.appendchild(doc.createtextnode(sel + " {" + decl + "}")); } h.appendchild(s); if (ua.ie && ua.win && typeof doc.stylesheets != undef && doc.stylesheets.length > 0) { var ls = doc.stylesheets[doc.stylesheets.length - 1]; if (typeof ls.addrule == object) { ls.addrule(sel, decl); } } } function setvisibility(id, isvisible) { var v = isvisible ? "visible" : "hidden"; if (isdomloaded && getelementbyid(id)) { getelementbyid(id).style.visibility = v; } else { createcss("#" + id, "visibility:" + v); } } /* filter to avoid xss attacks */ function urlencodeifnecessary(s) { var regex = /[\\\"<>\.;]/; var hasbadchars = regex.exec(s) != null; return hasbadchars ? encodeuricomponent(s) : s; } /* release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/netconnections to disconnect (internet explorer only) */ var cleanup = function() { if (ua.ie && ua.win) { window.attachevent("onunload", function() { // remove listeners to avoid memory leaks var ll = listenersarr.length; for (var i = 0; i < ll; i++) { listenersarr[i][0].detachevent(listenersarr[i][1], listenersarr[i][2]); } // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and netconnections to disconnect var il = objidarr.length; for (var j = 0; j < il; j++) { removeswf(objidarr[j]); } // cleanup library's main closures to avoid memory leaks for (var k in ua) { ua[k] = null; } ua = null; for (var l in swfobject) { swfobject[l] = null; } swfobject = null; }); } }(); return { /* public api - reference: http://code.google.com/p/swfobject/wiki/swfobject_2_0_documentation */ registerobject: function(objectidstr, swfversionstr, xiswfurlstr) { if (!ua.w3cdom || !objectidstr || !swfversionstr) { return; } var regobj = {}; regobj.id = objectidstr; regobj.swfversion = swfversionstr; regobj.expressinstall = xiswfurlstr ? xiswfurlstr : false; regobjarr[regobjarr.length] = regobj; setvisibility(objectidstr, false); }, getobjectbyid: function(objectidstr) { var r = null; if (ua.w3cdom) { var o = getelementbyid(objectidstr); if (o) { var n = o.getelementsbytagname(object)[0]; if (!n || (n && typeof o.setvariable != undef)) { r = o; } else if (typeof n.setvariable != undef) { r = n; } } } return r; }, embedswf: function(swfurlstr, replaceelemidstr, widthstr, heightstr, swfversionstr, xiswfurlstr, flashvarsobj, parobj, attobj) { if (!ua.w3cdom || !swfurlstr || !replaceelemidstr || !widthstr || !heightstr || !swfversionstr) { return; } widthstr += ""; // auto-convert to string heightstr += ""; if (hasplayerversion(swfversionstr)) { setvisibility(replaceelemidstr, false); var att = {}; if (attobj && typeof attobj === object) { for (var i in attobj) { if (attobj[i] != object.prototype[i]) { // filter out prototype additions from other potential libraries att[i] = attobj[i]; } } } att.data = swfurlstr; att.width = widthstr; att.height = heightstr; var par = {}; if (parobj && typeof parobj === object) { for (var j in parobj) { if (parobj[j] != object.prototype[j]) { // filter out prototype additions from other potential libraries par[j] = parobj[j]; } } } if (flashvarsobj && typeof flashvarsobj === object) { for (var k in flashvarsobj) { if (flashvarsobj[k] != object.prototype[k]) { // filter out prototype additions from other potential libraries if (typeof par.flashvars != undef) { par.flashvars += "&" + k + "=" + flashvarsobj[k]; } else { par.flashvars = k + "=" + flashvarsobj[k]; } } } } adddomloadevent(function() { createswf(att, par, replaceelemidstr); if (att.id == replaceelemidstr) { setvisibility(replaceelemidstr, true); } }); } else if (xiswfurlstr && !isexpressinstallactive && hasplayerversion("6.0.65") && (ua.win || ua.mac)) { isexpressinstallactive = true; // deferred execution setvisibility(replaceelemidstr, false); adddomloadevent(function() { var regobj = {}; regobj.id = regobj.altcontentid = replaceelemidstr; regobj.width = widthstr; regobj.height = heightstr; regobj.expressinstall = xiswfurlstr; showexpressinstall(regobj); }); } }, getflashplayerversion: function() { return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; }, hasflashplayerversion: hasplayerversion, createswf: function(attobj, parobj, replaceelemidstr) { if (ua.w3cdom) { return createswf(attobj, parobj, replaceelemidstr); } else { return undefined; } }, removeswf: function(objelemidstr) { if (ua.w3cdom) { removeswf(objelemidstr); } }, createcss: function(sel, decl) { if (ua.w3cdom) { createcss(sel, decl); } }, adddomloadevent: adddomloadevent, addloadevent: addloadevent, getqueryparamvalue: function(param) { var q = doc.location.search || doc.location.hash; if (param == null) { return urlencodeifnecessary(q); } if (q) { var pairs = q.substring(1).split("&"); for (var i = 0; i < pairs.length; i++) { if (pairs[i].substring(0, pairs[i].indexof("=")) == param) { return urlencodeifnecessary(pairs[i].substring((pairs[i].indexof("=") + 1))); } } } return ""; }, // for internal usage only expressinstallcallback: function() { if (isexpressinstallactive && storedaltcontent) { var obj = getelementbyid(express_install_id); if (obj) { obj.parentnode.replacechild(storedaltcontent, obj); if (storedaltcontentid) { setvisibility(storedaltcontentid, true); if (ua.ie && ua.win) { storedaltcontent.style.display = "block"; } } storedaltcontent = null; storedaltcontentid = null; isexpressinstallactive = false; } } } }; }();