function Ajax() {
  var obj;
  try { obj = new XMLHttpRequest(); }
  catch(e) {
    var AjList = ["MSXML2.XMLHTTP","MSXML.XMLHTTP","Microsoft.XMLHTTP"];
    for(var i=0;i < AjList.length;i++) {
      try {
        obj = new ActiveXObject(AjList[i]);
        break;
      } catch(e) { }
    }
  }
  return obj;
}

//登陆
function openme(){
document.getElementById('loginbg').style.display='block';
document.getElementById('loginshow').style.display='block';
}
function closeme(){
document.getElementById('loginbg').style.display='none';
document.getElementById('loginshow').style.display='none';
}

function logo_in(){
var username=document.getElementById('myname').value;
var userpass=document.getElementById('mypass').value;

  var xmlhttp = Ajax();
  var AjaxURL = 'dologin.asp?username='+escape(username)+'&userpass='+escape(userpass);
  xmlhttp.onreadystatechange = function() {
    if(xmlhttp.readyState == 4) { 
      var getText = parseInt(xmlhttp.responseText);
      if(getText == 1) 
	  {
		  dologin();
		  closeme();
		  document.getElementById('myname').value="";
		  document.getElementById('mypass').value="";
	  }
	  else if(getText == 2)
	  {
		  alert("用户名或密码错误!");
	  }
	  else if(getText == 3)
	  {
		  alert("你的帐号已经被冻结！");
	  }
	  else if(getText == 0)
	  {
		  alert("用户名密码不能够为空！")
	  }
	  else
	  {
		  alert("用户名或密码错误！")
	  }
    }
  }
  xmlhttp.open("GET",AjaxURL,true);
  xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
  xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlhttp.send();
}



//选肤cookie
function getCookie(name) 
{
	var my_cookie = document.cookie;
	var start = my_cookie.indexOf(name + "=");
	if (start == -1) return '';
	
	start += name.length + 1; //1 stands of '='
	
	var end = my_cookie.indexOf(";" ,start);
	if (end == -1) end = my_cookie.length;
	return my_cookie.substr(start, end - start);
}





<!-- 层ID号处理函数 Start -->
function $(id) {
  if(document.getElementById) { return document.getElementById(id); }
  else if(document.all) { return document.all[id]; }
  else if(document.layers) { return document.layers[id]; }
  else { return false; }
}
<!-- 层ID号处理函数 end -->


<!-- 登录显示 start -->
function dologin() {
  var xmlhttp = Ajax();
  var AjaxURL = 'login.asp';
  xmlhttp.onreadystatechange = function() {
    if(xmlhttp.readyState == 4) { 
      var getText = xmlhttp.responseText;
      xmlhttp = '';
      $('mylogin').innerHTML = getText;
    }
  }
  xmlhttp.open("GET",AjaxURL,true);
  xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
  xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlhttp.send();
}
<!-- 登录显示 end -->

<!-- 退出显示 start -->
function loginout() {
  var xmlhttp = Ajax();
  var AjaxURL = 'loginout.asp';
  xmlhttp.onreadystatechange = function() {
    if(xmlhttp.readyState == 4) { 
		dologin();
    }
  }
  xmlhttp.open("GET",AjaxURL,true);
  xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
  xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlhttp.send();
}
<!-- 登录显示 end -->
