﻿//获取滚动的边框值
var bodyScrollWidth=0;
var bodyScrollHeight=0;
function reCalBodySize(){
	//bodyScrollWidth=document.body.scrollWidth;
	//bodyScrollHeight=document.body.scrollHeight;
	
	//bodyScrollWidth=document.documentElement.clientWidth;
	//bodyScrollHeight=window.screen.availHeight;
	
	//获取网页可见区域窗口宽度
    if (window.innerWidth)
    bodyScrollWidth = window.innerWidth;
    else if ((document.body) && (document.body.clientWidth))
    bodyScrollWidth = document.body.clientWidth;
    
	//获取窗口高度    
	if (window.innerHeight)
    bodyScrollHeight = window.innerHeight;
    else if ((document.body) && (document.body.clientHeight))
    bodyScrollHeight = document.body.clientHeight;           

	//通过深入Document内部对body进行检测，获取窗口大小
    if (document.documentElement  && document.documentElement.clientHeight && document.documentElement.clientWidth)
    {
     bodyScrollHeight = document.documentElement.clientHeight;
     bodyScrollWidth = document.documentElement.clientWidth;
    }
}

//判断客户端浏览器的类型
if(navigator.appName.indexOf("Explorer") > -1){//ie
	var exp=1;
} 
else{//for ff
	var exp=2;
}

//*********************
//隐藏元素
function HideElement(strElementTagName){
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "hidden";
		}
	}catch(e){
		alert(e.message);
	}
}

//显示元素
function ShowElement(strElementTagName){
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "visible";
		}
	}catch(e){
		alert(e.message);
	}
}

function hideElementAll(){
	HideElement("SELECT");
	HideElement("OBJECT");
	HideElement("IFRAME");
}

function showElementAll(){
	ShowElement("SELECT");
	ShowElement("OBJECT");
	ShowElement("IFRAME");
}

//层的属性赋值
function set_div_style(obj,id,top,left,width,height,position,border,cursor,background) {
        var obj = obj;
        obj.id = id?id:null;
        obj.style.top = top?top:'0px';
        obj.style.left = left?left:'0px';
        obj.style.width = width?width:'0px';
        obj.style.height = height?height:'0px';
        obj.style.position = position?position:"static";
        obj.style.border = border?border:"1px #000 solid";
        obj.style.cursor = cursor?cursor:"default";
        obj.style.background = background?background:"";
        return obj;
}

// 创建滤镜
function CreGlobalDiv(){
		var DivWidth=document.documentElement.clientWidth;
		var DivHeight=document.documentElement.scrollHeight>bodyScrollHeight?document.documentElement.scrollHeight:bodyScrollHeight;
		var globalDiv=document.createElement('div');
		globalDiv.id='globalDiv';
		globalDiv.style.display='none';
		globalDiv.style.zIndex='98';
		globalDiv = set_div_style(globalDiv,'globalDiv','0px','0px',DivWidth+'px',DivHeight+'px',"absolute"," #333333 0px solid","default","darkgray");
		globalDiv.onselectstart=function(){return false}
		if ( 1 == exp ) {
			globalDiv.style.filter="alpha(opacity=30)";
		}
		else {
			globalDiv.style.opacity=30/100;
		}
		document.body.appendChild(globalDiv);
}

//滤镜定位
function LocGlobalDiv() {
	//reCalBodySize();
	var argArr=LocGlobalDiv.arguments;
	for ( var i=0;i<argArr.length;i++ ) {
		if ( document.getElementById(argArr[i]) != null ) {
			document.getElementById(argArr[i]).style.width = (bodyScrollWidth)+'px';
			document.getElementById(argArr[i]).style.height = (bodyScrollHeight)+'px';
		}
	}
}
function changYZM()
{         
	document.getElementById("safecodeimg").src = document.getElementById("safecodeimg").src + '?';
}
//显示操作定义
function dis(){	
	reCalBodySize();
	CreGlobalDiv();
	LocGlobalDiv();
	document.getElementById("globalDiv").style.display = "block";	
	var onpnlDiv=document.createElement('div');
	onpnlDiv.id='floginpart'; 
	document.body.appendChild(onpnlDiv);
	document.getElementById("floginpart").innerHTML='<div class="tips_m"  id="onpnl"><div class="tips_b" style="z-index: 1500">'
     +'   <div class="tips_box">'
         +'   <div class="tips_title">'
         +'      <h2>  用户登录</h2>'
           +'    <span class="close" id="flclose"><a href="javascript:void(0)" onclick="cls()">关闭</a></span>'
         +'   </div>'
        +'    <div class="tips_text">'
          +'      <div class="dl_tips" id="error_tips" style="display: none">'
          +'          <b class="dl_err"></b>您输入的账户名和密码不匹配，请重新输入。</div>'
         +'       <table width="100%" cellspacing="0" cellpadding="0" border="0" class="dl_tbl">'
           +'         <colgroup> <col width="52" /> <col width="180" /> <col width="" />'
          +' </colgroup>'
           +'         <tr>  <td>  用户名：</td> <td>  <input type="text" class="tips_txt text_on" id="fnameinput" name="u" /></td>'
         +'          <td class="t_ar">'
           +'                 <a href="/user/reg" target="_blank" tabindex="-1">免费注册</a></td>'
           +'         </tr>'
              +'      <tr>'
              +'          <td>    密&nbsp;&nbsp;码：</td>'
             +'  <td>  <input type="password" class="tips_txt" id="fpassinput" name="p" /></td>'
             +'  <td class="t_ar">    <a href="/user/mima" target="_blank" tabindex="-1">忘记密码</a></td>'
             +'  </tr>'
              +'      <tr>   <td> 验证码：</td>'
              +'<td colspan="2">  <input type="text" class="tips_yzm" id="codeinput" name="c" />'
			  +'<img src="/inc/Code.aspx"  id="safecodeimg" alt="验证码" style="vertical-align:bottom" /> <a href="javascript:changYZM();"" ><span>看不清?</span></a>'
            +'            </td>'
              +'      </tr>'
              +'      <tr>'
               +'        <td colspan="3">'
                +'            <input type="button" class="btn_Dora_b" value="" id="floginbtn" onclick="floglogin()" />'
                +'            <input type="button" class="zxb_btn" value="" onclick="alipayurl()" />&nbsp;'
                +'            <input type="button" class="qq_btn" value="" onclick="toQzoneLogin()" />'
                +'        </td>'
              +'      </tr>'
             +'  </table>'
           +' </div>'
       +' </div> </div></div>';
	GetCenterXY_ForLayer(document.getElementById("onpnl"));
	if ( 1 == exp ) {
		hideElementAll();
	}	
	//return;
}

function cls(){ 
	document.getElementById("onpnl").style.display = "none";
	document.getElementById("globalDiv").style.display = "none";
	if ( 1 == exp ) {
		showElementAll();
	}
	return false;
}
//将悬浮层的位置定位在body可见区域中央
function GetCenterXY_ForLayer(objdiv){	
	objdiv.style.display="block";	
	var styleWidth=objdiv.style.width.substring(0,objdiv.style.width.length-2);
	if (objdiv.firstChild.clientWidth>styleWidth)
	{
		objdiv.style.width=objdiv.firstChild.clientWidth+'px';
		styleWidth=objdiv.firstChild.clientWidth;
	}
	
	var styleHeight=objdiv.style.height.substring(0,objdiv.style.width.length-2);
	if (objdiv.firstChild.clientHeight>styleHeight)
	{
		objdiv.style.height=objdiv.firstChild.clientHeight+'px';
		styleHeight=objdiv.firstChild.clientHeight;
	}
	var objLeft = parseInt(document.documentElement.scrollLeft+(bodyScrollWidth - styleWidth)/2)+'px';
	var relTop=(bodyScrollHeight-styleHeight)/2 > 0 ? (bodyScrollHeight-styleHeight)/2:0;
	var objTop = parseInt(document.body.scrollTop+relTop)+'px';
	objdiv.style.top = objTop;	
	objdiv.style.left = objLeft;

	//checkAndResetStyleTop(objdiv);			// 调整高度	
}

function checkAndResetStyleTop (obj) {
	var clientHeight=obj.firstChild.clientHeight;
	var styleTop=parseInt(obj.style.top.substring(0,obj.style.top.length-2));
	if (clientHeight+styleTop>bodyScrollHeight ) {
		obj.style.top=(bodyScrollHeight- clientHeight)+'px';
	}
}
