jscore.requireJS("json");
function signupForm() {
	jscore.ajax.sendRequest({
		url:"signup.php",
		onComplete:function(res) {
			if(res) {
				jscore.ge("dialogSignUp").innerHTML = res.transport.responseText;
				
				jscore.ge("btnSignup").onmouseup = function() {
					var signup_callback = function(res_post) {
						if(res_post) {
		                    if(res_post.transport && res_post.transport.responseText) {
		                        var response = res_post.transport.responseText,new_response;
		
		                        if(response != "") {
		                            try{ new_response = jscore.json.parse(response); if(new_response) { response = new_response; } }catch(e) { }

		                            if(jscore.isObject(response)) {
		                                if(response['error']) {
		                                    var str = "";
		                                    for(var p in response['error']) {
		                                        if(jscore.isString(response['error'][p])) {
		                                            str += "* "+response['error'][p]+"\r\n";
		                                        }
		                                    }
		
		                                    alert(str);
		                                } else if(response['result']) {
		                                	changeDialog('Info', '<span style="font-size:9pt;color:#000">Thank you for signing up.<br><br>An email has been sent with the login details.</span>');
		                                	if(jscore.ge("dlgInfo")) {
		                                		jscore.ge("dlgInfo").onmousedown = function() {
				                                	window.location.reload(true);
			                                	}
		                                	}
		                                	//jscore.widget.dialog.hideDialog('dlgInfo','dlgModal');
		                                } else {
		                                    alert("Problem occured while trying to process your application.");
		                                }
		                            } else {
		                                //jscore.widget.dialog.notify("alert",response);
		                            }
		                        }
		                    }
		                }
					}
					jscore.ajax.form('frmSignup',signup_callback,{},{});
				}
			}
		}
	});
}
