﻿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:
				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://www.dipan.cn";
				}
				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 qxdl()
{
	alert('请先登录。');
	$('UserName1').focus();
}
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(document.getElementById('url_1')!=null)
		{
			document.getElementById('url_1').href="javascript:qxdl()";
			document.getElementById('url_1').target="_self";
			document.getElementById('url_2').href="javascript:qxdl()";
			document.getElementById('url_2').target="_self";
			document.getElementById('url_3').href="javascript:qxdl()";
			document.getElementById('url_3').target="_self";
			document.getElementById('url_4').href="javascript:qxdl()";
			document.getElementById('url_4').target="_self";
			document.getElementById('url_5').href="javascript:qxdl()";
			document.getElementById('url_5').target="_self";
			document.getElementById('url_6').href="javascript:qxdl()";
			document.getElementById('url_6').target="_self";
			document.getElementById('url_7').href="javascript:qxdl()";
			document.getElementById('url_7').target="_self";
			document.getElementById('url_8').href="javascript:qxdl()";
			document.getElementById('url_8').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.getYear()+1);
					setCookie("sg_pid",pid,nextYear,"dipan.cn");
		 }
		 	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.cn");
		 }
			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.cn");
		 }	

}
function changeTab(id)
{
   $("tab_1").style.display="none";
   $("tab_2").style.display="none";   
   $("tab_3").style.display="none";
   $("tab_"+id).style.display="";   	
}
