﻿
var OutUrl="";var DisplayLevel="";var UrlFp="";function OutputLoginLayer(visibled)
{var olayer=document.getElementById('UserloginLayer');if(olayer!=null)
{var htmls='';htmls=htmls+"<div class='J_expend'>";htmls=htmls+"<div id='J_loginHead'><span class='Title' id='spanTitle'></span><span class='J_txtImage'  name='txtImg' onclick='ShowLoginLayer(false);' ></span><div>";htmls=htmls+"<div id='confirmM' ></div>";htmls=htmls+"<div id='confirm' ></div>";htmls=htmls+"<div class='J_loginPanel' >";htmls=htmls+"<div class='J_Line'><span class='J_lbshow'>用&nbsp;&nbsp;&nbsp;&nbsp;户：</span><span class='lbinput'><input type='text' name='txtName' id='txtUser' value='OK号/EMAIL' onclick='ClearMessage();'  onkeydown='EnterPress();' /></span><span class='J_newRegister'><a href='../WebRegister.aspx' target='_blank'>注册新用户</a></span></div>";htmls=htmls+"<div class='J_Line' style='margin-bottom:15px;'><span class='J_lbshow'>密&nbsp;&nbsp;&nbsp;&nbsp;码：</span><span class='lbinput'><input type='password' name='txtPwd' id='txtPwd' onkeydown='EnterPress();' /></span><span class='J_findPwd'><a href='../FindPwd.aspx' target='_blank'>找回密码</a></span></div>";htmls=htmls+"<div class='J_BtnSave'>";htmls=htmls+"<input type='button' name='btnSubmit' id='btnSubmit' onkeydown='EnterPress();' value='确 定' onclick='login();'/>";htmls=htmls+"<input type='button' name='btnCancle' id='btnCancle' value='取 消' onclick='ShowLoginLayer(false);' style='margin-left:40px;' />";htmls=htmls+"</div>";htmls=htmls+"</div>";htmls=htmls+"</div>";olayer.innerHTML=htmls;}}
function getWidth(){var strWidth,clientWidth,bodyWidth;clientWidth=document.documentElement.clientWidth;bodyWidth=document.body.clientWidth;if(bodyWidth>clientWidth){strWidth=bodyWidth+20;}else{strWidth=clientWidth;}
return strWidth;}
function getHeight(){var strHeight,clientHeight,bodyHeight;clientHeight=document.documentElement.clientHeight;bodyHeight=document.body.clientHeight;if(bodyHeight>clientHeight){strHeight=bodyHeight+30;}else{strHeight=clientHeight;}
return strHeight;}
function ScreenLayer()
{var oScreen=document.getElementById('Screen');if(oScreen!=null)
{oScreen.style.width=getWidth()+"px";oScreen.style.height=getHeight()+"px";oScreen.style.display='block';}}
function ClearMessage()
{var oMessage=document.getElementById('txtName');if(oMessage!=null)
{if(oMessage.value=='OK号/EMAIL')
oMessage.value='';}}
function ShowLoginLayer(visibled,value,state,displayLevel,url)
{var oScreen=document.getElementById('Screen');var objLayer=document.getElementById('UserloginLayer');if(objLayer!=null)
{if(visibled==true)
{if(url!=null)this.OutUrl=url;if(displayLevel!=null)this.DisplayLevel=displayLevel;OutputLoginLayer(true);objLayer.style.display='';var obj=document.getElementById('ctl00_SpecialHead1_Txt_Query');if(obj!=null)obj.focus();var obj1=document.getElementById('ctl00_Head1_Txt_Query');if(obj1!=null)obj1.focus();ScreenLayer();}
else
{OutputLoginLayer(false);objLayer.style.display='none';if(oScreen!=null)
oScreen.style.display='none';}
if(value!=null)$('#confirmM').html(value);if(state!=null)
{if(state==1)
{this.UrlFp=1;$('#spanTitle').html('请先登录');}
else
{$('#spanTitle').html('请先登录');}}
else
{var otitle=document.getElementById("spanTitle");if(otitle!=null)
{otitle.innerHTML="用户登录";}}}}
function EnterPress()
{if(event.keyCode==13||event.which==13)
login();}
function FormUserLogin()
{ShowLoginLayer(true);}
function login()
{var id=document.getElementById('txtName').value;var pwd=document.getElementById('txtPwd').value;if(id==''||id=='OK号/EMAIL'){$('#confirm').html('请输入用户名!');$('#txtName').focus();return false;}
if(pwd==""){$('#confirm').html('请输入密码!');$('#txtName').focus();return false;}
$.ajax({type:'Post',url:window.location.protocol+'//'+window.location.host+'/Data/JqueryLogin.aspx',data:'id='+id+'&pwd='+pwd,dataType:'json',success:function(data)
{if(data.sta==1)
{if(OutUrl!=null)
{if(DisplayLevel==null)
{window.location.href=data.info;}
else
{if(data.userlevel!=null)
{if(data.userlevel<DisplayLevel)
{ShowLoginLayer(false);ShowNoRight();return false;}
else
{window.location.href=window.location.protocol+'//'+window.location.host+'/'+OutUrl;}}}}
if(OutUrl=='')
{if(UrlFp==1)
{window.location.href=data.info+'&fp=1';}
else
{window.location.href=data.info;}}}
else
{$('#confirm').html(data.info).addClass('red');}}});}