﻿// JScript 文件

//4.29增加
//侧边栏目会员登陆口
//显示登陆成功的会员信息
function leftUserLogin()
{
    var name; var pwd; var img;
    // alert(document.cookie.substring(document.cookie.length-5,document.cookie.length));
    img = document.getElementById("txtImg").value;
    
    //判断验证码是否正确
    if(img==document.cookie.substring(document.cookie.length-5,document.cookie.length))
    {
        name = document.getElementById("txtName").value;
        pwd = document.getElementById("txtPwd").value;
        
        //以下是验证用户合法性
        
        var loginBool = ShowASP_Control_leftusercol.leftLogin(name,pwd);
        if(loginBool.value == true)
        {
            alert('登陆成功！');
            
            //页面显示成功登陆的会员信息
            //document.getElementById("liUserInfo").innerHtml = "";
            //se.UserInfo();
            //alert(se.UserInfo());
            
            //会员编号
            var id = ShowASP_Control_leftusercol.GetUserIdByName(name).value;
            
            showLeftUserInfo(name,id)
        }
        else
        {
            alert('登陆失败！');
        }
    }
    else
    {
        alert('验证码错误！');
        document.getElementById("txtImg").value = '';
        document.getElementById("txtImg").focus();
    }
}

//取消按钮，清空页面输入框
function clearinfo()
{
    document.getElementById("txtName").value = "";
    document.getElementById("txtPwd").value = "";
    document.getElementById("txtImg").value = "";
}


//显示登陆成功的会员信息
function showLeftUserInfo(name,id)
{
    document.getElementById("liUserInfo").innerHTML = "";
    
    var str = ShowASP_Control_leftusercol.ShowUserInfo(name,id).value;

    document.getElementById("liUserInfo").innerHTML =str;
} 

function openUI(id)
{
    window.parent.location.href('../../ShowASP/AssociatorASP/userinfo.aspx?u_id='+id);
}
function openShopInfo(id)
{
    window.parent.location.href('../../ShowASP/Shop_Room/buylist.aspx?u_id='+id);
}
function openDef()
{
    window.parent.location.href("../../ShowASP/BBs/Default.aspx");
}
function inShopRoom()
{
     window.parent.location.href("../../ShowASP/Shop_Room/shop_index.aspx");
}

function leftReg()
{
    window.location.href("../../ShowASP/AssociatorASP/reg.aspx");
//window.open ('ShowASP/AssociatorASP/reg.aspx', 'newwindow', 'height=800, width=800, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');
}

//会员退出登陆
function exitUser()
{
    ShowASP_Control_leftusercol.UserExit();
    

    document.getElementById("liUserInfo").innerHTML ="<div class=\"index_interact indexCon\" id=\"divUser\">";
    document.getElementById("liUserInfo").innerHTML ="<ul id=\"liUserInfo\" class=\"indexUser\">";
    document.getElementById("liUserInfo").innerHTML +="<li><small>用户名:</small><input id=\"txtName\" type=\"text\" class=\"text\" /></li>";

    document.getElementById("liUserInfo").innerHTML += "<li><small>密&nbsp;&nbsp;&nbsp;码:</small><input id=\"txtPwd\" type=\"password\" class=\"text\" /></li>";
    document.getElementById("liUserInfo").innerHTML += "<li><small>验证码:</small><input id=\"txtImg\" type=\"text\" style=\"width: 50px\" class=\"text\"/></li>";
    document.getElementById("liUserInfo").innerHTML += "<li class=\"sub\"><small>&nbsp;</small><input id=\"btnSubmit\" type=\"button\" value=\"登陆\" onclick=\"javascript:login();\" /><input id=\"btnSubmits\" type=\"button\" value=\"注册\" onclick=\"javascript:leftReg();\" /></li>";
    document.getElementById("liUserInfo").innerHTML += "</ul>";
    document.getElementById("liUserInfo").innerHTML += "</div>";
    document.getElementById("liUserInfo").innerHTML += "<div class=\"clear\"></div>";

   
}
