var lnetshowtime=11000;
var minlnetshowtime=8000;
if(checkCookieExist('username')) lnetshowtime=minlnetshowtime=4000;
gdserver=gameserver.replace('game','gd');
var servers = new Array();
servers[0]=['电信服务器',gameserver];
servers[1]=['江苏电信',	gameserver];
servers[2]=['广东电信',	gameserver];
servers[3]=['网通服务器',gdserver];
var currentserver=getCookie('currentserver');
if(currentserver!=null && currentserver<servers.length){
	serverid=currentserver;
}else{
	var randserver=Math.floor(Math.random()*100);
	if(randserver<18) serverid=0;
	if(randserver>=18) serverid=1;
	if(randserver>=58) serverid=2;
}
var servername=servers[serverid][0];
var server=servers[serverid][1];
setCookie('currentserver',serverid,'/');
var sleft="<div class='left'><a href='/help/' target='_0'>不能播放看这里</a> <a href=\"javascript:window.external.AddFavorite('http://wt.dingu.net/?favp', '叮咕小游戏 - wt.dingu.net');\" style=\"color:red\">收藏叮咕小游戏</a> <a href='/' target='_0' style='color:#4c892e'>返回首页</a></div>";
var sright="";
var s_html="<span style='font-weight:bold;float:left;font-size:14px;padding-top:4px;'>选择游戏服务器→</span>";
for(
var i=0;i<servers.length;i++)
{if(serverid==i){s_html+="<a hideFocus id='s"+i+"' class='current' href='javascript:changeserver("+i+");' title='当前所在服务器'>"+servers[i][0]+"</a>"
}else{
	s_html+="<a hideFocus id='s"+i+"' href='javascript:changeserver("+i+");'>"+servers[i][0]+"</a>"
	}
	}
var serverdivhtml=sleft+"<div class='servers'>"+s_html+"</div>"+sright+"<div class='spacer'></div>";
var fullbarhtml="<div id='fullbar'><span class='left'><strong>"+title+"</strong> <a href=\"javascript:openintro();\">[查看游戏说明]</a> <a href=\"javascript:Replay();\">[重新开始游戏]</a></span><span class='right'>如果游戏显示不全，请按F11键 <button id='BestSizeButton' onclick='bestsize();'>最佳画面</button> <button id='MaxSizeButton' onclick='maxsize();' disabled='true'>最大画面</button> <button onclick='closefull();'>退出全屏</button></span></div>";
var file;
var fullscreen=false;
var tt=0;
var width=640;
var height=466;
var ScreenSize;
if(screen.width<1024){
	width=550;height=400
	}
var Type;
function getType(){
	var a=/(.*)\.(.*)$/gi;
	var b=file.split('?');
	var c=a.exec(b[0]);
	return RegExp.$2
}
function fuck(){
	if(!file){
		sid=(sid=='wt.dingu.net')?'':sid+'/';
		file=sid+s+f
		}
}
function cfile(){
	if((file.slice(0,7)!="http://")){//&&(file.slice(0,1)!=" ")
		if(server==undefined)server=servers[0][1];
		return server+file
		}
		return file
		}
function addfav(){
	if(!islogin){
		window.external.AddFavorite("http://"+self.location.host+self.location.pathname+'?fav',title+' - 叮咕小游戏');
	}else{
		makeRequest('/e/enews/index.php?enews=AddFava&classid='+classid+'&id='+id+'&cid=0&doajax=1','EchoReturnedText','GET','');
		}
}
function addfav_return(r){
	var a=r.responseText;
	if(a=='notlogin'){
		alert("只有登录帐号后才能使用收藏夹功能!")
	}else if(a=='repeat'){
		alert("你选择的小游戏 ["+title+"] 已经在你的收藏夹内了!")
	}else if(a=='succeed'){
		alert(title+"小游戏已成功添加到您的收藏夹!")
	}else{
		alert("系统忙,请稍后再试!")
		}
}
function gotoqzone(){
	qq=prompt("请先登录QQ空间后在此输入你的QQ号码",checkCookieExist('qq')?unescape(getCookie('qq')):"");
	if(qq){
		if(qq.match(/^[1-9]\d{4,9}$/)==null){
			alert('请输入正确的QQ号码');
			return gotoqzone()
		}
		setCookie('qq',qq,'/');
		$('qzonelink').href="http://wt.dingu.net/go.php?action=qzone&id="+id+"&qq="+qq;
		return true
	}
	return false
}
function copyToClipBoard(){
	var a="http://"+self.location.host+self.location.pathname;a+='\n这个是我很喜欢的小游戏，名字叫《'+title+'》，真诚向你推荐，希望你也会喜欢哦!';
	window.clipboardData.setData("Text",a);
	alert("耶！复制成功喽！你可以粘贴在QQ消息里送给你的好朋友呀！再次感谢您对本站的支持哦！")
}
function Replay(){
	changeserver(serverid)
}
function getScreenSize(){
	var w=0;var h=0;
	if(self.innerHeight){
		w=self.innerWidth;
		h=self.innerHeight
		}else if(document.documentElement&&document.documentElement.clientHeight){
			w=document.documentElement.clientWidth;
			h=document.documentElement.clientHeight
		}else if(document.body){
				w=document.body.clientWidth;
				h=document.body.clientHeight
		}
		return{width:w,height:h}
}
function openintro(){
	if(document.all){
		$s('flash');
		$s('bpic',1)
		}
	var b=adddiv("coverdiv","");
	b.onclick=function(){
		closeintro()
		};
	ScreenSize=getScreenSize();
	var a="<div class='t'>游戏说明：</font></div><div class='c'>"+$('introcontent').innerHTML+"</div><div class='q' onclick='closeintro();' title='关闭游戏说明'>关 闭</div>";
	var c=adddiv("fullintro",a);
	c.style.left=(ScreenSize.width-c.clientWidth)/2+'px';
	c.style.top=(ScreenSize.height-c.clientHeight)/2+'px'
}
function closeintro(){
	if(document.all){
		$s('flash',1);
		$s('bpic')}$s('bpic');
		$('coverdiv').parentNode.removeChild($('coverdiv'));
		$('fullintro').parentNode.removeChild($('fullintro'));
		$('flash').focus()
}
function getplaysize(w,h){
	if(pwidth>0&&pheight>0){
		if(pwidth/pheight>w/h){
			h=pheight*(w/pwidth)
		}else{
			w=pwidth*(h/pheight)
		}
	}
	return{width:w,height:h}
}
function bestsize(){
	setCookie('play_mode','bestsize','/');
	if(!fullscreen){FullScreen()}
	else{
	var a=(pwidth<=ScreenSize.width&&pwidth>0)?pwidth:ScreenSize.width;
	var b=(pheight<=(ScreenSize.height-$('fullbar').clientHeight)&&pheight>0)?pheight:ScreenSize.height-$('fullbar').clientHeight;
	var c=getplaysize(a,b);
	$('flash').style.width=$('gamec').style.width=c.width+'px';
	$('flash').style.height=$('gamec').style.height=c.height+'px';
	$('gamec').style.marginTop=(ScreenSize.height-c.height-$('fullbar').clientHeight)/2+'px';
	$('MaxSizeButton').disabled=false;$('BestSizeButton').disabled=true;document.location.hash="#bestsize";
	$('flash').focus()
	}
}
function maxsize(){
	setCookie('play_mode','maxsize','/');
	if(!fullscreen){
		FullScreen()
	}else{
	var a=ScreenSize.width;var b=ScreenSize.height-$('fullbar').clientHeight;
	var c=getplaysize(a,b);
	$('gamec').style.width=$('flash').style.width=c.width+'px';
	$('gamec').style.height=$('flash').style.height=c.height+'px';
	$('gamec').style.marginTop=(b-c.height)/2+'px';
	$('MaxSizeButton').disabled=true;
	$('BestSizeButton').disabled=false;document.location.hash="#maxsize";
	$('flash').focus()
	}
}
function FullScreen(){
	if(!$('game')){
		document.location.hash=='#bestsize';
		return}if(fullscreen)return;
		fullscreen=true;
		if($('leftnet'))$s('leftnet');
		if($('rightnet'))$s('rightnet');
		if($('divc'))$s('divc');
		$s('p_info');
		ScreenSize=getScreenSize();
		$s('fullbar',1);
		$('fullbar').innerHTML=fullbarhtml;
		if(pwidth=="0"||pheight=="0"||pwidth>ScreenSize.width||pheight>ScreenSize.height-$('fullbar').clientHeight){
			$s('MaxSizeButton');
			$s('BestSizeButton')
		}
		document.body.style.overflow="hidden";
		document.getElementsByTagName('body')[0].scroll="no";
		document.body.style.width=ScreenSize.width+'px';
		document.body.style.height=ScreenSize.height+'px';
		$('game').className="fulldiv";
		$('game').style.width=ScreenSize.width+'px';
		$('game').style.height=ScreenSize.height+'px';
		if(getCookie('play_mode')=='maxsize'){
			maxsize()
			}else
				{bestsize()
		}
		window.scrollTo(0,0);
		$('flash').focus()
}
function refullscreen(){
	if(fullscreen){
		fullscreen=false;
		FullScreen()
	}
}
function closefull(){
	fullscreen=false;
	$s('fullbar');
	$s('p_info',1);
	if($('leftnet'))$s('leftnet',1);
	if($('rightnet'))$s('rightnet',1);
	if($('divc'))$s('divc',1);
	document.body.style.width='';
	document.body.style.height='';
	document.body.style.overflow="auto";
	$('game').style.width=$('gamec').style.width="";
	$('game').style.height=$('gamec').style.height="";
	$('game').className=$('game').className.replace('fulldiv','');
	var a=getplaysize(width,height);
	$('flash').style.width=$('gamec').style.width=a.width+'px';
	$('flash').style.height=$('gamec').style.height=a.height+'px';
	$('gamec').style.marginTop=(height-a.height)/2+'px';
	document.location.href="#best";
	$('flash').focus()
}
function addEvent(a,b,c){
	if(a.addEventListener){
		a.addEventListener(b,c,true)
	}else{
		a.attachEvent("on"+b,c)
	}
}
function removeEvent(a,b,c){
	if(a.removeEventListener){
		a.removeEventListener(b,c,true)
	}else{
		a.detachEvent("on"+b,c)
	}
}
function FullPlay(){
	FullScreen()
}
function adddiv(i,c){
	var o=document.createElement("div");
	o.id=i;o.innerHTML=c;
	document.body.appendChild(o);
	return o
}
function changeserver(sid){
	for(var i=0;i<servers.length;i++){
		$('s'+i).className=(sid==i)?'current':''
	}
	serverid=sid;
	servername=servers[sid][0];
	server=servers[sid][1];
	if(file.slice(0,1)!=""){
		if(Type=="swf"){
			if(navigator.userAgent.indexOf("Firefox")>0){
				$('gamec').innerHTML=FlashPlayer(cfile(),"flash",width,height)
			}else{$('flash').movie=" ";
				$('flash').movie=cfile();
				loaded()
			}
		}
		if(Type=="htm")$('flash').src=cfile()+"?loadingbar=1";
		if(Type=="dcr"||Type=="dir")$('gamec').innerHTML=DcrPlayer(cfile(),"flash","100%","100%")
	}
	setCookie('currentserver',sid,'/')
}
function FlashPlayer(src,id,width,height){
	var wmode="window";
	if(navigator.userAgent.indexOf("Firefox")>0)wmode='opaque';
	if(typeof(anw)=="undefined")anw=0;
	var allownetworking=(anw==1)?"internal":"all";
	return"<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+"' allownetworking='"+allownetworking+"'><PARAM NAME=src VALUE='"+src+"'><param name='allowScriptAccess' value='sameDomain'><PARAM NAME='AllowNetworking' VALUE='"+allownetworking+"'><PARAM NAME=quality VALUE='high'><param name='wmode' value='"+wmode+"'><EMBED src='"+src+"' id='"+id+"' loop=false menu=true WIDTH="+width+" HEIGHT="+height+" TYPE='application/x-shockwave-flash' wmode='"+wmode+"' PLUGINSPAGE='=http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash' allownetworking='"+allownetworking+"'></EMBED></OBJECT>"
}
function DcrPlayer(a,b,c,d){
	return'<span id="sfhelp" style="font-weight:bold;color:red;">如果这个游戏无法播放，请 <a href="/help/help.htm" target="_0" style="color:#fff;">点这里安装插件！</a> <a href="javascript:$s(\'sfhelp\')" style="color:red">[关闭提示]</a></span><object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=11,0,0,465" width="'+c+'" height="'+d+'" id="'+b+'"><param name="src" value="'+a+'"><param name="logo" value="false"><param name="playerVersion" value="11"><param name="menu" value="false"><param name="bgColor" value="#000000"><embed src="'+a+'" id="'+b+'" logo="false" menu="false" pluginspage="http://www.macromedia.com/shockwave/download/" width="'+c+'" height="'+d+'"></embed></object>'
}
function IframePlayer(a,b,c,d){
	if(file.slice(0,20)!="/upload/gamelink.htm")a+="?loadingbar=1";return"<iframe name='igame' id='"+b+"' src='"+a+"' width='"+c+"' height='"+d+"' marginwidth=0 marginheight=0 scrolling=no border=0 frameborder=0></iframe>"
}
var Percentage=100;
function loaded(){
	if(navigator.userAgent.indexOf("Firefox")>0)return;tt=tt+30;
	$s('loadingdiv',1);
	Percentage=$('flash').PercentLoaded();
	if(Percentage<0)Percentage=100;
	$('bar').style.width=5*Percentage;$('percent').innerHTML=Percentage+'%';
	if(Percentage<100||tt<minlnetshowtime){
		var a=window.setTimeout(loaded,30)
	}else{
		$s('loadingdiv');
		if(tt>minlnetshowtime){
			clearTimeout(a);
			closeloadnet();
			$('flash').focus()
		}
		tt=0;
		setCookie('visited'+id,'yes','/')
	}
}
function hid(){
	$s('ffload')
}
function closeloadnet(){
	$s('loadnet')
}
function play(){
	fuck();
	var a;
	$s('fullbar');
	$('serverdiv').innerHTML=serverdivhtml;
	Type=getType();
	$('loadingdiv').style.display='none';
	var b=getplaysize(width,height);
	$('gamec').style.width=b.width;
	$('gamec').style.height=b.height;
	$('gamec').style.marginTop=(height-b.height)/2;
	switch(Type){
		case"dcr":
		case"dir":
			a=DcrPlayer(cfile(),"flash","100%","100%");
			break;
		case"htm":
		case"html":
			a=IframePlayer(cfile(),"flash","100%","100%");
			break;
		default:
			a=FlashPlayer(cfile(),"flash","100%","100%");
			break
	}
	document.write(a);
	document.write('<img id="bpic" src="'+pic+'" style="width:100%;height:100%;display:none;" />');
	if(Type=='swf')loaded();
	if(Type=='htm'||Type=='dcr'||getCookie('visited'+id)=='yes')lnetshowtime=minlnetshowtime;
	if(islogin)lnetshowtime=minlnetshowtime=5000;if(file.slice(0,1)=="/")closeloadnet();
	window.setTimeout(closeloadnet,lnetshowtime)
}
addEvent(window,"resize",refullscreen);