﻿// JScript 文件
function ajaxlogin(){
   $("loginMsg").innerHTML="<img src=\"/images/loading.gif\" width=16 height=16>正在向服务器提交登陆请求，请等待......";
    var username=$("username").value;
    var password=$("password").value;
	var myurl="login.aspx";
	var action="username="+username+"&password="+password;
	xmlHttp.open("POST",myurl,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = login_callback;
	xmlHttp.send(action);
}

function login_callback(){
    if (xmlHttp.readyState == 4){
       if (xmlHttp.status == 200){
		    webtext = xmlHttp.responseText;
		    showResult(webtext);
			}
		 }
}
function showResult(result){
     var strs=result.split(":");
     if (strs[0]=="error"){
     $("loginMsg").innerHTML="<font color=\"yellow\">"+strs[1]+"</font>";}
     if (strs[0]=="ok"){
     //$("Righttop").style.visibility="collapse";
     //$("Righttop").innerHTML="<div style=\"height:10px\"></div><font color=\"yellow\">"+"您好，"+strs[1]+"您有"+strs[2].toString()+"个喇叭"+"</font>";
     $("Righttop").innerHTML=result.substring(3);
     }
     
}

function ajaxlogout(){
   $("loginMsg").innerHTML="<img src=\"/images/loading.gif\" width=16 height=16>正在向服务器提交登陆请求，请等待......";
	var myurl="logout.aspx";
	xmlHttp.open("POST",myurl,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = logout_callback;
	xmlHttp.send(null);
}

function logout_callback(){
    if (xmlHttp.readyState == 4){
       if (xmlHttp.status == 200){
		    webtext = xmlHttp.responseText;
		    showResult1(webtext);
			}
		 }
}
function showResult1(result){
     $("Righttop").innerHTML=result;
}
