/**
	Swf total
*/
function SWFObject(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._holder;
}
SWFObject.prototype.getId = function()
{
	return this.id;
}
SWFObject.prototype.getHolder = function()
{
	return this._holder;
}
SWFObject.prototype.addParam = function(key,value)
{
	this.params[key] = value;
}
SWFObject.prototype.getParam = function(key)
{
	return this.params[key];
}
SWFObject.prototype.addVariable = function(key,value)
{	
	switch( typeof value ){
		case "string":
		value = value.replace(/\&/g, "&amp;");
		value = value.replace(/\%/g, "%25");
			break;
		case "number":
			break;
	}	
	this.variables[key] = value;
}
SWFObject.prototype.getVariable = function(key)
{
	return this.variables[key];
}
SWFObject.prototype.getVariablePairs = function()
{
	var variablePairs = new Array();
	for(key in this.variables){
		variablePairs.push(key +"="+ this.variables[key]);
	}
	return variablePairs;
}

SWFObject.prototype.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;	
}
SWFObject.prototype.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--------------------
SWFObject.prototype.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;
}

SWFObject.prototype.getSwfVer = function()
{
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		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"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	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 ( this.isIE && this.isWin && !this.isOpera ) {
		flashVer = this.getWinFPVer();
	}
	return flashVer;
}

SWFObject.prototype.isVersionGE = function( requireVer, spliter )
{
	var versionStr = this.getSwfVer();
	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-------------------
SWFObject.prototype.getDataTo = function( key )
{
	this.onGetDataTo( key );

	var _value;
	try{
		_value = eval(key);
	}catch (e){
		_value = undefined;
	}
	return _value;
}
SWFObject.prototype.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;
}
SWFObject.prototype.onGetDataTo = function( key )
{
	//alert( key );
}

SWFObject.prototype.setDataTo = function( flsName, key, value ) 
{
	this.getFlash().setData( key, value );
}

SWFObject.prototype.updateFPlayer = function()
{
	try {  
		if( typeof(eval( updateFlashPlayer ))=="function" ) {updateFlashPlayer();}
	}catch(e){
	}
}

SWFObject.prototype.getFlash = function() {
	return this.isIE ? window[this.id]:document[this.id];  
}

//--------------------size support---------------/-----
SWFObject.prototype.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";
}

SWFObject.prototype.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){
	}
}
SWFObject.prototype.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){				
	}
}

//--------------------辅助函数-其他地方也可以调用---------------------
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;
}