var ffile;
var islogin;
var ml;
var tt = 0;
var border = 0;
var bordercolor = "#CEBE90";
bordercolor = "#E7E7E7";
var Type;
var fullplay = false;
var servers = new Array();
servers[0]=['电信服务器&nbsp;&nbsp;', 'http://www.bt345.cn/softdown/'];
servers[1]=['网通服务器', 'http://www.bt345.cn/softdown/'];
if(window.location.href.indexOf("_Flash")<0){
	var currentserver = getCookie('currentserver');
	var serverid = (currentserver!=null && currentserver<=2) ? currentserver:Math.floor(Math.random()*servers.length);
} else {
	var serverid=1;
}
var servername = servers[serverid][0];
var server     = servers[serverid][1];

var lad = "<div id='load_flash' style='background:#ccc;width:346px;height:2px;padding:10px;font-size:14px;font-weight:bold;color:#fff;border:1px #aaa solid;'><script type='text/javascript'>google_ad_client='pub-7347184282770257';google_ad_slot ='8674963443';google_ad_width=336;google_ad_height=280;</script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script><div></div></div>";


function getType(){
	var pattern = /(.*)\.(.*)$/gi;
	var arr = pattern.exec(file);
	return RegExp.$2;
}
function fuck(){
	if(!file) {
		sid = (sid=='bt345.cn')?'':sid+'/';
		file = sid + s + f
	}
	ffile = file;
	if((file.slice(0,7)!="http://") && (file.slice(1,2)!=":")){
		if(server==undefined) server = servers[0][1];
		file=server+file;
	}
}
function copyToClipBoard(){
	var clipBoardContent=document.location; 
	clipBoardContent+='\n这个是我很喜欢的小游戏，名字叫《' + title + '》，真诚向你推荐，希望你也会喜欢哦!';
	window.clipboardData.setData("Text",clipBoardContent);
	alert("耶！复制成功喽！你可以粘贴在QQ消息里送给你的好朋友呀！再次感谢您对本站的支持哦！");
}
function Replay() {
	if(Type=="swf"){
		document.getElementById('flash').movie=" ";
		document.getElementById('flash').movie=server+ffile;
	} else {
		document.location.reload();
	}
}
function FullPlay() {
	playwin = window.open("/fullplay.htm?id="+id+"&file="+ffile+"&title="+encodeURIComponent(title),"","fullscreen");
	//playwin = window.open("/swf/default.htm?file="+ffile,"","fullscreen");
}
function changeserver(sid){
	for (var i=0; i<servers.length; i++){
		document.getElementById('s'+i).className=(sid==i)?'current':'';
	}
	servername = servers[sid][0];
	server = servers[sid][1];
	if((ffile.slice(0,7)!="http://") && (ffile.slice(1,2)!=":")){
		document.getElementById('flash').movie=server+ffile;
		loaded();
	}
	setCookie('currentserver', sid, '/');
}
function makeFlashPlayer(src, id, width, height){
	document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' id=" + id + " WIDTH=" + width + " HEIGHT=" + height + " style='border:" + border + "px solid " + bordercolor + ";'>");
	document.write("<PARAM NAME=src VALUE='"+ src +"'>\n");
	document.write("<PARAM NAME=quality VALUE=\"high\">\n");
	document.write("<EMBED src='" + src + "' id='" + id + "' loop=false menu=false WIDTH=" + width + " HEIGHT=" + height + " TYPE='application/x-shockwave-flash' PLUGINSPAGE='=http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash'></EMBED></OBJECT>");
}

//function makeDcrPlayer(src, id, width, height){
//	document.write("<object classid='clsid:166B1BCA-3F9C-11CF-8075-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,0,0,0' ID=" + id + " WIDTH=" + width + " HEIGHT=" + height + ">\n");
//	document.write("<PARAM NAME=src VALUE='"+ src +"'>\n");
//	document.write("<param name=swRemote value=\"swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true' \">\n");
//	document.write("<param name=swStretchStyle value=none>\n");
//	document.write("<embed src=src='" + src + "' WIDTH=" + width + " HEIGHT=" + height + " swRemote=\"swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true'\" swStretchStyle=none type=\"application/x-director\" pluginspage=\"http://www.macromedia.com/shockwave/download/\"></embed></object>\n");
//}

function makeDcrPlayer(src, id, width, height){
var thearray = navigator.plugins;
var isShockwave = false;
var arraylength = thearray.length;
for (i=0; i<arraylength; i++)
{
	theplugin = thearray[i]; 
	thename   = theplugin.name;
	thedesc   = theplugin.description;
	if (thedesc.indexOf("Shockwave") != -1 && thedesc.indexOf("Director") != -1)
	{ 
		isShockwave = true;
	}
}

	if(isShockwave == false){str_7k8k = '<div id="aobj" style="height:120px;"><iframe src="http://www.bt345.cn/ad/shockwaveplayer.html" height="120" width="450" marginheight="0" marginwidth="0" scrolling="no" frameborder="0"></iframe></div>';
	//alert(isShockwave);
	document.write(str_7k8k);
	document.write(lad);
	
	}
	
	else{
		str_7k8k='<object name="'+id+'" id="'+id+'" width="'+width+'" height="'+height+'" classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0"><param name="background" value="#000"><param name="swStretchStyle" value="fill"><param name="logo" value="false"><param name="menu" value="false"><param name="src" value="'+src+'">';
	document.write(str_7k8k);
		}
	
	
}




function makeMediaPlayer(src, width, height){
	document.write("<embed src=\""+ src +"\" autostart=\"1\" showcontrol=\"1\" showdisplay=\"0\" showstatusbar=\"1\" width=\""+ width +"\" height=\""+ height +"\">\n");
}
function makeMovPlayer(src, width, height){
	document.write("<embed src=\""+ src +"\" border=\"0\" controller=\"true\" target=\"myself\" pluginspage=\"http://www.apple.com/quicktime/download/\" loop=\"FALSE\" autoplay=\"true\" width=\""+ width +"\" height=\""+ height +"\">\n");
}
var file;
function makeMp3Player(src,width, height){
	document.write("<embed src=\""+ src +"\" width=\""+ width +"\" height=\""+ height +"\" autostart=\"1\" showcontrol=\"1\" showdisplay=\"0\" showstatusbar=\"1\"></embed>\n");
}
function makeIframe(src,width, height){
	document.write("<iframe name=ali src='"+src+"?width="+width+"&height="+height+"' width='"+width+"' height='"+height+"' marginwidth=0 marginheight=0 scrolling=no border=0 frameborder=0></iframe>");	
}
function loaded(){
	tt = tt+30;
	document.getElementById('percentdiv').style.display="";
	var bg = document.getElementById('bar');
	var bb = document.getElementById('percent');
	if(document.getElementById('flash').PercentLoaded()<0) {
		document.getElementById('percentdiv').style.display="none";
		hid();
	} else {
		bg.style.width=5 * document.getElementById('flash').PercentLoaded();
		bb.innerHTML=document.getElementById('flash').PercentLoaded() + '%';
	}
	if(document.getElementById('flash').PercentLoaded()<90) {
		if(tt>15000) hid();
		var timeout = window.setTimeout(loaded,30);
	} else {
		tt = 0;
		clearTimeout(timeout);
		document.getElementById('percentdiv').style.display="none";
		hid();
	}
}
function hid(){
	//if(document.getElementById('load_flash')!=null)
	//document.getElementById('load_flash').style.display='none';
	//document.getElementById('load_flash').style.display='inline';
	document.getElementById('flash').style.display='';
}
function play(){
	fuck();
	Type = getType();
	switch(Type){
	case "swf":
		if(!fullplay){
			document.write("<div id='servers'>  选择最快的服务器：");
			for (var i=0; i<servers.length; i++){
				if(serverid==i){
					document.write("<a id='s"+i+"' class='current' href='javascript:changeserver("+i+");'>"+servers[i][0]+"</a>");
				} else {
					document.write("<a id='s"+i+"' href='javascript:changeserver("+i+");'>"+servers[i][0]+"</a>");
				}
			}
			document.write("</div>");
		}
		if(document.all && ml!=false){
			document.write('<div id="percentdiv" class="center"><div class="loading_bar"><div id="bar"></div></div><div class="lf" style="color:#ff0000">加载完成:<span id="percent"></span></div></div>');
			if(!fullplay){
				if (islogin){
       					makeFlashPlayer("/images/1.swf", "load_flash", width, height);
				} else {
					document.write(lad);
				}
			}else{
					document.write(lad);
			}
       			makeFlashPlayer(file, "flash", width, height);
			document.getElementById('flash').style.display='none';
			loaded();
		} else {
			border=0;
       			makeFlashPlayer("/images/1.swf", "load_flash", width, height);
       			makeFlashPlayer(file, "flash", '500', height);
			document.getElementById('flash').style.display='none';
		}
		break;
	case "dcr":
	case "dir":
		makeDcrPlayer(file, "flash", '500', height);
		break;
	case "htm":
	case "html":
		makeIframe(file, '500', height);
		break;
	case "mp3":
                makeMp3Player(file, '300', '70');
		break;
	case "mov":
		makeMovPlayer(file, '400', '300');
		break;
	case "wav":
	case "wmv":
	case "mpg":
	case "mpeg":
	case "asf":
		makeMediaPlayer(file, '550', '400');
		break;
	default: 
       		makeFlashPlayer(file, "flash", width, height, "#000000");
		break;
	}
}
