Index: Dev/branches/jQueryUI/js/api.js
===================================================================
--- Dev/branches/jQueryUI/js/api.js	(revision 246)
+++ Dev/branches/jQueryUI/js/api.js	(revision 246)
@@ -0,0 +1,42 @@
+$(function() {
+
+    rft = {
+        api: {
+            post: function(action,args,success,error) {
+                $.ajax({
+                    type: "POST",
+                    url: "api.php",
+                    contentType: "application/json",
+                    data: JSON.stringify({ action:action, args:args }),
+                    success: success,
+                    error: error
+                });
+            }
+        },
+        auth: {
+            login: function(username,password,success,error) {
+                rft.api.post("login",
+                    {username:username,password:password},
+                    function(data,textStatus,jqXHR) {
+                        success && success()
+                    },
+                    function(jqXHR,textStatus,errorThrown) {
+                        error && error()
+                    }
+                );
+            },
+            register: function(username,password,success,error) {
+                rft.api.post("register",
+                    {username:username,password:password},
+                    function(data,textStatus,jqXHR) {
+                        success && success()
+                    },
+                    function(jqXHR,textStatus,errorThrown) {
+                        error && error()
+                    }
+                );
+            }
+        }
+    };
+
+});
Index: Dev/branches/jQueryUI/js/main.js
===================================================================
--- Dev/branches/jQueryUI/js/main.js	(revision 244)
+++ Dev/branches/jQueryUI/js/main.js	(revision 246)
@@ -1,39 +1,36 @@
 $(function() {
+
+    function loadMenu() {
+        $.get("pages/mainmenu/mainmenu.html",function(html){
+            $("#content").html(html);
+        });
+        $.getScript("pages/mainmenu/mainmenu.js");
+    }
+
     $("#loginForm").dialog({
         buttons: {
             "Login": function() {
-                $.ajax({
-                    type: "POST",
-                    url: "api.php",
-                    contentType: "application/json",
-                    data: JSON.stringify({
-                        action:"login",
-                        args:{username:$("#username").val(),password:$("#password").val()}
-                    }),
-                    success: function(data,textStatus,jqXHR) {
-                        $("#info").html("Succes: "+data);
+                rft.auth.login($("#username").val(),$("#password").val(),
+                    function(){
+                        $("#info").html("Login succesful.");
                         $("#loginForm").dialog("close");
+                        loadMenu();
                     },
-                    error: function(jqXHR,textStatus,errorThrown) {
-                        $("#info").html("Login Failed: "+errorThrown);
+                    function(){
+                        $("#info").html("Login failed.");
                     }
-                });
+                );
+
+
             },
             "Register": function() {
-                $.ajax({
-                    type: "POST",
-                    url: "api.php",
-                    contentType: "application/json",
-                    data: JSON.stringify({
-                        action:"register",
-                        args:{username:$("#username").val(),password:$("#password").val()}
-                    }),
-                    success: function(data,textStatus,jqXHR) {
-                        $("#info").val("Succes: "+data);
+                rft.auth.register($("#username").val(),$("#password").val(),
+                    function(){
+                        $("#info").val("Succesfully registered, please login now.");
                     },
-                    error: function(jqXHR,textStatus,errorThrown) {
-                        $("#info").html("Register Failed: "+errorThrown);
+                    function(){
+                        $("#info").html("Register failed, username already in use.");
                     }
-                });
+                );
             }
         }
