﻿var isclose=true;
var firstPost=true;
			function $(o)
			{
				return document.getElementById(o);
			}

			function login()
			{
				if ($('UserName1').value=="")
				{
					alert("请输入用户名");
					$('UserName1').focus();
					return;
				}
				if ($('Password1').value=="")
				{
					alert("请输入密码");
					$('Password1').focus();
					return;
				}
				if ($('checkcode').value=="")
				{
					alert("请输入验证码");
					$('checkcode').focus();
					return;
				}
				if(!IsNum($('UserName1').value))
				{
					$('LoginType1').value = 0;
				}
				else
				{
					$('LoginType1').value = 1;
				}
        var obj_fra;
        if(!window.ActiveXObject)
        	obj_fra=document.getElementById("login_fr").contentDocument;
        else
        {
        	obj_fra=frames["login_fr"].document;
        }
				obj_fra.getElementById('UserName1').value=$('UserName1').value;
				obj_fra.getElementById('Password1').value=$('Password1').value;				
				obj_fra.getElementById('LoginType1').value=$('LoginType1').value;	
				obj_fra.getElementById('checkcode').value=$('checkcode').value;		
				frames["login_fr"].login();
			}
var isok = function(obj)
{
		firstPost = true;
	var ret = obj.responseText;
	var retstr=eval('(' + ret + ')') ;
	switch (retstr.ret)
	{
		case 1:
				isclose=false;
				var r = new Request();
				var URL=r.QueryString["url"];
				if(URL!="" && URL!=null)
				{
					top.document.location.href=unescape(URL);	
				}
				else
				{
					//top.document.location.href=top.document.location.href;
					//showLoginStatus();
					top.document.location.href=top.document.location.href;
				}
				break;
		case -801:
			  alert('验证码错误');
			 	$('check_img').src='http://pass.dipan.cn/ValidateNumber.aspx?r='+Math.random();
			  $('checkcode').focus();
			  break;
		default:
			alert("用户名或密码错误！");
			$('check_img').src='http://pass.dipan.cn/ValidateNumber.aspx?r='+Math.random();
			break;
	}

}
function IsNum(str) 
{  
			return /^\d+$/.test(str);//为真
}
function showLoginStatus()
{   
	var objLogin_In = document.getElementById("Login_In");
	var objLogin_Out = document.getElementById("Login_Out");
	if((GetCookie("5show_user_id") !=null) && (GetCookie("5show_user_id") !="-1") && (GetCookie("5show_user_id") !=""))
	{   
		objLogin_In.style.display = "";
		objLogin_Out.style.display = "none";
		if(GetCookie_client("5show_nick_name_client")!="")
		{
			document.getElementById("AA_In").innerHTML ='<div class="k">'+GetCookie_client("5show_nick_name_client")+"，欢迎回来！"+'</div>';
		}
		else
			document.getElementById("AA_In").innerHTML = '<div class="k">'+GetCookie("5show_user_name")+"，欢迎回来！"+'</div>';
		if($('index_js_1')!=null)
		{
				$('index_js_1').href='http://pass.dipan.cn/m.aspx?cn=payselect';
				$('index_js_2').href='http://pass.dipan.cn/m.aspx?cn=PassportInfo';		
		}
	}
	else
	{   
		objLogin_In.style.display = "none";
		objLogin_Out.style.display = "";
		if($('index_js_1')!=null)
		{
				$('index_js_1').href='javascript:alert("请先登录！")';
				$('index_js_2').href='javascript:alert("请先登录！")';		
				$('index_js_1').target="_self";
				$('index_js_2').target="_self";	
		}		
	}

}
function DecodeCookie(str)
{
　var strArr;
　var strRtn="";

　strArr=str.split("a");

　for (var i=strArr.length-1;i>=0;i--) 
　strRtn+=String.fromCharCode(eval(strArr[i]));

　return strRtn;
}

function GetCookie_client (cookiename) 
{
    var thebigcookie = document.cookie;
    var firstchar = thebigcookie.indexOf(cookiename);
    if (firstchar != -1) {
        firstchar += cookiename.length + 1;
        lastchar = thebigcookie.indexOf(";",firstchar);
        if(lastchar == -1) lastchar = thebigcookie.length;
        return DecodeCookie(unescape(thebigcookie.substring(firstchar, lastchar)));
    }
    return "";
}
function showimg1()
{
	$('check_img').style.display='inline';
	$('check_img').src='http://pass.dipan.cn/ValidateNumber.aspx?r='+Math.random();
}
window.onload=function()
{
	    
    	var r = new Request();
			var pid=r.QueryString["pid"];
			if(document.location.href=='http://sg.dipan.cn/index.html?')
				pid=1;
			if(pid!="" && pid!=null)
			{
					var nextYear = new Date();
					nextYear.setYear(nextYear.getFullYear()+1);
					setCookie("sg_pid",pid,nextYear,"dipan.cn");
		 }
		 	var uid=r.QueryString["uid"];
			if(uid!="" && uid!=null)
			{
					var nextYear = new Date();
					nextYear.setYear(nextYear.getFullYear()+1);
					setCookie("sg_p_uid",uid,nextYear,"dipan.cn");
		 }
			var uname=r.QueryString["uname"];
			if(uname!="" && uname!=null)
			{
					var nextYear = new Date();
					nextYear.setYear(nextYear.getFullYear()+1);
					setCookie("sg_p_uname",uname,nextYear,"dipan.cn");
		 }	
		 //已经收藏
		 if(document.location.href.indexOf("?favorite")!=-1)
		 {
			var nextYear = new Date();
			nextYear.setYear(nextYear.getFullYear()+1);
			setCookie("dipan_cn_favorite","1",nextYear,"dipan.cn");		
		 }

}
window.onbeforeunload=function()
{

		if(GetCookie("dipan_cn_favorite")=="" && GetCookie("dipan_cn_favorite_t")=="" && isclose && ($('index_js_1')!=null))
		{
			var nextYear = new Date();			
			nextYear.setHours(nextYear.getHours()+24);			
			setCookie("dipan_cn_favorite_t","1",nextYear,"dipan.cn");			
var title="《武林英雄》今日新服！在线火爆！现在注册，拿888礼金券！";
var url="http://hero.dipan.cn/?favorite";
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera  &&  window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);			
		}


}
function changeTab(id)
{
   $("tab_1").style.display="none";
   $("tab_2").style.display="none";   
   $("tab_3").style.display="none";
   $("tab_"+id).style.display="";   	
}

function show_serverlist()
{
	if((GetCookie("5show_user_id") !=null) && (GetCookie("5show_user_id") !="-1") && (GetCookie("5show_user_id") !=""))
	{
	$('server_list_ul').innerHTML="";
	$('server_list_ul').innerHTML+='<li class="xin"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=11" target="_blank">双线11服• 剑胆琴心</a> <span style="color:red;font-weight:bold;">新</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=10" target="_blank">双线10服• 笑傲江湖</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=9" target="_blank">双线9服• 刀光剑影</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=8" target="_blank">双线8服• 肝胆相照</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=7" target="_blank">双线7服• 义薄云天</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=6" target="_blank">双线6服• 侠骨柔情</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=5" target="_blank">双线5服• 铁血丹心</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=4" target="_blank">双线4服• 仗剑江湖</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=3" target="_blank">双线3服• 风云际会</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=2" target="_blank">双线2服• 潜龙出渊</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	$('server_list_ul').innerHTML+='<li class="xin3"><a onclick="javascript:close_layer();" href="http://pass.dipan.cn/m.aspx?cn=Login_hero&sid=1" target="_blank">双线1服• 初入江湖</a> <span style="color:red;font-weight:bold;">荐</span></li>';
	document.getElementById('dlg_message').style.display="";
	document.getElementById('mask').style.display="";
	if($('flash_div')!=null)
		$('flash_div').style.visibility="hidden";
	document.getElementById('mask').style.height=document.body.scrollHeight+"px";
 	if(document.body.clientHeight>document.body.scrollHeight)
  {
   			document.getElementById('mask').style.height=document.body.clientHeight+"px";
 	}
	document.getElementById('mask').style.width="100%";
	document.body.style.marginRight="0";
	document.body.style.marginLeft="0";
	document.getElementById('dlg_message').style.left=(window.screen.width-document.getElementById('dlg_message').style.width.replace('px',''))/2+"px";

	if((window.screen.height-document.getElementById('dlg_message').style.height.replace('px',''))/2-100<0)
	{
   		document.getElementById('dlg_message').style.top=0;
	}
	else
	{
   		document.getElementById('dlg_message').style.top=(window.screen.height-document.getElementById('dlg_message').style.height.replace('px',''))/2-100+document.documentElement.scrollTop+"px";
	}
}

}


function close_layer()
{
		document.getElementById('dlg_message').style.display="none";
	  document.getElementById('mask').style.display="none";	
	  if($('flash_div')!=null)
	  	$('flash_div').style.visibility="visible";
	  
}

