/* vim:set ts=2 sw=2 sts=2 et cin: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 function copyToClipBoard(s) {
            //alert(s);
            if (window.clipboardData) {
                window.clipboardData.setData("Text", s);
                
            } else if (navigator.userAgent.indexOf("Opera") != -1) {
                window.location = s;
            } else if (window.netscape) {
              
                var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
                if (!clip)
                    return;
                var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
                if (!trans)
                    return;
                trans.addDataFlavor('text/unicode');
                var str = new Object();
                var len = new Object();
                var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
                var copytext = s;
                str.data = copytext;
                trans.setTransferData("text/unicode", str, copytext.length * 2);
                var clipid = Components.interfaces.nsIClipboard;
                if (!clip)
                    return false;
                clip.setData(trans, null, clipid.kGlobalClipboard);
            
            }
        }
function json2str(obj) {
    var THIS = this;
    switch (typeof (obj)) {
        case 'string':
            return "\"" + obj.replace(/(["\\])/g, '\\$1') + "\"";
        case 'array':
            return '[' + obj.map(THIS.json2str).join(',') + ']';
        case 'object':
            if (obj instanceof Array) {
                var strArr = [];
                var len = obj.length;
                for (var i = 0; i < len; i++) {
                    strArr.push(THIS.json2str(obj[i]));
                }
                return '[' + strArr.join(',') + ']';
            } else if (obj == null) {
                return 'null';

            } else {
                var string = [];
                for (var property in obj) string.push(THIS.json2str(property) + ':' + THIS.json2str(obj[property]));
                return '{' + string.join(',') + '}';
            }
        case 'number':
            return obj;
        case 'boolean':
            return obj;
        case false:
            return obj;
    }
}
var autologin={
	
	serverurl:["http://dts.37.com","http://dtszj.yy.com/","http://dtszj.wan.360.cn","http://dts.6711.com/","http://youxi.baidu.com/dts/index/","http://wan.sogou.com/login.do?gid=269",
	"http://dts.yilewan.com/","http://wan.liebao.cn/dts/server_list.html","http://dts.swjoy.com/","http://dts.niu.xunlei.com/index.shtml","http://game.weibo.com/","http://games.ifeng.com/webgame/dtszj/",
	"http://www.9211.com/GameWeb/1000054","http://www.5599.com/dts/","http://game.funshion.com/xf/124/"],
	open:function(agent){
		//brow.loadURI(autologin.serverurl[agent], null, null);
		if(agent<0||agent>=autologin.serverurl.length)return "chrome://simple/content/index.html";
		var url=autologin.serverurl[agent];
		return url;
	},
	login:function(doc,agent,user,pass,serverid){
		var agentlist=[autologin.f_37wan,autologin.f_yy,autologin.f_360,autologin.f_6711,autologin.f_baidu,autologin.f_sougou,autologin.f_shengda,autologin.f_jinshan,
		autologin.f_shunwang,autologin.f_xunlei,autologin.f_xinlang,autologin.f_fenghuang,autologin.f_9211,autologin.f_5599,autologin.f_fengxing];
		if(agent<0||agent>=agentlist.length)return;
		return agentlist[agent](doc ,user,pass,serverid);
	},
	f_fengxing:function(doc,user,pass,serverid){	
		
		if(doc.getElementsByClassName("userpanel").length<=0)return;
		if(doc.getElementById("loginedPannel")!=null&&doc.getElementById("loginedPannel").ownerDocument.defaultView.getComputedStyle(doc.getElementById("loginedPannel"), null)["display"]=="block")
		{
			var serlist=doc.getElementById("all_server").getElementsByTagName('a');
			for(var i=0;i<serlist.length;i++){
			//	simple.Log(serlist[i].text);
				if(serlist[i].text.indexOf("风行"+serverid+"区")!=-1)
				return serlist[i].href;
			}
		
		}
		if(doc.getElementById("loginPannel")!=null&&doc.getElementById("loginPannel").ownerDocument.defaultView.getComputedStyle(doc.getElementById("loginPannel"), null)["display"]=="block")
		{
			if(doc.getElementById("login_username")==null||doc.getElementById("login_password")==null||doc.getElementById("login_sum")==null)return;
			doc.getElementById("login_username").value=user;
			doc.getElementById("login_password").value=pass;
			doc.getElementById("login_sum").click();
		}
	},
	f_5599:function(doc,user,pass,serverid){	
		
		if(doc.title=="用户登录")
		{
			if(doc.getElementById("userInput")==null||doc.getElementById("passInput")==null||doc.getElementsByTagName("button").length<=0)return;
			doc.getElementById("userInput").value=user;
			doc.getElementById("passInput").value=pass;
			
			doc.getElementsByTagName("button")[0].click();
			return;
		}
		if(doc.getElementById("box_login")==null)return;
		

		if(doc.getElementById("box_login").ownerDocument.defaultView.getComputedStyle(doc.getElementById("box_login"), null)["display"]=="block"){
			//登陆前
			
			doc.getElementById("box_login").getElementsByClassName("ipt5")[0].click();
			
		}else{
			var serlist=doc.getElementById("box_moreSlist").getElementsByTagName('a');
			for(var i=0;i<serlist.length;i++){
				if(serlist[i].text.indexOf("线"+serverid+"服")!=-1)
				return serlist[i].href;
			}
		}
	},
	f_9211:function(doc,user,pass,serverid){	
		
		if(doc.title=="9211-登录")
		{
			if(doc.getElementById("txtUser")==null||doc.getElementById("txtPassWord")==null||doc.getElementById("autoLogin")==null||doc.getElementsByClassName("confirm").length<=0)return;
			doc.getElementById("txtUser").value=user;
			doc.getElementById("txtPassWord").value=pass;
			doc.getElementById("autoLogin").checked=true;			
			doc.getElementsByClassName("confirm")[0].click();
		}
		if(doc.getElementsByClassName("loginCont").length<=0)return;
		
		if(doc.getElementsByClassName("loginCont")[0].getElementsByClassName("rgrbor").length<=0){
		//登陆后
			return "http://www.9211.com/Game/Play?gameId=1000054&serverId="+serverid;
		}else{
			doc.getElementById("headerLogoutPart").getElementsByTagName('a')[0].click();
		}
	},
	f_fenghuang:function(doc,user,pass,serverid){	
		if(doc.getElementById("nologin")==null)return;
		if(doc.getElementById("nologin").ownerDocument.defaultView.getComputedStyle(doc.getElementById("nologin"), null)["display"]=="none"){
			//已经登陆成功
			return "http://play.ifeng.com/?_c=dtszj&_a=enterGame&area="+serverid;
			
		}else{
			
			if(doc.getElementById("_M_username")==null||doc.getElementById("_M_password")==null||doc.getElementById("M_inpass")==null||doc.getElementById("M_btnConfirm")==null)return;
			doc.getElementById("_M_username").value=user;
			doc.getElementById("_M_password").value=pass;
			doc.getElementById("M_inpass").checked=true;			
			doc.getElementById("M_btnConfirm").click();
			var timer=setInterval(function (){
					if(doc.getElementById("nologin")==null)return;
					if(doc.getElementById("nologin").ownerDocument.defaultView.getComputedStyle(doc.getElementById("nologin"), null)["display"]=="none"){
						//已经登陆成功
						clearInterval(timer);
						document.getElementById("textbox").value="http://play.ifeng.com/?_c=dtszj&_a=enterGame&area="+serverid;
						simple.brow.loadURI(document.getElementById("textbox").value,null, null);
						return ;
					}
			},500);
		}

			
	

	},
	f_xinlang:function(doc,user,pass,serverid){	
		

			
		if(doc.getElementById("newWYX_loginUname")!=null&&doc.getElementById("newautoLogin")!=null&&doc.getElementById("newWYX_loginUpwd")!=null&&doc.getElementById("newWYX_loginBtn")!=null)
		{
			doc.getElementById("newWYX_loginUname").focus();
			doc.getElementById("newWYX_loginUname").value=user;
			doc.defaultView.wrappedJSObject.wyxIndexLogin.medata.username=user;
			doc.defaultView.wrappedJSObject.wyxIndexLogin.prelogin();
			doc.getElementById("newWYX_loginUpwd").focus();
			doc.getElementById("newWYX_loginUpwd").value=pass;
			doc.getElementById("newautoLogin").checked=true;	
			setTimeout(function(){
					doc.getElementById("newWYX_loginBtn").click();},800);			
		
		}
		else
		{
	
			if(doc.getElementsByClassName("topnav_con").length>0&&doc.getElementsByClassName("topnav_con")[0].getElementsByClassName("pr").length>0&&
			doc.getElementsByClassName("topnav_con")[0].getElementsByClassName("pr")[0].getElementsByClassName("user").length>0)
			return "http://game.weibo.com/datianshizhijian?action=login&service="+(180012401000+parseInt(serverid))+"&ownpt=weibo";
		}
		

	},
	f_xunlei:function(doc,user,pass,serverid){	
		if(doc.getElementById("loginedBox")==null)return;
		if(doc.getElementById("loginedBox").ownerDocument.defaultView.getComputedStyle(doc.getElementById("loginedBox"), null)["display"]=="block"){
			//已经登陆成功
			return "http://niu.xunlei.com/entergame/dts/?fenQuNum="+serverid;
			
		}else{
		
			if(doc.getElementById("accountBox")==null||doc.getElementById("passwordBox")==null||doc.getElementById("autoLoginLink")==null||doc.getElementById("loginBtn")==null)return;
			doc.getElementById("accountBox").getElementsByTagName("label")[0].click();
			doc.getElementById("accountBox").getElementsByTagName("input")[0].value=user;
			doc.defaultView.wrappedJSObject.OfficialLoginModule.getInstance().checkVerifyCode();
			doc.getElementById("passwordBox").getElementsByTagName("label")[0].click();
			doc.getElementById("passwordBox").getElementsByTagName("input")[0].value=pass;
			doc.getElementById("autoLoginLink").className=doc.getElementById("autoLoginLink").className+" chked";			
				setTimeout(function(){
					doc.getElementById("loginBtn").click();},800);
			var timer=setInterval(function (){
					if(doc.getElementById("loginedBox")==null)return;
					if(doc.getElementById("loginedBox").ownerDocument.defaultView.getComputedStyle(doc.getElementById("loginedBox"), null)["display"]=="block"){
						//已经登陆成功
						clearInterval(timer);
						document.getElementById("textbox").value="http://niu.xunlei.com/entergame/dts/?fenQuNum="+serverid;
						simple.brow.loadURI(document.getElementById("textbox").value,null, null);
						return ;
					}
			},500);
			
		}
	},
	f_shunwang:function(doc,user,pass,serverid){	
	//这服务器商太慢了，暂时不支持
		if(doc.title=="顺网SSO 登录页"){
			if(doc.getElementById("login_form_")==null)return;
			//if(doc.getElementById("lpad").ownerDocument.defaultView.getComputedStyle(doc.getElementById("secid"), null)["display"]=="none")
			{
				if(doc.getElementById("userName")==null||doc.getElementById("passwordInp")==null||doc.getElementById("loginButton_YHJ")==null)return;
				doc.getElementById("userName").value=user;
				doc.getElementById("passwordInp").value=pass;
					
				doc.getElementById("loginButton_YHJ").click();
			}
			
		}else{
			
			if(doc.getElementById("contents")==null)return;
			var timer=setInterval(function (){
					if(doc.getElementsByClassName("yesLoginCID").length<=0)return;
					
					//已经登陆成功
					clearInterval(timer);
					document.getElementById("textbox").value="http://dts.swjoy.com/front/play.htm?serverid="+serverid;
					simple.brow.loadURI(document.getElementById("textbox").value,null, null);
					return ;
					
				},500);
		}
		
		
	
			
		
	},
	f_jinshan:function(doc,user,pass,serverid){	
		if(doc.title=="登录"){
			if(doc.getElementById("lpad")==null)return;
			//if(doc.getElementById("lpad").ownerDocument.defaultView.getComputedStyle(doc.getElementById("secid"), null)["display"]=="none")
			{
				if(doc.getElementById("unm")==null||doc.getElementById("pwd")==null||doc.getElementById("rm")==null||doc.getElementById("loginbtn_img")==null)return;
				doc.getElementById("unm").value=user;
				doc.getElementById("pwd").value=pass;
				doc.getElementById("rm").checked=true;			
				doc.getElementById("loginbtn_img").parentElement.click();
			}
			
		}
		if(doc.getElementById("log")==null)return;
		if(doc.getElementById("log").ownerDocument.defaultView.getComputedStyle(doc.getElementById("log"), null)["display"]=="none"&&
		doc.getElementById("log").ownerDocument.defaultView.getComputedStyle(doc.getElementById("loged"), null)["display"]=="block"
		){
			//已经登陆成功
			return "http://wan.liebao.cn/game_frame/play_1040.php?sid="+serverid;
			//return "http://gameapp.37.com/controller/enter_game.php?game_id=237&sid="+serverid+"&showlogintype=3";
		}
		
	},
	f_shengda:function(doc,user,pass,serverid){
		if(doc.getElementById("js-nologin")==null||doc.getElementById("js-logined")==null)return;
		if(doc.getElementById("js-nologin").ownerDocument.defaultView.getComputedStyle(doc.getElementById("js-logined"), null)["display"]=="block"){
			//已经登陆成功
			return "http://www.yilewan.com/Game/play/gameId/DTS/serverId/s"+serverid+".html";
			
		}else{
			
			if(doc.getElementById("login_account")==null||doc.getElementById("password")==null||doc.getElementById("js-cross-form")==null)return;
			if(doc.getElementById("js-nologin").ownerDocument.defaultView.getComputedStyle(doc.getElementById("js-nologin"), null)["display"]=="block")
			{
				doc.getElementById("login_account").value=user;
				doc.getElementById("password").value=pass;
					
				doc.getElementById("js-cross-form").getElementsByTagName("Button")[0].click();
				var timer=setInterval(function (){
					if(doc.getElementById("js-nologin")==null||doc.getElementById("js-logined")==null)return;
					if(doc.getElementById("js-nologin").ownerDocument.defaultView.getComputedStyle(doc.getElementById("js-logined"), null)["display"]=="block"){
						//已经登陆成功
						clearInterval(timer);
						document.getElementById("textbox").value="http://www.yilewan.com/Game/play/gameId/DTS/serverId/s"+serverid+".html";
						simple.brow.loadURI(document.getElementById("textbox").value,null, null);
						return ;
					}
				},500);
			}

		}
	},
	f_37wan:function(doc,user,pass,serverid){
		if(doc.getElementById("log")==null)return;
		if(doc.getElementById("log").ownerDocument.defaultView.getComputedStyle(doc.getElementById("log"), null)["display"]=="none"){
			//已经登陆成功
			return "http://www.37.com/game/play.php?game_id=237&sid="+serverid;
			//return "http://gameapp.37.com/controller/enter_game.php?game_id=237&sid="+serverid+"&showlogintype=3";
		}else{
			
			if(doc.getElementById("username")==null||doc.getElementById("password")==null||doc.getElementById("remember")==null||doc.getElementById("log-btn")==null)return;
			doc.getElementById("username").value=user;
			doc.getElementById("password").value=pass;
			doc.getElementById("remember").checked=true;			
			doc.getElementById("log-btn").click();
			var timer=setInterval(function (){
					if(doc.getElementById("log")==null)return;
					if(doc.getElementById("log").ownerDocument.defaultView.getComputedStyle(doc.getElementById("log"), null)["display"]=="none"){
						//已经登陆成功
						clearInterval(timer);
						document.getElementById("textbox").value="http://www.37.com/game/play.php?game_id=237&sid="+serverid;
						simple.brow.loadURI(document.getElementById("textbox").value,null, null);
						return ;
					}
			},500);
		}
		
	},
	f_yy:function(doc,user,pass,serverid){
		
		if(doc.title=="用YY帐号登录"){
	
			if(doc.getElementById("secid")==null)return;
			
				if(doc.getElementById("username")==null||doc.getElementById("password")==null||doc.getElementById("login_button")==null)return;
				doc.getElementById("username").value=user;
				doc.getElementById("password").value=pass;
			if(doc.getElementById("secid").ownerDocument.defaultView.getComputedStyle(doc.getElementById("secid"), null)["display"]=="none"){
				doc.getElementById("login_button").click();
			}
			
		}
		if(doc.getElementById("not_login2")==null)return;
		if(doc.getElementById("not_login2").ownerDocument.defaultView.getComputedStyle(doc.getElementById("not_login2"), null)["display"]=="none")
		{
			return "http://udblogin.duowan.com/login.do?game=DTSZJ&server=s"+serverid;
			//已经登陆
		}else{
			if(doc.getElementById("udbsdk_login")==null)return;
			if(doc.getElementById("udbsdk_login").ownerDocument.defaultView.getComputedStyle(doc.getElementById("udbsdk_login"), null)["display"]=="none")
			{
				doc.getElementById("not_login2").getElementsByClassName("TopH_fl")[0].click();
			//还没点开登陆窗口
				//doc.getElementById("udbsdk_login")
			}else{
				//已经点开登陆窗口
				
			}
		}
	},
	f_360:function(doc,user,pass,serverid){
		
		if(doc.getElementById("loginWrap")!=null){
			if(doc.getElementById("loginAccount")==null||doc.getElementById("loginSubmit")==null||doc.getElementById("iskeepalive")==null||doc.getElementById("lpassword")==null)return;
			doc.getElementById("loginAccount").value=user;
			doc.getElementById("lpassword").value=pass;
			doc.getElementById("iskeepalive").checked="checked";			
			doc.getElementById("loginSubmit").click();
			
		}else
		{
			if(doc.getElementsByClassName("j-logout").length>0)
			return "http://dtszj.wan.360.cn/game_login.php?server_id=S"+serverid+"&src=360wan-jp-dtszj";
		}
	},
	f_6711:function(doc,user,pass,serverid){
		if(doc.getElementById("user")==null)return;
		if(doc.getElementById("user").ownerDocument.defaultView.getComputedStyle(doc.getElementById("user"), null)["display"]=="none"){
			//已经登陆成功
			return "http://www.6711.com/entergame.php?game=dts&server=S"+serverid+"&showlogintype=3";
		}else{
			
			if(doc.getElementById("login_account")==null||doc.getElementById("password")==null||doc.getElementById("cookie_save")==null||doc.getElementById("login_button")==null)return;
			doc.getElementById("login_account").value=user;
			doc.getElementById("password").value=pass;
			doc.getElementById("cookie_save").checked=true;			
			doc.getElementById("login_button").click();
		}
		
		
	},
	f_baidu:function(doc,user,pass,serverid){
		if(doc.getElementsByClassName("login-form").length<=0)return;
		var timer=setInterval(function (){		
					clearInterval(timer);
					if(doc.getElementsByClassName("login-form")[0].ownerDocument.defaultView.getComputedStyle(doc.getElementsByClassName("login-form")[0], null)["display"]=="none"){
						//已经登陆成功
						
						document.getElementById("textbox").value="http://youxi.baidu.com/login_game_by_post.xhtml?id=842&serverId=S"+serverid;
						simple.brow.loadURI(document.getElementById("textbox").value,null, null);
						
					}else{
						
						if(doc.getElementById("username")==null||doc.getElementById("password")==null||doc.getElementById("remember")==null||doc.getElementById("log-btn")==null)return;
						doc.getElementById("username").value=user;
						doc.getElementById("password").value=pass;
						doc.getElementById("remember").checked=true;			
						doc.getElementById("log-btn").click();
					}
			},1000);
						
		
		
		
	
			
	},
	f_sougou:function(doc,user,pass,serverid){
		if(doc.getElementById("name")==null||doc.getElementById("userPass")==null||doc.getElementById("auto-login")==null||doc.getElementById("qfname")==null||doc.getElementById("playNow")==null)return;
			var event = doc.createEvent('HTMLEvents');  

			event.initEvent("focus", true, true);  
			event.eventType = 'message'; 

			doc.getElementById("name").dispatchEvent(event);  

			doc.getElementById("name").value=user;
			doc.getElementById("userPass").value=pass;
			doc.getElementById("auto-login").getElementsByClassName("auto-login")[0].className=doc.getElementById("auto-login").getElementsByClassName("auto-login")[0].className+" auto";
			doc.getElementById("qfname").setAttribute("sid",""+serverid);
			doc.getElementById("playNow").click();
	
		
	}
};
var simple = {
    debug: true,
    brow: null,
	gamename:"DTS",
	version:28,
	wguserlist:null,
    botcfg: {
        tasklist:["狼魂要塞","赤色要塞","世界BOSS","血色城堡","恶魔广场","精英挑战","日常任务","主线任务","自动挂机"],	
		dailygametask:{Enable:true,RunTils:300,CanDoTime:[],CanNotDoWeekDay:[],cfg:{}},//任务设置
		maingametask:{Enable:true,RunTils:300,CanDoTime:[],CanNotDoWeekDay:[],cfg:{}},//任务设置		
		equip:{Enable:true,RunTils:10,CanDoTime:[],CanNotDoWeekDay:[],cfg:{}},//基本设置
		shop:{Enable:true,RunTils:60,CanDoTime:[],CanNotDoWeekDay:[],cfg:{usegamesell:false,HPCount:200,MPCount:200,intensify:1,q_equip_steplv:1,onlyforme:true,luck:1,addAttributLevel:1,q_quality_lv:2,q_remarkable:0}},//买卖设置
		addpoint:{Enable:true,RunTils:30,CanDoTime:[],CanNotDoWeekDay:[],cfg:{minpoint:30,usegame:true,agile:1,vitality:1,strength:1,intelligence:1}},		//基本设置
		guaji:{Enable:true,RunTils:60,CanDoTime:[],CanNotDoWeekDay:[],cfg:{pos:[],autofightback:true,changepostils:60,huntmode:false,killermode:false}},//挂机设置		
		globalset:{Enable:true,RunTils:1200,CanDoTime:[],CanNotDoWeekDay:[],cfg:{offlineexpenable:true,usegoldexp:false,usemoneyexp:false,autosign:true,autogetsignreward:true,clearmode:true,livenessreward:true}},//基本设置
		useitem:{Enable:true,RunTils:10,CanDoTime:[],CanNotDoWeekDay:[],cfg:{useexpmedicinfb:false,useexpmedicingj:false}},//使用物品
		zhuzao:{Enable:true,RunTils:1800,CanDoTime:[],CanNotDoWeekDay:[],cfg:{moneymin:1400000}},
		moniter:{Enable:true,RunTils:1,CanDoTime:[],CanNotDoWeekDay:[],cfg:{}},
		boss:{Enable:true,RunTils:30,CanDoTime:[],CanNotDoWeekDay:[],cfg:{bosslist:[]}},//boss设置		
		chiseyaosai:{Enable:true,RunTils:60,CanDoTime:[{BeginTime:900,EndTime:910},{BeginTime:1260,EndTime:1270}],CanNotDoWeekDay:[],cfg:{onlyFightBack:true}},//副本设置
		langhunyaosai:{Enable:true,RunTils:60,CanDoTime:[{BeginTime:1230,EndTime:1320}],CanNotDoWeekDay:[],cfg:{}},//副本设置
		jingyintiaozhan:{Enable:true,RunTils:600,CanDoTime:[],CanNotDoWeekDay:[],cfg:{usemoney:true,usegold:false,autohecheng:true,autobuy:true,fightpowerhigh:100}},		//副本设置
		xuese:{Enable:true,RunTils:300,CanDoTime:[],CanNotDoWeekDay:[],cfg:{autohecheng:true,autobuy:true}},//副本设置
		emo:{Enable:true,RunTils:300,CanDoTime:[],CanNotDoWeekDay:[],cfg:{autohecheng:true,autobuy:true}},//副本		
		system:{autostart:false,flashtils:60,autoreconnect:true,entergametils:30,blocktils:10}//基本设置
	
    },
	username:"",
	cfgfilename:"",
	autologinset:{enable:false,user:"",pass:"",agent:1,serverid:"231"},	
	maplist:["坎特鲁废墟","黄金火龙王","失落之塔六层","勇者大陆","VIP5副本","VIP7副本","地下城二层","失落之塔一层","失落之塔二层","失落之塔三层","失落之塔四层","罗兰峡谷","地下城一层","失落之塔七层","地下城三层","死亡沙漠",
"天空之城","古战场(自由PK区)","魔炼之地(自由PK区)","冰风谷","坎特鲁遗址","亚特兰蒂斯","冰霜之城","幽暗森林","失落之塔五层","VIP4副本"],
    urlfixer: null,
	flashtimer:null,
	LastHeart:0,	
	EnterGameTimer:null,
	HeartTimer:null,
    runstate: {start:false},
	onClearLog:function(){
//		alert(Object.prototype.toString.call(simple.botcfg));
		var list=document.getElementById("LogList");
		while(list.getRowCount()>0){		
			list.removeItemAt( 0 );
		}
	},
    GetCfg: function () {
       
        return json2str(simple.botcfg);
    },
    GetRunState: function () {
        return json2str(simple.runstate);
    },
    ShowGameInfo: function (str) {
        document.getElementById("GameInfo").label = str
    },
	extend:function(to,from,override){
	
		if(from==null)return;
		for(var p in from)
		{
			if(!to.hasOwnProperty(p))
			{
			//如果to没有这个节点那么加进去
				to[p]=from[p];
			}else{
			//如果有这个节点那么
				if(Object.prototype.toString.call(from[p])=='[object Object]')
				{
					simple.extend(to[p],from[p],override);
				}else
				//if(Object.prototype.toString.call(from[p])=='[object Array]')
				//{					
				//}else
				if(override) to[p]=from[p];
			}
		}
		//if(n.hasOwnProperty(p) && (!o.hasOwnProperty(p) || override))o[p]=n[p];
	},
	GameStart:function(rolename){
		var v = new Date();
		simple.LastHeart=v.getTime();
		simple.Log("登入");
		simple.cfgfilename=simple.username+"_"+rolename;
		var obj=simple.LoadcfgFile(simple.cfgfilename,false);
		
		simple.extend(simple.botcfg,obj,true);
		
		//simple.botcfg=(obj==null?simple.botcfg:obj);				
		simple.CfgToView(document.getElementById("cfgdlg"));
		document.getElementById("Cfgbutton").style.display="block";
		if(simple.EnterGameTimer!=null){clearTimeout(simple.EnterGameTimer);simple.EnterGameTimer=null;}//清楚登陆卡住判断
		
		if(simple.flashtimer!=null)clearTimeout(simple.flashtimer);
		
		simple.flashtimer=setTimeout(function(){simple.brow.reload();},1000*60*simple.botcfg.system.flashtils);//刷新延迟
		
		if(simple.botcfg.system.autostart&&simple.runstate.start==false){
			window.setTimeout(function(){
				simple.runstate.start=true;
				document.getElementById("Startbutton").label="停止挂机";
				
				},
			3000);
		}
		//登陆进来后,开启卡住检测
		if(simple.HeartTimer!=null)clearInterval(simple.HeartTimer);
	
		var v = new Date();	
		simple.LastHeart=v.getTime();	
		simple.HeartTimer=setInterval(function(){
			//首先判断是否存在flash如果存在就刷新
			var now = new Date();
			var isSwfLoaded=simple.EnumSwf(document,"IndexSwf_");
			if(isSwfLoaded==false){clearInterval(simple.HeartTimer);simple.HeartTimer=null;return;}
			
			if(now.getTime()-simple.LastHeart>simple.botcfg.system.blocktils*1000)
			{
				simple.Log("游戏卡住，刷新");
				simple.brow.reload();
			}
		},1000);
		
	},
	GameDisConnect:function(){
		if(!simple.botcfg.system.autoreconnect)return;		
		if(simple.HeartTimer!=null)clearInterval(simple.HeartTimer);
		simple.HeartTimer=null;
		if(simple.EnterGameTimer!=null){clearTimeout(simple.EnterGameTimer);simple.EnterGameTimer=null;}//清楚登陆卡住判断
		simple.brow.reload();

	},
	shellExe:function(url){
		
		simple.urlfixer.shell(url);
		return false;
	},
	EnumSwf:function(doc,swfname){
		
		if (doc.nodeName != "#document" && doc.nodeName != "IFRAME") { return false;}
		//simple.Log(doc.title);
		var list=doc.getElementsByTagName("embed");
		for(var i=0;i<list.length;i++)
		{
			
			if(list[i].src.indexOf(swfname)!=-1)return true;
		}
		var aWindow=doc.defaultView;
		if (aWindow.frames.length > 0) {
            var nFrames = aWindow.frames.length;
            for (var i = 0; i < nFrames; i++) 
			{
				if(simple.EnumSwf(aWindow.frames[i].document,swfname)==true)return true;
			}
        }
        
		return false;
	},
	RemoveFromState:function(){
		simple.Log("离开场景");
		if(simple.HeartTimer!=null)
		{
			clearInterval(simple.HeartTimer);
			simple.HeartTimer=null;
		}
		if(simple.EnterGameTimer!=null){clearTimeout(simple.EnterGameTimer);simple.EnterGameTimer=null;}
	},
	AddToStage:function(){
		simple.Log("进入场景");
		
		simple.EnterGameTimer=setTimeout(function(){
			var isSwfLoaded=simple.EnumSwf(document,"IndexSwf_");
			if(isSwfLoaded==false){simple.EnterGameTimer=null;return;}			
			simple.Log("登陆卡住，刷新");
			simple.EnterGameTimer=null;
			simple.brow.reload();
			
			
		},simple.botcfg.system.entergametils*1000);
		

	},
	Heart:function(seed){
		var v = new Date();
		simple.LastHeart=v.getTime();
		
		return this.urlfixer.tick(seed);
	},
	Log: function (str) {
		
		if(document.getElementById("ShowLog").checked!=true)return;
		var list=document.getElementById("LogList");
		if(list.getRowCount()>100){
		
			list.removeItemAt( list.getRowCount()-1 );
		}

		list.insertItemAt(0,str);
    },

    LoadcfgFile: function (filename,iscompareversion) {
        
        var mt = new MTB_File(filename+".cfg");
        if (mt.open("r")) {
            var s = mt.read(mt.fileSize());
            mt.close();
            var b = new Base64();
            var str = b.decode(s);
			
            var obj = eval("(" + str + ")");
			if(iscompareversion==true&&(obj.version==null||obj.version!=simple.version))return null;
			return obj.cfg;
		
        } 
		return null;
    },
	SavecfgFile:function(filename,obj){
		var mt = new MTB_File(filename+".cfg");
        if (mt.open("w+")) {
			var saveobj={version:simple.version,cfg:obj};
            var b = new Base64();
            var str = b.encode(json2str(saveobj));
            mt.write(str)
            mt.close();
			return true;
        }
		return false
	},
	AddGuajiPoint:function(){
		
		
		
		var row = document.createElement('listitem');
		var cell = document.createElement('listcell');
		cell.setAttribute('label',document.getElementById("maplist").selectedItem.label);
		row.appendChild(cell);
		cell = document.createElement('listcell');
		cell.setAttribute('label', document.getElementById("mapx").value);
		row.appendChild(cell);
		cell = document.createElement('listcell');
		cell.setAttribute('label', document.getElementById("mapy").value);
		row.appendChild(cell);
		document.getElementById("botcfg.guaji.cfg.pos").appendChild(row);
	},
	ClearGuajiPoint:function(){
		var ele=document.getElementById("botcfg.guaji.cfg.pos");
		while(ele.getRowCount()>0)ele.removeItemAt(0);
	},
	DelGuajiPoint:function(){
		var ele=document.getElementById("botcfg.guaji.cfg.pos");
		while(ele.selectedCount>0){
			ele.removeItemAt(ele.selectedIndex);
		}
		
	},
	CfgToView:function(container){
		var list=container.getElementsByClassName("cfg");
		
		for(var i=0;i<list.length;i++){
			var ele=list[i];			
			if(ele.tagName=="textbox"){
				
				ele.value=eval(("simple."+ele.id));
			}
			
		
			if(ele.tagName=="menulist"){
				var items=ele.getElementsByTagName("menuitem");
				var value=eval(("simple."+ele.id));
				for(var j=0;j<items.length;j++){
					if(items[j].value==value){
						
						ele.selectedItem=items[j];
						break;
					}
				}
			}
			if(ele.tagName=="checkbox"){
				ele.checked=eval(("simple."+ele.id));
			}
			if(ele.tagName=="groupbox"){
				
				var items=ele.getElementsByTagName("checkbox");
				var value=eval(("simple."+ele.id));
				for(var j=0;j<items.length;j++){
					var label=items[j].label;
					items[j].checked=false;
					for(var k=0;k<value.length;k++)
					{
						if(label==value[k])
						{
							items[j].checked=true;
							break;
						}
					}
				}
			}
			if(ele.tagName=="listbox"){
				while(ele.getRowCount()>0)ele.removeItemAt(0);
				var header=ele.getElementsByTagName("listheader");
				var value=eval(("simple."+ele.id));
				for(var k=0;k<value.length;k++){
					var row = document.createElement('listitem');
					for(var j=0;j<header.length;j++){
						var cell = document.createElement('listcell');
						cell.setAttribute('label', eval(  ("simple."+ele.id+"["+k+"]."+header[j].id) ));
						row.appendChild(cell);
					}
					ele.appendChild(row);
				}				
			}
		}
	},

	ViewToCfg:function(container){
		var list=container.getElementsByClassName("cfg");
		
		for(var i=0;i<list.length;i++){
			var ele=list[i];			
			if(ele.tagName=="textbox"){
				
				eval(("simple."+ele.id+"=ele.value"));
			}
			
		
			if(ele.tagName=="menulist"){
				
				
				eval(("simple."+ele.id+"=ele.selectedItem.value"));				
			}
			if(ele.tagName=="checkbox"){
				eval(("simple."+ele.id+"=ele.checked"));
			}
			if(ele.tagName=="groupbox"){
				
				var items=ele.getElementsByTagName("checkbox");
				eval(("simple."+ele.id+".length=0"));
				for(var j=0;j<items.length;j++){
					var label=items[j].label;
					if(items[j].checked){
						eval(("simple."+ele.id+".push('"+label+"')"));
					}					
				}
			}
			if(ele.tagName=="listbox"){
				eval(("simple."+ele.id+".length=0"));
				var header=ele.getElementsByTagName("listheader");
				for(var k=0;k<ele.getRowCount();k++)
				{
					var row=ele.getItemAtIndex(k);
					var cells=row.getElementsByTagName("listcell");
					var obj={};
					for(var j=0;j<cells.length;j++){
						
						eval("obj."+header[j].id+"=cells[j].getAttribute('label')");
					}
					eval(("simple."+ele.id+".push(obj)"));
				}
				
					
			}
		}
	},
	SaveAutoLogin:function(){
		simple.ViewToCfg(document.getElementById("autologinset"));
		simple.SavecfgFile(simple.username,simple.autologinset);
	},
	CancelAutoLogin:function(){
		simple.CfgToView(document.getElementById("autologinset"));
		document.getElementById("autologinset").hidePopup();
	},
	onReg:function(){
		var username=document.getElementById("reg_username").value;
		var p=document.getElementById("reg_password").value;
		var sp=document.getElementById("reg_superpassword").value;
		if(username==""){
			document.getElementById("logintip").value="请输入辅助帐号";
			return;
		}
		if(p==""){
			document.getElementById("logintip").value="请输入辅助密码"
			return;
		}
		if(document.getElementById("reg_password2").value!=p){
			document.getElementById("logintip").value="两次密码输入不一致"
			return;
		}
		if(sp==""){
			document.getElementById("logintip").value="请输入辅助超级密码"
			return;
		}
		var result=simple.urlfixer.reg(username,p,sp);
		result= eval("(" + result + ")");
		if(result.success){
			var sr=simple.urlfixer.activegame(username,p,simple.gamename);			
			alert("注册成功");
			document.getElementById("logintip").value="注册成功";
		}else{
			alert(result.text);
			document.getElementById("logintip").value=result.text;
		}
	},
	onRecharge:function(){
		var username=document.getElementById("recharge_username").value;
		var c=document.getElementById("recharge_cardid").value;
		var p=document.getElementById("recharge_cardps").value;
		var code=document.getElementById("recharge_code").value;
		if(username==""){
			document.getElementById("logintip").value="请输入辅助帐号";
			return;
		}
		if(c==""){
			document.getElementById("logintip").value="请输入充值卡卡号";
			return;
		}
		if(p==""){
			document.getElementById("logintip").value="请输入充值卡密码";
			return;
		}
		var result=simple.urlfixer.recharge(c,p,simple.gamename,username,code,document.getElementById("recharge_force").checked?1:0);
		result= eval("(" + result + ")");
		if(result.success){
			var s="充值成功,帐号到期时间为"+result.endTime+(result.code==""?"":(" 获得亲友码:"+result.code+" (已经复制到剪切板)"));
			document.getElementById("logintip").value="充值成功,帐号到期时间为"+result.endTime;
			copyToClipBoard(result.code);
			alert(s);
		}else{
			alert(result.text);
			document.getElementById("logintip").value=result.text;
		}
	},
	onLogin:function(){
		
		simple.username=document.getElementById("username").value;
		
		var p=document.getElementById("password").value
		if(simple.username==""){
			document.getElementById("logintip").value="请输入辅助帐号";
			return;
		}
		if(p==""){
			document.getElementById("logintip").value="请输入辅助密码"
			return;
		}
		
		var result=simple.urlfixer.login(simple.username,p,simple.gamename,simple.version,document.getElementById("toolwindow").checked,document.getElementById("hotkey").selectedItem.value);
		
		
		result= eval("(" + result + ")");
		
		if(result.success){
			if(document.getElementById("remeberps").checked==true)
			{
				if(simple.wguserlist==null)simple.wguserlist=new Array();
				var finded=false;
				for(var i=0;i<simple.wguserlist.length;i++)
				{
					if(simple.wguserlist[i].user==simple.username){
						finded=true;
						break;
					}
				}
				if(finded==false)
				simple.wguserlist.push({user:simple.username,pass:p});
				simple.SavecfgFile("userlist",simple.wguserlist);
			}	
			
			
			document.getElementById("logintip").value=result.text;
			simple.ShowGameInfo(simple.username+"使用中,"+result.text);
			var obj=simple.LoadcfgFile(simple.username,false)
			simple.autologinset=(obj==null?simple.autologinset:obj);				
			if(document.getElementById("disableAutoLogin").checked)
				simple.autologinset.enable=false;
			simple.CfgToView(document.getElementById("autologinset"));
		//	document.getElementById("Autologinbutton").style.display="block";
			//document.getElementById("Startbutton").style.display="block"
			document.getElementById("toolbox").style.display="block"
			document.getElementById("urlenter").style.maxHeight=null;
			
			document.getElementById("logindlg").hidePopup();
			
			if(simple.autologinset.enable){
				
				document.getElementById("textbox").value=autologin.open(simple.autologinset.agent);
				simple.brow.loadURI(document.getElementById("textbox").value,null, null);
			}else{
				document.getElementById("textbox").value="";
				simple.brow.loadURI("chrome://simple/content/index.html" ,null, null);
			}
			
		}else{
			//弹出错误信息		
			
			alert(result.text);
			document.getElementById("logintip").value=result.text;
		}
		return;

		
	},
    onCfgSave: function () {      
		simple.ViewToCfg(document.getElementById("cfgdlg"));		
		simple.SavecfgFile(simple.cfgfilename,simple.botcfg);
			if(simple.flashtimer!=null)clearTimeout(simple.flashtimer);
		simple.flashtimer=setTimeout(function(){simple.brow.reload();},1000*60*simple.botcfg.system.flashtils);
        simple.addDocJs(simple.brow.contentWindow);
		
    },
    onCfgCancel: function () {
        
		simple.CfgToView(document.getElementById("cfgdlg"));
		document.getElementById("cfgdlg").hidePopup();
    },
	
	onMoreUserpop:function(){
		var userlist=document.getElementById("usernamelist");
		userlist.openPopup(document.getElementById("username") ,"after_start",3,3,false,false,null);
	},
	onMoreUserClick:function(e){
		if(e.target.label=="清空帐号")
		{
			simple.wguserlist.splice(0);
			simple.SavecfgFile("userlist",simple.wguserlist);
			document.getElementById("username").removeEventListener("click", simple.onMoreUserpop, false);
			document.getElementById("username").value="";
			document.getElementById("password").value="";
			document.getElementById("remeberps").checked=false;
			return false;
		}
		for(var i=0;i<simple.wguserlist.length;i++){
			
			if(simple.wguserlist[i].user==e.target.label){
				document.getElementById("username").value=simple.wguserlist[i].user;
				document.getElementById("password").value=simple.wguserlist[i].pass;
				return false;
			}
			
		}
	},
    onLoad: function () 
	{		
		//  var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
		//	document.getElementById("username").value=prefService.getBoolPref("browser.xul.error_pages.enabled");
			//alert(prefService.getPrefType("browser.xul.error_pages.enabled"));

		this.brow = document.getElementById("br");
		
		window.setTimeout(function(){
			var menu = document.getElementById("maplist");
			for (var i = 0; i < simple.maplist.length; i++) {
				menu.appendItem(simple.maplist[i]);
			}
			simple.wguserlist=simple.LoadcfgFile("userlist",false);
			
			if(simple.wguserlist!=null&&simple.wguserlist.length>0){
			 
				document.getElementById("username").addEventListener("click", simple.onMoreUserpop, false);
				var userlist=document.getElementById("usernamelist");
				
				
				document.getElementById("username").value=simple.wguserlist[0].user;
				document.getElementById("password").value=simple.wguserlist[0].pass;
				document.getElementById("remeberps").checked=true;
				var item = document.createElement('menuitem');
				item.setAttribute('label',"清空帐号");
				item.addEventListener("click", simple.onMoreUserClick, false);
				userlist.appendChild(item);
				item = document.createElement('menuseparator');						
				userlist.appendChild(item);
				for(var i=0;i<simple.wguserlist.length;i++){
					
					item = document.createElement('menuitem');
					item.setAttribute('label',simple.wguserlist[i].user);
					item.addEventListener("click", simple.onMoreUserClick, false);
					userlist.appendChild(item);
					
				}
			}	
			
			document.getElementById("logindlg").openPopup(null ,"overlap",window.screen.width/2-200,window.screen.height/2-200,false,false,null);
		},500);
		
		
        
		document.getElementById("infodlg").sizeTo( window.screen.width/2,window.screen.height/2 );
		this.urlfixer = Components.classes["@urlfix.com/urlfixer;1"].
        createInstance(Components.interfaces.IUrlfixerInterface);
		document.getElementById("textbox").value=this.urlfixer;
        this.brow.addEventListener("DOMContentLoaded", this.onPageLoad, true);
        this.brow.addEventListener("DOMFrameContentLoaded", this.onPageLoad, true);
        return;
     
		
    },

    onPageLoad: function (aEvent) {
		if(simple.brow.currentURI.host=="simple")
		document.getElementById("textbox").value=""
		else
		document.getElementById("textbox").value="http://"+simple.brow.currentURI.host+simple.brow.currentURI.path;
        var doc = aEvent.originalTarget;
        if (doc.nodeName != "#document" && doc.nodeName != "IFRAME") { return; }
        // perform substitutions on the loaded document
        simple.addDocJs(doc.defaultView);
    },
    addDocJs: function (aWindow) {
        if (!aWindow) aWindow = window.content;
        if (aWindow.frames.length > 0) {
            var nFrames = aWindow.frames.length;
            for (var i = 0; i < nFrames; i++) this.addDocJs(aWindow.frames[i]);
        }
        var doc = aWindow.document;

        if (!doc || !("body" in doc)) return;

        var url = doc.URL;
        if (!url) return;
		aWindow.addEventListener('load',function(e)
		{
			var d=e.currentTarget.document;
			if(d==null)return;
			var Alist=d.getElementsByTagName("A");
			for(var i=0;i<Alist.length;i++)
			{
				Alist[i].target="";
				Alist[i].addEventListener("click",function(){
						aWindow.setTimeout(function(){var Alist=d.getElementsByTagName("A");
						for(var i=0;i<Alist.length;i++)
						{
							Alist[i].target="_parent";
						}},300);
						aWindow.setTimeout(function(){var Alist=d.getElementsByTagName("A");
						for(var i=0;i<Alist.length;i++)
						{
							Alist[i].target="_parent";
						}},500);
						aWindow.setTimeout(function(){var Alist=d.getElementsByTagName("A");
						for(var i=0;i<Alist.length;i++)
						{
							Alist[i].target="_parent";
						}},1000);
						aWindow.setTimeout(function(){var Alist=d.getElementsByTagName("A");
						for(var i=0;i<Alist.length;i++)
						{
							Alist[i].target="_parent";
						}},2000);
					
				}, true);
				
				
			}
		
	
			//加入自动登陆
			if(simple.autologinset.enable){
				var url=autologin.login(d,simple.autologinset.agent,simple.autologinset.user,simple.autologinset.pass,simple.autologinset.serverid);
				if(url!=""&&url!=null){
					document.getElementById("textbox").value=url;
					simple.brow.loadURI(url, null, null);
				}
			
			}
			
		},false);
		

		var Alist=doc.getElementsByTagName("A");
		for(var i=0;i<Alist.length;i++)
		{
			Alist[i].target="_parent";			
		}
        

        //写入配置
		aWindow.wrappedJSObject.window.open=function(url){simple.brow.loadURI(url, null, null);return false;}
		aWindow.wrappedJSObject.window.onbeforeunload=null;
		if(doc.getElementsByClassName("fastEnterGameLink").length>0)
		{
			
			for(var i=0;i<doc.getElementsByClassName("fastEnterGameLink").length;i++)
			{
				var ele=doc.getElementsByClassName("fastEnterGameLink")[i];		
				aWindow.wrappedJSObject.window.jQuery.event.remove(ele, 'click', null,null)
				
				ele.addEventListener("click",function(){
				
					simple.brow.loadURI("http://niu.xunlei.com/entergame/dts/?fenQuNum="+this.parentElement.getElementsByClassName('fastEnterGameInput')[0].value,null,null);
					
					return false;
				},false);
				//ele.parent.getElementsByClassName("fastEnterGameInput").value
			}
		}
		if(doc.getElementsByClassName("btn_serv").length>0)
		{
			for(var i=0;i<doc.getElementsByClassName("btn_serv").length;i++)
			{
				var ele=doc.getElementsByClassName("btn_serv")[i];		
				aWindow.wrappedJSObject.window.jQuery.event.remove(ele, 'click', null,null)
				
				ele.addEventListener("click",function(){
					
					simple.brow.loadURI("http://niu.xunlei.com/entergame/dts/?fenQuNum="+this.getAttribute('sid'),null,null);
					return false;
				},false);
				//ele.parent.getElementsByClassName("fastEnterGameInput").value
			}
		}
		/*if(aWindow.wrappedJSObject.ishook==null);
		{
		alert("asdf");
			aWindow.wrappedJSObject.document.createElement2 = aWindow.wrappedJSObject.document.createElement;	
			aWindow.wrappedJSObject.document.createElement = function(tag){		
			 if (tag != "a"&&tag!="A")return aWindow.wrappedJSObject.document.createElement2(tag);
				
				var node = aWindow.wrappedJSObject.document.createElement2(tag)
				
				//node.click =function(){simple.brow.loadURI(node.getAttribute("href"),null,null);};
				return node

			}
			aWindow.wrappedJSObject.ishook=function(){}
		}*/
		aWindow.wrappedJSObject.Heart=function(seed)
		{
			return simple.Heart(seed);
		}
		aWindow.wrappedJSObject.AddToStage=function()
		{
			return simple.AddToStage();
		}
		aWindow.wrappedJSObject.RemoveFromState=function()
		{
			return simple.RemoveFromState();
		}
		aWindow.wrappedJSObject.GetCfg=function()
		{
			return simple.GetCfg();
		}
		aWindow.wrappedJSObject.GameStart=function(rolename)
		{
			return simple.GameStart(rolename);
		}
		
		aWindow.wrappedJSObject.GameDisConnect=function()
		{
			return simple.GameDisConnect();
		}
		
		aWindow.wrappedJSObject.GetRunState=function()
		{
			return simple.GetRunState();
		}
		aWindow.wrappedJSObject.ShowGameInfo=function(srt)
		{
			return simple.ShowGameInfo(srt);
		}
		aWindow.wrappedJSObject.Log=function(srt)
		{
			return simple.Log(srt);
		}
		aWindow.wrappedJSObject.saveToFile=function(srt)
		{
			var mt=new MTB_File(Math.random()+".sswf");
			mt.open("w+");
			mt.write(srt);
			mt.close();
		}
		
	
    },

    onGoButtonClick: function () {
        var textbox = document.getElementById("textbox");

        if (textbox.value == "") {
           
        } else {
			if(textbox.value.indexOf("http://")==-1)textbox.value="http://"+textbox.value;
            simple.brow.loadURI(textbox.value, null, null);
        }

        return;

    },
	onBackIndex:function(){
		document.getElementById("textbox").value="";
				simple.brow.loadURI("chrome://simple/content/index.html" ,null, null);
	},
	onReFlashButtonClick:function(){
	 var textbox = document.getElementById("textbox");

        if (textbox.value == "") {
            
        } else {
			if(textbox.value.indexOf("http://")==-1)textbox.value="http://"+textbox.value;
            simple.brow.loadURI(textbox.value, null, null);
        }
	},
	
   
	onStartButtonClick:function(){
		simple.runstate.start=!simple.runstate.start;
		document.getElementById("Startbutton").label=simple.runstate.start?"停止挂机":"开始挂机";
	}
	
};


window.addEventListener("load", function () {
    simple.onLoad();
}, false);
window.addEventListener("unload",function(){
	simple.urlfixer.loginout(simple.gamename);
},false);
window.addEventListener("close", function( event ) { 
   simple.urlfixer.loginout(simple.gamename);
}, false);
//*****************************************************************************************************//
