/*璇存槑锛欶lashJs涓篎LASH璇诲彇澶栭儴鍥剧墖JS绋嬪簭锛宨nit闇€鍦╟reateFlash鍒涘缓鍓嶅垱寤恒€俰fclick涓篔s鏁版嵁宀涘瓨璐垱寤虹殑FLASH鐨勭浉鍏冲弬鍿flashAble
澶栭儴浼犲叆鍙傛暟涓哄垽鏂璅lash鏄惁宸茬粡鍔犺浇鍥剧墖;_Back鍔熻兘鍚宖lashAble搴旂敤浜庡唴閮↗S鍐呴傿idname涓轰复鏃跺彉閲忓簲鐢ㄤ簬init鐨剋indow.setTimeout;
鍑′笅鏂囧嚱鏁颁腑鍑虹幇浠ヤ笅鍙傛暟鎰忔€濈浉鋿娉ㄦ槑闄ゅ)钿
Url涓鸿鍙栧浘鐗囧湴鍧‿flashId涓鸿璇诲浘鐗囩殑FLASHID鋿mov_width涓哄綋鍓嶇▼搴忎腑Falsh鐨勫mov_height涓哄綋鍓嶇▼搴忎腑Falsh鐨勯獿
_click:褰撳墠鍏冧欢鏄惁鏈夊崟鍑讳簨浠?width:褰撳墠鍏冧欢瀹藉嬿height:褰撳墠鍏冧欢楂樺嬿noPhoto:鏃犲浘鏃跺姞杞藉湴鍧‿loadUrl涓鸿鍙栧浘鐗囧湴鍧‿
Num:FlashID鋿
--------------------------------------------------------------------------------------------------------------------------*/
var Ifclick = new Array ;
var flashAble = true;
var _Back = false;
var idname;
//doflash鏄鐞嗗彉鎹㈠浘鐗囩殑鎵ц鍑芥昿
function doflash(Url,flashId){
	//flash涓殑鍐呭myVar鏄帴鏀跺彉閲弙ar mov_width = Ifclick[flashId].w;
	var mov_width = Ifclick[flashId].w;
	var mov_height = Ifclick[flashId].h	;
	var mov=document.getElementById(flashId);
	if(Ifclick[flashId].st >= 1){
        var Gif = ifGif(Url,flashId,mov_width,mov_height);
		if(!Gif){
		  var _UUrl = Ifclick[flashId].Url;
		  var _click = Ifclick[flashId].cl;
		  var noPhoto = Ifclick[flashId].np
		  var swfUrl = Ifclick[flashId].Url+"?myVar="+Url+"&Url="+Url;
		  newFlash(mov_width,mov_height,_UUrl,flashId,noPhoto,_click,Url);
		}
	}else{
		var Gif = ifGif(Url,flashId,mov_width,mov_height);
		if(!Gif){
		   var swfUrl = Ifclick[flashId].Url+"?myVar="+Url;
           mov.setAttribute("movie",swfUrl);
		   Ifclick[flashId].ld = Url;
		 }
	}
}
//ifGif鍒ゆ柇Url浼犲叆鐨勫浘鐗囨牸寮忥紱
function ifGif(Url,flashId,mov_width,mov_height){
      var _Url = Url.substr(Url.lastIndexOf(".")+1);
	  _Url = _Url.toLowerCase();
	  if(!flashAble){_Url = "other"}
      if( _Url == "jpg" || _Url =="swf" || _Url == "jpeg"){
		       return false; 
	  }else{
		       var newImage = new Image();
			   newImage.src = Url;
			   var temp = "Num_"+flashId;
			   var tempId = "img_"+flashId;
			   resize(newImage,mov_width,mov_height);
		       var mov_id=document.getElementById(temp);
		       var newHTML = '<img src="'+newImage.src+'" alt="" width='+newImage.width+' height='+newImage.height+' hspace="'+newImage.hspace+'" vspace="'+newImage.vspace+'" style="border:0px;"/>';
		           if(Ifclick[flashId].cl){
			           newHTML = '<a href="'+Url+'" target="_blank">'+newHTML+'</a>'
			   }	   
		       mov_id.innerHTML = newHTML;
			   Ifclick[flashId].st = 1;
			   return true;
	           
	  }
}
// Ar涓簀s鏁版嵁宀涜鍿state:DIV褰撳墠鐘舵€?琛ㄧずFLASH 1琛ㄧず鍥剧墖;Url:FLASH鐨勬簮鍦板潃;
function Ar(state,Url,_click,width,height,noPhoto,loadUrl){
	this.st = state;
	this.Url = Url;
	this.cl = _click;
	this.w = width;
	this.h = height;
	this.np = noPhoto;
	this.ld = loadUrl;
	}
//createFlash鐢ㄤ簬鍒涘缓FLASH;璇存楿Url涓篎lash婧愬湴鍧‿
function createFlash(width,height,Url,Num,noPhoto,_click,loadUrl){
    var id = "Num_"+Num;
	Ifclick[Num] = new Ar(0,Url,_click,width,height,noPhoto,loadUrl);
    document.write('<div id='+id+' style="width:'+width+';height:'+height+'"></div>');
	var Gif = ifGif(loadUrl,Num,width,height,noPhoto);
    if(!Gif) {
	newFlash(width,height,Url,Num,noPhoto,_click,loadUrl)
	}
}
//newFlash鐢ㄤ簬FLASH瀹炰緥鍖?璇存楿Url涓篎lash婧愬湴鍧‿
function newFlash(width,height,Url,Num,noPhoto,_click,loadUrl){
    var _width = width;
	var _height =height;
	var _Url = Url;
	var _noPhotoUrl = noPhoto;
	var id = "Num_"+Num;
    Ifclick[Num] = new Ar(0,Url,_click,_width,_height,noPhoto,loadUrl);
	var m=document.getElementById(id);
	var newHTML ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+_width +'" height="'+_height +'"id="'+Num+'">';
	newHTML +='<param name="allowScriptAccess" value="always"><param name="movie" value="'+_Url+'"><param name="quality" value="high"><param name="menu" value="false">';
	newHTML +='<param name="FlashVars" value="noPhoto='+_noPhotoUrl+'&myVar='+loadUrl+'">';
	newHTML +='<embed src="'+_Url+' FlashVars="noPhoto='+_noPhotoUrl+'"&myVar="'+loadUrl+'" menu="false" quality="high" width="'+ _width +'" height="'+ _height +'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" name="'+Num+'"/></object>';
	m.innerHTML = newHTML;
}
//resize浜庡浘鐗囬噸瀹氬ぇ灏?璇存楿_this:瑕佹敼鍙樺ぇ灏忕殑鍏冧欢;w:鏀瑰彉鍒板ぇ灏忕殑澿h:鏀瑰彉鍒板ぇ灏忕殑棿
function resize(_this,w,h){
	var n = w/h;
	var _width = _this.width;
	var _height = _this.height;
	/*鍘熷鍥剧墖涓嶅彉澶у瘿---------------------------------------------------
		if (_width<=w && _height<=h) {
			_this.width = _width;
			_this.height = _height;
			_this.vspace = (w-_this.width)/2
			_this.hspace = (h-_this.height)/2
			return ;
	}
	*/
	if (_width/_height>=n) {
			_this.width = w;
			_this.height = w/_width*_height;;
			_this.hspace = 0;
			_this.vspace = (h-_this.height)/2;
			return;
	}
	if (_width/_height<n) {
			_this.width = h/_height*_width;
			_this.height = h;
			_this.hspace = (w-_this.width)/2;
			_this.vspace = 0;
			return;
	}
}
//ifLoadImg搴旂敤浜嶫S鍒ゆ柇FLASH鏄惁鍔犺浇鍒版暟鎹?idname涓虹綉椤典笂鍒涘缓鐨凢LASHid闆嗗悎锛?
function IfLoadImg(idname) {
	var m=document.getElementById("ifFlashHome");
	if (!_Back){
		flashAble = false;
		var _id = new Array;
		id = idname.split("-");		  
		var idIength = id.length-1; 
		for (var i = 0;i< idIength;i++){ 
			_flashId = id[i];
			doflash(Ifclick[_flashId].ld,_flashId);
			}
	}

}
//ifFlashImage涓篎lash杈撳嚭鍙傛暟鍒癑S鏉ヤ互姝ゆ潵鍒ゆ柇FLASH鏄惁鍔犺浇鍒板浘鐗?
function ifFlashImage(command) {
	if (command == "ShowImg"){
       _Back = true;
	}
}
//init涓烘枃妗ｅ垵濮嬪寲鍑芥暟;璇存楿Url涓哄垽鏂璅lash鏄惁鍙敤鐨凢LASH婧愬湴鍧‿idname涓虹綉椤典笂鍒涘缓鐨凢LASHid闆嗗怿loadUrl浼犲叆鍥剧墖鍦板潃瑕佹眰蹇呴渶涓簀peg鏍煎粿
function init(Url,_idname,loadUrl){
    document.write('<div id="ifFlashHome"></div>'); 
    var m=document.getElementById("ifFlashHome");
	var loadUrl = "noPhoto.jpg"
	var _width = 1
	var _height = 1
	var Num = "flashnewName"
	idname =_idname
    var newHTML ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+_width +'" height="'+_height +'"id="'+Num+'">';
	newHTML +='<param name="allowScriptAccess" value="always"><param name="movie" value="'+Url+'"><param name="quality" value="high"><param name="menu" value="false">';
	newHTML +='<param name="FlashVars" value="myVar='+loadUrl+'">';
	newHTML +='<embed src="'+Url+' FlashVars="myVar="'+loadUrl+'" menu="false" quality="high" width="'+ _width +'" height="'+ _height +'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" name="'+Num+'"/></object>';
	newHTML +='<iframe src="about:blank" frameborder="0" width="1" height="1" name="commandFrame"></iframe>';
	m.innerHTML = newHTML;
    window.frames['commandFrame'].document.write('<'+'script type="text/javascript">function commandDelegate(command){parent.ifFlashImage(command);}<'+'/script>');
    window.setTimeout("IfLoadImg(idname)", 3000);
}