﻿function GetElem(id){return document.getElementById(id);}
function RequestLogin(m_vercode)
{
    if(GetElem('txtNickName').value=='' || GetElem('txtPwd').value=='')
    {
        alert('请填写用户名和密码！');
        return false;
    }
    
    GetElem('loginstate2').style.display='none';
    GetElem('loginstate1').style.display='';
    
    RequestLoginCommon(GetElem('txtNickName').value,GetElem('txtPwd').value,m_vercode,DispIsExistUser)
    return false;
}
function DispIsExistUser()
{
 //alert(xmlHttp.status);
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {
            if(xmlHttp.responseText=='0')
            {
                window.location.href='/Index.shtml';
                return;
            }
            else if(xmlHttp.responseText=='8' || xmlHttp.responseText=='7')
            {
                window.alert('用户名或密码错误！');
            }
           else if(xmlHttp.responseText=='4')
            {
                 window.alert('验证码错误，请核对后重新输入！');
            }    
            else
            {
               window.alert('异常错误，请联系本站客服！');
            }
            GetElem('loginstate2').style.display='';
            GetElem('loginstate1').style.display='none';
            vercodex='1111';
        }
        else
        {
  //     location=location;
     //       alert('检测账号时发生错误！');
        }
    }
}
function SetTextSytle(id,InitValue)
{
    if(GetElem(id).value==InitValue)
    {
        GetElem(id).value='';
    }
    GetElem(id).style.color="black";
}
//推荐
function tuijian(title)
{
    var content='';
    var head='在中国供求网(www.gongqiu.com.cn)上找到的信息：\r\n'+title;
    var url=window.location.href;
    content+= head;
    content+='\r\n'+url;
    window.clipboardData.setData("Text",content);
    alert("此信息已经复制到剪贴板，\n赶快共享给你QQ、MSN和其它商业伙伴吧！: )");
}
//收藏
function shoucang(sURL, sTitle)
{
    //sTitle=='' ? sTitle='http://www.gongqiu.com.cn/' : sTitle=sTitle ;
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
//设为首页
function SetHome(obj,vrl){
try{
        obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
}
catch(e){
        if(window.netscape) {
                try {
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                } 
                catch (e) { 
                        alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                }
                var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                prefs.setCharPref('browser.startup.homepage',vrl);
         }
}
}

function RequestLoginCommon(nickname,pwd,vercode,callback)
{
    createXMLHttpRequest();
    xmlHttp.onreadystatechange=callback;
    xmlHttp.open("GET",'/AjaxRequest/RequestLogin.aspx?UserID='+encodeURI(nickname)+'&Pwd='+encodeURI(pwd)+'&VerCode='+encodeURI(vercode),true);
    xmlHttp.setRequestHeader("If-Modified-Since","0"); 
    xmlHttp.send(null);

 
    return false;
}

