--- /dev/null
+/**\r
+ * FusionCharts: Flash Player detection and Chart embedding.\r
+ * Version: 1.2.3 (15th September, 2008) - Added fix for % and & characters. Additional fixes to properly handle double quotes and single quotes in setDataXML() function.\r
+ * Version: 1.2.2 (10th July, 2008) - Added fix for % scaled dimensions, fixes in setDataXML() and setDataURL() functions\r
+ * Version: 1.2.1 (21st December, 2007) - Added setting up transparent/opaque mode: setTransparent() function \r
+ * Version: 1.2 (1st November, 2007) - Added FORM fixes for IE \r
+ * Version: 1.1 (29th June, 2007) - Added Player detection, New conditional fixes for IE\r
+ *\r
+ * Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:\r
+ * http://www.opensource.org/licenses/mit-license.php\r
+ *\r
+ */\r
+if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();\r
+if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();\r
+infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){\r
+ if (!document.getElementById) { return; }\r
+ \r
+ //Flag to see whether data has been set initially\r
+ this.initialDataSet = false;\r
+ \r
+ //Create container objects\r
+ this.params = new Object();\r
+ this.variables = new Object();\r
+ this.attributes = new Array();\r
+ \r
+ //Set attributes for the SWF\r
+ if(swf) { this.setAttribute('swf', swf); }\r
+ if(id) { this.setAttribute('id', id); }\r
+\r
+ debugMode = debugMode ? debugMode : 0;\r
+ this.addVariable('debugMode', debugMode);\r
+\r
+ w=w.toString().replace(/\%$/,"%25");\r
+ if(w) { this.setAttribute('width', w); }\r
+ h=h.toString().replace(/\%$/,"%25");\r
+ if(h) { this.setAttribute('height', h); }\r
+\r
+ \r
+ //Set background color\r
+ if(c) { this.addParam('bgcolor', c); }\r
+ \r
+ //Set Quality \r
+ this.addParam('quality', 'high');\r
+ \r
+ //Add scripting access parameter\r
+ this.addParam('allowScriptAccess', 'always');\r
+ \r
+ //Pass width and height to be appended as chartWidth and chartHeight\r
+ this.addVariable('chartWidth', w);\r
+ this.addVariable('chartHeight', h);\r
+\r
+ //Whether in debug mode\r
+ //Pass DOM ID to Chart\r
+ this.addVariable('DOMId', id);\r
+ //Whether to registed with JavaScript\r
+ registerWithJS = registerWithJS ? registerWithJS : 0;\r
+ this.addVariable('registerWithJS', registerWithJS);\r
+ \r
+ //Scale Mode of chart\r
+ scaleMode = scaleMode ? scaleMode : 'noScale';\r
+ this.addVariable('scaleMode', scaleMode);\r
+ \r
+ //Application Message Language\r
+ lang = lang ? lang : 'EN';\r
+ this.addVariable('lang', lang);\r
+ \r
+ //Whether to auto detect and re-direct to Flash Player installation\r
+ this.detectFlashVersion = detectFlashVersion?detectFlashVersion:1;\r
+ this.autoInstallRedirect = autoInstallRedirect?autoInstallRedirect:1;\r
+ \r
+ //Ger Flash Player version \r
+ this.installedVer = infosoftglobal.FusionChartsUtil.getPlayerVersion();\r
+ \r
+ if (!window.opera && document.all && this.installedVer.major > 7) {\r
+ // Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE\r
+ infosoftglobal.FusionCharts.doPrepUnload = true;\r
+ }\r
+}\r
+\r
+infosoftglobal.FusionCharts.prototype = {\r
+ setAttribute: function(name, value){\r
+ this.attributes[name] = value;\r
+ },\r
+ getAttribute: function(name){\r
+ return this.attributes[name];\r
+ },\r
+ addParam: function(name, value){\r
+ this.params[name] = value;\r
+ },\r
+ getParams: function(){\r
+ return this.params;\r
+ },\r
+ addVariable: function(name, value){\r
+ this.variables[name] = value;\r
+ },\r
+ getVariable: function(name){\r
+ return this.variables[name];\r
+ },\r
+ getVariables: function(){\r
+ return this.variables;\r
+ },\r
+ getVariablePairs: function(){\r
+ var variablePairs = new Array();\r
+ var key;\r
+ var variables = this.getVariables();\r
+ for(key in variables){\r
+ variablePairs.push(key +"="+ variables[key]);\r
+ }\r
+ return variablePairs;\r
+ },\r
+ getSWFHTML: function() {\r
+ var swfNode = "";\r
+ if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { \r
+ // netscape plugin architecture \r
+ swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" ';\r
+ swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';\r
+ var params = this.getParams();\r
+ for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }\r
+ var pairs = this.getVariablePairs().join("&");\r
+ if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }\r
+ swfNode += '/>';\r
+ } else { // PC IE \r
+ swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';\r
+ swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';\r
+ var params = this.getParams();\r
+ for(var key in params) {\r
+ swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';\r
+ }\r
+ var pairs = this.getVariablePairs().join("&"); \r
+ if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}\r
+ swfNode += "</object>";\r
+ }\r
+ return swfNode;\r
+ },\r
+ setDataURL: function(strDataURL){\r
+ //This method sets the data URL for the chart.\r
+ //If being set initially\r
+ if (this.initialDataSet==false){\r
+ this.addVariable('dataURL',strDataURL);\r
+ //Update flag\r
+ this.initialDataSet = true;\r
+ }else{\r
+ //Else, we update the chart data using External Interface\r
+ //Get reference to chart object\r
+ var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));\r
+ \r
+ if (!chartObj.setDataURL)\r
+ {\r
+ __flash__addCallback(chartObj, "setDataURL");\r
+ }\r
+ \r
+ chartObj.setDataURL(strDataURL);\r
+ }\r
+ },\r
+ //This function :\r
+ //fixes the double quoted attributes to single quotes\r
+ //Encodes all quotes inside attribute values\r
+ //Encodes % to %25 and & to %26;\r
+ encodeDataXML: function(strDataXML){\r
+ \r
+ var regExpReservedCharacters=["\\$","\\+"];\r
+ var arrDQAtt=strDataXML.match(/=\s*\".*?\"/g);\r
+ if (arrDQAtt){\r
+ for(var i=0;i<arrDQAtt.length;i++){\r
+ var repStr=arrDQAtt[i].replace(/^=\s*\"|\"$/g,"");\r
+ repStr=repStr.replace(/\'/g,"%26apos;");\r
+ var strTo=strDataXML.indexOf(arrDQAtt[i]);\r
+ var repStrr="='"+repStr+"'";\r
+ var strStart=strDataXML.substring(0,strTo);\r
+ var strEnd=strDataXML.substring(strTo+arrDQAtt[i].length);\r
+ var strDataXML=strStart+repStrr+strEnd;\r
+ }\r
+ }\r
+ \r
+ strDataXML=strDataXML.replace(/\"/g,"%26quot;");\r
+ strDataXML=strDataXML.replace(/%(?![\da-f]{2}|[\da-f]{4})/ig,"%25");\r
+ strDataXML=strDataXML.replace(/\&/g,"%26");\r
+\r
+ return strDataXML;\r
+\r
+ },\r
+ setDataXML: function(strDataXML){\r
+ //If being set initially\r
+ if (this.initialDataSet==false){\r
+ //This method sets the data XML for the chart INITIALLY.\r
+ this.addVariable('dataXML',this.encodeDataXML(strDataXML));\r
+ //Update flag\r
+ this.initialDataSet = true;\r
+ }else{\r
+ //Else, we update the chart data using External Interface\r
+ //Get reference to chart object\r
+ var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));\r
+ chartObj.setDataXML(strDataXML);\r
+ }\r
+ },\r
+ setTransparent: function(isTransparent){\r
+ //Sets chart to transparent mode when isTransparent is true (default)\r
+ //When no parameter is passed, we assume transparent to be true.\r
+ if(typeof isTransparent=="undefined") {\r
+ isTransparent=true;\r
+ } \r
+ //Set the property\r
+ if(isTransparent)\r
+ this.addParam('WMode', 'transparent');\r
+ else\r
+ this.addParam('WMode', 'Opaque');\r
+ },\r
+ \r
+ render: function(elementId){\r
+ //First check for installed version of Flash Player - we need a minimum of 8\r
+ if((this.detectFlashVersion==1) && (this.installedVer.major < 8)){\r
+ if (this.autoInstallRedirect==1){\r
+ //If we can auto redirect to install the player?\r
+ var installationConfirm = window.confirm("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same.");\r
+ if (installationConfirm){\r
+ window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";\r
+ }else{\r
+ return false;\r
+ }\r
+ }else{\r
+ //Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link).\r
+ //So, expect the developers to provide a course of way to their end users.\r
+ //window.alert("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. ");\r
+ return false;\r
+ } \r
+ }else{\r
+ //Render the chart\r
+ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;\r
+ n.innerHTML = this.getSWFHTML();\r
+ \r
+ //Added <FORM> compatibility\r
+ //Check if it's added in Mozilla embed array or if already exits \r
+ if(!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])\r
+ window[this.getAttribute('id')]=document.getElementById(this.getAttribute('id')); \r
+ //or else document.forms[formName/formIndex][chartId] \r
+ return true; \r
+ }\r
+ }\r
+}\r
+\r
+/* ---- detection functions ---- */\r
+infosoftglobal.FusionChartsUtil.getPlayerVersion = function(){\r
+ var PlayerVersion = new infosoftglobal.PlayerVersion([0,0,0]);\r
+ if(navigator.plugins && navigator.mimeTypes.length){\r
+ var x = navigator.plugins["Shockwave Flash"];\r
+ if(x && x.description) {\r
+ PlayerVersion = new infosoftglobal.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));\r
+ }\r
+ }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ \r
+ //If Windows CE\r
+ var axo = 1;\r
+ var counter = 3;\r
+ while(axo) {\r
+ try {\r
+ counter++;\r
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);\r
+ PlayerVersion = new infosoftglobal.PlayerVersion([counter,0,0]);\r
+ } catch (e) {\r
+ axo = null;\r
+ }\r
+ }\r
+ } else { \r
+ // Win IE (non mobile)\r
+ // Do minor version lookup in IE, but avoid Flash Player 6 crashing issues\r
+ try{\r
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");\r
+ }catch(e){\r
+ try {\r
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");\r
+ PlayerVersion = new infosoftglobal.PlayerVersion([6,0,21]);\r
+ axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)\r
+ } catch(e) {\r
+ if (PlayerVersion.major == 6) {\r
+ return PlayerVersion;\r
+ }\r
+ }\r
+ try {\r
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");\r
+ } catch(e) {}\r
+ }\r
+ if (axo != null) {\r
+ PlayerVersion = new infosoftglobal.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));\r
+ }\r
+ }\r
+ return PlayerVersion;\r
+}\r
+infosoftglobal.PlayerVersion = function(arrVersion){\r
+ this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;\r
+ this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;\r
+ this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;\r
+}\r
+// ------------ Fix for Out of Memory Bug in IE in FP9 ---------------//\r
+/* Fix for video streaming bug */\r
+infosoftglobal.FusionChartsUtil.cleanupSWFs = function() {\r
+ var objects = document.getElementsByTagName("OBJECT");\r
+ for (var i = objects.length - 1; i >= 0; i--) {\r
+ objects[i].style.display = 'none';\r
+ for (var x in objects[i]) {\r
+ if (typeof objects[i][x] == 'function') {\r
+ objects[i][x] = function(){};\r
+ }\r
+ }\r
+ }\r
+}\r
+// Fixes bug in fp9\r
+if (infosoftglobal.FusionCharts.doPrepUnload) {\r
+ if (!infosoftglobal.unloadSet) {\r
+ infosoftglobal.FusionChartsUtil.prepUnload = function() {\r
+ __flash_unloadHandler = function(){};\r
+ __flash_savedUnloadHandler = function(){};\r
+ window.attachEvent("onunload", infosoftglobal.FusionChartsUtil.cleanupSWFs);\r
+ }\r
+ window.attachEvent("onbeforeunload", infosoftglobal.FusionChartsUtil.prepUnload);\r
+ infosoftglobal.unloadSet = true;\r
+ }\r
+}\r
+/* Add document.getElementById if needed (mobile IE < 5) */\r
+if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}\r
+/* Add Array.push if needed (ie5) */\r
+if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}\r
+\r
+/* Function to return Flash Object from ID */\r
+infosoftglobal.FusionChartsUtil.getChartObject = function(id)\r
+{\r
+ var chartRef=null;\r
+ if (navigator.appName.indexOf("Microsoft Internet")==-1) {\r
+ if (document.embeds && document.embeds[id])\r
+ chartRef = document.embeds[id]; \r
+ else\r
+ chartRef = window.document[id];\r
+ }\r
+ else {\r
+ chartRef = window[id];\r
+ }\r
+ if (!chartRef)\r
+ chartRef = document.getElementById(id);\r
+ \r
+ return chartRef;\r
+}\r
+/* Aliases for easy usage */\r
+var getChartFromId = infosoftglobal.FusionChartsUtil.getChartObject;\r
+var FusionCharts = infosoftglobal.FusionCharts;
\ No newline at end of file