/**
 * ChartObject : Dynamic Chart v2.0 - http://www.dcharts.com
 * 用于在页面判断浏览器类型并加载图表flash文件，可在此文件中修改图表的全局设置。
 * 该文件参考了SWFObject v1.5，http://blog.deconcept.com
 */
if(typeof dc == "undefined") var dc = new Object();
if(typeof dc.ChartObjectUtil == "undefined") dc.ChartObjectUtil = new Object();
dc.ChartObject = function(id, w, h,chart_type,data_url) {
	if (!document.getElementById) { return; }
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();	
	this.setAttribute('id', id);
	this.setAttribute('width', w);
	this.setAttribute('height', h);
	if(chart_type) { this.addVariable('type', chart_type); }
	var data = data_url ? data_url.replace(/&amp;|&/g,"||") : '';
	this.setAttribute('data', data);
	this.setAttribute('version', [9,0]); 
	this.addParam('quality', 'high');

	/** 以下为图表全局设置，避免在每个显示图表的语句中单独设置 **/
	//如果图表swf文件的位置改变，请更改该路径
	this.setAttribute('swf', 'chart1.swf');

	//图片输出下载的URL
	this.addVariable('server_path','exportimage.php');

	/** 以下的图表全局设置，可改变图表中的默认定义 **/
	//this.addVariable("cutline_position","R");//图例位置
	//this.addVariable("charset", "en");//语言设置
	//this.addVariable("type_range", "column,columnstack,bar,barstack,pie,radar,line,curve");//可转换图表范围
	//其它设置...
	/** 全局设置结束 **/

	this.installedVer = dc.ChartObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		dc.ChartObject.doPrepUnload = true;
	}
}
dc.ChartObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		var bgcolor=this.getParams()['bgcolor']?this.getParams()['bgcolor'].replace("#","0x"):"";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'?data='+this.getAttribute('data')+'&bgcolor='+bgcolor+'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'?data='+this.getAttribute('data')+'&bgcolor='+bgcolor+'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		//alert(swfNode);
		return swfNode;
	},
	write: function(elementId){
		if(this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}
		return false;
	}
}

/* ---- detection functions ---- */
dc.ChartObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new dc.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new dc.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
				PlayerVersion = new dc.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { // Win IE (non mobile)
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new dc.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new dc.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
dc.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
dc.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
if (dc.ChartObject.doPrepUnload) {
	if (!dc.unloadSet) {
		dc.ChartObjectUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
		}
		window.attachEvent("onbeforeunload", dc.ChartObjectUtil.prepUnload);
		dc.unloadSet = true;
	}
}
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
var ChartObject = dc.ChartObject; 
var SWFObject = dc.ChartObject;
var jsReady=false;function isReady(){return jsReady;}window.onload = function(){jsReady=true}