/*! swfobject v2.0
copyright (c) 2007 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 = [],
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 && typeof doc.appendchild != undef && typeof doc.replacechild != undef && typeof doc.removechild != undef && typeof doc.clonenode != 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) {
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
var s = getelementbyid("__ie_ondomload");
if (s) {
s.onreadystatechange = function() {
if (this.readystate == "complete") {
this.parentnode.removechild(this);
calldomloadfunctions();
}
};
}
}
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 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) {
win.attachevent("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.tolowercase() == "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.tolowercase() == "param") {
e.setattribute(c[j].getattribute("name"), c[j].getattribute("value"));
}
}
}
obj.parentnode.replacechild(e, obj);
}
}
/* fix hanging audio/video threads and force open sockets and netconnections to disconnect
- occurs when unloading a web page in ie using fp8+ and innerhtml/outerhtml
- dynamic publishing only
*/
function fixobjectleaks(id) {
if (ua.ie && ua.win && hasplayerversion("8.0.0")) {
win.attachevent("onunload", function () {
var obj = getelementbyid(id);
if (obj) {
for (var i in obj) {
if (typeof obj[i] == "function") {
obj[i] = function() {};
}
}
obj.parentnode.removechild(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";
win.attachevent("onload", function() { obj.parentnode.removechild(obj); });
}
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";
win.attachevent("onload", function() { obj.parentnode.removechild(obj); });
}
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.tolowercase() == "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 (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 == "data") {
parobj.movie = attobj[i];
}
else if (i.tolowercase() == "styleclass") { // 'class' is an ecma4 reserved keyword
att += ' class="' + attobj[i] + '"';
}
else if (i != "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 = '';
fixobjectleaks(attobj.id); // this bug affects 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 == "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 != "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 != "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 != "classid") { // filter out ie specific attribute
o.setattribute(m, attobj[m]);
}
}
}
for (var n in parobj) {
if (parobj[n] != object.prototype[n] && n != "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);
}
function getelementbyid(id) {
return doc.getelementbyid(id);
}
function createelement(el) {
return doc.createelement(el);
}
function hasplayerversion(rv) {
var pv = ua.pv, v = rv.split(".");
v[0] = parseint(v[0], 10);
v[1] = parseint(v[1], 10);
v[2] = parseint(v[2], 10);
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 ? "inherit" : "hidden";
if (isdomloaded) {
getelementbyid(id).style.visibility = v;
}
else {
createcss("#" + id, "visibility:" + v);
}
}
function gettargetversion(obj) {
if (!obj)
return 0;
var c = obj.childnodes;
var cl = c.length;
for (var i = 0; i < cl; i++) {
if (c[i].nodetype == 1 && c[i].nodename.tolowercase() == "object") {
c = c[i].childnodes;
cl = c.length;
i = 0;
}
if (c[i].nodetype == 1 && c[i].nodename.tolowercase() == "param" && c[i].getattribute("name") == "swfversion") {
return c[i].getattribute("value");
}
}
return 0;
}
function getexpressinstall(obj) {
if (!obj)
return "";
var c = obj.childnodes;
var cl = c.length;
for (var i = 0; i < cl; i++) {
if (c[i].nodetype == 1 && c[i].nodename.tolowercase() == "object") {
c = c[i].childnodes;
cl = c.length;
i = 0;
}
if (c[i].nodetype == 1 && c[i].nodename.tolowercase() == "param" && c[i].getattribute("name") == "expressinstall") {
return c[i].getattribute("value");
}
}
return "";
}
return {
/* public api
- reference: http://code.google.com/p/swfobject/wiki/swfobject_2_0_documentation
*/
registerobject: function(objectidstr, swfversionstr, xiswfurlstr) {
if (!ua.w3cdom || !objectidstr) {
return;
}
var obj = document.getelementbyid(objectidstr);
var xi = getexpressinstall(obj);
var regobj = {};
regobj.id = objectidstr;
regobj.swfversion = swfversionstr ? swfversionstr : gettargetversion(obj);
regobj.expressinstall = xiswfurlstr ? xiswfurlstr : ((xi != "") ? xi : false);
regobjarr[regobjarr.length] = regobj;
setvisibility(objectidstr, false);
},
getobjectbyid: function(objectidstr) {
var r = null;
if (ua.w3cdom && isdomloaded) {
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 to make it idiot proof
heightstr += "";
if (hasplayerversion(swfversionstr)) {
setvisibility(replaceelemidstr, false);
var att = (typeof attobj == object) ? attobj : {};
att.data = swfurlstr;
att.width = widthstr;
att.height = heightstr;
var par = (typeof parobj == object) ? parobj : {};
if (typeof flashvarsobj == object) {
for (var i in flashvarsobj) {
if (flashvarsobj[i] != object.prototype[i]) { // filter out prototype additions from other potential libraries
if (typeof par.flashvars != undef) {
par.flashvars += "&" + i + "=" + flashvarsobj[i];
}
else {
par.flashvars = i + "=" + flashvarsobj[i];
}
}
}
}
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)) {
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 && isdomloaded) {
return createswf(attobj, parobj, replaceelemidstr);
}
else {
return undefined;
}
},
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 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 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;
}
}
}
};
}();