/** 
	Swf total v1.002
*/
//-------------全局静态函数 (这个函数太好了，就像加装甲一般，对原来的类进行一层的包装^_^)------------------

if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();

deconcept.SWFObject = function(swfurl, initwidth, initheight, ver, id )
{
	//---------create a random Id if undefined is passed!--------;
	var tstr = String((new Date()).getTime());
	this.id = (id == undefined) ? "FP"+tstr.substring( tstr.length-6 ) : id;

	this.params = new Object();
	this.variables = new Object();

	this.initwidth = initwidth;
	this.initheight = initheight;
	this.version = ver;
	this.swfurl = swfurl;	
	this.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
	
	this.isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	this.isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	this.isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	
	this.installedVer = this.getPlayerVersion();

	if (!window.opera && document.all && this.isVersionGE( "7", "." ) ) {
		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		deconcept.SWFObjectUtil.setUpUnload();
	}

	//---------记录自己的父节点句柄---------
	this._holder;
}

deconcept.SWFObject.prototype = {
	getId : function()
	{
		return this.id;
	},
	getHolder : function()
	{
		return this._holder;
	},
	addParam : function(key,value)
	{
		this.params[key] = value;
	},
	getParam : function(key)
	{
		return this.params[key];
	},
	addVariable : function(key,value)
	{
		switch( typeof value ){
			case "string":
			value = value.replace(/\&/g, "%26");
			value = value.replace(/\%/g, "%25");
			value = value.replace(/\+/g, "%2B");
			value = trim( value );
				break;
			case "number":
				break;
		}	
		this.variables[key] = value;
	},
	getVariable : function(key)
	{
		return this.variables[key];
	},
	getVariablePairs : function()
	{
		var variablePairs = new Array();
		for(key in this.variables){
			variablePairs.push(key +"="+ this.variables[key]);
		}
		return variablePairs;
	},
	
	getHTML : function()
	{
		var con = '';
		if (!this.isIE) {
			con = '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'	+ this.swfurl
				+'" width="'+ this.initwidth 
				+'" height="'+ this.initheight
				+'" id="'+ this.id
				+'" name="'+ this.id
				+'" ';
			for(var key in this.params){ 
				con += [key] +'="'+ this.params[key] +'" '; 
			}
			var pairs = this.getVariablePairs().join("&");
			if (pairs.length > 0){
				con += 'flashvars="'+ pairs +'"'; 
			}
			con += '/>';
			
		}else{
			con = '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version
				+'" width="'+ this.initwidth
				+'" height="'+ this.initheight
				+'" id="'+ this.id
				+'" classid="'+ this.classid
				+'">';
			con += '<param name="movie" value="'+ this.swfurl +'" />';
			for(var key in this.params) {
				con += '<param name="'+ key +'" value="'+ this.params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {
				con += '<param name="flashvars" value="'+ pairs +'" />';
			}
			con += "</object>";
		}
		return con;	
	},
	write : function( holderId )
	{
		if(typeof holderId == 'undefined'){
			this._holder = document.createElement('div');
	
			var tstr = String((new Date()).getTime());
			this._holder.id = "divFP" + tstr.substring( tstr.length-6 );
			document.body.appendChild( this._holder );
		}else {
			this._holder = (typeof holderId == "string") ? document.getElementById(holderId) : holderId;	
		}
	
		if( this._holder ){
			this._holder.innerHTML = this.getHTML();
		}	
	},
	
	//---------------Version control--------------------
	getWinFPVer : function()
	{
		var version = -1;
		var axo;
		var e;
	
		for (var i = 12; i >= 3; i = i-1){
		
			try {
			
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
			switch( i ){
			
			case 6:
				version = "WIN 6,0,21,0";
				axo.AllowScriptAccess = "always";
				version = axo.GetVariable("$version");
				break;
				
			case 3:
				try{version = axo.GetVariable("$version");}catch(e){};
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
				version = "WIN 3,0,18,0";
				break;
			
			default:
				version = axo.GetVariable("$version");
				break;
			
			}			
			
			} catch (e) {
			}
			
			if (version != -1) return version;
		}
		
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
		
		return version;
	},
	
	getPlayerVersion : function()
	{
		var flashVer = -1;
		
		if (navigator.plugins != null && navigator.plugins.length > 0) {
			/*-----old version------if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
				var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
				var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
				var descArray = flashDescription.split(" ");
				var tempArrayMajor = descArray[2].split(".");			
				var versionMajor = tempArrayMajor[0];
				var versionMinor = tempArrayMajor[1];
				var versionRevision = descArray[3];
				if (versionRevision == "") {
					versionRevision = descArray[4];
				}
				if (versionRevision[0] == "d") {
					versionRevision = versionRevision.substring(1);
				} else if (versionRevision[0] == "r") {
					versionRevision = versionRevision.substring(1);
					if (versionRevision.indexOf("d") > 0) {
						versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
					}
				}
				flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
			}*/
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var x = navigator.plugins["Shockwave Flash" + swVer2];
			if(x && x.description) {
				flashVer = x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".");
			}
		}
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
		else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
		else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0)	{ // if Windows CE
			var axo = 1;
			var counter = 3;
			while(axo) {
				try {
					counter = counter + 1;
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
					flashVer = counter+".0.0";
				} catch (e) {
					axo = null;
				}
			}
		}
		else if ( this.isIE && this.isWin && !this.isOpera ) {// Win IE (non mobile)
			// do minor version lookup in IE, but avoid fp6 crashing issues
			// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
			// ---old version----flashVer = this.getWinFPVer();
			try{
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			}catch(e){
				try {
					var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					flashVer = "6,0,21";
					axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
				} catch(e) {
					if (flashVer == "6,0,21") {
						return flashVer;
					}
				}
				try {
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				} catch(e) {}
			}
			if (axo != null) {
				flashVer = axo.GetVariable("$version");
			}
		}
		return flashVer;
	},
	
	isVersionGE : function( requireVer, spliter )
	{
		var versionStr = this.installedVer;
		var versionArr = null;
		
		var requireArr = null;
		
		if( versionStr<=0 ) return false;
		
		if( this.isIE && this.isWin && !this.isOpera ) {
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArr      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArr      = versionStr.split(".");
		}
		
		try{
			spliter = typeof(spliter) == 'undefined' ? ".":spliter;
			requireArr = requireVer.split( spliter );
			
			var cycleTime = requireArr.length > versionArr.length ? requireArr.length : versionArr.length;
			for (var i = 0; i < cycleTime; i=i+1) {
				var requireNum = parseFloat( typeof(requireArr[i]) == 'undefined' ? "0" : requireArr[i]);
				var verNum = parseFloat( typeof(versionArr[i]) == 'undefined' ? "0" : versionArr[i]);
				if (requireNum < verNum) {
					return true;
				} else if (requireNum > verNum) {
					return false;
				}
			}
			return true;
		
		}catch (e){
			return false;
		}
	},
	
	//--------------------data/action support-------------------
	getDataTo : function( key )
	{
		this.onGetDataTo( key );
	
		var _value;
		try{
			_value = eval(key);
		}catch (e){
			_value = undefined;
		}
		return _value;
	},
	getBrowserInfo : function()
	{
		var commonInfo = new Object();
		commonInfo.appName = navigator.appName;
		commonInfo.platform = navigator.platform;
		var appVersion = "0.0";
		
		var verPart1 = "";
		var verPart2 = "";
		
		var regeXVer = /^([^\s]*)\s+\(([^\)]*)\)$/;
		var matcher = navigator.appVersion.match( regeXVer );
		
		if( matcher!=null ){
			verPart1 = matcher[1];
			verPart2 = matcher[2];
		}
		
		if( navigator.appName == "Microsoft Internet Explorer" ){
			var infoArr = verPart2.toLowerCase().split(";");
			for( var i=0;i<infoArr.length;i=i+1 ){
				var regeXSubver = /^\s*msie\s*([^\s]*)$/;
				var matchsub = infoArr[i].match( regeXSubver );
				if( matchsub == null ) continue;
				appVersion = matchsub[1]; break;
			}
		}
		else if ( navigator.appName == "Netscape" ){
			appVersion = verPart1;
		}
		else if ( navigator.appName == "Opera" ){
			appVersion = verPart1;
		}
		
		commonInfo.appVersion = appVersion;
		
		return commonInfo;
	},
	onGetDataTo : function( key )
	{
		//alert( key );
	},
	
	callBackTo : function( key, value )
	{
		this.getFlash().callBackTo( key, value );
	},
	
	updateFPlayer : function()
	{
		try {  
			if( typeof(eval( updateFlashPlayer ))=="function" ) {updateFlashPlayer();}
		}catch(e){
		}
	},
	
	getFlash : function() {
		return this.isIE ? window[this.id]:document[this.id];  
	},
	
	//--------------------size support---------------/-----
	setSize : function( width, height )
	{
		var theF = this.getFlash();
		this.initwidth = theF.width = width;
		this.initheight = theF.height = height;
		this._holder.style.width = width+"px";
		this._holder.style.height = height+"px";
	},
	fullBrowser : function()
	{
		if( !this.isFullScreen ){
			this.initleft = get_X( this._holder );
			this.inittop = get_Y( this._holder );
		}
	
		this.isFullScreen = true;
		var screenSize = getScreenSize();
		try{
			this._holder.style.position = "absolute";
			this._holder.style.top = "0px";
			this._holder.style.left = "0px";
			this._holder.style.width = screenSize.width +"px";
			this._holder.style.height = screenSize.height +"px";
			this.getFlash().width = screenSize.width;
			this.getFlash().height = screenSize.height;
			document.body.style.overflow="hidden";
			window.scrollTo(0,0);
		}catch(e){
		}
	},
	normalBrowser : function()
	{
		if( !this.isFullScreen ) return;
		this.isFullScreen = false;
		try{
			this._holder.style.position = "";
			this._holder.style.left = this.initleft;
			this._holder.style.top = this.inittop;
			this._holder.style.width = this.initwidth;
			this._holder.style.height = this.initheight;
			this.getFlash().width = this.initwidth;
			this.getFlash().height = this.initheight;
			document.body.style.overflow="auto";
		}catch(e){				
		}
	}
}


/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() 
{
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i=i-1) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
deconcept.SWFObjectUtil.setUpUnload = function()
{
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
		}
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true;
	}
}

/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
var SWFObjectUtil = deconcept.SWFObjectUtil; // f**kyou!

//--------------------辅助函数-其他地方也可以调用--------------------
function getScreenSize(){
	var w = 0;
	var h = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		w = window.innerWidth;
		h = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	return {width:w,height:h};
}
function get_X(obj){
    var ParentObj=obj;
    var left=obj.offsetLeft;
    while(ParentObj=ParentObj.offsetParent){
        left+=ParentObj.offsetLeft;
    }
    return left;
}

function get_Y(obj){
    var ParentObj=obj;
    var top=obj.offsetTop;
    while(ParentObj=ParentObj.offsetParent){
        top+=ParentObj.offsetTop;
    }
    return top;
}
function trim( value ) {
	if( value == undefined ) return "";
	return value.replace( /^\s*/, "").replace( /\s*$/, "");
}

