﻿function openLogin(jump_url)
{
    login_wnd=document.getElementById("_login_div_quick_");
    if(!jump_url)jump_url='';
    if(!document.getElementById("_login_div_quick_"))
    {
         var bodyBack = document.createElement("div");
          bodyBack.setAttribute("id","bodybg")
          bodyBack.style.position = "absolute";
          bodyBack.style.width = "100%";
          bodyBack.style.height = (1000 + 'px');
          bodyBack.style.zIndex = 98;
          bodyBack.style.top = 0;
          bodyBack.style.left = 0;   
          bodyBack.style.filter = "alpha(opacity=70)";
          bodyBack.style.opacity = 0.7;
          bodyBack.style.background = "#ddf";
          document.body.insertBefore(bodyBack,document.body.firstChild);

        var newDiv=document.createElement("div");
        newDiv.id="_login_div_quick_";
        newDiv.style.position="absolute";
        newDiv.style.zIndex="100";
        newDiv.style.width="382px";
        newDiv.style.height="205px";
        newDiv.style.top="120px";
        newDiv.style.left="35%"
        newDiv.style.visibility="visible";//hidden
        newDiv.innerHTML='<iframe name="_login_frame_quick_" id="_login_frame_quick_" frameborder="no" scrolling="no" width="100%" height="100%" src="about:blank"></iframe>';
        document.body.insertBefore(newDiv,document.body.firstChild);
        login_wnd=newDiv;
       document.getElementById("bodybg").style.display = "";
    }
    else
    {
        if(login_wnd.style.display=="none")
        {
        login_wnd.style.display="block";
        document.getElementById("bodybg").style.display = "";
        }
        else
        {
         login_wnd.style.display="none";
         document.getElementById("bodybg").style.display = "none";
        }
    }
    document.getElementById("_login_frame_quick_").src="/login/?url="+jump_url;
}
function ptlogin2_onClose()
{
    login_wnd=document.getElementById("_login_div_quick_");
    login_wnd.style.display="none";
    document.getElementById("bodybg").style.display ="none";
}
function ptlogin1_onClose()
{
    login_wnd=document.getElementById("_login_div_quick_");
    login_wnd.style.display="none";
    document.getElementById("bodybg").style.display ="none";
    //document.getElementById("exchangeInfo").innerHTML="你登录了!哈哈";
    ajax_loginHtml();
}
function ajax_loginHtml()
{
    var pagetype="html";
    var params = new Array();
    params[0] = new Array("pagetype",escape(pagetype));
    var htmlstr=postPageData("/Ajax/Comm_Ajax.aspx?type=loginhtml", "POST",params);
    if(htmlstr!="")
    {
    document.getElementById("accountContent").innerHTML=htmlstr;
    }
}
var submited = false;
function SubLogin()
{
    if (!submited)
	{
        var loginAcc=document.getElementById('loginid').value;
	    var loginPwd = document.getElementById('logPwd').value;
	    if(loginAcc=="")
	    {
	        alert("登录帐号不能为空！");
	        return false;
	    }
	    if(loginPwd=="")
	    {
	        alert("登录密码不能为空！");
	        return false;
	    }
	    var checkcode= "1111";
	    var selLoginType= "unit";
        var params = new Array();
        params[0] = new Array("loginpwd",escape(loginPwd)); 
        params[1] = new Array("loginacc",escape(loginAcc));
        params[2] = new Array("lgointype",escape(selLoginType));
        params[3] = new Array("checkcode",escape(checkcode));
        submited = true;
        var result=postPageData("/Ajax/Comm_Ajax.aspx?type=login", "POST",params);
        submited = false;
        if(result=="1")
        {
            location.href="/MainUnit/";
        }
        else if(result == '-1')
        {
            alert('对不起,您的帐号出现异常,请联系管理员!!');
        }
        else if(result == '0')
       {
            alert('登录失败,用户名或密码错!');
       }
       else
       {
            alert('登录失败!未知错误:\n' + result);
       }
    }
    else
    {
	    alert('请勿重复提交请求');
    }
}
function bgMsOv(obj)
{
    obj.style.backgroundColor='#F1DBC6';
}
function bgMsOut(obj,num)
{
    if(num==1)
	    obj.style.backgroundColor='#F8F6F3';
    else
	    obj.style.backgroundColor='#FFFFFF';
}