//document.domain="bodani.cn";
//window.location="http://passport.bodani.cn/?login&tpl=ik&u="+escape("http://bible.bodani.cn/");
document.write('<style>.text{height:20px;}#shadowDiv{display:none;width:100%;height:100%;position:absolute;top:0px:left:0px;background-color:#FFF;z-index:5553;filter: alpha(opacity=70);opacity:0.7;z-index:65534}#popDiv{border:1px solid #00676B;display:none;position:absolute;width:450px;height:300px;z-index:65535;background-color:#fff;}a.tLink{color:#000;text-decoration: none;}</style>');
function G(id){	if(typeof(id)=="string"){return document.getElementById(id);}return id;}
String.prototype.trim=function(){
	return this.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+$)/g, "");
};

String.prototype.byteLength=function(){
	return this.replace(/[^\u0000-\u007f]/g,"\u0061\u0061").length;	
}
String.prototype.format=function(){
  if(arguments.length==0) return this;
  for(var s=this, i=0; i<arguments.length; i++)
    s=s.replace(new RegExp("\\$"+i+"\\$","g"), arguments[i]);
  return s;
};
function addEvent(ele,event,fun){
	if(typeof(window.attachEvent)!="undefined"){
		ele.attachEvent("on"+event,fun);
	}else{
		if(window.addEventListener){
			ele.addEventListener(event,fun,true);
		}
	}
}
if (![].push) Array.prototype.push = function() {
    for (var i = 0; i < arguments.length; i++) {
      this[this.length] = arguments[i];
    }
    return this.length;
  };
if (![].pop) Array.prototype.pop = function(){
    var _item = this[this.length - 1];
    this.length--;
    return _item;
  };
function proxy(){
	var __a=[];
	for(var i=0,l=arguments.length;i<l;i++){
		__a[i]=arguments[i];
	}
	var __func=__a[0];
	__a.shift();
	 return function(){__func.apply(null,__a)};
}
function changeClassName(id,className,act)
{
	var ele=G(id);
	var reg=new RegExp("\\b"+className+"\\b","g");
	var cn=ele.className.replace(className,"");
	ele.className=(act?cn+" "+className:cn);
	return true;
}
function addClassName(ele,className){
	changeClassName(ele,className,true);
}
function removeClassName(ele,className){
	changeClassName(ele,className,false);
}

function userLogin(){
    Pop.show("登录",{url:"login",width:320,height:240});
}
var defalutLoginSuccess=function(){window.location.reload();}
var onLoginSuccess=defalutLoginSuccess;
var loginSuccess=function(){
	Pop.hide();
	//onLoginSuccess();
}
var defaultLoginFail=function(){
    window.location="/?login&tpl=ik&u="+escape("/");
}
var onLoginFailed=defaultLoginFail;
var loginFailed=function(){
        Pop.hide();
        onLoginFailed();
    }


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\" bgcolor=\"#00676B\" cellpadding=\"0\" border=\"0\" style=\"-moz-user-select: none; height: 24px;padding:0;margin:0;\">"+
					"<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/dialogclose.gif\"\/>"+
					"</td><td width=\"6\"\/>"+"</tr></table>"+"</div>"+"<div id=\"popBody\" style=\"display:none;text-align:center;padding:5px;20px;font-size:14px;\"></div>"+
				    "<div id=\"ifrDiv\" class=\"loginbox\" >" + "<div class=\"login\" ><form id=\"loginForm\"  name=\"loginForm\" onsubmit=\"return false;\"><div style=\"margin-top:5px;text-align:center;height:18px;\"><div id=\"errorInfo\"></div></div><div class=\"item\"><label for=\"userName\">用户名：</label><input class=\"text\" type=\"text\" name=\"username\" id=\"username\"/>" +"</div><div class=\"item\"><label for=\"password\">密&nbsp;&nbsp;码：</label><input class=\"text\" type=\"password\" name=\"password\" id=\"password\"/></div><div class=\"buttons\"><a href=\"/passport/?t=forgot\"class=\"f12\" target=\"_blank\">忘记密码？</a>&nbsp;&nbsp;<input type=\"submit\" class=\"button\" value=\" 登录\"  onclick=\"submitLogin()\"/></div></form><hr size=\"0\" style=\"margin:5px 15px; border-top: 1px solid #AAA\"/><br /><b class=\"f12\">没有账号？</b><div>"+"<input type=\"button\" value=\"立即注册新帐号\" class=\"button_reg\" onclick=\"window.open('/Passport/?t=reg&tpl=ik&u='+escape(parent.location));\"></div></div>" +"</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.body.scrollTop;
		var w = document.body.scrollWidth;
		var h =document.body.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.body.clientWidth-pw)/2;
		var divTop = (document.body.clientHeight-ph)/2+top;
		if(divLeft < 1) divLeft=top;
		if(divTop < 1) divTop="20";
		sf.style.left=popDiv.style.left = divLeft+"px";
		sf.style.top=popDiv.style.top = "200px";
	},
	 hide:function()
	 {
		Pop.onclosed();
		try{
          G("popDiv").style.display = "none";
		  G("shadowDiv").style.display = "none";
          G("shadowIframe").style.width="0px";
          G("shadowIframe").style.height="0px"; 
          G("shadowIframe").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 p=G("popDiv");
        var sf=G("shadowIframe");
		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("popDiv").style.display = "block";
		G("shadowDiv").style.display = "block";
        G("shadowIframe").style.display="";
	},
    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="/?login&tpl=ik&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();}
