/*//////////////////////////////////////////////////////////////////////////////////////// swfIN 2.4.0 - 2010-07-26 javascript toolkit for flash developers © 2005-2010 Francis Turmel | swfIN.nectere.ca | www.nectere.ca | francis@nectere.ca released under the MIT license /*//////////////////////////////////////////////////////////////////////////////////////// /** * swfIN constructor * Note: width and height can be either Numbers or Strings (for percentage: "100%") * @param {String} swfPath * @param {String} swfID * @param {String} width * @param {String} height */ if( typeof swfIN == "undefined" ){ var swfIN = function(swfPath, swfID, width, height){ //init this.params = []; this.flashVars = []; this.swfPath = swfPath; this.swfID = swfID; this.containerDivID = "div_" + swfID; this.width = String(width); this.height = String(height); this.scrollbarWidth = null; this.scrollbarHeight = null; this.requiredVersion = [0,0,0]; this.redirectURL = null; this.redirectUseParams = false; this.xiPath = null; this.xiWidth = null; this.xiHeight = null; this.is_written = false; this.showDivName = null; this.showDivStyleMemory = null; this.isUsingMacMousewheel = false; //init windows resize & array proto, but only once! swfIN._static.init(); } swfIN.prototype = { /** * Add an embed param * @param {String} name * @param {Object} val * @return {void} */ addParam: function(name, val){ if(name != "") this.params[name] = val; }, /** * Adds multiple embed params * @param {Object} params * @return {void} */ addParams: function(params){ for(var i in params){ if(params.hasOwnProperty(i)) this.addParam(i, params[i]); } }, /** * Add a flashVar * @param {String} name * @param {Object} val * @return {void} */ addVar: function(name, val){ if(name != "") this.flashVars[name] = val; }, /** * Add multiple flashVars. Note: works well with swfIN.utils.getAllQueryParams() * @param {Object} vars * @return {void} */ addVars: function(vars){ for(var i in vars){ if(vars.hasOwnProperty(i)) this.addVar(i, vars[i]); } }, /** * Set the size at which the browser scrollbar will take over. Old minSize() method. * Can be used after write() * @param {Number} width * @param {Number} height * @return {void} */ scrollbarAt: function(width, height){ this.scrollbarWidth = width; this.scrollbarHeight = height; if( this.isWritten() ) this.refresh(); }, /** * Resize the embeded SWF * Cam be used after write() * @param {Number} width * @param {Number} height * @return {void} */ resize: function(width, height){ this.width = width; this.height = height; if( this.isWritten() ) this.refresh(); }, /** * Set the required Flash version, and optional redirect infos * LEGACY - use detectRedirect * @param {Array} requiredVersion * @param {String} redirectURL * @param {Boolean} redirectUseParams * @return {void} */ detect: function(requiredVersion, redirectURL, redirectUseParams){ this.detectRedirect(requiredVersion, redirectURL, redirectUseParams); }, /** * Set the required Flash version. Will redirect to a URL with optional querystring params if Flash requirements are not met. * @param {Array} requiredVersion * @param {String} redirectURL * @param {Boolean} redirectUseParams * @return {void} */ detectRedirect: function(requiredVersion, redirectURL, redirectUseParams){ this.requiredVersion = requiredVersion; this.redirectURL = redirectURL; this.redirectUseParams = redirectUseParams || false; }, /** * Set the required Flash version. Will destroy the specified div if Flash requirements are met. * @param {Array} requiredVersion * @param {String} showDivName * @param {Boolean} autoHide (optional, defaults to true) */ detectShowDiv: function(requiredVersion, showDivName, autoHide){ this.requiredVersion = requiredVersion; this.showDivName = showDivName; }, /** * Indicates the use of express install by specifying the path the to xi.swf to use * Optional width/height * @param {String} xiPath * @param {Number} width * @param {Number} height * @return {void} */ useExpressInstall: function(xiPath, width, height){ this.xiPath = xiPath; this.xiWidth = width; this.xiHeight = height; }, /** * Shortcut to init SWFAddress * @return {void} */ useSWFAddress: function(){ if( typeof SWFAddress != "undefined" ){ SWFAddress.setId( this.getSWFID() ); }else{ this._error( "Can't find SWFAddress. Remove the .useSWFAddress() call if you're not using it."); } }, /** * Required to reroute mousewheel events to swf (for mac support) * @return {void} */ useMacMousewheel: function(){ this.isUsingMacMousewheel = true; }, /** * Helper for ExternalInterface callbacks * @param {String} funk * @return {*} */ callback: function(funk){ var o = this.getSWFRef(); var a = arguments; var f = funk; var expression = ""; for( var i = 1; i < arguments.length; i++){ expression += (i == 1) ? "a["+i+"]" : ", a["+i+"]"; } var result = null; try{ if (o[f]){ result = eval("o[f](" + expression + ");"); }else{ this._error("callback function \"" + funk + "\" does not exist"); } }catch(err){ this._error("callback function \"" + funk + "\" failed"); } return result; }, /** * Write the html tags! * @return {void} */ write: function(){ //decide action to take if( !swfIN.detect.isPlayerVersionValid(this.requiredVersion) && swfIN.detect.isPlayerVersionValid(swfIN._memory.expressInstallVersion) && this.xiPath != null && swfIN.utils.getQueryParam("detect") != "false" ){ //embed the express install swf //NOTE: if the express install process fails or the user selects "no", the swfIN._static.expressInstallFailed() method will be called //and will allow for a redirection or hidden div //express install flashVars document.title = document.title.slice(0, 47) + " - Flash Player Installation"; this.addVar("MMdoctitle", document.title); this.addVar("MMplayerType", ( swfIN.detect.nsPlugin() ) ? "PlugIn": "ActiveX"); this.addVar("MMredirectURL", window.location); //change swfPath and width/height //TODO: make the min size check for express install work with % - tie it with _calculateWidth() etc.. this.width = this.xiWidth || this.width; if(this.width < swfIN._memory.expressInstallMinSize.w) this.width = swfIN._memory.expressInstallMinSize.w; this.height = this.xiHeight || this.height; if(this.height < swfIN._memory.expressInstallMinSize.h) this.height = swfIN._memory.expressInstallMinSize.h; this.swfPath = this.xiPath; //embed express install swf document.write( this.getHTML() ); //flag as written this.is_written = true; }else if ( swfIN.detect.isPlayerVersionValid(this.requiredVersion) || swfIN.utils.getQueryParam("detect") == "false" ){ //Flash player OK or detect == false, embed the SWF normally document.write( this.getHTML() ); //flag as written this.is_written = true; }else if( this.redirectURL != null ){ //redirect to noFlash url var url = ( this.redirectUseParams ) ? this.redirectURL + "?required=" + this.requiredVersion.join(".") + "&installed=" + swfIN.detect.getPlayerVersionString() : this.redirectURL; location.href = url; } if (this.isWritten()) { if( this.showDivName ){ var style = swfIN.utils.$(this.showDivName).style; this.showDivStyleMemory = {visibility:style.visibility, position:style.position}; swfIN.utils.$hide(this.showDivName); } //check for all possible conflicts this._checkForConflicts(); //push a reference to the swfIN instance swfIN._memory.swf_stack.push(this); //refresh size //TODO: will this fix the IE6 table bug, or only the old innerHTML trick will work? Do we still need this? this.refresh(); //form fix this._formFix(); }else{ if( this.showDivName ){ var style = swfIN.utils.$(this.showDivName).style; style.visibility = this.showDivStyleMemory.visibility; style.position = this.showDivStyleMemory.position; } } }, /** * Checks if this swfIN instance has been written * @return {Boolean} */ isWritten: function(){ return this.is_written; }, /** * Clear and hide the SEO div * @param {String} seoDiv * @return {void} */ hideSEO: function(seoDiv){ swfIN.utils.$delete(seoDiv); /* //old stuff var div = swfIN.utils.$(seoDiv); div.innerHTML = ""; div.style.display = "none"; */ }, /** * Returns the container div's ID as a String * @return {String} */ getDivID: function(){ return this.containerDivID; }, /** * Returns the container div's reference (Object / HTMLDivElement) * @return {HTMLDivElement} */ getDivRef: function(){ return swfIN.utils.$( this.getDivID() ); }, /** * Returns the embedded SWF's ID as a String * return {String} */ getSWFID: function(){ return this.swfID; }, /** * Returns the embedded SWF's reference (Object / HTMLDivElement) * @return {HTMLDivElement} */ getSWFRef: function(){ return swfIN.utils.$( this.getSWFID() ); }, /** * Refresh display and calculates if scrollbars are needed * @return {void} */ refresh: function(){ var div = this.getDivRef(); div.style.width = this._calculateWidth(); div.style.height = this._calculateHeight(); if(this.scrollbarWidth) div.style["min-width"] = this.scrollbarWidth + "px"; if(this.scrollbarHeight) div.style["min-height"] = this.scrollbarHeight + "px"; }, /** * Returns the HTML code to be written for the embedding * @return {String} */ getHTML: function(){ //flashvars var fv = ""; for(var i in this.flashVars){ if(this.flashVars.hasOwnProperty(i)){ var mod = (fv == "") ? "" : "&"; fv += mod + i + "=" + escape(this.flashVars[i]); } } //params default var p = {}; p["movie"] = this.swfPath; p["quality"] = "high"; p["menu"] = "false"; p["swLiveConnect"] = "true"; p["pluginspage"] = swfIN._memory.player_download; p["allowScriptAccess"] = "always"; p["FlashVars"] = fv; //override default with user defined params for(var i in this.params){ if (this.params.hasOwnProperty(i)) p[i] = this.params[i]; } //object attributes var a = {data:this.swfPath, name:this.swfID, id:this.swfID, width:"100%", height:"100%", align:"top", hspace:0, vspace:0}; if( swfIN.detect.ie() ){ a.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; }else{ a.type = "application/x-shockwave-flash"; } //build the object tag var tag = ""; //output var minValues = (this.scrollbarWidth > 0 && this.scrollbarHeight > 0) ? "min-width:"+this.scrollbarWidth + "px; min-height:"+this.scrollbarHeight+"px" : "" ; tag = "