﻿function check_login()
{
    if(!Blog_Public.check_loginajax().value)
    {
        window.document.getElementById("bloglogined").style.display="none";
        window.document.getElementById("bloglogin").style.display="";
    }
    else
    {
        window.document.getElementById("bloglogined").style.display="";
        window.document.getElementById("bloglogin").style.display="none";
        var ls_logintext=Blog_Public.re_logininformation().value;
        if(ls_logintext=="0")
        {
            if(confirm("你还没有开通博客,点击确定开通博客,点击取消退出登录!"))
            {
                window.open("Webfile/Blog_Register_1_1.aspx","_Blank","");
            }
            else
            {
                loginout();
            }
        }
        else
        {
            window.document.getElementById("blogloginedtext").innerHTML=ls_logintext;
        }
    }
}
function   GetCookieVal(offset)   
{ //获得Cookie解码后的值   
    var   endstr   =   document.cookie.indexOf(";",offset);   
    if   (endstr   ==   -1)   
    endstr   =   document.cookie.length;   
    return   unescape(document.cookie.substring(offset,   endstr));   
}   
function   SetCookie(name,   value)   {   
    var   today   =   new   Date();   
    var   expires   =   new   Date();   
    expires.setTime(today.getTime()   +   1000*60*60*24*365);   
    document.cookie   =   name   +   "="   +   escape(value)         +   ";   expires="   +   expires.toGMTString();   
}   
function   DelCookie(name)   
{//删除Cookie    
    var   exp   =   new   Date();   
    exp.setTime   (exp.getTime()   -   1);   
    var   cval   =   GetCookie   (name);   
    document.cookie   =   name   +   "="   +   cval   +   ";   expires="+   exp.toGMTString();   
}   
function   GetCookie(name)    
{//获得Cookie的原始值   
    var   arg   =   name   +   "=";   
    var   alen   =   arg.length;   
    var   clen   =   document.cookie.length;   
    var   i = 0;
    var ls_text="";
    while(i<clen)   
    {   
        var   j   =   i   +   alen; 
        if(document.cookie.substring(i,j) == arg)
        { 
            return   GetCookieVal(j);
        }
        i = document.cookie.indexOf(" ",i) + 1; 
        if(i == 0) break;  
    }   
    return   null;   
}    
function   submitForm(){   
    var ls_uid=document.getElementById("PageTop1_T_UID2").value;
    var ls_pwd=document.getElementById("PageTop1_T_PWD2").value;
    if(ls_uid=="" || ls_pwd=="")
    {
        alert("请输入用户名和密码，否则无法登录！");
        return false;
    }
    if(document.getElementById("Checkbox1").checked){
        SetCookie("zcm11",ls_uid);
    }
    else
    {   
        DelCookie("zcm11");
    }
    var ls_relogin=Blog_Public.blog_login(ls_uid,ls_pwd).value;
    if(ls_relogin=="false")
    {
        alert("登录失败,请正确输入用户名和密码!");
        return false;
    }
    else
    {
        check_login();
    }
}

function check_mail(myint)
{
  var checkOK = "@";
  var checkStr = myint;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
if(checkStr.charAt(0)=='@') return(false);
if(checkStr.charAt(checkStr.length-1)=='@')
return(false);
if(checkStr.charAt(checkStr.length-1)=='.')
return(false);
a_valid=0; a_count=0;
d_valid=0;
 for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == '@')   {a_valid=1; a_count++;  }
    if (ch == '.')   {d_valid=1;  }
  }
   if(a_count>1) return(false);
   if(a_valid==1 && d_valid==1) return(true); else return(false);
}

function readcookies()
{
    var ls_name=GetCookie("zcm11");
    if(ls_name!=null && ls_name!="")
    {
        document.getElementById("PageTop1_T_UID2").value=ls_name;
        document.getElementById("Checkbox1").checked=true;
    }
}
function loginout()
{
    SetCookie("zcm1","");
    window.location.reload();
}

function title_click(uid)
{
    for(var i=1;i<9;i++)
    {
        if(i==uid)
        {
            document.getElementById("title"+i).className="butt1bg";
        }
        else
        {
            document.getElementById("title"+i).className="butt2bg";
        }
    }
}
function go_search()
{
    var ls_title=window.document.getElementById("T_Search1").value;
    if(ls_title!="")
    {
        window.location.href="Index_NewsSearch.aspx?tsearch="+ls_title;
    }
    else
    {
        alert("请输入要搜索的博文标题！");
        return;
    }
}
 function outlogin()
{//退出登录
    var lv_re1=Blog_Public.outlogin().value;
//    var lv_re="&nbsp;<a href=\"http://user.cnfund.cn\">登录</a>&nbsp;<a href=\"http://user.cnfund.cn/Register.aspx\">注册</a>&nbsp;<a href=\"http://user.cnfund.cn/findpassword.aspx\">找回密码</a>&nbsp;<span id=\"setHomePage\" onclick=\"this.style.behavior='url(#default#homepage)';this.setHomePage(location.href);return(false);\" style=\"behavior:url(#default#homepage); cursor:pointer;\">设为首页</span>&nbsp;<span onclick=\"window.external.AddFavorite(location.href, '<%=L_topblogname.Text.Trim() %>的博客' )\" style=\"cursor:pointer\">加入收藏</span>";
//    document.getElementById("information").innerHTML=lv_re;
    window.location.reload();
}