
document.write('<style>#shadowDiv{display:none;width:100%;height:100%;position:absolute;top:0px:left:0px;background-color:#FFF;filter: alpha(opacity=70);opacity:0.7;z-index:65534}#popDiv{border:1px solid #d57500;display:none;position:absolute;width:450px;height:300px; z-index:65535;background-color:#fff;}a.tLink{color:#000;text-decoration: none;}</style>');

function userLogin(onSucc,onFail,p){
	if(onSucc){
        onLoginSuccess=onSucc;
    }else{
        onLoginSuccess=defalutLoginSuccess;
    }
    if(onFail){
        onLoginFailed=onFail;
    }else{
        onLoginFailed=defaultLoginFail;
    }
    p = p ? "?"+p : "";
	Pop.show("登录",{url:"/usergame/userlogin.htm",width:400,height:300});
	
}
function dialogShow(title,msg,p){

    p = p ? "?"+p : "";
	Pop.show(title,{url:"/usergame/userlogin.htm",width:400,height:240});
	
}
var defalutLoginSuccess=function(){
	window.location.reload();
}
var onLoginSuccess=defalutLoginSuccess;
var loginSuccess=function(){
	Pop.hide();
	onLoginSuccess();
}
var defaultLoginFail=function(){
    window.location="/common.do?eventSubmit_Login=Login&u="+escape("http://zhidao.baidu.com/");
}
var onLoginFailed=defaultLoginFail;
var loginFailed=function(){
        Pop.hide();
        onLoginFailed();
    }
FactoryXMLHttpRequest=function(){
	if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");}
	else if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}else{return null;}
}
function request(url,onOk,onErr)
{
	var req=FactoryXMLHttpRequest();
	req.open("GET",url,true);
	req.onreadystatechange=proxy(
	function(obj,ok,err){
		if(obj.readyState==4){
			if(obj.status==200){
				ok(obj);
			}else{
				err(obj);
			}
		}
	},req,onOk,onErr);
	req.send(null);
}
function checkLogin(hasLogin,notLogin,p){
	function onOk(req,hasLogin,notLogin){
		if(!!eval("("+req.responseText+")")){
			hasLogin();
		    return true;
        }
	    userLogin(hasLogin,notLogin,p);
        return false;
	}
	request("/q?ct=28&lm=1"+ '&s=' + (new Date()).getTime(),function(req){onOk(req,hasLogin,notLogin);},hasLogin);
}
function checkLoginF(action,p){
    checkLogin(action,action,p);
}
var pop_load_div="<div id=\"candlelit_loading\" style =\"width: 200px;display: none;margin: 50px auto;\"><div class=\"clear\"></div><br/><table align=\"center\"><tr><td><img src=\"/images/loading_1.gif\" />&nbsp;&nbsp;&nbsp;正在载入数据...&nbsp;&nbsp;</td></tr></table></div>"
var Pop={
	onOk:function(){},
	onclosed:function(){},
	create:function ()
	{
		if(!G("popDiv")){
			var sha=document.createElement("div");
			sha.id="shadowDiv";
			var p=document.createElement("div");
			p.id="popDiv";
            var fr=document.createElement("iframe");
            fr.id="shadowIframe";
            fr.style.filter="alpha(opacity=0)";
            fr.style.opacity="0";
            fr.style.position="absolute";
            
			p.innerHTML="<div id=\"popTitle\">"+
					"<table width=\"100%\" cellspacing=\"0\"  cellpadding=\"0\" border=\"0\" style=\"-moz-user-select: none; height: 24px;background: url(/images/bg_menu.gif) repeat-x;\">"+
					"<tr><td width=\"6\" height=\"24\"\/>"+
					"<td id=\"dialogBoxTitle\" style=\"color:#fff; font-size: 14px; font-weight: bold;\"></td>"+
					"<td id=\"dialogClose\" width=\"20\" valign=\"middle\" align=\"right\">"+
						"<input id=\"dialogBoxClose\" onclick=\"Pop.hide()\" width=\"16\" type=\"image\" height=\"16\" border=\"0\" align=\"absmiddle\" title=\"关闭\" src=\"/images/diaclose2.gif\"\/>"+
					"</td><td width=\"6\"\/>"+
					"</tr></table>"+
				"</div>"+
				"<div id=\"popBody\" style=\"display:none;text-align:center;padding:20px;font-size:14px;\"></div>"+
				"<div id=\"ifrDiv\">"+
				"<iframe id=\"popIframe\" name=\"popIframe\" style=\"height:240px;\" width=\"98%\" frameborder=\"0\"  scrolling=\"no\" src=\"about:blank\"></iframe>"+
				"</div>";
			document.body.insertBefore(fr,document.body.firstChild);
			document.body.insertBefore(p,document.body.firstChild);
            document.body.insertBefore(sha,document.body.firstChild);
			//addEvent(window,"resize",Pop.resize);
		}
	},
	resize:function ()
	{
		Pop.create();
		var top=document.documentElement.scrollTop;
		var w = document.documentElement.scrollWidth;
		var h =document.documentElement.scrollHeight;
		var shadowDiv = G("shadowDiv");
		var popDiv = G("popDiv");
        var sf=G("shadowIframe");
        var pw=parseInt(popDiv.style.width,10)||500;
        var ph=parseInt(popDiv.style.height,10)||500;
		shadowDiv.style.width=w+"px";
		
		shadowDiv.style.height=h+"px";
		shadowDiv.style.left=shadowDiv.style.top="0px";
		divLeft=(document.documentElement.clientWidth-pw)/2;
		var divTop = (document.documentElement.clientHeight-ph)/2+top;
		if(divLeft < 1) divLeft=top;
		if(divTop < 1) divTop="20";
		//alert(" divTop xx "+ top );
		sf.style.left= divLeft+"px";
		sf.style.top=divTop+"px";
		popDiv.style.left = divLeft+"px";
		popDiv.style.top = divTop+"px";
	},
	 hide:function()
	 {
		Pop.onclosed();
		try{
          
		  G("shadowDiv").style.display = "none";
          G("shadowIframe").style.width="0px";
         G("shadowIframe").style.height="0px"; 
          G("shadowIframe").style.display="none";
		  G("popDiv").style.display = "none";
		}catch(uncreatepop){}
        
        try{G("popIframe").src="about:blank";}catch(e)
		{
			try{document.frames["popIframe"].location="about:blank";}catch(e){}
		}
	 },
	 config:function(title,conf){
		if(title){
			G("dialogBoxTitle").innerHTML=title;
		}
			Pop.onclosed=conf.onclosed||function(){};
		if(conf.url){
			if(conf.url!=true){
				try{G("popIframe").src=conf.url;}
				catch(e){
					try{document.frames["popIframe"].location=conf.url;}
					catch(e){}
				}
			}
			G("ifrDiv").style.display="block";
			G("popBody").style.display="none";
		}
		else{
			if(conf.info){
				G("ifrDiv").style.display="none";
				G("popBody").style.display="block";
				G("popBody").innerHTML=conf.info;
			}
		}
		var pw=conf.width||450;
		var ph=conf.height||400;
		
        var sf=G("shadowIframe");
		var p=G("popDiv");
		sf.style.width=p.style.width=pw+"px";
		sf.style.height=p.style.height=ph+"px";
	},
	show:function (title,conf)
	{
		
		Pop.create();
		Pop.config(title,conf);
		Pop.resize();
		
		G("shadowDiv").style.display = "block";
        G("shadowIframe").style.display="";
		G("popDiv").style.display = "block";
		
	},
    confirm:function(msg,conf)
	{
		Pop.onOk=proxy(function(func){Pop.onclosed=function(){};Pop.hide();func();},conf.ok||Pop.hide);
		var m="<span class='f14'>$2$</span><br><br><p align='center'><input type='button'value='$0$' onclick='Pop.onOk();'>&nbsp;&nbsp;&nbsp;&nbsp;<input type='button'value='$1$' onclick='Pop.hide()'></p>";
		m=m.format(conf.okInfo||"确定",conf.cancelInfo||"取消",msg);
		Pop.show(conf.title||"信息确认",{info:m,width:(conf.width||300),height:(conf.height||150),onclosed:conf.cancel});
	}	
}
function TopLoginSuccess(){
	window.location.reload();
}
function TopLoginFail(){window.location="/common.do?eventSubmit_Login=Login&u="+escape(location.href);}
function NewAskTop(){document.fask.word.value=document.ftop.word.value;document.fask.submit();}
function NewAskBottom(){document.fask.word.value=document.fbot.word.value;document.fask.submit();}
function AddScore(){document.faddscore.submit();}
function EditAnswer(){ if(checkcoAndsn(document.myform,'回答'))document.myform.submit(); }
function JudgeBestAnswer(){document.fpj.submit();}
