
//显示用户列表
function showUlAccount(isShow)
{
	if (isShow =="true")
	{
		ulAccount1.style.display = "inline";
	}
	else if (isShow =="false")
	{
		ulAccount1.style.display = "none";
	
	}
	else
	{
		if (ulAccount1.style.display != 'inline')
		{
			ulAccount1.style.display = "inline";
		}
		else
		{
			ulAccount1.style.display = "none"; 
		}
	}
	
}

//显示用户列表
function showStatelist()
{
	
		if (statelist.style.display != 'inline')
		{
			statelist.style.display = "inline";
		}
		else
		{
			statelist.style.display = "none"; 
		}
	
	
}


function rememberPwdCheck_OnClick()
{
    if (RememberPwdCheck.className == 'check1 check checkdown')
    {
		RememberPwdCheck.className = 'check1 check checkover';
    }
	else
	{
		RememberPwdCheck.className = 'check1 check checkdown';
		
	}

   
}
function rememberPwdCheck_OnMouseOver()
{
    if (RememberPwdCheck.className != 'check1 check checkdown')
    {
		RememberPwdCheck.className = 'check1 check checkover';
    }
	
}

function rememberPwdCheck_OnMouseOut()
{
    if (RememberPwdCheck.className != 'check1 check checkdown')
    {
		RememberPwdCheck.className = 'check1 check';
    }
	
}


function autoLoginCheck_OnClick()
{
    if (AutoLoginCheck.className == 'check2 check checkdown')
    {
		AutoLoginCheck.className = 'check2 check checkover';
    }
	else
	{
		AutoLoginCheck.className = 'check2 check checkdown';
		
	}

   
}
function autoLoginCheck_OnMouseOver()
{
    if (AutoLoginCheck.className != 'check2 check checkdown')
    {
		AutoLoginCheck.className = 'check2 check checkover';
    }
	
}

function autoLoginCheck_OnMouseOut()
{
    if (AutoLoginCheck.className != 'check2 check checkdown')
    {
		AutoLoginCheck.className = 'check2 check';
    }
	
}

function DiaplaySoft(softType)
{
    if (softType == "0")
    {
		Soft91See.className = "soft";        
		Soft91See.onmouseover = function() {Soft91See.className = "soft softon" }
		Soft91See.onmouseout = function() {Soft91See.className = "soft" }
		Soft91See.innerHTML = " <div class='icon1' style='right: 165px'></div> <div class='names'>91看图</div> <div class='btn'></div>";
	}
	
	if (softType == "1")
    {
	    Soft91English.className = "soft";        
		Soft91English.onmouseover = function() {Soft91English.className = "soft softon" }
		Soft91English.onmouseout = function() {Soft91English.className = "soft" }
		Soft91English.innerHTML = " <div class='icon2' style='right: 165px'></div> <div class='names'>91英语</div> <div class='btn'></div>";
	
    }
    
    if (softType == "2")
    {
	    Soft91Note.className = "soft";        
		Soft91Note.onmouseover = function() {Soft91Note.className = "soft softon" }
		Soft91Note.onmouseout = function() {Soft91Note.className = "soft" }
		Soft91Note.innerHTML = " <div class='icon3' style='right: 165px'></div> <div class='names'>91剪报</div> <div class='btn'></div>";
	
    }
    
    if (softType == "3")
    {
	    Soft91Divine.className = "soft";        
		Soft91Divine.onmouseover = function() {Soft91Divine.className = "soft softon" }
		Soft91Divine.onmouseout = function() {Soft91Divine.className = "soft" }
		Soft91Divine.innerHTML = " <div class='icon4' style='right: 165px'></div> <div class='names'>91算命</div> <div class='btn'></div>";
	
    }
    
    if (softType == "4")
    {
	    Soft91Money.className = "soft";        
		Soft91Money.onmouseover = function() {Soft91Money.className = "soft softon" }
		Soft91Money.onmouseout = function() {Soft91Money.className = "soft" }
		Soft91Money.innerHTML = " <div class='icon5' style='right: 165px'></div> <div class='names'>91理财</div> <div class='btn'></div>";
	
    }

}



//在光标到textbox特定位置
function   moveAtCaret(obj,n)   
{   
     
      //将obj中光标向dirc方向移动n个字符
	  textobj = document.getElementById(obj);
	  textobj.focus();     
	  var rng=document.selection.createRange();     
	  rng.moveStart("character",   n);     
	  rng.select();  
}

//设置用户列表
var arruserlist = null;
function  setuserlist(value)
{
	arruserlist = value.split(";");
	filluserlist("");
}

//填充用户列表，filter用于过滤
function  filluserlist(filter)
{
	if (arruserlist == null || arruserlist.length <= 0)
	    return;
		
	 index = 0;
	 var strallline = "";
	 var h = 10;
	 for (i = 0; i < arruserlist.length; i++)
	 {
		 if (filter != "")
		 {
			 if (arruserlist[i].indexOf(filter) != 0)
			    continue;
				
			if (arruserlist[i] == filter)
			   continue;
 
		 }
		 strline = "<li id='accountsub" + index + "' ";
		 strline += " onmousedown='mousedown();' onclick='showUlAccount();' ";
		 strline += " class='selectlistli' onmouseover='this.className=\"selectlistlion\"' onmouseout='this.className=\"selectlistli\"'>";
		 strline +=  arruserlist[i] + "</li> ";
	
		 strallline += strline;
		 
		 h = 5 + (index + 1) * 24; //计算整个下拉列表框的高度，24为每个item的高度
		 if (h > 200)
		    h = 200;

		 index++;
		 
	 }
	 ulAccount1.innerHTML = strallline;
	 ulAccount1.style.height = h;
	 
	 //选中第一项
	 selectIndex = -1;
	 if (index > 0)
	 {
	   accountsub0.className = "selectlistlion";
	   selectIndex = 0;
	 }
 
}

//主要用于方向键的判断
var selectIndex = -1;
function document.onkeydown()
{
 hideMsg();
  with(window.event)
  {
    if(keyCode==40)   //按下向下方向键
	{
		  if (ulAccount1.style.display == "inline")  //如果显示用户列表，则在用户列表中移动
		  {
			  var ils = document.getElementById('ulAccount1').getElementsByTagName('li').length;
			  for (i = 0; i < ils; i++)
			  {
				  document.getElementById("accountsub" + i).className = "selectlistli";
			  }
			  
			  selectIndex ++;
			  if (selectIndex >= ils)
				selectIndex = 0;
				
			  document.getElementById("accountsub" + selectIndex).className = "selectlistlion";
	
		  }
		  else if (window.event.srcElement.id == "UserIDInputbox") //如果用户列表不显示，则光标移动到密码框
		  {
			  if (ulAccount1.style.display == "none")
			  {
				  moveAtCaret("PwdInputbox", 100);
			  } 
		  }
    }
    else if(keyCode==38) //按下向上方向键，光标移动到用户输入框
	{
	  if (window.event.srcElement.id == "PwdInputbox")
	  {
		  moveAtCaret("UserIDInputbox", 100);
	  }
    }
  }
}

//用户输入框触发onkeyup事件时，判断是否显示用户列表
function document.onkeyup()
{

  if (event.srcElement.id == "UserIDInputbox")
  {
	  if (event.keyCode != 40 && event.keyCode != 13 && event.keyCode != 38)
	  {
		  filluserlist(event.srcElement.value);
		  if (ulAccount1.getElementsByTagName('li').length <= 0) //如果用户列表为空则不显示
		  {
			 showUlAccount("false");
		  }
		  else
		  {
			  showUlAccount("true");  //否则显示用户列表
		  }
		  
		  document.getElementById("UserIDInputbox").fireEvent("Onchange");
	  }
	  
  }
	  

}

//垵下鼠标先保存选择的用户名
var username = "";
function mousedown()
{
   
   hideMsg();
	username = window.event.srcElement.innerText;
}
function document.onclick()
{
	 if (username != "")
	 {
		UserIDInputbox.blur();
		UserIDInputbox.value = username;
		moveAtCaret("UserIDInputbox", 100);
		//UserIDInputbox.fireEvent('onchange');
		
		 document.getElementById("UserIDInputbox").fireEvent("Onchange");   
	 }
	 username ="";	
	 
	 if (event.srcElement.id != "UserIDInputbox" && event.srcElement.id != "DropBtn")
	 {
	 	 if (ulAccount1.style.display == "inline")
	 		ulAccount1.style.display = "none";
	 }
	 	 
	 
}

//判断按回车键是否是要登录
function CanLogin()
{
	//如果有信息框，则关闭信息框，不登陆
	if (document.getElementById("msgBoxBtnOk") != null)
	{
		if ($("msgBox").style.display != "none" && MBMethod != null)
		{
		   MBMethod(msgBoxBtnOk);
		   return false;
		}
	}
	
	//如果用户下拉列表有显示，则关闭用户列表，不登陆
	if (ulAccount1.style.display == "inline")
	{
	    var ils = document.getElementById('ulAccount1').getElementsByTagName('li').length;
		if (selectIndex >= 0 && selectIndex < ils)
		{
		    UserIDInputbox.value = document.getElementById("accountsub" + selectIndex).innerText; //将选中的项放入用户输入
			 document.getElementById("UserIDInputbox").fireEvent("Onchange");  
		}
		ulAccount1.style.display = "none"
		return false;
	}
	
	//除去上面两种情况，按回车键表示登录
	return true;
}

function execute(statement)
{
	eval(statement);
}

function showMsg(m){
	$("#div_msg .pup-c p").html(m);
	$("#div_msg").hide().slideDown("fast");
}

function hideMsg(){
	$("#div_msg").slideUp("fast");
	
}

function AfxMessageBox(caption, content, method, btncaption)
{
	showMsg(content);
	
	if (method)
	 eval(method);
}



