var servleturl='../servlet/getRequest?';

function msg(msgHead,msgBody)
{
 this.msgHead=msgHead;	
 this.msgBody=msgBody;
}
//消息头
function msgHead(fromType,fromID,toType,toID,
		msgType, modelId, cmdCode, sysNumber,
		sequense, errorCode,userSequense)
{
  this.fromType=fromType;
  this.fromID=fromID;
  this.toType=toType;
  this.toID=toID;
  this.msgType=msgType;
  this.modelId=modelId;
  this.cmdCode=cmdCode;
  this.sysNumber=sysNumber;
  this.sequense=sequense;
  this.errorCode=errorCode;
  this.userSequense=userSequense;
}

/*
 * 登陆
 * */
 //// 消息体
 //登陆消息体 200
function requestLoginBody(userName,password,isCompelLogin) {
	this.name=userName;
	this.passward=password;
	this.isCompelLogin = isCompelLogin;
}

function submitLogin(ip,username,psw,code,isCompelLogin){
  this.requestOfLogin=new msgHead(0, "0", 0, "0",1, 200, 200, 10, 0, 0,0);
  this.requestOfLoginBody=new requestLoginBody(username,psw,true);
  this.msgOfLogin=new msg(this.requestOfLogin,this.requestOfLoginBody);
  this.msgsOfLogin = "msgs=" + JSON.stringify(this.msgOfLogin)+"&ip="+ip+"&codeValue="+code+"&action=login";
  var ajaxobj=new AJAX();   
  ajaxobj.method="GET"; 
  ajaxobj.url=servleturl + this.msgsOfLogin +"&sid=" + Math.random();
  ajaxobj.responseMsg= function () {
  }
  ajaxobj.send(); 
}

//3.1.13	MOD 200  CMD 204  用户注册
function requestOfUserRegister(userName,passwords,sex,email)
{
  	this.userDetailedInfo = {
  			userId : 0,
  			userName : userName,
  			sex : sex,
  			email: email
  	};
}

/*
 * 用户注册
 * 测试OK
 * */
function submitUserRegister(ip,userName,passwords,sex,email,code){
	this.msgHeadofUserRegister=new msgHead(0, "0", 0, 0,1, 200, 204, 10, 0, 0,""); //getCookie("userSequense")
	this.msgBodyOfUserRegister=new requestOfUserRegister(userName,passwords,sex,"aaa.gif","aaa",email,"aaa","aaa","aaa","aaa","aaa","aaa","aaa","aaa");
	this.msgBodyOfUserRegister.userDetailedInfo.userName = userName;	
	this.msgBodyOfUserRegister.userDetailedInfo.passwords = passwords;
	this.msgBodyOfUserRegister.userDetailedInfo.sex = sex;
	this.msgBodyOfUserRegister.userDetailedInfo.imageId = "imageId";
	this.msgBodyOfUserRegister.userDetailedInfo.realName = "realName";
	this.msgBodyOfUserRegister.userDetailedInfo.email = email;
	this.msgBodyOfUserRegister.userDetailedInfo.identity = "identity";
	this.msgBodyOfUserRegister.userDetailedInfo.identityType = "identityType";
	this.msgBodyOfUserRegister.userDetailedInfo.question = "question";
	this.msgBodyOfUserRegister.userDetailedInfo.answer = "answer";
	this.msgBodyOfUserRegister.userDetailedInfo.telephone = "88282695";
	this.msgBodyOfUserRegister.userDetailedInfo.address = "Macross city";
	this.msgBodyOfUserRegister.userDetailedInfo.birthday = "19820101";
	this.msgBodyOfUserRegister.userDetailedInfo.memo = "memo";
	this.msgOfUserRegister=new msg(this.msgHeadofUserRegister,this.msgBodyOfUserRegister);
	this.msgsOfUserRegister = "msgs=" + JSON.stringify(this.msgOfUserRegister)+"&ip="+ip+"&codeValue="+code+"&action=register";
	  
	var ajaxobj=new AJAX();
	ajaxobj.method="POST"; 
	ajaxobj.url=servleturl + this.msgsOfUserRegister +"&sid=" + Math.random();
	//alert(ajaxobj.url);
	ajaxobj.responseMsg= function () {
	
	}
	ajaxobj.send();  	
}
function loginAction(){
	var username = document.getElementById("username");
	var password = document.getElementById("password");
	var code = document.getElementById("code");
	if(username.value == "") {
		alert("请输入用户名!");
		username.focus();
		return false;
	} else if(password.value == "") {
		alert("请输入密码!");
		password.focus();
		return false;
	} else if(code.value == "") {
		alert("请输入验证码!");
		code.focus();
		return false;
	}
}