﻿


function ReObj(idstr) {
    return document.getElementById(idstr);
}


var xmlHttp1, xmlHTTP2;

function UserRegion() {
   self.parent.document.location.href = "http://nm.sci99.com/user/reginNew.aspx";
}

function SciLogOut() {
    pnlloginobj.style.display = "none";
    pnlUserMesobj.style.display = "none";
    ReObj("div_logining").style.display = "";
    ReObj("div_logining").innerHTML = "正在退出请稍候.....";
    
    var Url = "";
    Url = "/include/LoginCheck.aspx?logout=1";
    // alert(Url);
    // alert(Url);
    if (window.ActiveXObject) {
        xmlHTTP2 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
    xmlHTTP2 = new XMLHttpRequest();
    }
    else {
        alert("对象创建失败");
    }
   // alert(Url);
    xmlHTTP2.onreadystatechange = ShowComment2;
    xmlHTTP2.open("GET", Url, true);
    xmlHTTP2.send(null);

    
}

function SCICheckLogin() {

    var tname = ReObj("txtName").value;
    var tpass = ReObj("txtPass").value;
    var tsitetype = ReObj("selectSiteType").value.split('$')[0];
   // var tsitetype = ReObj("selectSiteType").value;

    if (tname.value == "") {
        alert("请输入用户名！");
        usernameobj.focus();
        return;
    }
    if (tpass.value == "") {
        alert("请输入密码！");
        userpassobj.focus();
        return;
    }

//    if (ischeckcodevalue == "1") {
//        if (document.getElementById("scipicocode").value == "") {
//            alert("请输入验证码！");
//            document.getElementById("scipicocode").focus();
//            return;
//        }
//    }
    

    var Url = "";
    Url = "/include/LoginCheck.aspx?username=" + tname + "&userpass=" + tpass + "&sitetype=" + tsitetype;
    // alert(Url);
    // alert(Url);
    if (window.ActiveXObject) {
        xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp1 = new XMLHttpRequest();
    }
    else {
        alert("对象创建失败");
    }
    xmlHttp1.onreadystatechange = ShowComment;
    xmlHttp1.open("GET", Url, true);
    xmlHttp1.send(null);
    pnlloginobj.style.display = "none";
    ReObj("div_logining").style.display = "";
    ReObj("div_logining").innerHTML = '正在登陆通行证，请稍候......';
}
var checkcount = 0;
var usermesshow = "";
//此方法直接从服务器端返回HTML
function ShowComment() {

    if (xmlHttp1.readyState == 4) {
        // alert("信息返回");
        if (xmlHttp1.status == 200) {
            // alert(xmlHttp1.responseText);

            if (xmlHttp1.responseText == "1") {
                document.location.href = "/";
            }
            else {
               // alert(xmlHttp1.responseText);
                if (xmlHttp1.responseText.split('%%%%%%%%%%').length == 2) {
                    //alert("ok");
                     //alert("嘿嘿，成功啦！如果页面刷新证明你可以看美女啦！");
                    var resText = xmlHttp1.responseText;
                    //alert("restext:\n"+resText);
                    var lrstr = resText.split('##########');
                    var cokdata = lrstr[1].split('$$$$$$$$');
                    usermesshow = cokdata[3];
                    var coksrc;
                    if (document.location.href.toLowerCase().indexOf("sci99.com", 0) != -1) {
                        // var sitetypet = ReObj("selectSiteType").value;
                        var sitetypet = ReObj("selectSiteType").value.split('$')[0];
                        coksrc = "http://www.chem99.com/cok/?u=" + cokdata[0] + "&p=" + cokdata[1] + "&t=" + cokdata[2] + "&s=" + ((sitetypet=="21" || sitetypet =="22") ? "1" :"2" );
                    }
                    else {
                        coksrc = "http://www.sci99.com/cok/?u=" + cokdata[0] + "&p=" + cokdata[1] + "&t=" + cokdata[2] + "&s=" + ((sitetypet == "21" || sitetypet == "22") ? "1" : "2");
                    }
                    //alert(coksrc);
                   // window.open(coksrc);
                    //document.getElementById("frame1").src = coksrc;
                    var fmstr = "<iframe width=100 height=100 src='" + coksrc + "' onLoad='initLoad();' style='display:none;'>";
                    var divobject = document.createElement("div");
                    divobject.innerHTML = fmstr;
                    document.body.appendChild(divobject);
                 
                    

                }
                else {
                    alert("用户名或密码错误！");
                    pnlloginobj.style.display = "";
                    ReObj("div_logining").style.display = "none";
                    return;
                    Sci99piccodeLoad();
                    checkcount = checkcount + 1;
                    document.getElementById("span-tishi").innerHTML=xmlHttp1.responseText;
                    document.getElementById("span-tishi").style.color = "red";
                    if (checkcount > 2) {
                        document.getElementById("span_piccodetishi").style.display = "";
                        PicCodeControlT1obj.style.display = "";
                        document.getElementById('scipicocode').style.display = "";
                    }
                }
            }

            // document.getElementById("votehaurl").click();

        } else {
            alert("对不起，系统繁忙请稍候再试！");
        }
    }
    else {
    }
}

function initLoad() {
   // alert("ok");
    
        // document.location.href = document.location.href;
    ReObj("div_logining").innerHTML = "卓创资讯欢迎您登录：" + ReObj("txtName").value + "&nbsp;" + usermesshow + "&nbsp;&nbsp;进入 <a href='" + ReObj("selectSiteType").value.split('$')[1] + "' target='_blank'>" + ReObj("selectSiteType").options[ReObj("selectSiteType").selectedIndex].text + "</a> &nbsp;<input type='button' onclick='SciLogOut()' value='安全退出' style='background:#f5ebc6; width:74px; height:20px; border:1px #e3d6a6 solid; color:#000; text-align:center; line-height:22px'>";
   
    // window.open(ReObj("selectSiteType").value);
}

//此方法直接从服务器端返回HTML
function ShowComment2() {

    if (xmlHTTP2.readyState == 4) {
         //alert("信息返回");
        if (xmlHTTP2.status == 200) {
            //alert(xmlHTTP2.responseText);

            if (xmlHTTP2.responseText == "1") {
                //alert(xmlHTTP2.responseText);
                var coksrc = "http://www.chem99.com/cok/clear.aspx";
                var fmstr = "<iframe width=100 height=100 src='" + coksrc + "' onLoad='initLoadout();' style='display:none;'>";
                var divobject = document.createElement("div");
                divobject.innerHTML = fmstr;
                document.body.appendChild(divobject);
            
                
            }

            // document.getElementById("votehaurl").click();

        } else {
            alert("对不起，系统繁忙请稍候再试！");
        }
    }
    else {
        //alert('loading');
    }
}

function initLoadout() {
   // alert("ok");
    pnlloginobj.style.display = "";
    pnlUserMesobj.style.display = "none";
    ReObj("div_logining").style.display = "none";
   
}