var isCancel = false;
function handleConError(e) {
	document.getElementById("loading").style.display = "none";
	switch (e.getAttribute("code")) {
	  case "400":
		alert("服务器不允许注册");
		break;
	  case "401":
		alert("\u9a8c\u8bc1\u5931\u8d25");
		if (!con.connected()) {
			window.close();
		}
		break;
	  case "409":
		alert("该用户已存在");
		break;
	  case "410":
		alert("邮箱已存在");
		break;
	  case "503":
	  	if(conAmount<4){
	  		con._connected=false;
	  		conAmount++;
			changeStatus(onlstat, onlmsg);
	  	}
		break;
	  case "500":
		if (!con.connected() && !logoutCalled && onlstat != "offline") {
			if (confirm("\u670d\u52a1\u5668\u5185\u90e8\u9519\u8bef\uff01\n\n\u8fde\u63a5\u65ad\u5f00\uff01\n\u91cd\u65b0\u8fde\u63a5\u5417\uff1f")) {
				changeStatus(onlstat, onlmsg);
			}
		}
		break;
	  default:
		alert("An Error Occured:\nCode: " + e.getAttribute("code") + "\nType: " + e.getAttribute("type") + "\nCondition: " + e.firstChild.nodeName); // this shouldn't happen :)
		break;
	}
}
/************************************************************************
*                       ******  END HANDLERS  ******* 
************************************************************************
*/
/************************************************************************
*                           ******  INIT  *******
************************************************************************
*/
var con, Debug, srcW;
function member_reg(umwebserver,username,pw,email,familyname,givenname,sex,companyname,duty){
	if(FlashHelper.flashLoaded){
		document.getElementById("loading").style.display = "block";
		/* initialise debugger */
		if (!Debug || typeof (Debug) == "undefined" || !Debug.start) {
			if (typeof (Debugger) != "undefined") {
				Debug = new Debugger(DEBUG_LVL, "JWChat " + cutResource(jid));
			} else {
				Debug = new Object();
				Debug.log = function () {
				};
				Debug.start = function () {
				};
			}
		}
		/* ***
	   * create new connection
	   */
		var oArg = {oDbg:Debug};
		con = new JSJaCHttpBindingConnection(oArg);
		/* register handlers */
		con.registerHandler("onerror", handleConError);
		oArg = {domain:umwebserver, username:username, resource:"wum", pass:pw, email:email, familyname:familyname, givenname:givenname, sex:sex, companyname:companyname, duty:duty, register:true};
		con.connect(oArg);
	}else{
		setTimeout("eval(member_reg('" + umwebserver + "','" + username + "','" + pw + "','" + email + "','" + familyname + "','" + givenname + "','" + sex + "','" + companyname + "','" + (duty || "") + "'))",100);
	}
}

/************************************************************************
*                     ******  INITIALISE VARS  *******
************************************************************************
*/

/* check for unsupported browsers */

if (is.b == "op" || is.b == "Konqueror" || (is.b == "ns" && is.v < "5") || (is.ie && is.mac) || is.ie4) {
	open("http://" + hostPath + "/umservice/unsupported.html", "unsupported", "width=380,height=180");
}
document.writeln("<div id=\"shared_downDiv\" style=\"position:absolute;\" >");
document.writeln("<script type=\"text\/javascript\">");
document.writeln("FlashHelper.writeFlash(\"storage\",\"http://" + hostPath + "/umservice/JHBFlash4AJAX.swf\",\"1\",\"1\");");
document.writeln("<\/script></div>");
/*document.writeln("<div onclick=\"member_reg('192.168.0.190','guoqing','lenovo','gqlog_007@163.com','guo','qing','男','青岛携商网络科技有限公司');\">");
document.writeln("注册");
document.writeln("</div>");*/