﻿function login()
{
var id =1;

    //------------------------------------创建背景层开始
    var bgObj=document.createElement("div");
    bgObj.setAttribute('id','bgDiv');
    bgObj.style.position="absolute";
    bgObj.style.width=document.body.offsetWidth+"px"; 
    bgObj.style.height=30+document.body.offsetHeight + "px";
    bgObj.style.top="0";
    bgObj.style.left="0";
    bgObj.style.background="#333333";//
    bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=25,finishOpacity=75"; 
    bgObj.style.zIndex="1001";
    document.body.appendChild(bgObj); 
    //------------------------------------创建背景层结束
    //------------------------------------创建弹出筐开始
    var msgObj=document.createElement("div");
    msgObj.setAttribute("id","msgDiv"); 
    msgObj.setAttribute("align","center"); 
    msgObj.style.background="white"; 
    msgObj.style.border="2px solid #cccccc"; 
    msgObj.style.position = "absolute"; 
    msgObj.style.left = "50%"; 
    msgObj.style.top = "200px"; 
    msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
    msgObj.style.width = "250px"; 
    msgObj.style.height ="152px"; 
    msgObj.style.textAlign = "center"; 
//    msgObj.style.lineHeight ="25px"; 
    msgObj.style.zIndex = "1002";
    msgObj.style.overflow = "auto";
    //-------------------------------------创建弹出筐结束
    //-------------------------------------创建title层开始
    var title=document.createElement("h4"); 
    title.setAttribute("id","msgTitle"); 
    title.setAttribute("align","right"); 
    title.style.margin="0"; 
    title.style.padding="3px"; 
    title.style.background="#8FB391"; 
    title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
    title.style.opacity="0.75"; 
    title.style.border="1px solid #8FB391"; 
    title.style.height="15px";
    title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
    title.style.color="white"; 
    title.style.cursor="pointer"; 
    title.title="　用户登陆";
    title.innerHTML="用户登陆&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;×关闭"; 
    title.onclick=function(){
        document.body.removeChild(bgObj); 
        document.getElementById("msgDiv").removeChild(title); 
        document.body.removeChild(msgObj);
        parent.location.href=parent.location.href;
    } 
    document.body.appendChild(msgObj); 
    document.getElementById("msgDiv").appendChild(title); 
    
    var txt=document.createElement("div");
    txt.setAttribute("id","msgTxt");
    
//    txt.innerHTML="aaaa";
    var frmobj=document.createElement("iframe");
    frmobj.src="login/login.aspx";
    frmobj.style.width="250px";
    frmobj.style.height="127px";
    frmobj.style.margin="0";
    frmobj.style.padding="0";
    frmobj.scrolling="no";
    frmobj.frameborder="0";
    frmobj.style.border="none";
    frmobj.paddingTop="-2";
    frmobj.style.overflow="hidden";
    
    
    BOX_layout(bgObj, msgObj);
    onresize = function(){BOX_layout(bgObj, msgObj);} //改变窗体重新调整位置
    onscroll = function(){BOX_layout(bgObj, msgObj);} //滚动窗体重新调整位
    
    
    document.getElementById("msgDiv").appendChild(txt);
    document.getElementById("msgTxt").appendChild(frmobj);
}
function BOX_layout(e, msgObj)
{
    //取客户端左上坐标，宽，高
    var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    var clientWidth;
    //if (window.innerWidth) {
    //     clientWidth = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
    //} else {
           clientWidth = document.documentElement.clientWidth;
    //}
    var clientHeight;
    //if (window.innerHeight) {
    //     clientHeight = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
    //} else {
           clientHeight = document.documentElement.clientHeight;
    //}
    //调整遮掩层位置
    e.style.left = scrollLeft+'px';
    e.style.top = scrollTop+'px';
    e.style.width = clientWidth+'px';
    e.style.height = clientHeight+'px';
    
    //调整内容层位置
    msgObj.style.left = scrollLeft+((clientWidth-msgObj.offsetWidth)/2)+'px';
    msgObj.style.top = scrollTop+((clientHeight-msgObj.offsetHeight)/2)+'px';
}
