﻿// JScript 文件
function request(name)
{
  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r!=null) return unescape(r[2]); return null;
}
/*
function getCookie(objName) 
{
    var arrStr = document.cookie.split("; ");
    for (var i = 0; i < arrStr.length; i++) {
        var temp = arrStr[i].split("=");        
        if (temp[0] == objName) return decodeURIComponent(temp[1]);
    }
}
*/
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return decodeURIComponent(document.cookie.substring(c_start,c_end))    
    } 
  }
return null
}
function DelCookie(name){
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = getCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}		

function LoginXXUserManage()
{
    var loginSate=getCookie("LoginError");    
    if(loginSate!=null)
    {    if(loginSate=="0"||loginSate=="1")
            {     
                if(loginSate=="0")
                {//个人用户
                    var UcenterId=getCookie("UcenterId");
                    if(UcenterId!=null&&UcenterId!="")
                    {
                        window.location.href="http://space.soojoo.cn/?"+UcenterId;
                        //登陆的时候有问题
                    }
                    else
                    {
                        window.location.href="myIndex.aspx";
                    }
                    
                }
                if(loginSate=="1")
                {//机构用户
                   window.location.href="myIndex.aspx";
                }
            }        
            else
            {
                DelCookie("LoginError");
                alert(loginSate);
            }
    }
}
function UserLogin()
{
//debugger;
    var loginSate=getCookie("LoginError");
    //alert(loginSate);
    
    //alert(loginSate);    
    if(loginSate!=null)
    {
        if(loginSate=="0"||loginSate=="1")
        {
        //登陆成功
            var ReUrl=request('ReUrl');
            //alert(ReUrl);
            if(ReUrl!=""&&ReUrl!=null&&ReUrl!="null")
            {
                   //ReUrl="http://space.soojoo.cn/link.php?url="+ReUrl; 
                   window.location.href=ReUrl;    
                   return ;               
            }
            else
            {
          
                if(loginSate=="0")
                {//个人用户
                    /*
                    var UcenterId=getCookie("UcenterId");
                    if(typeof(UcenterId)!="undefined" && UcenterId!="")
                    {
                        window.location.href="http://space.soojoo.cn/?"+UcenterId;
                        //登陆的时候有问题
                    }
                    else
                    {
                        window.location.href="usercenter.aspx";
                    }
                    */
                    window.location.href="../default.htm";
                    return ;
                    
                }
                else                
                {
                    window.location.href="usercenter.aspx";
                   return ;
                }
               
            }                      
            
        }
        else
        {
            DelCookie("LoginError");
            alert(loginSate);
            
        }    
                
    }
    else
    {
        //alert("aa");
    }
    
}
