Index: /Dev/branches/jos-branch/classes/styles/Logo.php
===================================================================
--- /Dev/branches/jos-branch/classes/styles/Logo.php	(revision 237)
+++ /Dev/branches/jos-branch/classes/styles/Logo.php	(revision 238)
@@ -14,4 +14,13 @@
     // hardcoded logo div, image is defined in stylesheet. (#logo background:"";)
     public function __construct() {
+        if (isset($_SESSION['userUid'])) {
+            $users = User::get(array("uid" => $_SESSION['userUid']));
+            $user = $users[0];
+            $loggedIn = true;
+            $message = "Welcome, " . $user->name . "!";
+        } else {
+            $message = "Please log in.";
+            $loggedIn = false;
+        }
         ?>
 
@@ -21,5 +30,11 @@
             </div>
             <div id="logoControls">
-                Welcome, Igor! <a href="logout.php">Log out</a>
+                <?php echo $message; ?> 
+
+                <?php
+                if ($loggedIn == true) {
+                    echo "<a href='logout.php'>Log out</a>";
+                }
+                ?>
             </div>
         </div>
Index: /Dev/branches/jos-branch/classes/widgets/SessionEditorWidget.php
===================================================================
--- /Dev/branches/jos-branch/classes/widgets/SessionEditorWidget.php	(revision 237)
+++ /Dev/branches/jos-branch/classes/widgets/SessionEditorWidget.php	(revision 238)
@@ -52,6 +52,4 @@
                 <input type="button" id="editSelected" value="Edit step" class="smallButton" onClick="editStep();" />
                 <input type="button" id="deleteSelected" value="Delete step" class="smallButton" onClick="deleteStep();" />
-                <input type="submit" id ="clearPipeline" name="clearPipeline" value="Clear pipeline" class="smallButton dis" disabled="true"/>
-                <input type="checkbox" id="confirmClear" name="confirmClear" onChange="IsCheckEnabled(this, document.getElementById('clearPipeline'));" />Really clear?
                 <input type="button" value="debug_save" onClick="savePipeline(true);" />
             </div>
@@ -91,9 +89,9 @@
     public function LoadSession() {   // Initialize variables on page load.
 		// Redirect if no session is set
-        if (!isset($_SESSION['currentSession'])) {
+        if (!isset($_POST['objectUid'])) {
             redirect("selectSession.php");
         }
-        // Store the current session in internal variable
-        $results = Session::get(array("uid"=> $_SESSION['currentSession']));
+        
+        $results = Session::get(array("uid"=> $_POST['objectUid']));
 		//print_r($results);
         if (!empty($results)) {
Index: /Dev/branches/jos-branch/classes/widgets/SurveyEditorWidget.php
===================================================================
--- /Dev/branches/jos-branch/classes/widgets/SurveyEditorWidget.php	(revision 237)
+++ /Dev/branches/jos-branch/classes/widgets/SurveyEditorWidget.php	(revision 238)
@@ -15,14 +15,15 @@
 
     public function __construct() {
-        
+        // Nothing yet
     }
 
     public function handlePost() {
         // Get POSTed data and store variables to class instance properties
-        
+
         if (isset($_POST['objectUid']) && !empty($_POST['objectUid'])) {
             $surveyResults = Survey::get(array("uid" => $_POST['objectUid']));
             if (!empty($surveyResults)) {
                 $this->loadedSurvey = $surveyResults[0];
+                $this->loadedSurvey->evaluate();
             } else {
                 die("No surveys found!");
Index: /Dev/branches/jos-branch/createObject.php
===================================================================
--- /Dev/branches/jos-branch/createObject.php	(revision 237)
+++ /Dev/branches/jos-branch/createObject.php	(revision 238)
@@ -43,4 +43,15 @@
         $uid = $newQuestion->uid;
         break;
+    case "session":
+        if (isset($_POST['newSessionName']) && !empty($_POST['newSessionName'])) {
+            $newSession = new Session(null, $_POST['newSessionName'], $creator, new DateTime(), null, null);
+            $newSession->save();
+            $uid = $newSession->uid;
+        } else {
+            die("No session name specified!");
+        }
+
+
+        break;
     default:
         //die ("Variable \$otc: $otc does not match a compatible object type!");
Index: /Dev/branches/jos-branch/getObject.php
===================================================================
--- /Dev/branches/jos-branch/getObject.php	(revision 237)
+++ /Dev/branches/jos-branch/getObject.php	(revision 238)
@@ -14,5 +14,11 @@
 foreach ($requestArray as $request) {
     $type = $request->type;
-    $results = $type::get(array("uid" => $request->uid));
+
+    if (isset($request->uid)) {
+        $results = $type::get(array("uid" => $request->uid));
+    } else if (isset($request->title)) {
+        $results = $type::get(array("title" => $request->title));
+    }
+
 
     if (isset($results) && !empty($results) && count($results) > 0) {
@@ -20,7 +26,6 @@
         $results[0]->objectType = $type;
         $resultArray[] = $results[0];
-    }
-    else {
-        $resultArray[] = array("uid"=>"Not found!");
+    } else {
+        $resultArray[] = false; //Insert a false return so that the calling JS code knows when an object is not found
     }
 }
Index: /Dev/branches/jos-branch/js/questionEditorScripts.js
===================================================================
--- /Dev/branches/jos-branch/js/questionEditorScripts.js	(revision 237)
+++ /Dev/branches/jos-branch/js/questionEditorScripts.js	(revision 238)
@@ -24,4 +24,5 @@
     // Properties    
     this.uid = null;    // The uid of the question contained in this editor
+    this.saved = false; // Whether or not the question displayed in the editor has been saved already.
     var me = this;      // Retarded self-reference because: Javascript
     this.element = null;    // The parent div element containing the questionEditor
@@ -73,4 +74,5 @@
     this.init = function() {
         // Outer div
+        this.saved = false;
         me.element = ce("div");
         me.element.className = "smallFrame questionEditor";
@@ -248,8 +250,12 @@
     }
     this.discard = function() {
-        me.element.parentNode.removeChild(me.element);
-        me.init();
-        sequencer.state.loaded = true;
-        sequencer.state.editing = false;
+            debugger;
+            me.element.parentNode.removeChild(me.element);
+            me.init();
+            sequencer.state.loaded = true;
+            sequencer.state.editing = false;
+            sequencer.survey.questions.upToDate[sequencer.survey.questions.uids.indexOf(me.uid)] = false;
+            updateSequencer();
+        
     }
     this.reset = function() {
Index: /Dev/branches/jos-branch/js/sequencerScripts.js
===================================================================
--- /Dev/branches/jos-branch/js/sequencerScripts.js	(revision 237)
+++ /Dev/branches/jos-branch/js/sequencerScripts.js	(revision 238)
@@ -759,5 +759,5 @@
     //console.log(requestString);
     newAjaxRequest(requestString, "savesession.php", function(result){
-        //console.log(result.responseText);
+        console.log(result.responseText);
         }, true);
 }
Index: /Dev/branches/jos-branch/mainmenu.php
===================================================================
--- /Dev/branches/jos-branch/mainmenu.php	(revision 237)
+++ /Dev/branches/jos-branch/mainmenu.php	(revision 238)
@@ -10,4 +10,55 @@
         <?php new StyleSheet("visualeditors"); ?>
         <script type="text/javascript" src="js/generalScripts.js"></script>
+        <script type="text/javascript">
+            function browseSessions() {
+                // This one doesn't use the objectSelector yet. Just redirect to selectSession.php
+                window.location = 'selectSession.php';
+            }
+            
+            function browseSurveys() {
+                var form = ce("form");
+                form.method = "POST";
+                form.action = "selectObject.php";
+                var input1 = ce("input");
+                input1.name = "objectType";
+                input1.value = "Survey";
+                var input2 = ce("input");
+                input2.name = "function";
+                input2.value = "redirEditor";
+                form.appendChild(input1);
+                form.appendChild(input2);
+                form.submit();
+            }
+            
+            function browseQuestions() {
+                var form = ce("form");
+                form.method = "POST";
+                form.action = "selectObject.php";
+                var input1 = ce("input");
+                input1.name = "objectType";
+                input1.value = "Question";
+                var input2 = ce("input");
+                input2.name = "function";
+                input2.value = "redirEditor";
+                form.appendChild(input1);
+                form.appendChild(input2);
+                form.submit();
+            }
+            
+            function browseApplications() {
+                var form = ce("form");
+                form.method = "POST";
+                form.action = "selectObject.php";
+                var input1 = ce("input");
+                input1.name = "objectType";
+                input1.value = "Application";
+                var input2 = ce("input");
+                input2.name = "function";
+                input2.value = "redirEditor";
+                form.appendChild(input1);
+                form.appendChild(input2);
+                form.submit();
+            }
+        </script>
     </head>
     <body>
@@ -22,8 +73,8 @@
                     <div class="innerLargeFrame">
                         <p>Use the below buttons to access, edit and create new sessions and content.</p><br />
-                        <input type="button" class="bigButton vertical" value="Browse Sessions" id="btnEditSessions" onClick="window.location='selectSession.php'" /><br />
-                        <input type="button" class="bigButton vertical" value="Browse Surveys" id="btnEditSessions" onClick="window.location='selectSurvey.php'" /><br />
-                        <input type="button" class="bigButton vertical" value="Browse Questions" id="btnEditSessions" onClick="window.location='selectQuestion.php'" /><br />
-                        <input type="button" class="bigButton vertical" value="Browse Applications" id="btnEditSessions" onClick="window.location='selectApplication.php'" /><br />
+                        <input type="button" class="bigButton vertical" value="Browse Sessions" id="btnBrowseSessions" onClick="browseSessions()" /><br />
+                        <input type="button" class="bigButton vertical" value="Browse Surveys" id="btnBrowseSurveys" onClick="browseSurveys()" /><br />
+                        <input type="button" class="bigButton vertical" value="Browse Questions" id="btnBrowseQuestions" onClick="browseQuestions()" /><br />
+                        <input type="button" class="bigButton vertical" value="Browse Applications" id="btnBrowseApplications" onClick="browseApplications()" /><br />
 
                     </div>
Index: /Dev/branches/jos-branch/saveSurvey.php
===================================================================
--- /Dev/branches/jos-branch/saveSurvey.php	(revision 237)
+++ /Dev/branches/jos-branch/saveSurvey.php	(revision 238)
@@ -18,6 +18,5 @@
 // Query the survey object from the database.
 
-$dbi = new DatabaseInterface();
-$survey_results = $dbi->get("Survey", array("uid" => $args->uid));
+$survey_results = Survey::get(array("uid" => $args->uid));
 if (!empty($survey_results)) {
     $survey = $survey_results[0];
@@ -28,5 +27,5 @@
 $question->questions = array();
 foreach ($args->questions->uids as $questionUid) {
-    $question_results = $dbi->get("Question", array("code"=>$questionUid));
+    $question_results = Question::get(array("uid"=>$questionUid));
     $question = $question_results[0];
     $survey->questions[] = $question;
@@ -40,6 +39,6 @@
   }
  */
-var_dump($survey);
+//var_dump($survey);
 // Do I need to check if this is done before proceeding?
-$dbi->set($survey);
+$survey->save();
 ?>
Index: /Dev/branches/jos-branch/savesession.php
===================================================================
--- /Dev/branches/jos-branch/savesession.php	(revision 237)
+++ /Dev/branches/jos-branch/savesession.php	(revision 238)
@@ -11,11 +11,9 @@
     if (!empty($_POST['uids']) && !empty($_POST['types']) && !empty($_POST['sessionUid'])) {
         // user has passed a pipeline/type string from javascript in order to save the session.
-        $pl = explode(",", $_POST['uids']);
-        $t = explode(",", $_POST['types']);
+        $uids = explode(",", $_POST['uids']);
+        $types = explode(",", $_POST['types']);
 
         $sessionUid = $_POST['sessionUid'];
-        //var_dump($t);
-        $dbi = new DatabaseInterface();
-        $session_results = $dbi->get("Session", array("uid" => $sessionUid));
+        $session_results = Session::get(array("uid" => $sessionUid));
         if (count($session_results) > 0) {
             $session = $session_results[0];
@@ -24,14 +22,15 @@
             die();
         }
-        if (count($pl) == count($t)) {
-            $count = count($pl);
+        if (count($uids) == count($types)) {
+            $count = count($uids);
         } else {
             echo "!!!!!!!!!!!!!!!!!NON MATCHING ARGUMENTS PASSED!!!!!!!!!!!!!!!";
             die();
         }
-        
+
         $session->pipeline = array();
         for ($i = 0; $i < $count; $i++) {
-            $results = $dbi->get($t[$i], array("uid" => $pl[$i]));
+            $type = $types[$i];
+            $results = $type::get(array("uid" => $uids[$i]));
             if (count($results) > 0) {
                 $result = $results[0];
@@ -40,5 +39,5 @@
         }
 
-        $dbi->set($session);
+        $session->save();
         //var_dump($session);
     }
Index: /Dev/branches/jos-branch/selectObject.php
===================================================================
--- /Dev/branches/jos-branch/selectObject.php	(revision 238)
+++ /Dev/branches/jos-branch/selectObject.php	(revision 238)
@@ -0,0 +1,109 @@
+<?php
+require 'classes/master.php'; //should be at top of every page
+
+if (!isset($_SESSION['userUid'])) {
+    redirect("index.php");
+}
+
+if (isset($_POST['objectType']) && isset($_POST['function'])) {
+    if (!empty($_POST['objectType']) && !empty($_POST['function'])) {
+        $objectType = $_POST['objectType'];
+        $function = $_POST['function'];
+    }
+    else
+        die("Empty!");
+} else
+    die("No input!");
+
+$objects = $objectType::get(array());
+?>
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title></title>
+        <?php new Stylesheet("visualeditors"); ?>
+        <script type="text/javascript" src="js/generalScripts.js"></script>
+        <script type="text/javascript">
+            function redirEditor(uid, type) {
+                // Function to select the object and post the uid to the relevant object editor
+                // Question = stand-alone questionEditor
+                // Survey = surveyEditor.php
+                // Session = sessionEditor.php
+                // Application = applicationEditor.php
+                // Dashboard = N/A, dashboards currently cannot be stored
+                var form = ce("form");
+                form.method = "POST";
+                var input = ce("input");
+                input.type = "hidden";
+                input.value = uid;
+                form.appendChild(input);
+                
+                
+                switch (type.toLowerCase()) {
+                    case "question":
+                        form.action = "questionEditor.php";
+                        input.name = "questionUid";
+                        break;
+                    case "survey":
+                        form.action = "surveyEditor.php";
+                        input.name = "objectUid";
+                        break;
+                    case "session":
+                        // SessionsEditor input structure is not consistent with the others. Should be changed in next version ASAP!
+                        break;
+                    case "application":
+                        form.action = "applicationEditor.php";
+                        input.name = "applicationUid";
+                        break;
+                    default:
+                        return false;
+                        break;
+                }
+                
+                form.submit();
+            }
+        
+            function redirInsert(uid, type) {
+                // Function to select the object and post the uid to the editor that it can be insert into.
+                // Question = Survey editor
+                // Application/Survey = Session Editor
+                // Session = N/A, should use redirEditor instead!
+                var form = ce("form");
+                form.method = "POST";
+                var input = ce("input");
+                input.type = "hidden";
+                input.value = uid;
+                form.appendChild(input);
+            }
+        
+        
+        
+        </script>
+    </head>
+    <body>
+        <div id="header">
+            <?php new Logo(); ?>
+        </div>
+
+        <div id="content">
+            <div id="wrapper">
+                <div id="objectSelector" class="largeFrame">
+                    <div class="largeTitle">Browse <?php echo $objectType; ?>s</div>
+                    <div class="content">
+                        <select size="15" id="objectSelectBox" style="width: 350px;">
+                            <?php
+                            foreach ($objects as $object) {
+                                echo "<option value='" . $object->uid . "'>" . $object->title . "</option>";
+                            }
+                            ?>
+                        </select>
+                    </div>
+                    <div class="controls">
+                        <input type="button" value="Edit" id="btnEdit" class="smallButton" onclick="<?php echo $function; ?>(ge('objectSelectBox').value, '<?php echo $objectType; ?>');" />
+                    </div>
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
Index: /Dev/branches/jos-branch/selectSession.php
===================================================================
--- /Dev/branches/jos-branch/selectSession.php	(revision 237)
+++ /Dev/branches/jos-branch/selectSession.php	(revision 238)
@@ -23,5 +23,5 @@
                 $creator = $creators[0];
                 $session = new Session(null, $_POST['newSessionName'], $creator, new DateTime(), null, null);
-				$session->save();
+                $session->save();
             } else {
                 $errorMessage[] = "A session with the name " . $_POST['newSessionName'] . " already exists!";
@@ -40,8 +40,8 @@
 
 if (isset($_POST['editSession'])) {
-	var_dump($_POST);
+    var_dump($_POST);
     if (isset($_POST['sessionUid'])) {
         $session_results = Session::get((array("uid" => $_POST['sessionUid'])));
-		var_dump($session_results);
+        var_dump($session_results);
         if (count($session_results) == 1 && $session_results[0] != null) {
             // DEZE SESSION MOET UITEINDELIJK EEN POST WORDEN, WANNEER DEZE HELE PAGINA IS OVERGEZET IN JAVASCRIPT!
@@ -66,4 +66,56 @@
         <script type="text/javascript" src="js/sequencerScripts.js"></script>
         <script type="text/javascript" src="js/generalScripts.js"></script>
+        <script type="text/javascript">
+            function sendToEditor() {
+                debugger;
+                var uid = ge('objectUid').value;
+                if (uid.length == 32) {
+                    // A valid uid has actually been passed
+                    var form = ce("form");
+                    form.method = "POST";
+                    form.action = "sessionEditor.php";
+                    var input = ce("input");
+                    input.name = "objectUid";
+                    input.value = uid;
+                    form.appendChild(input);
+                    form.submit();
+                }
+            }
+            
+            function createNewSession() {
+                //debugger;
+                var desiredName = ge('newSessionName').value;
+                if (desiredName.length < 1) return;
+                var request = Array({
+                    type: "Session",
+                    title: desiredName
+                });
+                var requestString = "args="+JSON.stringify(request);
+                newAjaxRequest(requestString, "getObject.php", function(result){
+                    debugger;
+                    console.log(result.responseText);
+                    var session = JSON.parse(result.responseText)[0];
+                    if (session != false) {
+                        alert("Session with that name already exists. Please choose a different name.");
+                    }
+                    else {
+                        var requestString = "objectToCreate=Session&newSessionName="+desiredName;
+                        
+                        newAjaxRequest(requestString, "createObject.php", function(result){
+                            var objectUid = result.responseText;
+                            if (objectUid.length != 32) return;
+                            var form = ce("form");
+                            form.method = "POST";
+                            form.action = "sessionEditor.php";
+                            var input = ce("input");
+                            input.value = objectUid;
+                            input.name = "objectUid";
+                            form.appendChild(input);
+                            form.submit();
+                        },false);
+                    }
+                }, false);
+            }
+        </script>
     </head>
     <body>
@@ -79,5 +131,5 @@
                         <form action="selectSession.php" method="POST">
                             <div style="float: left; clear: left;">
-                                <select name="sessionUid" style="float: left;" onChange="ajaxInfoRequest(this.value, document.getElementById('infoPanelContent'), 'Session');">
+                                <select id ="objectUid" name="objectUid" style="float: left;" onChange="ajaxInfoRequest(this.value, document.getElementById('infoPanelContent'), 'Session');">
                                     <option value="" disabled="true" selected>Please select a session</option>
                                     <?php
@@ -93,9 +145,9 @@
                                 </select>
                                 <input type="hidden" name="updateNeeded" value="true" />
-                                <input type="text" name="newSessionName" value="Name..." style="float: left; clear: left;" /><br />
+                                <input type="text" id="newSessionName" name="newSessionName" value="Name..." style="float: left; clear: left;" /><br />
                             </div>
                             <div style="float: left; clear: none;">
-                                <input type="submit" name="createSession" value="Create new session" class="smallButton vertical" style="float: left;" />
-                                <input type="submit" name="editSession" value="Edit session" class="smallButton vertical" style="float: left;" />
+                                <input type="button" onclick="createNewSession();" name="createSession" value="Create new session" class="smallButton vertical" style="float: left;" />
+                                <input type="button" name="editSession" value="Edit session" class="smallButton vertical" style="float: left;" onclick="sendToEditor();" />
                                 <input type="submit" name="deleteSession" value="Delete session" class="smallButton vertical" style="float: left;" />
                             </div>
