﻿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:
				$('regend_2').src='http://60.191.72.148:81/Interfaces/LogonAdd.aspx?uid='+GetCookie("5show_user_id");
				setTimeout("login_ok()",500);
				break;
		case -801:
			  alert('验证码错误');
			 	$('check_img').src='http://pass.dipan.com/ValidateNumber.aspx?r='+Math.random();
			  $('checkcode').focus();
			  break;
		case -202:
			  alert('帐户已冻结，如有问题请联系客服（电话：0571-87755673）');
			 	$('check_img').src='http://pass.dipan.com/ValidateNumber.aspx?r='+Math.random();
			  break;
		default:
			alert("用户名或密码错误！");
			$('check_img').src='http://pass.dipan.com/ValidateNumber.aspx?r='+Math.random();
			break;
	}

}
function login_ok()
{
				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="http://sg.dipan.com/";
				}
}
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 = GetCookie_client("5show_nick_name_client")+'，欢迎回来！';
		}
		else
			document.getElementById("AA_In").innerHTML = GetCookie("5show_user_name")+'，欢迎回来！';

	}
	else
	{		
		objLogin_In.style.display = "none";
		objLogin_Out.style.display = "";
		if($('index_ln_1')!=null)
		{
				for(var i=1;i<7;i++)
				{				
					if($('index_ln_'+i)!=null)
					{
							$('index_ln_'+i).href='javascript:please_login()';
							$('index_ln_'+i).target="_self";
					}
				}				
				
		}
	}

}
function please_login()
{
	alert('请先登录。');	
	if($('UserName1')!=null)
		$('UserName1').focus();
}
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.com/ValidateNumber.aspx?r='+Math.random();
}
window.onload=function()
{
	    MM_preloadImages('../images/index/index_026.gif','../images/index/index_027.gif','../images/index/index_028.gif','../images/index/index_029.gif','../images/index/index_030.gif');
    	var r = new Request();
			var pid=r.QueryString["pid"];
			if(document.location.href=='http://sg.dipan.com/index.html?')
				pid=1;
			if(pid!="" && pid!=null)
			{
					var nextYear = new Date();
					nextYear.setYear(nextYear.getYear()+1);
					setCookie("sg_pid",pid,nextYear,"dipan.com");
		 }
		 	var uid=r.QueryString["uid"];
			if(uid!="" && uid!=null)
			{
					var nextYear = new Date();
					nextYear.setYear(nextYear.getYear()+1);
					setCookie("sg_p_uid",uid,nextYear,"dipan.com");
		 }
			var uname=r.QueryString["uname"];
			if(uname!="" && uname!=null)
			{
					var nextYear = new Date();
					nextYear.setYear(nextYear.getYear()+1);
					setCookie("sg_p_uname",uname,nextYear,"dipan.com");
		 }	
		 show_server_info();
}

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(id3)
{
	if((GetCookie("5show_user_id") !=null) && (GetCookie("5show_user_id") !="-1") && (GetCookie("5show_user_id") !=""))
	{
				document.getElementById('dlg_message').style.display="none";
	document.getElementById('mask').style.display="none";
	setrightserverlist(id3);

	if($('flash')!=null)
		$('flash').style.visibility="hidden";	
  document.getElementById('mask').style.height=document.documentElement.scrollHeight+"px";
	document.getElementById('mask').style.width="100%";
	document.body.style.marginRight="0";
	document.body.style.marginLeft="0";
	document.getElementById('dlg_message').style.left=(document.documentElement.scrollWidth-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";
	}
		document.getElementById('dlg_message').style.display="";
	document.getElementById('mask').style.display="";
}

}


function close_layer()
{
		document.getElementById('dlg_message').style.display="none";
	  document.getElementById('mask').style.display="none";	
	  if($('flash')!=null)
	  	$('flash').style.visibility="visible";
	  
}