﻿function showDilog()
{
	var b_div= $E("login_background");
	b_div.zIndex=999;
	b_div.style.background="#000000";
	b_div.style.width = document.documentElement.scrollWidth+"px";
	b_div.style.height= document.documentElement.scrollHeight+"px";
	b_div.style.filter="alpha(opacity=35)";
	b_div.style.opacity="0.35";
	b_div.style.position="absolute";
	b_div.style.display="block";
	b_div.style.left="0px";
	b_div.style.top="0px";
	var l_div = $E("login");
	b_div.zIndex=1000;
	l_div.style.position="absolute";
	l_div.style.display="block";
	if(arguments[0]==null)
	{
             l_div.style.width="300px";
	     l_div.style.height="150px";
             l_div.style.left=parseInt(document.documentElement.clientWidth/2)-150+"px"
	     l_div.style.top=220+document.documentElement.scrollTop+"px";
	     l_div.innerHTML="<table width='300' border='0' cellspacing='0' cellpadding='0' style='border:#ACD942 3px solid;background:#ffffff;'><tr style='background:url(http://www.liangdian.tv/image/login_bg.gif) repeat right'><th width='91' height='25' align='left' style='color:#FFFFFF'>&nbsp;登录</th><td width='203' height='25' align='right' valign='top'><img src='http://www.liangdian.tv/image/user_close.gif' width='20' height='20' id='tip_close' alt='关闭' onclick='closeDilog()' style='border:#C7D89E 1px solid;cursor:pointer;' />&nbsp; </td></tr><tr><th height='40' colspan='2' align='center' style='display:none' id='loading'><img src='http://www.liangdian.tv/image/loading.gif' />正在登录，请稍后…… </th></tr><tr><th height='40' align='right'>用 户:</th><td height='40' align='left'><label>&nbsp; <input name='username' type='text' id='username' style='width:140px;font-family:宋体' size='20' /></label></td></tr><tr><th height='40' align='right'>密 码:</th><td height='40' align='left'>&nbsp; <input name='password' type='password' onkeyup='enterLogin(event)' id='password' style='font-family:宋体;width:140px' size='20' /></td></tr><tr><th height='30' colspan='2'><input type='button' value='确定' id='que_btn' onclick='userLogin()' />&nbsp; &nbsp; &nbsp; &nbsp; <input type='button' value='关闭' onclick='closeDilog()' /></th></tr></table>";
	     $E("username").focus();
	}
	else
	{
                l_div.style.width="500px";
	        l_div.style.height="300px";
                l_div.style.left=parseInt(document.documentElement.clientWidth/2)-220+"px"
	        l_div.style.top=150+document.documentElement.scrollTop+"px";
                l_div.innerHTML="<img alt='单击即可关闭' src='/image/help.gif' onclick='closeDilog()' />";
		//l_div.innerHTML="<iframe src='agentlist.aspx?r="+Math.random()+"' frameborder='' width='300' height='153'></iframe>";
	}
}
function closeDilog()
{
	$E("login").style.display="none";
	$E("login_background").style.display="none";
}
function ul()
{
	$E("login").innerHTML="<table width='300' border='0' cellspacing='0' cellpadding='0' style='border:#ACD942 3px solid;background:#ffffff;'><tr style='background:url(http://www.liangdian.tv/image/login_bg.gif) repeat right'><th width='91' height='25' align='left' style='color:#FFFFFF'>&nbsp;登录</th><td width='203' height='25' align='right' valign='top'><img src='http://www.liangdian.tv/image/user_close.gif' width='20' height='20' id='tip_close' alt='关闭' onclick='closeDilog()' style='border:#C7D89E 1px solid;cursor:pointer;' />&nbsp; </td></tr><tr><th height='40' colspan='2' align='center' style='display:none' id='loading'><img src='http://www.liangdian.tv/image/loading.gif' />正在登录，请稍后…… </th></tr><tr><th height='40' align='right'>用 户:</th><td height='40' align='left'><label>&nbsp; <input name='username' type='text' id='username' style='width:150px;font-family:'宋体'' /></label></td></tr><tr><th height='40' align='right'>密 码:</th><td height='40' align='left'>&nbsp; <input name='password' type='password' onkeyup='enterLogin(event)' id='password' style='font-family:'宋体';width:150px'/></td></tr><tr><th height='30' colspan='2'><input type='button' value='确定' id='que_btn' onclick=\"userLogin('agent')\" />&nbsp; &nbsp; &nbsp; &nbsp; <input type='button' value='关闭' onclick='closeDilog()' /></th></tr></table>";
	$E("username").focus();
}
function ulAgent()
{
	$E("login").innerHTML="<iframe src='agentlist.aspx?r="+Math.random()+"' frameborder='' width='300px' height='260px'></iframe>";
}
function userLogin()
{
	if($E("username").value=="")
	{
		alert("用户名不能为空！");
		$E("username").focus();
		return;
	}
	if($E("password").value=="")
	{
		alert("密码不能为空！");
		$E("username").focus();
		return;
	}
	var url="http://www.liangdian.tv/user/top_login.aspx";
	url+="?username="+escape($E("username").value);
	url+="&password="+escape($E("password").value);
	if(arguments[0]=="agent") url+="&r=ok";
	url+="&t="+escape(Math.random());
	createScript(url);
	showLoading(true);
}
function showLoading(isOpen)
{
	if(isOpen)
	{
		$E("que_btn").disabled="disabled";
		$E("username").readonly="true";
		$E("password").readonly="true";
		$E("loading").style.display="block";
	}
	else
	{
		$E("que_btn").disabled="";
		$E("username").readonly="false";
		$E("password").readonly="false";
		$E("loading").style.display="none";
	}
}
function showResult(message)   
{
    switch(message)
	{
		case 0:
		     alert('用户名或密码错误！');
	         showLoading(false);
		     break
		case 1:
		     alert('您的用户信息正在审核中，如有问题请与亮点医药视频招商网联系。\n\n 0371-63263677 65791577');
	         closeDilog();
		     break
		case 3:
		     alert('该帐户已经登录不允许重复登录，如有问题请与亮点医药视频招商网联系。\n\n 0371-67263677 65791577');
	         closeDilog();
		     break
	    default:
		     location.href='http://www.liangdian.tv/user/default.aspx'; //http://www.liangdian.tv
	         closeDilog();
	}
}
function enterLogin(event)
{
	if(event.keyCode==13)
	{
		userLogin();
	}
}
function createScript(url)
{
	var script =$E("loginJs");
	if(script)
	{
         $E("login").removeChild(script);
	}
	script = document.createElement("script");    
	script.type="text/javascript";
	script.id="loginJs";
	script.src=url;
	$E("login").appendChild(script);
}
